use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class AMD64LIRGenerator method emitAddress.
@Override
public Variable emitAddress(AllocatableValue stackslot) {
Variable result = newVariable(LIRKind.value(target().arch.getWordKind()));
append(new StackLeaOp(result, stackslot));
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class AMD64LIRGenerator method emitArrayCompareTo.
@Override
public Variable emitArrayCompareTo(JavaKind kind1, JavaKind kind2, Value array1, Value array2, Value length1, Value length2) {
LIRKind resultKind = LIRKind.value(AMD64Kind.DWORD);
RegisterValue raxRes = AMD64.rax.asValue(resultKind);
RegisterValue cnt1 = AMD64.rcx.asValue(length1.getValueKind());
RegisterValue cnt2 = AMD64.rdx.asValue(length2.getValueKind());
emitMove(cnt1, length1);
emitMove(cnt2, length2);
append(new AMD64ArrayCompareToOp(this, kind1, kind2, raxRes, array1, array2, cnt1, cnt2));
Variable result = newVariable(resultKind);
emitMove(result, raxRes);
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class AMD64LIRGenerator method emitStringIndexOf.
@Override
public Variable emitStringIndexOf(Value source, Value sourceCount, Value target, Value targetCount, int constantTargetCount) {
Variable result = newVariable(LIRKind.value(AMD64Kind.DWORD));
RegisterValue cnt1 = AMD64.rdx.asValue(sourceCount.getValueKind());
emitMove(cnt1, sourceCount);
RegisterValue cnt2 = AMD64.rax.asValue(targetCount.getValueKind());
emitMove(cnt2, targetCount);
append(new AMD64StringIndexOfOp(this, result, source, target, cnt1, cnt2, AMD64.rcx.asValue(), AMD64.xmm0.asValue(), constantTargetCount, getVMPageSize()));
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class AMD64LIRGenerator method emitConditionalMove.
@Override
public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
boolean isFloatComparison = cmpKind == AMD64Kind.SINGLE || cmpKind == AMD64Kind.DOUBLE;
Condition finalCondition = cond;
Value finalTrueValue = trueValue;
Value finalFalseValue = falseValue;
if (isFloatComparison) {
// eliminate the parity check in case of a float comparison
Value finalLeft = left;
Value finalRight = right;
if (unorderedIsTrue != AMD64ControlFlow.trueOnUnordered(finalCondition)) {
if (unorderedIsTrue == AMD64ControlFlow.trueOnUnordered(finalCondition.mirror())) {
finalCondition = finalCondition.mirror();
finalLeft = right;
finalRight = left;
} else if (finalCondition != Condition.EQ && finalCondition != Condition.NE) {
// NaN semantics)
assert unorderedIsTrue == AMD64ControlFlow.trueOnUnordered(finalCondition.negate());
finalCondition = finalCondition.negate();
finalTrueValue = falseValue;
finalFalseValue = trueValue;
}
}
emitRawCompare(cmpKind, finalLeft, finalRight);
} else {
finalCondition = emitCompare(cmpKind, left, right, cond);
}
boolean isParityCheckNecessary = isFloatComparison && unorderedIsTrue != AMD64ControlFlow.trueOnUnordered(finalCondition);
Variable result = newVariable(finalTrueValue.getValueKind());
if (!isParityCheckNecessary && isIntConstant(finalTrueValue, 1) && isIntConstant(finalFalseValue, 0)) {
if (isFloatComparison) {
append(new FloatCondSetOp(result, finalCondition));
} else {
append(new CondSetOp(result, finalCondition));
}
} else if (!isParityCheckNecessary && isIntConstant(finalTrueValue, 0) && isIntConstant(finalFalseValue, 1)) {
if (isFloatComparison) {
if (unorderedIsTrue == AMD64ControlFlow.trueOnUnordered(finalCondition.negate())) {
append(new FloatCondSetOp(result, finalCondition.negate()));
} else {
append(new FloatCondSetOp(result, finalCondition));
Variable negatedResult = newVariable(result.getValueKind());
append(new AMD64Binary.ConstOp(AMD64BinaryArithmetic.XOR, OperandSize.get(result.getPlatformKind()), negatedResult, result, 1));
result = negatedResult;
}
} else {
append(new CondSetOp(result, finalCondition.negate()));
}
} else if (isFloatComparison) {
append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(finalTrueValue), load(finalFalseValue)));
} else {
append(new CondMoveOp(result, finalCondition, load(finalTrueValue), loadNonConst(finalFalseValue)));
}
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class AMD64LIRGenerator method emitByteSwap.
@Override
public Variable emitByteSwap(Value input) {
Variable result = newVariable(LIRKind.combine(input));
append(new AMD64ByteSwapOp(result, input));
return result;
}
Aggregations