# HG changeset patch # User Gilles Duboscq # Date 1311755583 -7200 # Node ID dcc79d5d0d82fd4159783cb8c69c57c97a9865c8 # Parent be914c1e065acabd58211ba12051a0ce6a110ba3 Add utility functions to create add & multiply integer nodes, removed wrong comment diff -r be914c1e065a -r dcc79d5d0d82 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/IntegerArithmeticNode.java --- 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(); + } + } } diff -r be914c1e065a -r dcc79d5d0d82 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Value.java --- 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) { diff -r be914c1e065a -r dcc79d5d0d82 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ReadEliminationPhase.java --- 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