Search in sources :

Example 41 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind 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 42 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class AMD64NodeMatchRules method narrowRead.

@MatchRule("(Narrow Read=access)")
@MatchRule("(Narrow FloatingRead=access)")
public ComplexMatchResult narrowRead(NarrowNode root, LIRLowerableAccess access) {
    return new ComplexMatchResult() {

        @Override
        public Value evaluate(NodeLIRBuilder builder) {
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            LIRKind addressKind = LIRKind.combineDerived(getLIRGeneratorTool().getLIRKind(root.asNode().stamp(NodeView.DEFAULT)), address.getBase(), address.getIndex());
            AMD64AddressValue newAddress = address.withKind(addressKind);
            LIRKind readKind = getLIRGeneratorTool().getLIRKind(root.stamp(NodeView.DEFAULT));
            return getArithmeticLIRGenerator().emitZeroExtendMemory((AMD64Kind) readKind.getPlatformKind(), root.getResultBits(), newAddress, getState(access));
        }
    };
}
Also used : AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) ComplexMatchResult(org.graalvm.compiler.core.match.ComplexMatchResult) NodeLIRBuilder(org.graalvm.compiler.core.gen.NodeLIRBuilder) LIRKind(org.graalvm.compiler.core.common.LIRKind) MatchRule(org.graalvm.compiler.core.match.MatchRule)

Example 43 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class AMD64NodeMatchRules method ifCompareLogicCas.

@MatchRule("(If (ObjectEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (PointerEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (FloatEquals=compare value LogicCompareAndSwap=cas))")
@MatchRule("(If (IntegerEquals=compare value LogicCompareAndSwap=cas))")
public ComplexMatchResult ifCompareLogicCas(IfNode root, CompareNode compare, ValueNode value, LogicCompareAndSwapNode cas) {
    JavaConstant constant = value.asJavaConstant();
    assert compare.condition() == CanonicalCondition.EQ;
    if (constant != null && cas.usages().count() == 1) {
        long constantValue = constant.asLong();
        boolean successIsTrue;
        if (constantValue == 0) {
            successIsTrue = false;
        } else if (constantValue == 1) {
            successIsTrue = true;
        } else {
            return null;
        }
        return builder -> {
            LIRKind kind = getLirKind(cas);
            LabelRef trueLabel = getLIRBlock(root.trueSuccessor());
            LabelRef falseLabel = getLIRBlock(root.falseSuccessor());
            double trueLabelProbability = root.probability(root.trueSuccessor());
            Value expectedValue = operand(cas.getExpectedValue());
            Value newValue = operand(cas.getNewValue());
            AMD64AddressValue address = (AMD64AddressValue) operand(cas.getAddress());
            Condition condition = successIsTrue ? Condition.EQ : Condition.NE;
            getLIRGeneratorTool().emitCompareAndSwapBranch(kind, address, expectedValue, newValue, condition, trueLabel, falseLabel, trueLabelProbability);
            return null;
        };
    }
    return null;
}
Also used : OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize) AMD64RMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp) AVXOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AVXOp) AMD64BinaryConsumer(org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode) LabelRef(org.graalvm.compiler.lir.LabelRef) UnsignedRightShiftNode(org.graalvm.compiler.nodes.calc.UnsignedRightShiftNode) SUB(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.SUB) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) FloatConvertNode(org.graalvm.compiler.nodes.calc.FloatConvertNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) NumUtil(org.graalvm.compiler.core.common.NumUtil) IfNode(org.graalvm.compiler.nodes.IfNode) GraphUtil(org.graalvm.compiler.nodes.util.GraphUtil) NodeView(org.graalvm.compiler.nodes.NodeView) LIRLowerableAccess(org.graalvm.compiler.nodes.memory.LIRLowerableAccess) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) MOVSX(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSX) NodeLIRBuilder(org.graalvm.compiler.core.gen.NodeLIRBuilder) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) TargetDescription(jdk.vm.ci.code.TargetDescription) JavaConstant(jdk.vm.ci.meta.JavaConstant) PlatformKind(jdk.vm.ci.meta.PlatformKind) ValueNode(org.graalvm.compiler.nodes.ValueNode) Value(jdk.vm.ci.meta.Value) ComplexMatchResult(org.graalvm.compiler.core.match.ComplexMatchResult) Access(org.graalvm.compiler.nodes.memory.Access) ADD(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.ADD) SS(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.SS) DWORD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.DWORD) GraalError(org.graalvm.compiler.debug.GraalError) ValueKind(jdk.vm.ci.meta.ValueKind) MatchRule(org.graalvm.compiler.core.match.MatchRule) LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) MOVSXB(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSXB) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) SD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.SD) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ReinterpretNode(org.graalvm.compiler.nodes.calc.ReinterpretNode) AMD64RRMOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RRMOp) AMD64(jdk.vm.ci.amd64.AMD64) AMD64MIOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp) ValueCompareAndSwapNode(org.graalvm.compiler.nodes.java.ValueCompareAndSwapNode) MOVSXD(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp.MOVSXD) Condition(org.graalvm.compiler.core.common.calc.Condition) CPUFeature(jdk.vm.ci.amd64.AMD64.CPUFeature) LIRKind(org.graalvm.compiler.core.common.LIRKind) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) SSEOp(org.graalvm.compiler.asm.amd64.AMD64Assembler.SSEOp) OR(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.OR) LIRValueUtil(org.graalvm.compiler.lir.LIRValueUtil) NodeMatchRules(org.graalvm.compiler.core.gen.NodeMatchRules) XOR(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.XOR) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool) AND(org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.AND) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) QWORD(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize.QWORD) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) Condition(org.graalvm.compiler.core.common.calc.Condition) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AMD64AddressValue(org.graalvm.compiler.lir.amd64.AMD64AddressValue) JavaConstant(jdk.vm.ci.meta.JavaConstant) LIRKind(org.graalvm.compiler.core.common.LIRKind) LabelRef(org.graalvm.compiler.lir.LabelRef) MatchRule(org.graalvm.compiler.core.match.MatchRule)

