Search in sources :

Example 81 with Variable

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;
}
Also used : StackLeaOp(org.graalvm.compiler.lir.amd64.AMD64Move.StackLeaOp) Variable(org.graalvm.compiler.lir.Variable)

Example 82 with Variable

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;
}
Also used : RegisterValue(jdk.vm.ci.code.RegisterValue) Variable(org.graalvm.compiler.lir.Variable) LIRKind(org.graalvm.compiler.core.common.LIRKind) AMD64ArrayCompareToOp(org.graalvm.compiler.lir.amd64.AMD64ArrayCompareToOp)

Example 83 with Variable

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;
}
Also used : RegisterValue(jdk.vm.ci.code.RegisterValue) Variable(org.graalvm.compiler.lir.Variable) AMD64StringIndexOfOp(org.graalvm.compiler.lir.amd64.AMD64StringIndexOfOp)

Example 84 with Variable

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

Example 85 with Variable

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;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) AMD64ByteSwapOp(org.graalvm.compiler.lir.amd64.AMD64ByteSwapOp)

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