Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
2776:398b8fa5dc81 | 2777:3e4d992fd312 |
---|---|
78 if (C1XOptions.PrintTimers) { | 78 if (C1XOptions.PrintTimers) { |
79 C1XTimers.HIR_CREATE.stop(); | 79 C1XTimers.HIR_CREATE.stop(); |
80 C1XTimers.HIR_OPTIMIZE.start(); | 80 C1XTimers.HIR_OPTIMIZE.start(); |
81 } | 81 } |
82 | 82 |
83 CriticalEdgeFinder finder = new CriticalEdgeFinder(this); | |
84 getHIRStartBlock().iteratePreOrder(finder); | |
85 finder.splitCriticalEdges(); | |
86 | |
83 Schedule schedule = new Schedule(this.compilation.graph); | 87 Schedule schedule = new Schedule(this.compilation.graph); |
84 List<Block> blocks = schedule.getBlocks(); | 88 List<Block> blocks = schedule.getBlocks(); |
85 NodeMap<Block> nodeToBlock = schedule.getNodeToBlock(); | 89 NodeMap<Block> nodeToBlock = schedule.getNodeToBlock(); |
90 /* orderedBlocks = new ArrayList<LIRBlock>(); | |
86 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); | 91 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
87 for (Block b : blocks) { | 92 for (Block b : blocks) { |
88 map.put(b, new LIRBlock(b.blockID())); | 93 LIRBlock block = new LIRBlock(b.blockID()); |
94 map.put(b, block); | |
95 block.setInstructions(b.getInstructions()); | |
96 orderedBlocks.add(block); | |
89 } | 97 } |
90 | 98 |
91 for (Block b : blocks) { | 99 for (Block b : blocks) { |
92 for (Block succ : b.getSuccessors()) { | 100 for (Block succ : b.getSuccessors()) { |
93 map.get(b).blockSuccessors().add(map.get(succ)); | 101 map.get(b).blockSuccessors().add(map.get(succ)); |
94 } | 102 } |
95 | 103 |
96 for (Block pred : b.getPredecessors()) { | 104 for (Block pred : b.getPredecessors()) { |
97 map.get(b).blockPredecessors().add(map.get(pred)); | 105 map.get(b).blockPredecessors().add(map.get(pred)); |
98 } | 106 } |
99 } | 107 }*/ |
108 | |
100 | 109 |
101 // TODO(tw): Schedule nodes within a block. | 110 // TODO(tw): Schedule nodes within a block. |
102 | 111 |
103 | 112 |
104 valueToBlock = computeLinearScanOrder(); | 113 |
114 | |
115 computeLinearScanOrder(); | |
116 | |
117 | |
118 valueToBlock = new HashMap<Value, LIRBlock>(); | |
119 for (LIRBlock b : orderedBlocks) { | |
120 for (Instruction i : b.getInstructions()) { | |
121 valueToBlock.put(i, b); | |
122 } | |
123 } | |
124 startBlock = valueToBlock.get(getHIRStartBlock()); | |
125 assert startBlock != null; | |
105 verifyAndPrint("After linear scan order"); | 126 verifyAndPrint("After linear scan order"); |
106 | 127 |
107 if (C1XOptions.PrintTimers) { | 128 if (C1XOptions.PrintTimers) { |
108 C1XTimers.HIR_OPTIMIZE.stop(); | 129 C1XTimers.HIR_OPTIMIZE.stop(); |
109 } | 130 } |
123 return makeLinearScanOrder(); | 144 return makeLinearScanOrder(); |
124 } | 145 } |
125 | 146 |
126 private Map<Value, LIRBlock> makeLinearScanOrder() { | 147 private Map<Value, LIRBlock> makeLinearScanOrder() { |
127 | 148 |
128 Map<Value, LIRBlock> valueToBlock = new HashMap<Value, LIRBlock>(); | |
129 | |
130 if (orderedBlocks == null) { | 149 if (orderedBlocks == null) { |
131 CriticalEdgeFinder finder = new CriticalEdgeFinder(this); | 150 |
132 getHIRStartBlock().iteratePreOrder(finder); | 151 Map<Value, LIRBlock> valueToBlock = new HashMap<Value, LIRBlock>(); |
133 finder.splitCriticalEdges(); | |
134 ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, getHIRStartBlock()); | 152 ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, getHIRStartBlock()); |
135 List<BlockBegin> blocks = computeLinearScanOrder.linearScanOrder(); | 153 List<BlockBegin> blocks = computeLinearScanOrder.linearScanOrder(); |
136 orderedBlocks = new ArrayList<LIRBlock>(); | 154 orderedBlocks = new ArrayList<LIRBlock>(); |
137 | 155 |
138 int z = 0; | 156 int z = 0; |
165 first = first.next(); | 183 first = first.next(); |
166 } | 184 } |
167 ++z; | 185 ++z; |
168 } | 186 } |
169 | 187 |
170 startBlock = valueToBlock.get(getHIRStartBlock()); | |
171 assert startBlock != null; | |
172 compilation.stats.loopCount = computeLinearScanOrder.numLoops(); | |
173 } | 188 } |
174 return valueToBlock; | 189 return valueToBlock; |
175 } | 190 } |
176 | 191 |
177 /** | 192 /** |