changeset 2537:4a016ff4d2df

Clean up on LIRGenerator and related.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 19:53:46 +0200
parents 099f2a12788a
children e1ba5a93e997
files graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java graal/GraalCompiler/src/com/sun/c1x/gen/LIRItem.java graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/If.java graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java graal/GraalCompiler/src/com/sun/c1x/ir/Value.java
diffstat 7 files changed, 22 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java	Wed Apr 27 19:53:46 2011 +0200
@@ -667,7 +667,12 @@
             if (canBeConstant) {
                 return item.instruction.operand();
             } else {
-                item.loadItem(var.kind);
+                CiKind kind = var.kind;
+                if (kind == CiKind.Byte || kind == CiKind.Boolean) {
+                    item.loadByteItem();
+                } else {
+                    item.loadItem();
+                }
                 return item.result();
             }
         }
@@ -1516,6 +1521,9 @@
      * @param instruction an instruction that produces a result value
      */
     protected CiValue makeOperand(Value instruction) {
+        if (instruction == null) {
+            return CiValue.IllegalValue;
+        }
         assert instruction.isLive();
         CiValue operand = instruction.operand();
         if (operand.isIllegal()) {
--- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRItem.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRItem.java	Wed Apr 27 19:53:46 2011 +0200
@@ -75,34 +75,13 @@
      */
     private CiValue intermediateOperand;
 
-    public LIRItem(Value value, LIRGenerator gen) {
+    public LIRItem(Value instruction, LIRGenerator gen) {
         this.gen = gen;
-        setInstruction(value);
-    }
-
-    public void setInstruction(Value instruction) {
         this.instruction = instruction;
-        if (instruction != null) {
-            resultOperand = gen.makeOperand(instruction);
-        } else {
-            resultOperand = CiValue.IllegalValue;
-        }
+        resultOperand = gen.makeOperand(instruction);
         intermediateOperand = CiValue.IllegalValue;
     }
 
-    public LIRItem(LIRGenerator gen) {
-        this.gen = gen;
-        setInstruction(null);
-    }
-
-    public void loadItem(CiKind kind) {
-        if (kind == CiKind.Byte || kind == CiKind.Boolean) {
-            loadByteItem();
-        } else {
-            loadItem();
-        }
-    }
-
     public void loadForStore(CiKind kind) {
         if (gen.canStoreAsConstant(instruction, kind)) {
             resultOperand = instruction.operand();
@@ -168,25 +147,12 @@
     }
 
     public void loadNonconstant() {
-        if (gen.compilation.target.arch.isX86()) {
-            CiValue r = instruction.operand();
-            if (r.isConstant()) {
-                resultOperand = r;
-            } else {
-                loadItem();
-            }
-        } else if (gen.compilation.target.arch.isSPARC()) {
-            CiValue r = instruction.operand();
-            if (gen.canInlineAsConstant(instruction)) {
-                if (!r.isConstant()) {
-                    r = instruction.asConstant();
-                }
-                resultOperand = r;
-            } else {
-                loadItem();
-            }
+        assert gen.compilation.target.arch.isX86();
+        CiValue r = instruction.operand();
+        if (r.isConstant()) {
+            resultOperand = r;
         } else {
-            Util.shouldNotReachHere();
+            loadItem();
         }
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed Apr 27 19:53:46 2011 +0200
@@ -636,7 +636,7 @@
         BlockBegin fsucc = blockAt(stream().nextBCI());
         int bci = stream().currentBCI();
         boolean isSafepoint = !scopeData.noSafepoints() && tsucc.bci() <= bci || fsucc.bci() <= bci;
-        append(new If(x, cond, false, y, tsucc, fsucc, isSafepoint ? stateBefore : null, isSafepoint));
+        append(new If(x, cond, y, tsucc, fsucc, isSafepoint ? stateBefore : null, isSafepoint));
     }
 
     void genIfZero(Condition cond) {
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/If.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/If.java	Wed Apr 27 19:53:46 2011 +0200
@@ -38,6 +38,7 @@
     Value x;
     Value y;
     Condition condition;
+    boolean unorderedIsTrue;
 
     /**
      * Constructs a new If instruction.
@@ -50,14 +51,13 @@
      * @param stateAfter the state before the branch but after the input values have been popped
      * @param isSafepoint {@code true} if this branch should be considered a safepoint
      */
-    public If(Value x, Condition cond, boolean unorderedIsTrue, Value y,
+    public If(Value x, Condition cond, Value y,
               BlockBegin trueSucc, BlockBegin falseSucc, FrameState stateAfter, boolean isSafepoint) {
         super(CiKind.Illegal, stateAfter, isSafepoint);
         this.x = x;
         this.y = y;
         condition = cond;
         assert Util.archKindsEqual(x, y);
-        initFlag(Flag.UnorderedIsTrue, unorderedIsTrue);
         successors.add(trueSucc);
         successors.add(falseSucc);
     }
@@ -91,7 +91,7 @@
      * @return {@code true} if unordered inputs produce true
      */
     public boolean unorderedIsTrue() {
-        return checkFlag(Flag.UnorderedIsTrue);
+        return unorderedIsTrue;
     }
 
     /**
@@ -143,7 +143,7 @@
      * @see Condition#negate()
      */
     public void swapSuccessors() {
-        setFlag(Flag.UnorderedIsTrue, !unorderedIsTrue());
+        unorderedIsTrue = !unorderedIsTrue;
         condition = condition.negate();
         BlockBegin t = successors.get(0);
         BlockBegin f = successors.get(1);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java	Wed Apr 27 19:53:46 2011 +0200
@@ -43,7 +43,6 @@
         super(CiKind.Object, stateBefore);
         this.length = length;
         setFlag(Flag.NonNull);
-        setFlag(Flag.ResultIsUnique);
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java	Wed Apr 27 19:53:46 2011 +0200
@@ -50,7 +50,6 @@
         this.cpi = cpi;
         this.constantPool = constantPool;
         setFlag(Flag.NonNull);
-        setFlag(Flag.ResultIsUnique);
     }
 
     /**
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 19:30:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java	Wed Apr 27 19:53:46 2011 +0200
@@ -66,9 +66,7 @@
         LiveStore,          // instruction is a store
         PhiDead,            // phi is illegal because local is dead
         PhiCannotSimplify,  // phi cannot be simplified
-        PhiVisited,         // phi has been visited during simplification
-
-        ResultIsUnique;     // the result of this instruction is guaranteed to be unique (e.g. a new object)
+        PhiVisited;         // phi has been visited during simplification
 
         public final int mask = 1 << ordinal();
     }