Chromium Code Reviews| Index: dart/frog/leg/ssa/codegen_helpers.dart |
| =================================================================== |
| --- dart/frog/leg/ssa/codegen_helpers.dart (revision 4084) |
| +++ dart/frog/leg/ssa/codegen_helpers.dart (working copy) |
| @@ -12,7 +12,9 @@ |
| * t0 and t1 would be marked and the resulting code would then be: |
| * t2 = add(4, 3); |
| */ |
| -class SsaInstructionMerger extends HGraphVisitor { |
| +class SsaInstructionMerger extends HBaseVisitor { |
| + List<HInstruction> expectedInputs; |
| + |
| void visitGraph(HGraph graph) { |
| visitDominatorTree(graph); |
| } |
| @@ -24,6 +26,16 @@ |
| return true; |
| } |
| + void visitInstruction(HInstruction instruction) { |
| + for (HInstruction input in instruction.inputs) { |
| + if (!input.generateAtUseSite() && input.usedBy.length == 1) { |
| + expectedInputs.add(input); |
| + } |
| + } |
| + } |
| + |
| + void visitIs(HIs instruction) {} |
|
floitsch
2012/02/10 09:38:17
add comment why this is empty.
ngeoffray
2012/02/10 09:40:48
Done.
|
| + |
| void visitBasicBlock(HBasicBlock block) { |
| // Visit each instruction of the basic block in last-to-first order. |
| // Keep a list of expected inputs of the current "expression" being |
| @@ -32,15 +44,11 @@ |
| // The expectedInputs list holds non-trivial instructions that may |
| // be generated at their use site, if they occur in the correct order. |
| - List<HInstruction> expectedInputs = new List<HInstruction>(); |
| + expectedInputs = new List<HInstruction>(); |
| // Add non-trivial inputs of instruction to expectedInputs, in |
| // evaluation order. |
| void addInputs(HInstruction instruction) { |
| - for (HInstruction input in instruction.inputs) { |
| - if (!input.generateAtUseSite() && input.usedBy.length == 1) { |
| - expectedInputs.add(input); |
| - } |
| - } |
| + instruction.accept(this); |
| } |
| // Pop instructions from expectedInputs until instruction is found. |
| // Return true if it is found, or false if not. |
| @@ -80,6 +88,7 @@ |
| addInputs(instruction); |
| } |
| } |
| + expectedInputs = null; |
| } |
| } |