Browse Source

Make unary intrinsics CFG intrinsics

jonathanvdc 8 years ago
parent
commit
d19e936007
1 changed files with 14 additions and 4 deletions
  1. 14 4
      kernel/modelverse_jit/jit.py

+ 14 - 4
kernel/modelverse_jit/jit.py

@@ -370,10 +370,20 @@ class ModelverseJit(object):
 
     def register_unary_intrinsic(self, name, operator):
         """Registers an intrinsic with the JIT that represents the given unary operation."""
-        self.register_intrinsic(name, lambda a: tree_ir.CreateNodeWithValueInstruction(
-            tree_ir.UnaryInstruction(
-                operator,
-                tree_ir.ReadValueInstruction(a))))
+        self.register_intrinsic(
+            name,
+            lambda a:
+            tree_ir.CreateNodeWithValueInstruction(
+                tree_ir.UnaryInstruction(
+                    operator,
+                    tree_ir.ReadValueInstruction(a))),
+            lambda original_def, a:
+            original_def.redefine(
+                cfg_ir.CreateNode(
+                    original_def.insert_before(
+                        cfg_ir.Unary(
+                            operator,
+                            original_def.insert_before(cfg_ir.Read(a)))))))
 
     def register_cast_intrinsic(self, name, target_type):
         """Registers an intrinsic with the JIT that represents a unary conversion operator."""