changeset 3232:dcc79d5d0d82

Add utility functions to create add & multiply integer nodes, removed wrong comment
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Wed, 27 Jul 2011 10:33:03 +0200
parents be914c1e065a
children e3d3fd5b638a
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerArithmeticNode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java
diffstat 3 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerArithmeticNode.java	Mon Jul 25 12:12:10 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerArithmeticNode.java	Wed Jul 27 10:33:03 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.max.graal.compiler.ir;
 
+import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 
@@ -33,4 +34,31 @@
         assert kind == CiKind.Int || kind == CiKind.Long;
     }
 
+    public static IntegerArithmeticNode add(Value v1, Value v2) {
+        assert v1.kind == v2.kind && v1.graph() == v2.graph();
+        Graph graph = v1.graph();
+        //TODO (gd) handle conversions here instead of strong assert ?
+        switch(v1.kind) {
+            case Int:
+                return new IntegerAdd(CiKind.Int, v1, v2, graph);
+            case Long:
+                return new IntegerAdd(CiKind.Long, v1, v2, graph);
+            default:
+                throw Util.shouldNotReachHere();
+        }
+    }
+
+    public static IntegerArithmeticNode mul(Value v1, Value v2) {
+        assert v1.kind == v2.kind && v1.graph() == v2.graph();
+        Graph graph = v1.graph();
+        //TODO (gd) handle conversions here instead of strong assert ?
+        switch(v1.kind) {
+            case Int:
+                return new IntegerMul(CiKind.Int, v1, v2, graph);
+            case Long:
+                return new IntegerMul(CiKind.Long, v1, v2, graph);
+            default:
+                throw Util.shouldNotReachHere();
+        }
+    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java	Mon Jul 25 12:12:10 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java	Wed Jul 27 10:33:03 2011 +0200
@@ -154,7 +154,7 @@
      * @param v the visitor to accept
      */
     public void accept(ValueVisitor v) {
-        throw new IllegalStateException("No visit method for this node");
+        throw new IllegalStateException("No visit method for this node (" + this.getClass().getSimpleName() + ")");
     }
 
     public void print(LogStream out) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java	Mon Jul 25 12:12:10 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java	Wed Jul 27 10:33:03 2011 +0200
@@ -27,9 +27,6 @@
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.graph.*;
 
-/**
- * Duplicates every node in the graph to test the implementation of the {@link com.oracle.max.graal.graph.Node#copy()} method in node subclasses.
- */
 public class ReadEliminationPhase extends Phase {
 
     @Override