Browse Source

Try harder to inline values during CFG->tree lowering

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

+ 7 - 4
kernel/modelverse_jit/cfg_to_tree.py

@@ -317,8 +317,8 @@ class LoweringState(object):
     def __create_value_load(self, value):
     def __create_value_load(self, value):
         """Creates a tree that loads the given value."""
         """Creates a tree that loads the given value."""
         if value.has_value():
         if value.has_value():
-            if isinstance(value, cfg_ir.Literal):
-                return self.lower_literal(value)
+            if isinstance(value, LoweringState.inline_value_types):
+                return self.lower_value(value)
             else:
             else:
                 return tree_ir.LoadLocalInstruction(None)
                 return tree_ir.LoadLocalInstruction(None)
         else:
         else:
@@ -346,10 +346,11 @@ class LoweringState(object):
 
 
     def lower_definition(self, definition):
     def lower_definition(self, definition):
         """Lowers the given definition to a tree."""
         """Lowers the given definition to a tree."""
-        if isinstance(definition.value, cfg_ir.Definition):
+        instruction = definition.value
+        if (isinstance(instruction, cfg_ir.Definition)
+                or isinstance(instruction, LoweringState.inline_value_types)):
             return tree_ir.EmptyInstruction()
             return tree_ir.EmptyInstruction()
 
 
-        instruction = definition.value
         tree_instruction = self.lower_value(instruction)
         tree_instruction = self.lower_value(instruction)
         def_load = self.load_definition(definition)
         def_load = self.load_definition(definition)
         if isinstance(def_load, tree_ir.LocalInstruction):
         if isinstance(def_load, tree_ir.LocalInstruction):
@@ -497,6 +498,8 @@ class LoweringState(object):
             self.load_definition(value.target),
             self.load_definition(value.target),
             [(name, self.load_definition(arg)) for name, arg in value.argument_list])
             [(name, self.load_definition(arg)) for name, arg in value.argument_list])
 
 
+    inline_value_types = (cfg_ir.Literal, cfg_ir.ResolveLocal, cfg_ir.FunctionParameter)
+
     value_lowerings = {
     value_lowerings = {
         cfg_ir.Literal : lower_literal,
         cfg_ir.Literal : lower_literal,
         cfg_ir.CheckLocalExists : lower_check_local_exists,
         cfg_ir.CheckLocalExists : lower_check_local_exists,