changeset 19605:4efe39251424

Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
author Andreas Woess <andreas.woess@oracle.com>
date Fri, 27 Feb 2015 13:56:01 +0100
parents 7d5a0223dc44
children d344d76b7b6d
files graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java
diffstat 1 files changed, 32 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Fri Feb 27 13:55:56 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java	Fri Feb 27 13:56:01 2015 +0100
@@ -86,42 +86,38 @@
 
     public static void registerExactMathPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {
         Registration r = new Registration(plugins, metaAccess, ExactMath.class);
-        r.register2("addExact", Integer.TYPE, Integer.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Int.getStackKind(), builder.append(new IntegerAddExactNode(x, y)));
-                return true;
-            }
-        });
-        r.register2("addExact", Long.TYPE, Long.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Long, builder.append(new IntegerAddExactNode(x, y)));
-                return true;
-            }
-        });
-        r.register2("subtractExact", Integer.TYPE, Integer.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Int.getStackKind(), builder.append(new IntegerSubExactNode(x, y)));
-                return true;
-            }
-        });
-        r.register2("subtractExact", Long.TYPE, Long.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Long, builder.append(new IntegerSubExactNode(x, y)));
-                return true;
-            }
-        });
-        r.register2("multiplyExact", Integer.TYPE, Integer.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Int.getStackKind(), builder.append(new IntegerMulExactNode(x, y)));
-                return true;
-            }
-        });
-        r.register2("multiplyExact", Long.TYPE, Long.TYPE, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
-                builder.push(Kind.Long, builder.append(new IntegerMulExactNode(x, y)));
-                return true;
-            }
-        });
+        for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) {
+            r.register2("addExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
+                    builder.push(kind.getStackKind(), builder.append(new IntegerAddExactNode(x, y)));
+                    return true;
+                }
+            });
+            r.register2("subtractExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
+                    builder.push(kind.getStackKind(), builder.append(new IntegerSubExactNode(x, y)));
+                    return true;
+                }
+            });
+            r.register2("multiplyExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
+                    builder.push(kind.getStackKind(), builder.append(new IntegerMulExactNode(x, y)));
+                    return true;
+                }
+            });
+            r.register2("multiplyHigh", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
+                    builder.push(kind.getStackKind(), builder.append(new IntegerMulHighNode(x, y)));
+                    return true;
+                }
+            });
+            r.register2("multiplyHighUnsigned", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
+                    builder.push(kind.getStackKind(), builder.append(new UnsignedMulHighNode(x, y)));
+                    return true;
+                }
+            });
+        }
     }
 
     public static void registerCompilerDirectivesPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {