Search in sources :

Example 1 with CondMoveOp

use of org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp in project graal by oracle.

the class AMD64LIRGenerator method emitLogicCompareAndSwap.

@Override
public Variable emitLogicCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
    ValueKind<?> kind = newValue.getValueKind();
    assert kind.equals(expectedValue.getValueKind());
    AMD64Kind memKind = (AMD64Kind) kind.getPlatformKind();
    AMD64AddressValue addressValue = asAddressValue(address);
    RegisterValue raxRes = AMD64.rax.asValue(kind);
    emitMove(raxRes, expectedValue);
    append(new CompareAndSwapOp(memKind, raxRes, addressValue, raxRes, asAllocatable(newValue)));
    assert trueValue.getValueKind().equals(falseValue.getValueKind());
    Variable result = newVariable(trueValue.getValueKind());
    append(new CondMoveOp(result, Condition.EQ, asAllocatable(trueValue), falseValue));
    return result;
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) Variable(org.graalvm.compiler.lir.Variable) CompareAndSwapOp(org.graalvm.compiler.lir.amd64.AMD64Move.CompareAndSwapOp) CondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp) FloatCondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondMoveOp)

Example 2 with CondMoveOp

use of org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp in project graal by oracle.

the class AMD64LIRGenerator method emitIntegerTestMove.

@Override
public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
    emitIntegerTest(left, right);
    Variable result = newVariable(trueValue.getValueKind());
    append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue)));
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) CondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp) FloatCondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondMoveOp)

Example 3 with CondMoveOp

use of org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp 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;
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) Variable(org.graalvm.compiler.lir.Variable) FloatCondSetOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondSetOp) LIRValueUtil.asConstantValue(org.graalvm.compiler.lir.LIRValueUtil.asConstantValue) ConstantValue(org.graalvm.compiler.lir.ConstantValue) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) Value(jdk.vm.ci.meta.Value) ValueUtil.isAllocatableValue(jdk.vm.ci.code.ValueUtil.isAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) RegisterValue(jdk.vm.ci.code.RegisterValue) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) CondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp) FloatCondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondMoveOp) FloatCondMoveOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondMoveOp) CondSetOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondSetOp) FloatCondSetOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondSetOp)

Aggregations

Variable (org.graalvm.compiler.lir.Variable)3 CondMoveOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondMoveOp)3 FloatCondMoveOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondMoveOp)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)2 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)1 ValueUtil.isAllocatableValue (jdk.vm.ci.code.ValueUtil.isAllocatableValue)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 Value (jdk.vm.ci.meta.Value)1 Condition (org.graalvm.compiler.core.common.calc.Condition)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1 LIRValueUtil.asConstantValue (org.graalvm.compiler.lir.LIRValueUtil.asConstantValue)1 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)1 CondSetOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.CondSetOp)1 FloatCondSetOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatCondSetOp)1 CompareAndSwapOp (org.graalvm.compiler.lir.amd64.AMD64Move.CompareAndSwapOp)1