changeset 2586:421da5f53b5e

more Op2 changes
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 14:37:17 +0200
parents 3e0e65161345
children 51ebe5f0516f
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java
diffstat 7 files changed, 79 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Thu May 05 14:37:17 2011 +0200
@@ -28,6 +28,7 @@
 import java.lang.reflect.*;
 import java.util.*;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.ir.*;
@@ -122,6 +123,12 @@
 
     boolean skipBlock;                     // skip processing of the rest of this block
     private Value rootMethodSynchronizedObject;
+
+
+
+    private Graph graph = new Graph();
+
+
     /**
      * Creates a new, initialized, {@code GraphBuilder} instance for a given compilation.
      *
@@ -548,7 +555,7 @@
     void genArithmeticOp(CiKind result, int opcode, CiKind x, CiKind y, FrameState state) {
         Value yValue = pop(y);
         Value xValue = pop(x);
-        Value result1 = append(new ArithmeticOp(opcode, result, xValue, yValue, isStrict(method().accessFlags()), state));
+        Value result1 = append(new ArithmeticOp(opcode, result, xValue, yValue, isStrict(method().accessFlags()), state, graph));
         push(result, result1);
     }
 
@@ -560,19 +567,19 @@
         Value s = ipop();
         Value x = pop(kind);
         // note that strength reduction of e << K >>> K is correctly handled in canonicalizer now
-        push(kind, append(new ShiftOp(opcode, x, s)));
+        push(kind, append(new ShiftOp(opcode, x, s, graph)));
     }
 
     void genLogicOp(CiKind kind, int opcode) {
         Value y = pop(kind);
         Value x = pop(kind);
-        push(kind, append(new LogicOp(opcode, x, y)));
+        push(kind, append(new LogicOp(opcode, x, y, graph)));
     }
 
     void genCompareOp(CiKind kind, int opcode, CiKind resultKind) {
         Value y = pop(kind);
         Value x = pop(kind);
-        Value value = append(new CompareOp(opcode, resultKind, x, y));
+        Value value = append(new CompareOp(opcode, resultKind, x, y, graph));
         if (!resultKind.isVoid()) {
             ipush(value);
         }
@@ -588,7 +595,7 @@
         int delta = stream().readIncrement();
         Value x = curState.localAt(index);
         Value y = append(Constant.forInt(delta));
-        curState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), null)));
+        curState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), null, graph)));
     }
 
     void genGoto(int fromBCI, int toBCI) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java	Thu May 05 14:37:17 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.value.*;
 import com.sun.cri.bytecode.*;
@@ -44,8 +45,8 @@
      * @param isStrictFP indicates this operation has strict rounding semantics
      * @param stateBefore the state for instructions that may trap
      */
