Search in sources :

Example 31 with Variable

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

the class AArch64LIRGenerator method emitConditionalMove.

/**
 * Conditionally move trueValue into new variable if cond + unorderedIsTrue is true, else
 * falseValue.
 *
 * @param left Arbitrary value. Has to have same type as right. Non null.
 * @param right Arbitrary value. Has to have same type as left. Non null.
 * @param cond condition that decides whether to move trueValue or falseValue into result. Non
 *            null.
 * @param unorderedIsTrue defines whether floating-point comparisons consider unordered true or
 *            not. Ignored for integer comparisons.
 * @param trueValue arbitrary value same type as falseValue. Non null.
 * @param falseValue arbitrary value same type as trueValue. Non null.
 * @return value containing trueValue if cond + unorderedIsTrue is true, else falseValue. Non
 *         null.
 */
@Override
public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
    boolean mirrored = emitCompare(cmpKind, left, right, cond, unorderedIsTrue);
    Condition finalCondition = mirrored ? cond.mirror() : cond;
    boolean finalUnorderedIsTrue = mirrored ? !unorderedIsTrue : unorderedIsTrue;
    ConditionFlag cmpCondition = toConditionFlag(((AArch64Kind) cmpKind).isInteger(), finalCondition, finalUnorderedIsTrue);
    Variable result = newVariable(trueValue.getValueKind());
    append(new CondMoveOp(result, cmpCondition, loadReg(trueValue), loadReg(falseValue)));
    return result;
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) Variable(org.graalvm.compiler.lir.Variable) CondMoveOp(org.graalvm.compiler.lir.aarch64.AArch64ControlFlow.CondMoveOp) ConditionFlag(org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag)

Example 32 with Variable

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

the class AArch64LIRGenerator method emitAddress.

@Override
public Variable emitAddress(AllocatableValue stackslot) {
    Variable result = newVariable(LIRKind.value(target().arch.getWordKind()));
    append(new AArch64Move.StackLoadAddressOp(result, stackslot));
    return result;
}
Also used : AArch64Move(org.graalvm.compiler.lir.aarch64.AArch64Move) Variable(org.graalvm.compiler.lir.Variable)

Example 33 with Variable

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

the class GenericValueMapTest method run0.

@Test
public void run0() {
    RegisterCategory cat = new RegisterCategory("regs");
    RegisterValue reg = new Register(0, 0, "reg0", cat).asValue();
    Variable var = new Variable(LIRKind.value(DummyKind.Long), 0);
    Object obj0 = new Object();
    Object obj1 = new Object();
    GenericValueMap<Object> map = new GenericValueMap<>();
    assertNull(map.get(reg));
    assertNull(map.get(var));
    map.put(reg, obj0);
    map.put(var, obj1);
    assertEquals(obj0, map.get(reg));
    assertEquals(obj1, map.get(var));
    map.remove(reg);
    map.remove(var);
    assertNull(map.get(reg));
    assertNull(map.get(var));
    map.put(reg, obj0);
    map.put(var, obj1);
    map.put(var, obj0);
    map.put(reg, obj1);
    assertEquals(obj1, map.get(reg));
    assertEquals(obj0, map.get(var));
    map.put(reg, null);
    map.put(var, null);
    assertNull(map.get(reg));
    assertNull(map.get(var));
}
Also used : RegisterValue(jdk.vm.ci.code.RegisterValue) RegisterCategory(jdk.vm.ci.code.Register.RegisterCategory) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) GenericValueMap(org.graalvm.compiler.lir.util.GenericValueMap) Test(org.junit.Test)

Example 34 with Variable

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

the class LinearScan method createDerivedInterval.

/**
 * Creates an interval as a result of splitting or spilling another interval.
 *
 * @param source an interval being split of spilled
 * @return a new interval derived from {@code source}
 */
Interval createDerivedInterval(Interval source) {
    if (firstDerivedIntervalIndex == -1) {
        firstDerivedIntervalIndex = intervalsSize;
    }
    if (intervalsSize == intervals.length) {
        intervals = Arrays.copyOf(intervals, intervals.length + (intervals.length >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT) + 1);
    }
    intervalsSize++;
    assert intervalsSize <= intervals.length;
    /*
         * Note that these variables are not managed and must therefore never be inserted into the
         * LIR
         */
    Variable variable = new Variable(source.kind(), numVariables++);
    Interval interval = createInterval(variable);
    assert intervals[intervalsSize - 1] == interval;
    return interval;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) LIRValueUtil.isVariable(org.graalvm.compiler.lir.LIRValueUtil.isVariable)

Example 35 with Variable

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

the class GlobalLivenessInfo method verifyBlock.

private boolean verifyBlock(AbstractBlockBase<?> block, LIR lir) {
    BitSet liveSet = new BitSet(lir.numVariables());
    int[] liveIn = getBlockIn(block);
    for (int varNum : liveIn) {
        liveSet.set(varNum);
    }
    ValueConsumer proc = new ValueConsumer() {

        @Override
        public void visitValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
            if (LIRValueUtil.isVariable(value)) {
                Variable var = LIRValueUtil.asVariable(value);
                if (mode == OperandMode.DEF) {
                    liveSet.set(var.index);
                } else {
                    assert liveSet.get(var.index) : String.format("Variable %s but not defined in block %s (liveIn: %s)", var, block, Arrays.toString(liveIn));
                }
            }
        }
    };
    for (LIRInstruction op : lir.getLIRforBlock(block)) {
        op.visitEachInput(proc);
        op.visitEachAlive(proc);
        op.visitEachState(proc);
        op.visitEachOutput(proc);
    // no need for checking temp
    }
    return true;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) ValueConsumer(org.graalvm.compiler.lir.ValueConsumer) EnumSet(java.util.EnumSet) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) BitSet(java.util.BitSet) Value(jdk.vm.ci.meta.Value) OperandMode(org.graalvm.compiler.lir.LIRInstruction.OperandMode)

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