comparison graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2581:4a36a0bd6d18

added GraalGraph to classpath, Node as superclass of Value
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 13:27:48 +0200
parents 274360f98f97
children 768d77a1c7af
comparison
equal deleted inserted replaced
2579:4984c8ebd6c7 2581:4a36a0bd6d18
164 * @param target the successor before which to insert a block 164 * @param target the successor before which to insert a block
165 * @return the new block inserted 165 * @return the new block inserted
166 */ 166 */
167 public BlockBegin splitEdge(BlockBegin source, BlockBegin target) { 167 public BlockBegin splitEdge(BlockBegin source, BlockBegin target) {
168 int bci; 168 int bci;
169 if (target.predecessors().size() == 1) { 169 if (target.blockPredecessors().size() == 1) {
170 bci = target.bci(); 170 bci = target.bci();
171 } else { 171 } else {
172 bci = source.end().bci(); 172 bci = source.end().bci();
173 } 173 }
174 174
197 target.removePredecessor(newSucc); 197 target.removePredecessor(newSucc);
198 198
199 // the successor could be the target of a switch so it might have 199 // the successor could be the target of a switch so it might have
200 // multiple copies of this predecessor, so substitute the new_sux 200 // multiple copies of this predecessor, so substitute the new_sux
201 // for the first and delete the rest. 201 // for the first and delete the rest.
202 List<BlockBegin> list = target.predecessors(); 202 List<BlockBegin> list = target.blockPredecessors();
203 int x = list.indexOf(source); 203 int x = list.indexOf(source);
204 assert x >= 0; 204 assert x >= 0;
205 list.set(x, newSucc); 205 list.set(x, newSucc);
206 newSucc.addPredecessor(source); 206 newSucc.addPredecessor(source);
207 Iterator<BlockBegin> iterator = list.iterator(); 207 Iterator<BlockBegin> iterator = list.iterator();
214 return newSucc; 214 return newSucc;
215 } 215 }
216 216
217 public void replaceBlock(BlockBegin oldBlock, BlockBegin newBlock) { 217 public void replaceBlock(BlockBegin oldBlock, BlockBegin newBlock) {
218 assert !oldBlock.isExceptionEntry() : "cannot replace exception handler blocks (yet)"; 218 assert !oldBlock.isExceptionEntry() : "cannot replace exception handler blocks (yet)";
219 for (BlockBegin succ : oldBlock.end().successors()) { 219 for (BlockBegin succ : oldBlock.end().blockSuccessors()) {
220 succ.removePredecessor(oldBlock); 220 succ.removePredecessor(oldBlock);
221 } 221 }
222 for (BlockBegin pred : oldBlock.predecessors()) { 222 for (BlockBegin pred : oldBlock.blockPredecessors()) {
223 // substitute the new successor for this block in each predecessor 223 // substitute the new successor for this block in each predecessor
224 pred.end().substituteSuccessor(oldBlock, newBlock); 224 pred.end().substituteSuccessor(oldBlock, newBlock);
225 // and add each predecessor to the successor 225 // and add each predecessor to the successor
226 newBlock.addPredecessor(pred); 226 newBlock.addPredecessor(pred);
227 } 227 }
228 // this block is now disconnected; remove all its incoming and outgoing edges 228 // this block is now disconnected; remove all its incoming and outgoing edges
229 oldBlock.predecessors().clear(); 229 oldBlock.blockPredecessors().clear();
230 oldBlock.end().successors().clear(); 230 oldBlock.end().blockSuccessors().clear();
231 } 231 }
232 232
233 /** 233 /**
234 * Disconnects the specified block from all other blocks. 234 * Disconnects the specified block from all other blocks.
235 * @param block the block to remove from the graph 235 * @param block the block to remove from the graph
236 */ 236 */
237 public void disconnectFromGraph(BlockBegin block) { 237 public void disconnectFromGraph(BlockBegin block) {
238 for (BlockBegin p : block.predecessors()) { 238 for (BlockBegin p : block.blockPredecessors()) {
239 p.end().successors().remove(block); 239 p.end().blockSuccessors().remove(block);
240 } 240 }
241 for (BlockBegin s : block.end().successors()) { 241 for (BlockBegin s : block.end().blockSuccessors()) {
242 s.predecessors().remove(block); 242 s.blockPredecessors().remove(block);
243 } 243 }
244 } 244 }
245 245
246 public int nextBlockNumber() { 246 public int nextBlockNumber() {
247 return compilation.stats.blockCount++; 247 return compilation.stats.blockCount++;