Browse Source

Use regular JIT intrinsics during CFG->tree lowering

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

+ 9 - 4
kernel/modelverse_jit/cfg_to_tree.py

@@ -534,10 +534,15 @@ class LoweringState(object):
 
     def lower_jit_call(self, value):
         """Lowers a direct call that uses the 'jit' calling convention."""
-        return tree_ir.create_jit_call(
-            tree_ir.LoadGlobalInstruction(value.target_name),
-            [(name, self.load_definition(arg)) for name, arg in value.argument_list],
-            tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME))
+        arg_list = [(name, self.load_definition(arg)) for name, arg in value.argument_list]
+        intrinsic = self.jit.get_intrinsic(value.target_name)
+        if intrinsic is not None:
+            return bytecode_to_tree.apply_intrinsic(intrinsic, arg_list)
+        else:
+            return tree_ir.create_jit_call(
+                tree_ir.LoadGlobalInstruction(value.target_name),
+                arg_list,
+                tree_ir.LoadLocalInstruction(jit_runtime.KWARGS_PARAMETER_NAME))
 
     call_lowerings = {
         cfg_ir.SIMPLE_POSITIONAL_CALLING_CONVENTION : lower_simple_positional_call,