Search in sources :

Example 1 with CopySignNode

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

the class AArch64GraphBuilderPlugins method registerMathPlugins.

private static void registerMathPlugins(InvocationPlugins plugins, boolean registerForeignCallMath) {
    Registration r = new Registration(plugins, Math.class);
    if (registerForeignCallMath) {
        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.register(new InlineOnlyInvocationPlugin("pow", double.class, double.class) {

            @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;
            }
        });
    }
    registerFMA(r);
    registerIntegerAbs(r);
    r.register(new InvocationPlugin("multiplyHigh", long.class, long.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
            b.push(JavaKind.Long, b.append(new IntegerMulHighNode(x, y)));
            return true;
        }
    });
    registerMinMax(r);
    r.register(new InvocationPlugin("copySign", float.class, float.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
            b.addPush(JavaKind.Float, new CopySignNode(magnitude, sign));
            return true;
        }
    });
    r.register(new InvocationPlugin("copySign", double.class, double.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
            b.addPush(JavaKind.Double, new CopySignNode(magnitude, sign));
            return true;
        }
    });
}
Also used : CopySignNode(org.graalvm.compiler.nodes.calc.CopySignNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) IntegerMulHighNode(org.graalvm.compiler.nodes.calc.IntegerMulHighNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with CopySignNode

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

the class AMD64GraphBuilderPlugins method registerMathPlugins.

private static void registerMathPlugins(InvocationPlugins plugins, AMD64 arch, Replacements replacements) {
    Registration r = new Registration(plugins, Math.class, replacements);
    registerUnaryMath(r, "log", LOG);
    registerUnaryMath(r, "log10", LOG10);
    registerUnaryMath(r, "exp", EXP);
    registerBinaryMath(r, "pow", POW);
    registerUnaryMath(r, "sin", SIN);
    registerUnaryMath(r, "cos", COS);
    registerUnaryMath(r, "tan", TAN);
    registerFMA(r, arch);
    registerMinMax(r, arch);
    r.registerConditional(arch.getFeatures().contains(CPUFeature.AVX512VL), new InvocationPlugin("copySign", float.class, float.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
            b.addPush(JavaKind.Float, new CopySignNode(magnitude, sign));
            return true;
        }
    });
    r.registerConditional(arch.getFeatures().contains(CPUFeature.AVX512VL), new InvocationPlugin("copySign", double.class, double.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
            b.addPush(JavaKind.Double, new CopySignNode(magnitude, sign));
            return true;
        }
    });
}
Also used : CopySignNode(org.graalvm.compiler.nodes.calc.CopySignNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 CopySignNode (org.graalvm.compiler.nodes.calc.CopySignNode)2 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)2 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)2 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)2 SnippetSubstitutionInvocationPlugin (org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin)2 IntegerMulHighNode (org.graalvm.compiler.nodes.calc.IntegerMulHighNode)1 InlineOnlyInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin)1