changeset 2947:e86e83c5adbc

More on lowering.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Fri, 10 Jun 2011 21:51:42 +0200
parents 0d103e2a38e5
children c76db61fbb73
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java
diffstat 2 files changed, 38 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Thu Jun 09 19:39:03 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/LoadField.java	Fri Jun 10 21:51:42 2011 +0200
@@ -25,6 +25,8 @@
 import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.graph.*;
 import com.oracle.max.graal.compiler.phases.CanonicalizerPhase.CanonicalizerOp;
+import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringOp;
+import com.oracle.max.graal.compiler.phases.LoweringPhase.LoweringTool;
 import com.oracle.max.graal.graph.*;
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
@@ -120,6 +122,16 @@
         return super.lookup(clazz);
     }
 
+    private static class LoadFieldLoweringOp implements LoweringOp {
+
+        @Override
+        public Node lower(Node n, LoweringTool tool) {
+            LoadField field = (LoadField) n;
+            return null;//field.field().createLoad(tool);
+        }
+
+    }
+
     private static class LoadFieldCanonicalizerOp implements CanonicalizerOp {
         @Override
         public Node canonical(Node node) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java	Thu Jun 09 19:39:03 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/LoweringPhase.java	Fri Jun 10 21:51:42 2011 +0200
@@ -22,10 +22,6 @@
  */
 package com.oracle.max.graal.compiler.phases;
 
-import java.util.*;
-
-import com.oracle.max.graal.compiler.*;
-import com.oracle.max.graal.compiler.debug.*;
 import com.oracle.max.graal.compiler.ir.*;
 import com.oracle.max.graal.compiler.schedule.*;
 import com.oracle.max.graal.graph.*;
@@ -36,36 +32,36 @@
         final IdentifyBlocksPhase s = new IdentifyBlocksPhase(false);
         s.apply(graph);
 
-//        for (Block b : s.getBlocks()) {
-//            TTY.println("Java block for block " + b.blockID() + " is " + b.javaBlock().blockID());
-//        }
+        for (Block b : s.getBlocks()) {
+            final Node firstNode = b.firstNode();
 
+            final LoweringTool loweringTool = new LoweringTool() {
+                @Override
+                public Node createStructuredBlockAnchor() {
+                    if (!(firstNode instanceof Anchor) && !(firstNode instanceof Merge)) {
+                        Anchor a = new Anchor(graph);
+                        assert firstNode.predecessors().size() == 1;
+                        Node pred = firstNode.predecessors().get(0);
+                        int predIndex = firstNode.predecessorsIndex().get(0);
+                        a.successors().setAndClear(Instruction.SUCCESSOR_NEXT, pred, predIndex);
+                        pred.successors().set(predIndex, a);
+                        return a;
+                    }
+                    return firstNode;
+                }
+            };
 
-        for (final Node n : graph.getNodes()) {
-            if (n instanceof FixedNode) {
-                LoweringOp op = n.lookup(LoweringOp.class);
-                if (op != null) {
-                    op.lower(n, new LoweringTool() {
-                        @Override
-                        public Node createStructuredBlockAnchor() {
-                            Block block = s.getNodeToBlock().get(n);
-                            Block javaBlock = block.javaBlock();
-                            Node first = javaBlock.firstNode();
-                            if (!(first instanceof Anchor) && !(first instanceof Merge)) {
-                                Anchor a = new Anchor(graph);
-                                assert first.predecessors().size() == 1;
-                                Node pred = first.predecessors().get(0);
-                                int predIndex = first.predecessorsIndex().get(0);
-                                a.successors().setAndClear(Instruction.SUCCESSOR_NEXT, pred, predIndex);
-                                pred.successors().set(predIndex, a);
-                                javaBlock.setFirstNode(a);
-                            }
-                            return javaBlock.firstNode();
+            for (final Node n : b.getInstructions()) {
+                if (n instanceof FixedNode) {
+                    LoweringOp op = n.lookup(LoweringOp.class);
+                    if (op != null) {
+                        Node newNode = op.lower(n, loweringTool);
+                        if (newNode != null) {
+                            n.replace(newNode);
                         }
-                    });
+                    }
                 }
             }
-
         }
     }
 
@@ -74,6 +70,6 @@
     }
 
     public interface LoweringOp extends Op {
-        void lower(Node n, LoweringTool tool);
+        Node lower(Node n, LoweringTool tool);
     }
 }