Example 44 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class AMD64ArithmeticLIRGenerator method emitDiv.

@Override
public Value emitDiv(Value a, Value b, LIRFrameState state) {
    TargetDescription target = getLIRGen().target();
    boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
    LIRKind resultKind = LIRKind.combine(a, b);
    switch((AMD64Kind) a.getPlatformKind()) {
        case DWORD:
            AMD64MulDivOp op = emitIDIV(DWORD, a, b, state);
            return getLIRGen().emitMove(op.getQuotient());
        case QWORD:
            AMD64MulDivOp lop = emitIDIV(QWORD, a, b, state);
            return getLIRGen().emitMove(lop.getQuotient());
        case SINGLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.DIV, SS, false, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.DIV, SS, false, a, b);
            }
        case DOUBLE:
            if (isAvx) {
                return emitBinary(resultKind, AVXOp.DIV, SD, false, a, b);
            } else {
                return emitBinary(resultKind, SSEOp.DIV, SD, false, a, b);
            }
        default:
            throw GraalError.shouldNotReachHere();
    }
}
Also used : AMD64MulDivOp(org.graalvm.compiler.lir.amd64.AMD64MulDivOp) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Example 45 with LIRKind

use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.

the class AArch64ArithmeticLIRGenerator method emitZeroExtend.

@Override
public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
    assert fromBits <= toBits && toBits <= 64;
    if (fromBits == toBits) {
        return inputVal;
    }
    LIRKind resultKind = getResultLirKind(toBits, inputVal);
    long mask = NumUtil.getNbitNumberLong(fromBits);
    Value maskValue = new ConstantValue(resultKind, JavaConstant.forLong(mask));
    return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
}
Also used : ConstantValue(org.graalvm.compiler.lir.ConstantValue) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) LIRKind(org.graalvm.compiler.core.common.LIRKind) ConstantValue(org.graalvm.compiler.lir.ConstantValue)

Aggregations

LIRKind (org.graalvm.compiler.core.common.LIRKind)60 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)20 Variable (org.graalvm.compiler.lir.Variable)19 Value (jdk.vm.ci.meta.Value)15 RegisterValue (jdk.vm.ci.code.RegisterValue)11 TargetDescription (jdk.vm.ci.code.TargetDescription)7 PlatformKind (jdk.vm.ci.meta.PlatformKind)7 LIRGeneratorTool (org.graalvm.compiler.lir.gen.LIRGeneratorTool)7 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 SPARCKind (jdk.vm.ci.sparc.SPARCKind)4 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)4 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)4 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)4 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)3 MatchRule (org.graalvm.compiler.core.match.MatchRule)3 ConstantValue (org.graalvm.compiler.lir.ConstantValue)3 AMD64MulDivOp (org.graalvm.compiler.lir.amd64.AMD64MulDivOp)3 SubstrateRegisterConfig (com.oracle.svm.core.graal.meta.SubstrateRegisterConfig)2 Op3s (org.graalvm.compiler.asm.sparc.SPARCAssembler.Op3s)2