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