Search in sources :

Example 36 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SaveCalleeSaveRegisters method restoreAtExit.

private static void restoreAtExit(LIR lir, LIRGeneratorTool.MoveFactory moveFactory, LIRGenerationResult lirGenRes, RegisterMap<Variable> calleeSaveRegisters, AbstractBlockBase<?> block) {
    ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
    int insertionIndex = instructions.size() - 1;
    LIRInsertionBuffer buffer = new LIRInsertionBuffer();
    buffer.init(instructions);
    assert instructions.get(insertionIndex) instanceof StandardOp.BlockEndOp;
    calleeSaveRegisters.forEach((Register register, Variable saved) -> {
        LIRInstruction restore = moveFactory.createMove(register.asValue(saved.getValueKind()), saved);
        buffer.append(insertionIndex, restore);
        restore.setComment(lirGenRes, "SaveCalleeSavedRegisters: restoreAtExit");
    });
    buffer.finish();
}
Also used : LIRInsertionBuffer(org.graalvm.compiler.lir.LIRInsertionBuffer) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction)

Example 37 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class SaveCalleeSaveRegisters method saveAtEntry.

private static RegisterMap<Variable> saveAtEntry(LIR lir, LIRGeneratorTool lirGen, LIRGenerationResult lirGenRes, RegisterArray calleeSaveRegisters, Architecture arch) {
    AbstractBlockBase<?> startBlock = lir.getControlFlowGraph().getStartBlock();
    ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(startBlock);
    int insertionIndex = 1;
    LIRInsertionBuffer buffer = new LIRInsertionBuffer();
    buffer.init(instructions);
    StandardOp.LabelOp entry = (StandardOp.LabelOp) instructions.get(insertionIndex - 1);
    RegisterValue[] savedRegisterValues = new RegisterValue[calleeSaveRegisters.size()];
    int savedRegisterValueIndex = 0;
    RegisterMap<Variable> saveMap = new RegisterMap<>(arch);
    for (Register register : calleeSaveRegisters) {
        PlatformKind registerPlatformKind = arch.getLargestStorableKind(register.getRegisterCategory());
        LIRKind lirKind = LIRKind.value(registerPlatformKind);
        RegisterValue registerValue = register.asValue(lirKind);
        Variable saveVariable = lirGen.newVariable(lirKind);
        LIRInstruction save = lirGen.getSpillMoveFactory().createMove(saveVariable, registerValue);
        buffer.append(insertionIndex, save);
        save.setComment(lirGenRes, "SaveCalleeSavedRegisters: saveAtEntry");
        saveMap.put(register, saveVariable);
        savedRegisterValues[savedRegisterValueIndex++] = registerValue;
    }
    entry.addIncomingValues(savedRegisterValues);
    buffer.finish();
    return saveMap;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) PlatformKind(jdk.vm.ci.meta.PlatformKind) RegisterValue(jdk.vm.ci.code.RegisterValue) LIRInsertionBuffer(org.graalvm.compiler.lir.LIRInsertionBuffer) Register(jdk.vm.ci.code.Register) RegisterMap(org.graalvm.compiler.lir.util.RegisterMap) LIRKind(org.graalvm.compiler.core.common.LIRKind) StandardOp(org.graalvm.compiler.lir.StandardOp)

Example 38 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class NodeLIRBuilder method createPhiOut.

private Value[] createPhiOut(AbstractMergeNode merge, AbstractEndNode pred) {
    List<Value> values = new ArrayList<>();
    for (PhiNode phi : merge.valuePhis()) {
        ValueNode node = phi.valueAt(pred);
        Value value = operand(node);
        assert value != null;
        if (isRegister(value)) {
            /*
                 * Fixed register intervals are not allowed at block boundaries so we introduce a
                 * new Variable.
                 */
            value = gen.emitMove(value);
        } else if (!allowObjectConstantToStackMove() && node instanceof ConstantNode && !LIRKind.isValue(value)) {
            /*
                 * Some constants are not allowed as inputs for PHIs in certain backends. Explicitly
                 * create a copy of this value to force it into a register. The new variable is only
                 * used in the PHI.
                 */
            Variable result = gen.newVariable(value.getValueKind());
            gen.emitMove(result, value);
            value = result;
        }
        values.add(value);
    }
    return values.toArray(new Value[values.size()]);
}
Also used : LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Variable(org.graalvm.compiler.lir.Variable) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ArrayList(java.util.ArrayList) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 39 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class LIRGenerator method emitLoadConstant.

@Override
public AllocatableValue emitLoadConstant(ValueKind<?> kind, Constant constant) {
    Variable result = newVariable(kind);
    emitMoveConstant(result, constant);
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) LIRValueUtil.isVariable(org.graalvm.compiler.lir.LIRValueUtil.isVariable)

Example 40 with Variable

use of org.graalvm.compiler.lir.Variable in project graal by oracle.

the class JVMCIInfopointErrorTest method testInvalidShortDerivedOop.

@Test(expected = Error.class)
public void testInvalidShortDerivedOop() {
    test((tool, state, safepoint) -> {
        Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
        tool.append(new ValueDef(baseOop));
        PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
        LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
        Variable var = tool.newVariable(lirKind);
        tool.append(new ValueDef(var));
        safepoint.accept(state);
        tool.append(new ValueUse(var));
    });
}
Also used : Variable(org.graalvm.compiler.lir.Variable) PlatformKind(jdk.vm.ci.meta.PlatformKind) LIRKind(org.graalvm.compiler.core.common.LIRKind) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Aggregations

Variable (org.graalvm.compiler.lir.Variable)113 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)27 LIRKind (org.graalvm.compiler.core.common.LIRKind)19 RegisterValue (jdk.vm.ci.code.RegisterValue)11 Value (jdk.vm.ci.meta.Value)11 Register (jdk.vm.ci.code.Register)10 AMD64Unary (org.graalvm.compiler.lir.amd64.AMD64Unary)9 AMD64Binary (org.graalvm.compiler.lir.amd64.AMD64Binary)8 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)8 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)7 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)7 SPARCKind (jdk.vm.ci.sparc.SPARCKind)6 ConstantValue (org.graalvm.compiler.lir.ConstantValue)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)5 PlatformKind (jdk.vm.ci.meta.PlatformKind)5 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)5 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)5 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)5 AMD64MathIntrinsicUnaryOp (org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp)5 AMD64Move (org.graalvm.compiler.lir.amd64.AMD64Move)5