comparison graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2780:79dda81dd337

Cleanup
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 25 May 2011 11:12:51 +0200
parents 93ec3f067420
children 915456e4959e
comparison
equal deleted inserted replaced
2779:93ec3f067420 2780:79dda81dd337
22 */ 22 */
23 package com.sun.c1x.graph; 23 package com.sun.c1x.graph;
24 24
25 import java.util.*; 25 import java.util.*;
26 26
27 import com.oracle.graal.graph.*;
28 import com.oracle.max.graal.schedule.*; 27 import com.oracle.max.graal.schedule.*;
29 import com.sun.c1x.*; 28 import com.sun.c1x.*;
30 import com.sun.c1x.debug.*; 29 import com.sun.c1x.debug.*;
31 import com.sun.c1x.ir.*; 30 import com.sun.c1x.ir.*;
32 import com.sun.c1x.lir.*; 31 import com.sun.c1x.lir.*;
107 } 106 }
108 } 107 }
109 108
110 109
111 // TODO(tw): Schedule nodes within a block. 110 // TODO(tw): Schedule nodes within a block.
112 //computeLinearScanOrder();
113
114 // assert orderedBlocks.size() == lirBlocks.size();
115 111
116 112
117 CriticalEdgeFinder finder = new CriticalEdgeFinder(lirBlocks, compilation.graph); 113 CriticalEdgeFinder finder = new CriticalEdgeFinder(lirBlocks, compilation.graph);
118 finder.splitCriticalEdges(); 114 finder.splitCriticalEdges();
119 115
135 this.compilation.stats.loopCount = clso.numLoops(); 131 this.compilation.stats.loopCount = clso.numLoops();
136 132
137 int z = 0; 133 int z = 0;
138 for (LIRBlock b : orderedBlocks) { 134 for (LIRBlock b : orderedBlocks) {
139 b.setLinearScanNumber(z++); 135 b.setLinearScanNumber(z++);
140
141 /* TTY.println();
142
143 for (Instruction i : b.getInstructions()) {
144 if (i instanceof BlockBegin) {
145 TTY.println("BlockBegin #" + ((BlockBegin) i).blockID);
146
147 TTY.print(" => succs: ");
148 for (LIRBlock succBlock : b.blockSuccessors()) {
149 TTY.print("B#" + ((BlockBegin) succBlock.getInstructions().get(0)).blockID);
150 }
151 TTY.print(" => ex: ");
152 for (LIRBlock succBlock : b.getExceptionHandlerSuccessors()) {
153 TTY.print("B#" + ((BlockBegin) succBlock.getInstructions().get(0)).blockID);
154 }
155 TTY.println();
156 } else {
157 TTY.println(i.getClass().getSimpleName() + " #" + i.id());
158 }
159 }*/
160 } 136 }
161 137
162 138
163 139
164 if (C1XOptions.PrintTimers) { 140 if (C1XOptions.PrintTimers) {
172 verifyAndPrint("After graph building"); 148 verifyAndPrint("After graph building");
173 149
174 if (C1XOptions.PrintCompilation) { 150 if (C1XOptions.PrintCompilation) {
175 TTY.print(String.format("%3d blocks | ", this.numberOfBlocks())); 151 TTY.print(String.format("%3d blocks | ", this.numberOfBlocks()));
176 } 152 }
177 }
178
179 private Map<Value, LIRBlock> computeLinearScanOrder() {
180 return makeLinearScanOrder();
181 }
182
183 private Map<Value, LIRBlock> makeLinearScanOrder() {
184 /*
185 if (orderedBlocks == null) {
186
187 Map<Value, LIRBlock> valueToBlock = new HashMap<Value, LIRBlock>();
188 ComputeLinearScanOrder computeLinearScanOrder = new ComputeLinearScanOrder(compilation.stats.blockCount, getHIRStartBlock());
189 List<BlockBegin> blocks = computeLinearScanOrder.linearScanOrder();
190 orderedBlocks = new ArrayList<LIRBlock>();
191
192 int z = 0;
193 for (BlockBegin bb : blocks) {
194 LIRBlock lirBlock = new LIRBlock(z);
195 lirBlock.getInstructions().add(bb);
196 valueToBlock.put(bb, lirBlock);
197 lirBlock.setLinearScanNumber(bb.linearScanNumber());
198 // TODO(tw): Initialize LIRBlock.linearScanLoopHeader and LIRBlock.linearScanLoopEnd
199 orderedBlocks.add(lirBlock);
200 ++z;
201 }
202
203 z = 0;
204 for (BlockBegin bb : blocks) {
205 LIRBlock lirBlock = orderedBlocks.get(z);
206 for (int i = 0; i < bb.numberOfPreds(); ++i) {
207 lirBlock.blockPredecessors().add(valueToBlock.get(bb.predAt(i).block()));
208 }
209
210 BlockEnd end = bb.end();
211 for (int i = 0; i < end.blockSuccessorCount(); ++i) {
212 lirBlock.blockSuccessors().add(valueToBlock.get(end.blockSuccessor(i)));
213 }
214
215 Instruction first = bb;
216 while (first != null) {
217 lirBlock.getInstructions().add(first);
218 first = first.next();
219 }
220 ++z;
221 }
222
223 }*/
224 return null;
225 //return valueToBlock;
226 } 153 }
227 154
228 /** 155 /**
229 * Gets the linear scan ordering of blocks as a list. 156 * Gets the linear scan ordering of blocks as a list.
230 * @return the blocks in linear scan order 157 * @return the blocks in linear scan order