Search in sources :

Example 21 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class SPARCGraphBuilderPlugins method registerIntegerLongPlugins.

private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, BytecodeProvider bytecodeProvider) {
    Class<?> declaringClass = kind.toBoxedJavaClass();
    Class<?> type = kind.toJavaClass();
    Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
    r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type);
    r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type);
    r.register1("bitCount", type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Int, b.append(new BitCountNode(value).canonical(null)));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) BitCountNode(org.graalvm.compiler.replacements.nodes.BitCountNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 22 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class SPARCGraphBuilderPlugins method registerMathPlugins.

private static void registerMathPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Math.class);
    registerUnaryMath(r, "sin", SIN);
    registerUnaryMath(r, "cos", COS);
    registerUnaryMath(r, "tan", TAN);
    registerUnaryMath(r, "exp", EXP);
    registerUnaryMath(r, "log", LOG);
    registerUnaryMath(r, "log10", LOG10);
    r.register2("pow", Double.TYPE, Double.TYPE, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
            b.push(JavaKind.Double, b.append(BinaryMathIntrinsicNode.create(x, y, BinaryMathIntrinsicNode.BinaryOperation.POW)));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 23 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class AArch64GraphBuilderPlugins method registerIntegerLongPlugins.

private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, BytecodeProvider bytecodeProvider) {
    Class<?> declaringClass = kind.toBoxedJavaClass();
    Class<?> type = kind.toJavaClass();
    Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
    r.register1("numberOfLeadingZeros", type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            ValueNode folded = AArch64CountLeadingZerosNode.tryFold(value);
            if (folded != null) {
                b.addPush(JavaKind.Int, folded);
            } else {
                b.addPush(JavaKind.Int, new AArch64CountLeadingZerosNode(value));
            }
            return true;
        }
    });
    r.register1("numberOfTrailingZeros", type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            ValueNode folded = AArch64CountTrailingZerosNode.tryFold(value);
            if (folded != null) {
                b.addPush(JavaKind.Int, folded);
            } else {
                b.addPush(JavaKind.Int, new AArch64CountTrailingZerosNode(value));
            }
            return true;
        }
    });
    r.registerMethodSubstitution(substituteDeclaringClass, "bitCount", type);
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 24 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class AMD64GraphBuilderPlugins method registerMathPlugins.

private static void registerMathPlugins(InvocationPlugins plugins, AMD64 arch, boolean arithmeticStubs, BytecodeProvider bytecodeProvider) {
    Registration r = new Registration(plugins, Math.class, bytecodeProvider);
    registerUnaryMath(r, "log", LOG);
    registerUnaryMath(r, "log10", LOG10);
    registerUnaryMath(r, "exp", EXP);
    registerBinaryMath(r, "pow", POW);
    if (arithmeticStubs) {
        registerUnaryMath(r, "sin", SIN);
        registerUnaryMath(r, "cos", COS);
        registerUnaryMath(r, "tan", TAN);
    } else {
        r.registerMethodSubstitution(AMD64MathSubstitutions.class, "sin", double.class);
        r.registerMethodSubstitution(AMD64MathSubstitutions.class, "cos", double.class);
        r.registerMethodSubstitution(AMD64MathSubstitutions.class, "tan", double.class);
    }
    if (arch.getFeatures().contains(CPUFeature.SSE4_1)) {
        registerRound(r, "rint", RoundingMode.NEAREST);
        registerRound(r, "ceil", RoundingMode.UP);
        registerRound(r, "floor", RoundingMode.DOWN);
    }
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)

Example 25 with Registration

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.

the class AMD64GraphBuilderPlugins method registerIntegerLongPlugins.

private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, AMD64 arch, BytecodeProvider bytecodeProvider) {
    Class<?> declaringClass = kind.toBoxedJavaClass();
    Class<?> type = kind.toJavaClass();
    Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
    if (arch.getFeatures().contains(AMD64.CPUFeature.LZCNT) && arch.getFlags().contains(AMD64.Flag.UseCountLeadingZerosInstruction)) {
        r.register1("numberOfLeadingZeros", type, new InvocationPlugin() {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
                ValueNode folded = AMD64CountLeadingZerosNode.tryFold(value);
                if (folded != null) {
                    b.addPush(JavaKind.Int, folded);
                } else {
                    b.addPush(JavaKind.Int, new AMD64CountLeadingZerosNode(value));
                }
                return true;
            }
        });
    } else {
        r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type);
    }
    if (arch.getFeatures().contains(AMD64.CPUFeature.BMI1) && arch.getFlags().contains(AMD64.Flag.UseCountTrailingZerosInstruction)) {
        r.register1("numberOfTrailingZeros", type, new InvocationPlugin() {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
                ValueNode folded = AMD64CountTrailingZerosNode.tryFold(value);
                if (folded != null) {
                    b.addPush(JavaKind.Int, folded);
                } else {
                    b.addPush(JavaKind.Int, new AMD64CountTrailingZerosNode(value));
                }
                return true;
            }
        });
    } else {
        r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type);
    }
    if (arch.getFeatures().contains(AMD64.CPUFeature.POPCNT)) {
        r.register1("bitCount", type, new InvocationPlugin() {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
                b.push(JavaKind.Int, b.append(new BitCountNode(value).canonical(null)));
                return true;
            }
        });
    }
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) BitCountNode(org.graalvm.compiler.replacements.nodes.BitCountNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)88 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)66 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)66 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)66 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)52 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)13 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)13 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)7 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)7 JavaKind (jdk.vm.ci.meta.JavaKind)5 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)5 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)5 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)5 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 AnalysisArraysCopyOfNode (com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 BlackholeNode (org.graalvm.compiler.nodes.debug.BlackholeNode)3