Search in sources :

Example 1 with IntegerTestNode

use of org.graalvm.compiler.nodes.calc.IntegerTestNode in project graal by oracle.

the class CompareCanonicalizerTest method testIntegerTest.

@Test
public void testIntegerTest() {
    for (int i = 1; i <= 4; i++) {
        StructuredGraph graph = getCanonicalizedGraph("integerTest" + i);
        ReturnNode returnNode = (ReturnNode) graph.start().next();
        ConditionalNode conditional = (ConditionalNode) returnNode.result();
        IntegerTestNode test = (IntegerTestNode) conditional.condition();
        ParameterNode param0 = graph.getParameter(0);
        ParameterNode param1 = graph.getParameter(1);
        assertTrue((test.getX() == param0 && test.getY() == param1) || (test.getX() == param1 && test.getY() == param0));
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) Test(org.junit.Test)

Example 2 with IntegerTestNode

use of org.graalvm.compiler.nodes.calc.IntegerTestNode in project graal by oracle.

the class NodeLIRBuilder method emitConditional.

public Variable emitConditional(LogicNode node, Value trueValue, Value falseValue) {
    if (node instanceof IsNullNode) {
        IsNullNode isNullNode = (IsNullNode) node;
        LIRKind kind = gen.getLIRKind(isNullNode.getValue().stamp(NodeView.DEFAULT));
        Value nullValue = gen.emitConstant(kind, JavaConstant.NULL_POINTER);
        return gen.emitConditionalMove(kind.getPlatformKind(), operand(isNullNode.getValue()), nullValue, Condition.EQ, false, trueValue, falseValue);
    } else if (node instanceof CompareNode) {
        CompareNode compare = (CompareNode) node;
        PlatformKind kind = gen.getLIRKind(compare.getX().stamp(NodeView.DEFAULT)).getPlatformKind();
        return gen.emitConditionalMove(kind, operand(compare.getX()), operand(compare.getY()), compare.condition().asCondition(), compare.unorderedIsTrue(), trueValue, falseValue);
    } else if (node instanceof LogicConstantNode) {
        return gen.emitMove(((LogicConstantNode) node).getValue() ? trueValue : falseValue);
    } else if (node instanceof IntegerTestNode) {
        IntegerTestNode test = (IntegerTestNode) node;
        return gen.emitIntegerTestMove(operand(test.getX()), operand(test.getY()), trueValue, falseValue);
    } else {
        throw GraalError.unimplemented(node.toString());
    }
}
Also used : CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) LIRKind(org.graalvm.compiler.core.common.LIRKind) PlatformKind(jdk.vm.ci.meta.PlatformKind)

Aggregations

IntegerTestNode (org.graalvm.compiler.nodes.calc.IntegerTestNode)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 PlatformKind (jdk.vm.ci.meta.PlatformKind)1 Value (jdk.vm.ci.meta.Value)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)1 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)1 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)1 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)1 IsNullNode (org.graalvm.compiler.nodes.calc.IsNullNode)1 Test (org.junit.Test)1