Search in sources :

Example 1 with RoundNode

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

the class TruffleGraphBuilderPlugins method registerExactMathPlugins.

public static void registerExactMathPlugins(InvocationPlugins plugins, Replacements replacements, LoweringProvider lowerer, MetaAccessProvider metaAccess) {
    final ResolvedJavaType exactMathType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.ExactMath");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(exactMathType), replacements);
    for (JavaKind kind : new JavaKind[] { JavaKind.Int, JavaKind.Long }) {
        Class<?> type = kind.toJavaClass();
        r.register(new InvocationPlugin("multiplyHigh", type, type) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
                b.addPush(kind, new IntegerMulHighNode(x, y));
                return true;
            }
        });
        r.register(new InvocationPlugin("multiplyHighUnsigned", type, type) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
                b.addPush(kind, new UnsignedMulHighNode(x, y));
                return true;
            }
        });
    }
    for (JavaKind kind : new JavaKind[] { JavaKind.Float, JavaKind.Double }) {
        r.registerConditional(lowerer.supportsRounding(), new InvocationPlugin("truncate", kind.toJavaClass()) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x) {
                b.addPush(kind, new RoundNode(x, RoundingMode.TRUNCATE));
                return true;
            }
        });
    }
}
Also used : Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) IntegerMulHighNode(org.graalvm.compiler.nodes.calc.IntegerMulHighNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) RoundNode(org.graalvm.compiler.nodes.calc.RoundNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) RequiredInlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInlineOnlyInvocationPlugin) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) JavaKind(jdk.vm.ci.meta.JavaKind) UnsignedMulHighNode(org.graalvm.compiler.replacements.nodes.arithmetic.UnsignedMulHighNode)

Aggregations

JavaKind (jdk.vm.ci.meta.JavaKind)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 IntegerMulHighNode (org.graalvm.compiler.nodes.calc.IntegerMulHighNode)1 RoundNode (org.graalvm.compiler.nodes.calc.RoundNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 RequiredInlineOnlyInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInlineOnlyInvocationPlugin)1 RequiredInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)1 UnsignedMulHighNode (org.graalvm.compiler.replacements.nodes.arithmetic.UnsignedMulHighNode)1