changeset 16165:0244e5bdddc1

intrinsify unsigned operations in java.lang.Integer/Long
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 23 Jun 2014 17:45:34 +0200
parents 3d76b518b007
children d69ede72299a
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java
diffstat 4 files changed, 40 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java	Mon Jun 23 17:03:21 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java	Mon Jun 23 17:45:34 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
     /**
      * Used by {@code NodeIntrinsic} in {@code UnsignedMathSubstitutions}.
      */
-    @SuppressWarnings("unused")
     private UnsignedDivNode(Kind kind, ValueNode x, ValueNode y) {
         this(StampFactory.forKind(kind), x, y);
     }
@@ -79,4 +78,10 @@
     public boolean canDeoptimize() {
         return !(y().stamp() instanceof IntegerStamp) || ((IntegerStamp) y().stamp()).contains(0);
     }
+
+    @NodeIntrinsic
+    public static native int unsignedDivide(@ConstantNodeParameter Kind kind, int a, int b);
+
+    @NodeIntrinsic
+    public static native long unsignedDivide(@ConstantNodeParameter Kind kind, long a, long b);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java	Mon Jun 23 17:03:21 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java	Mon Jun 23 17:45:34 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
     /**
      * Used by {@code NodeIntrinsic} in {@code UnsignedMathSubstitutions}.
      */
-    @SuppressWarnings("unused")
     private UnsignedRemNode(Kind kind, ValueNode x, ValueNode y) {
         this(StampFactory.forKind(kind), x, y);
     }
@@ -78,4 +77,10 @@
     public boolean canDeoptimize() {
         return !(y().stamp() instanceof IntegerStamp) || ((IntegerStamp) y().stamp()).contains(0);
     }
+
+    @NodeIntrinsic
+    public static native int unsignedRemainder(@ConstantNodeParameter Kind kind, int a, int b);
+
+    @NodeIntrinsic
+    public static native long unsignedRemainder(@ConstantNodeParameter Kind kind, long a, long b);
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java	Mon Jun 23 17:03:21 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java	Mon Jun 23 17:45:34 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,9 @@
  */
 package com.oracle.graal.replacements;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.replacements.nodes.*;
 
 @ClassSubstitution(Integer.class)
@@ -53,4 +55,14 @@
     public static int bitCount(int i) {
         return BitCountNode.bitCount(i);
     }
+
+    @MethodSubstitution
+    public static int divideUnsigned(int dividend, int divisor) {
+        return UnsignedDivNode.unsignedDivide(Kind.Int, dividend, divisor);
+    }
+
+    @MethodSubstitution
+    public static int remainderUnsigned(int dividend, int divisor) {
+        return UnsignedRemNode.unsignedRemainder(Kind.Int, dividend, divisor);
+    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Mon Jun 23 17:03:21 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java	Mon Jun 23 17:45:34 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,9 @@
  */
 package com.oracle.graal.replacements;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.replacements.nodes.*;
 
 @ClassSubstitution(Long.class)
@@ -53,4 +55,14 @@
     public static int bitCount(long i) {
         return BitCountNode.bitCount(i);
     }
+
+    @MethodSubstitution
+    public static long divideUnsigned(long dividend, long divisor) {
+        return UnsignedDivNode.unsignedDivide(Kind.Long, dividend, divisor);
+    }
+
+    @MethodSubstitution
+    public static long remainderUnsigned(long dividend, long divisor) {
+        return UnsignedRemNode.unsignedRemainder(Kind.Long, dividend, divisor);
+    }
 }