Browse Source

Use SwitchInstruction in CFG->tree lowering

jonathanvdc 8 years ago
parent
commit
a8f5f3434b
1 changed files with 4 additions and 5 deletions
  1. 4 5
      kernel/modelverse_jit/cfg_to_tree.py

+ 4 - 5
kernel/modelverse_jit/cfg_to_tree.py

@@ -83,16 +83,15 @@ class MultipleBlock(object):
 
     def lower_handled_blocks(self, state):
         """Lowers the handled blocks of this 'multiple' block to a tree."""
-        result = tree_ir.EmptyInstruction()
+        cond_clause_pairs = []
         for entry, block in self.handled_blocks:
-            result = tree_ir.SelectInstruction(
+            cond_clause_pairs.append((
                 tree_ir.BinaryInstruction(
                     tree_ir.LoadLocalInstruction(state.label_variable),
                     '==',
                     tree_ir.LiteralInstruction(entry.index)),
-                block.lower(state),
-                result)
-        return result
+                block.lower(state)))
+        return tree_ir.SwitchInstruction(cond_clause_pairs)
 
     def lower(self, state):
         """Lowers this 'multiple' block to a tree."""