diff graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2777:3e4d992fd312

towards replacing computelinearscanorder with scheduler.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Tue, 24 May 2011 14:40:47 +0200
parents 398b8fa5dc81
children 2ac7b30b7290
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Tue May 24 13:55:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Tue May 24 14:40:47 2011 +0200
@@ -80,12 +80,20 @@
             C1XTimers.HIR_OPTIMIZE.start();
         }
 
+        CriticalEdgeFinder finder = new CriticalEdgeFinder(this);
+        getHIRStartBlock().iteratePreOrder(finder);
+        finder.splitCriticalEdges();
+
         Schedule schedule = new Schedule(this.compilation.graph);
         List<Block> blocks = schedule.getBlocks();
         NodeMap<Block> nodeToBlock = schedule.getNodeToBlock();
+       /* orderedBlocks = new ArrayList<LIRBlock>();
         Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>();
         for (Block b : blocks) {
-            map.put(b, new LIRBlock(b.blockID()));
+            LIRBlock block = new LIRBlock(b.blockID());
+            map.put(b, block);
+            block.setInstructions(b.getInstructions());
+            orderedBlocks.add(block);
         }
 
         for (Block b : blocks) {
@@ -96,12 +104,25 @@
             for (Block pred : b.getPredecessors()) {
                 map.get(b).blockPredecessors().add(map.get(pred));
             }
-        }
+        }*/
+
 
         // TODO(tw): Schedule nodes within a block.
 
 
-        valueToBlock = computeLinearScanOrder();
+
+
+        computeLinearScanOrder();
+
+
+        valueToBlock = new HashMap<Value, LIRBlock>();
+        for (LIRBlock b : orderedBlocks) {
+            for (Instruction i : b.getInstructions()) {
+                valueToBlock.put(i, b);
+            }
+        }
+        startBlock = valueToBlock.get(getHIRStartBlock());
+        assert startBlock != null;
         verifyAndPrint("After linear scan order");
 
         if (C1XOptions.PrintTimers) {
@@ -125,12 +146,9 @@
 
     private Map<Value, LIRBlock> makeLinearScanOrder() {
 
-        Map<Value, LIRBlock> valueToBlock = new HashMap<Value, LIRBlock>();
+        if (orderedBlocks == null) {
 
-        if (orderedBlocks == null) {
-            CriticalEdgeFinder finder = new CriticalEdgeFinder(this);
-            getHIRStartBlock().iteratePreOrder(finder);
-            finder.splitCriticalEdges();
+            Map<Value, LIRBlock> valueToBlock = new HashMap<Value, LIRBlock>();
             ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, getHIRStartBlock());
             List<BlockBegin> blocks = computeLinearScanOrder.linearScanOrder();
             orderedBlocks = new ArrayList<LIRBlock>();
@@ -167,9 +185,6 @@
                 ++z;
             }
 
-            startBlock = valueToBlock.get(getHIRStartBlock());
-            assert startBlock != null;
-            compilation.stats.loopCount = computeLinearScanOrder.numLoops();
         }
         return valueToBlock;
     }