-    public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) {
-        super(kind, opcode, x, y);
+    public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore, Graph graph) {
+        super(kind, opcode, x, y, graph);
         this.isStrictFP = isStrictFP;
         this.stateBefore = stateBefore;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java	Thu May 05 14:37:17 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.cri.bytecode.*;
 import com.sun.cri.ci.*;
@@ -38,8 +39,8 @@
      * @param x the first input
      * @param y the second input
      */
-    public CompareOp(int opcode, CiKind kind, Value x, Value y) {
-        super(kind, opcode, x, y);
+    public CompareOp(int opcode, CiKind kind, Value x, Value y, Graph graph) {
+        super(kind, opcode, x, y, graph);
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/IfOp.java	Thu May 05 14:37:17 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.util.*;
 import com.sun.cri.bytecode.*;
@@ -35,24 +36,62 @@
  */
 public final class IfOp extends Op2 {
 
+    private static final int INPUT_COUNT = 2;
+    private static final int INPUT_TRUE_VALUE = 0;
+    private static final int INPUT_FALSE_VALUE = 1;
+
+    private static final int SUCCESSOR_COUNT = 0;
+
+    @Override
+    protected int inputCount() {
+        return super.inputCount() + INPUT_COUNT;
+    }
+
+    @Override
+    protected int successorCount() {
+        return super.successorCount() + SUCCESSOR_COUNT;
+    }
+
+
+    /**
+     * The instruction that produces the value if the comparison is true.
+     */
+    public Value trueValue() {
+        return (Value) inputs().get(super.inputCount() + INPUT_TRUE_VALUE);
+    }
+
+    public Value setTrueValue(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_TRUE_VALUE, n);
+    }
+
+    /**
+     * The instruction that produces the value if the comparison is false.
+     */
+    public Value falseValue() {
+        return (Value) inputs().get(super.inputCount() + INPUT_FALSE_VALUE);
+    }
+
+    public Value setFalseValue(Value n) {
+        return (Value) inputs().set(super.inputCount() + INPUT_FALSE_VALUE, n);
+    }
+
+
     Condition cond;
-    Value trueVal;
-    Value falseVal;
 
     /**
      * Constructs a new IfOp.
      * @param x the instruction producing the first value to be compared
      * @param cond the condition of the comparison
      * @param y the instruction producing the second value to be compared
-     * @param tval the value produced if the condition is true
-     * @param fval the value produced if the condition is false
+     * @param trueValue the value produced if the condition is true
+     * @param falseValue the value produced if the condition is false
      */
-    public IfOp(Value x, Condition cond, Value y, Value tval, Value fval) {
+    public IfOp(Value x, Condition cond, Value y, Value trueValue, Value falseValue, Graph graph) {
         // TODO: return the appropriate bytecode IF_ICMPEQ, etc
-        super(tval.kind.meet(fval.kind), Bytecodes.ILLEGAL, x, y);
+        super(trueValue.kind.meet(falseValue.kind), Bytecodes.ILLEGAL, x, y, graph);
         this.cond = cond;
-        this.trueVal = tval;
-        falseVal = fval;
+        setTrueValue(trueValue);
+        setFalseValue(falseValue);
     }
 
     /**
@@ -64,22 +103,6 @@
     }
 
     /**
-     * Gets the instruction that produces the value if the comparison is true.
-     * @return the instruction producing the value upon true
-     */
-    public Value trueValue() {
-        return trueVal;
-    }
-
-    /**
-     * Gets the instruction that produces the value if the comparison is false.
-     * @return the instruction producing the value upon false
-     */
-    public Value falseValue() {
-        return falseVal;
-    }
-
-    /**
      * Checks whether this comparison operator is commutative (i.e. it is either == or !=).
      * @return {@code true} if this comparison is commutative
      */
@@ -90,8 +113,8 @@
     @Override
     public void inputValuesDo(ValueClosure closure) {
         super.inputValuesDo(closure);
-        trueVal = closure.apply(trueVal);
-        falseVal = closure.apply(falseVal);
+        setTrueValue(closure.apply(trueValue()));
+        setFalseValue(closure.apply(falseValue()));
     }
 
     @Override
@@ -101,14 +124,14 @@
 
     @Override
     public int valueNumber() {
-        return Util.hash4(cond.hashCode(), x, y, trueVal, falseVal);
+        return Util.hash4(cond.hashCode(), x(), y(), trueValue(), falseValue());
     }
 
     @Override
     public boolean valueEqual(Instruction i) {
         if (i instanceof IfOp) {
             IfOp o = (IfOp) i;
-            return opcode == o.opcode && x == o.x && y == o.y && trueVal == o.trueVal && falseVal == o.falseVal;
+            return opcode == o.opcode && x() == o.x() && y() == o.y() && trueValue() == o.trueValue() && falseValue() == o.falseValue();
         }
         return false;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LogicOp.java	Thu May 05 14:37:17 2011 +0200
@@ -22,9 +22,9 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.cri.bytecode.*;
-import com.sun.cri.ci.*;
 
 /**
  * The {@code LogicOp} class definition.
@@ -37,14 +37,10 @@
      * Constructs a new logic operation instruction.
      * @param opcode the opcode of the logic operation
      * @param x the first input into this instruction
-     * @param s the second input into this instruction
+     * @param y the second input into this instruction
      */
-    public LogicOp(int opcode, Value x, Value s) {
-        super(x.kind, opcode, x, s);
-    }
-
-    public LogicOp(CiKind kind, int opcode, Value x, Value s) {
-        super(kind, opcode, x, s);
+    public LogicOp(int opcode, Value x, Value y, Graph graph) {
+        super(x.kind, opcode, x, y, graph);
     }
 
     @Override
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java	Thu May 05 14:37:17 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.util.*;
 import com.sun.cri.bytecode.*;
 import com.sun.cri.ci.*;
@@ -83,8 +84,8 @@
      * @param x the first input instruction
      * @param y the second input instruction
      */
-    public Op2(CiKind kind, int opcode, Value x, Value y) {
-        super(kind, INPUT_COUNT, SUCCESSOR_COUNT, null);
+    public Op2(CiKind kind, int opcode, Value x, Value y, Graph graph) {
+        super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         this.opcode = opcode;
         setX(x);
         setY(y);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java	Thu May 05 14:12:19 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ShiftOp.java	Thu May 05 14:37:17 2011 +0200
@@ -22,6 +22,7 @@
  */
 package com.sun.c1x.ir;
 
+import com.oracle.graal.graph.*;
 import com.sun.c1x.debug.*;
 import com.sun.cri.bytecode.*;
 
@@ -38,8 +39,8 @@
      * @param x the first input value
      * @param y the second input value
      */
-    public ShiftOp(int opcode, Value x, Value y) {
-        super(x.kind, opcode, x, y);
+    public ShiftOp(int opcode, Value x, Value y, Graph graph) {
+        super(x.kind, opcode, x, y, graph);
     }
 
     @Override