Search in sources :

Example 61 with AllocatableValue

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;
}
Also used : AMD64MathIntrinsicUnaryOp(org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp) Variable(org.graalvm.compiler.lir.Variable) ArithmeticLIRGenerator(org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator) LIRGenerator(org.graalvm.compiler.lir.gen.LIRGenerator) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 62 with AllocatableValue

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;
    }
}
Also used : AArch64ArithmeticOp(org.graalvm.compiler.lir.aarch64.AArch64ArithmeticOp) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 63 with AllocatableValue

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;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) AArch64ArithmeticOp(org.graalvm.compiler.lir.aarch64.AArch64ArithmeticOp) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 64 with AllocatableValue

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;
}
Also used : AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueMoveOp(org.graalvm.compiler.lir.StandardOp.ValueMoveOp)

Example 65 with AllocatableValue

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";
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRInsertionBuffer(org.graalvm.compiler.lir.LIRInsertionBuffer) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) LoadConstantOp(org.graalvm.compiler.lir.StandardOp.LoadConstantOp) MoveOp(org.graalvm.compiler.lir.StandardOp.MoveOp) ValueMoveOp(org.graalvm.compiler.lir.StandardOp.ValueMoveOp) DebugContext(org.graalvm.compiler.debug.DebugContext) ValueMoveOp(org.graalvm.compiler.lir.StandardOp.ValueMoveOp) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

AllocatableValue (jdk.vm.ci.meta.AllocatableValue)87 Value (jdk.vm.ci.meta.Value)22 Variable (org.graalvm.compiler.lir.Variable)20 LIRKind (org.graalvm.compiler.core.common.LIRKind)13 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)11 Indent (org.graalvm.compiler.debug.Indent)10 RegisterValue (jdk.vm.ci.code.RegisterValue)9 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)8 DebugContext (org.graalvm.compiler.debug.DebugContext)8 Register (jdk.vm.ci.code.Register)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 AMD64MathIntrinsicUnaryOp (org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp)5 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)4 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)4 ValueMoveOp (org.graalvm.compiler.lir.StandardOp.ValueMoveOp)4 ArithmeticLIRGenerator (org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator)4 LIRGenerator (org.graalvm.compiler.lir.gen.LIRGenerator)4 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)4 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)3 ValueUtil.isAllocatableValue (jdk.vm.ci.code.ValueUtil.isAllocatableValue)3