Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/graph/IR.java @ 2838:adc4b3ec0a8c
Deleted LIR critical edge splitter and replaced with GraalIR edge splitter using Anchor nodes (=> simpler).
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Tue, 31 May 2011 15:17:55 +0200 |
parents | c1c8a0291771 |
children | 633e66de40fe |
comparison
equal
deleted
inserted
replaced
2837:7b5831f0e913 | 2838:adc4b3ec0a8c |
---|---|
88 // replacement.put(compilation.graph.start(), newGraph.start()); | 88 // replacement.put(compilation.graph.start(), newGraph.start()); |
89 // replacement.put(compilation.graph.end(), newGraph.end()); | 89 // replacement.put(compilation.graph.end(), newGraph.end()); |
90 // newGraph.addDuplicate(compilation.graph.getNodes(), replacement); | 90 // newGraph.addDuplicate(compilation.graph.getNodes(), replacement); |
91 // compilation.graph = newGraph; | 91 // compilation.graph = newGraph; |
92 | 92 |
93 Schedule schedule = new Schedule(this.compilation.graph); | 93 Graph graph = compilation.graph; |
94 | |
95 // Split critical edges. | |
96 List<Node> nodes = graph.getNodes(); | |
97 for (int i = 0; i < nodes.size(); ++i) { | |
98 Node n = nodes.get(i); | |
99 if (Schedule.trueSuccessorCount(n) > 1) { | |
100 for (int j = 0; j < n.successors().size(); ++j) { | |
101 Node succ = n.successors().get(j); | |
102 if (Schedule.truePredecessorCount(succ) > 1) { | |
103 Anchor a = new Anchor(null, graph); | |
104 a.successors().setAndClear(1, n, j); | |
105 n.successors().set(j, a); | |
106 } | |
107 } | |
108 } | |
109 } | |
110 | |
111 Schedule schedule = new Schedule(graph); | |
94 List<Block> blocks = schedule.getBlocks(); | 112 List<Block> blocks = schedule.getBlocks(); |
95 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); | 113 List<LIRBlock> lirBlocks = new ArrayList<LIRBlock>(); |
96 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); | 114 Map<Block, LIRBlock> map = new HashMap<Block, LIRBlock>(); |
97 for (Block b : blocks) { | 115 for (Block b : blocks) { |
98 LIRBlock block = new LIRBlock(b.blockID()); | 116 LIRBlock block = new LIRBlock(b.blockID()); |
113 for (Block pred : b.getPredecessors()) { | 131 for (Block pred : b.getPredecessors()) { |
114 map.get(b).blockPredecessors().add(map.get(pred)); | 132 map.get(b).blockPredecessors().add(map.get(pred)); |
115 } | 133 } |
116 } | 134 } |
117 | 135 |
118 CriticalEdgeFinder finder = new CriticalEdgeFinder(lirBlocks, compilation.graph); | |
119 finder.splitCriticalEdges(); | |
120 | |
121 orderedBlocks = lirBlocks; | 136 orderedBlocks = lirBlocks; |
122 valueToBlock = new HashMap<Node, LIRBlock>(); | 137 valueToBlock = new HashMap<Node, LIRBlock>(); |
123 for (LIRBlock b : orderedBlocks) { | 138 for (LIRBlock b : orderedBlocks) { |
124 for (Node i : b.getInstructions()) { | 139 for (Node i : b.getInstructions()) { |
125 valueToBlock.put(i, b); | 140 valueToBlock.put(i, b); |
126 } | 141 } |
127 } | 142 } |
128 startBlock = lirBlocks.get(0); | 143 startBlock = lirBlocks.get(0); |
129 assert startBlock != null; | 144 assert startBlock != null; |
130 assert startBlock.blockPredecessors().size() == 0; | 145 assert startBlock.blockPredecessors().size() == 0; |
131 | |
132 /* if (startBlock.blockPredecessors().size() > 0) { | |
133 LIRBlock oldStartBlock = startBlock; | |
134 startBlock = new LIRBlock(orderedBlocks.size()); | |
135 startBlock.blockSuccessors().add(oldStartBlock); | |
136 | |
137 orderedBlocks.add(startBlock); | |
138 }*/ | |
139 | 146 |
140 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(lirBlocks.size(), startBlock); | 147 ComputeLinearScanOrder clso = new ComputeLinearScanOrder(lirBlocks.size(), startBlock); |
141 orderedBlocks = clso.linearScanOrder(); | 148 orderedBlocks = clso.linearScanOrder(); |
142 this.compilation.stats.loopCount = clso.numLoops(); | 149 this.compilation.stats.loopCount = clso.numLoops(); |
143 | 150 |