Search in sources :

Example 1 with ShortCircuitOrNode

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

the class ShortCircuitOrNodeTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    Registration r = new Registration(invocationPlugins, ShortCircuitOrNodeTest.class);
    r.register2("shortCircuitOr", boolean.class, boolean.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode b1, ValueNode b2) {
            LogicNode x = b.add(new IntegerEqualsNode(b1, b.add(ConstantNode.forInt(1))));
            LogicNode y = b.add(new IntegerEqualsNode(b2, b.add(ConstantNode.forInt(1))));
            ShortCircuitOrNode compare = b.add(new ShortCircuitOrNode(x, false, y, false, 0.5));
            b.addPush(JavaKind.Boolean, new ConditionalNode(compare, b.add(ConstantNode.forBoolean(true)), b.add(ConstantNode.forBoolean(false))));
            return true;
        }
    });
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) IntegerEqualsNode(org.graalvm.compiler.nodes.calc.IntegerEqualsNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ShortCircuitOrNode(org.graalvm.compiler.nodes.ShortCircuitOrNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) LogicNode(org.graalvm.compiler.nodes.LogicNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 LogicNode (org.graalvm.compiler.nodes.LogicNode)1 ShortCircuitOrNode (org.graalvm.compiler.nodes.ShortCircuitOrNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)1 IntegerEqualsNode (org.graalvm.compiler.nodes.calc.IntegerEqualsNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1