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;
}
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;
}
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));
}
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;
}
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;
}
Aggregations