Search in sources :

Example 1 with BranchOp

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

the class AMD64LIRGenerator method emitCompareBranchMemory.

public void emitCompareBranchMemory(AMD64Kind cmpKind, Value left, AMD64AddressValue right, LIRFrameState state, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) {
    boolean mirrored = emitCompareMemory(cmpKind, left, right, state);
    Condition finalCondition = mirrored ? cond.mirror() : cond;
    if (cmpKind.isXMM()) {
        append(new FloatBranchOp(finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability));
    } else {
        append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability));
    }
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) FloatBranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatBranchOp) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) FloatBranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatBranchOp)

Example 2 with BranchOp

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

the class AMD64NodeMatchRules method emitIntegerTestBranchMemory.

private ComplexMatchResult emitIntegerTestBranchMemory(IfNode x, ValueNode value, LIRLowerableAccess access) {
    LabelRef trueLabel = getLIRBlock(x.trueSuccessor());
    LabelRef falseLabel = getLIRBlock(x.falseSuccessor());
    double trueLabelProbability = x.probability(x.trueSuccessor());
    AMD64Kind kind = getMemoryKind(access);
    OperandSize size = kind == AMD64Kind.QWORD ? QWORD : DWORD;
    if (value.isConstant()) {
        JavaConstant constant = value.asJavaConstant();
        if (constant != null && kind == AMD64Kind.QWORD && !NumUtil.isInt(constant.asLong())) {
            // Only imm32 as long
            return null;
        }
        return builder -> {
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            gen.append(new AMD64BinaryConsumer.MemoryConstOp(AMD64MIOp.TEST, size, address, (int) constant.asLong(), getState(access)));
            gen.append(new BranchOp(Condition.EQ, trueLabel, falseLabel, trueLabelProbability));
            return null;
        };
    } else {
        return builder -> {
            AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
            gen.append(new AMD64BinaryConsumer.MemoryRMOp(AMD64RMOp.TEST, size, gen.asAllocatable(operand(value)), address, getState(access)));
            gen.append(new BranchOp(Condition.EQ, trueLabel, falseLabel, trueLabelProbability));
            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) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) JavaConstant(jdk.vm.ci.meta.JavaConstant) LabelRef(org.graalvm.compiler.lir.LabelRef) OperandSize(org.graalvm.compiler.asm.amd64.AMD64Assembler.OperandSize)

Example 3 with BranchOp

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

the class AMD64LIRGenerator method emitCompareAndSwapBranch.

public void emitCompareAndSwapBranch(ValueKind<?> kind, AMD64AddressValue address, Value expectedValue, Value newValue, Condition condition, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) {
    assert kind.equals(expectedValue.getValueKind());
    assert kind.equals(newValue.getValueKind());
    assert condition == Condition.EQ || condition == Condition.NE;
    AMD64Kind memKind = (AMD64Kind) kind.getPlatformKind();
    RegisterValue raxValue = AMD64.rax.asValue(kind);
    emitMove(raxValue, expectedValue);
    append(new CompareAndSwapOp(memKind, raxValue, address, raxValue, asAllocatable(newValue)));
    append(new BranchOp(condition, trueLabel, falseLabel, trueLabelProbability));
}
Also used : RegisterValue(jdk.vm.ci.code.RegisterValue) AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) FloatBranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatBranchOp) CompareAndSwapOp(org.graalvm.compiler.lir.amd64.AMD64Move.CompareAndSwapOp)

Example 4 with BranchOp

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

the class AMD64LIRGenerator method emitIntegerTestBranch.

@Override
public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
    emitIntegerTest(left, right);
    append(new BranchOp(Condition.EQ, trueDestination, falseDestination, trueDestinationProbability));
}
Also used : BranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp) FloatBranchOp(org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatBranchOp)

Aggregations

BranchOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.BranchOp)4 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)2 Condition (org.graalvm.compiler.core.common.calc.Condition)2 FloatBranchOp (org.graalvm.compiler.lir.amd64.AMD64ControlFlow.FloatBranchOp)2 AMD64 (jdk.vm.ci.amd64.AMD64)1 CPUFeature (jdk.vm.ci.amd64.AMD64.CPUFeature)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 PlatformKind (jdk.vm.ci.meta.PlatformKind)1 Value (jdk.vm.ci.meta.Value)1 ValueKind (jdk.vm.ci.meta.ValueKind)1 ADD (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.ADD)1 AND (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.AND)1 OR (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.OR)1 SUB (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.SUB)1 XOR (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic.XOR)1 AMD64MIOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp)1 AMD64RMOp (org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64RMOp)1