use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitMathLog.
@Override
public Value emitMathLog(Value input, boolean base10) {
LIRGenerator gen = getLIRGen();
Variable result = maths.emitLog(gen, input, base10);
if (result == null) {
result = gen.newVariable(LIRKind.combine(input));
AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), base10 ? LOG10 : LOG, result, gen.asAllocatable(input), stackSlot));
}
return result;
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitBinaryVar.
private void emitBinaryVar(Variable result, AArch64ArithmeticOp op, AllocatableValue a, AllocatableValue b) {
AllocatableValue x = moveSp(a);
AllocatableValue y = moveSp(b);
switch(op) {
case FREM:
case REM:
case UREM:
getLIRGen().append(new AArch64ArithmeticOp.BinaryCompositeOp(op, result, x, y));
break;
default:
getLIRGen().append(new AArch64ArithmeticOp.BinaryOp(op, result, x, y));
break;
}
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitUnary.
private Variable emitUnary(AArch64ArithmeticOp op, Value inputVal) {
AllocatableValue input = getLIRGen().asAllocatable(inputVal);
Variable result = getLIRGen().newVariable(LIRKind.combine(input));
getLIRGen().append(new AArch64ArithmeticOp.UnaryOp(op, result, input));
return result;
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class LinearScanAssignLocationsPhase method assignLocations.
/**
* Assigns the operand of an {@link LIRInstruction}.
*
* @param op The {@link LIRInstruction} that should be colored.
* @return {@code true} if the instruction should be deleted.
*/
protected boolean assignLocations(LIRInstruction op) {
assert op != null;
// remove useless moves
if (MoveOp.isMoveOp(op)) {
AllocatableValue result = MoveOp.asMoveOp(op).getResult();
if (isVariable(result) && allocator.isMaterialized(result, op.id(), OperandMode.DEF)) {
/*
* This happens if a materializable interval is originally not spilled but then
* kicked out in LinearScanWalker.splitForSpilling(). When kicking out such an
* interval this move operation was already generated.
*/
return true;
}
}
op.forEachInput(assignProc);
op.forEachAlive(assignProc);
op.forEachTemp(assignProc);
op.forEachOutput(assignProc);
// compute reference map and debug information
op.forEachState(debugInfoProc);
// remove useless moves
if (ValueMoveOp.isValueMoveOp(op)) {
ValueMoveOp move = ValueMoveOp.asValueMoveOp(op);
if (move.getInput().equals(move.getResult())) {
return true;
}
}
return false;
}
use of jdk.vm.ci.meta.AllocatableValue in project graal by oracle.
the class LinearScanEliminateSpillMovePhase method eliminateSpillMoves.
// called once before assignment of register numbers
@SuppressWarnings("try")
void eliminateSpillMoves(LIRGenerationResult res) {
DebugContext debug = allocator.getDebug();
try (Indent indent = debug.logAndIndent("Eliminating unnecessary spill moves")) {
/*
* collect all intervals that must be stored after their definition. The list is sorted
* by Interval.spillDefinitionPos.
*/
Interval interval;
interval = allocator.createUnhandledLists(mustStoreAtDefinition, null).getLeft();
if (Assertions.detailedAssertionsEnabled(allocator.getOptions())) {
checkIntervals(debug, interval);
}
LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer();
for (AbstractBlockBase<?> block : allocator.sortedBlocks()) {
try (Indent indent1 = debug.logAndIndent("Handle %s", block)) {
ArrayList<LIRInstruction> instructions = allocator.getLIR().getLIRforBlock(block);
int numInst = instructions.size();
// iterate all instructions of the block.
for (int j = firstInstructionOfInterest(); j < numInst; j++) {
LIRInstruction op = instructions.get(j);
int opId = op.id();
if (opId == -1) {
MoveOp move = MoveOp.asMoveOp(op);
/*
* Remove move from register to stack if the stack slot is guaranteed to
* be correct. Only moves that have been inserted by LinearScan can be
* removed.
*/
if (Options.LIROptLSRAEliminateSpillMoves.getValue(allocator.getOptions()) && canEliminateSpillMove(block, move)) {
/*
* Move target is a stack slot that is always correct, so eliminate
* instruction.
*/
if (debug.isLogEnabled()) {
if (ValueMoveOp.isValueMoveOp(op)) {
ValueMoveOp vmove = ValueMoveOp.asValueMoveOp(op);
debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", allocator.operandNumber(vmove.getInput()), vmove.getInput(), allocator.operandNumber(vmove.getResult()), vmove.getResult(), block);
} else {
LoadConstantOp load = LoadConstantOp.asLoadConstantOp(op);
debug.log("eliminating constant load from %s to %d (%s) in block %s", load.getConstant(), allocator.operandNumber(load.getResult()), load.getResult(), block);
}
}
// null-instructions are deleted by assignRegNum
instructions.set(j, null);
}
} else {
/*
* Insert move from register to stack just after the beginning of the
* interval.
*/
assert interval.isEndMarker() || interval.spillDefinitionPos() >= opId : "invalid order";
assert interval.isEndMarker() || (interval.isSplitParent() && interval.spillState() == SpillState.StoreAtDefinition) : "invalid interval";
while (!interval.isEndMarker() && interval.spillDefinitionPos() == opId) {
if (!interval.canMaterialize()) {
if (!insertionBuffer.initialized()) {
/*
* prepare insertion buffer (appended when all instructions
* in the block are processed)
*/
insertionBuffer.init(instructions);
}
AllocatableValue fromLocation = interval.location();
AllocatableValue toLocation = LinearScan.canonicalSpillOpr(interval);
if (!fromLocation.equals(toLocation)) {
assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState();
assert isStackSlotValue(toLocation) : "to operand must be a stack slot";
LIRInstruction move = allocator.getSpillMoveFactory().createMove(toLocation, fromLocation);
insertionBuffer.append(j + 1, move);
move.setComment(res, "LSRAEliminateSpillMove: store at definition");
if (debug.isLogEnabled()) {
debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId);
}
}
}
interval = interval.next;
}
}
}
if (insertionBuffer.initialized()) {
insertionBuffer.finish();
}
}
}
assert interval.isEndMarker() : "missed an interval";
}
}
Aggregations