Browse Source

Turn some read-like primitives into intrinsics

jonathanvdc 8 years ago
parent
commit
633daf3df2
1 changed files with 21 additions and 1 deletions
  1. 21 1
      kernel/modelverse_jit/intrinsics.py

+ 21 - 1
kernel/modelverse_jit/intrinsics.py

@@ -62,7 +62,27 @@ MISC_INTRINSICS = {
         lambda e:
         tree_ir.LoadIndexInstruction(
             tree_ir.ReadEdgeInstruction(e),
-            tree_ir.LiteralInstruction(1))
+            tree_ir.LiteralInstruction(1)),
+    'is_edge' :
+        lambda e:
+        tree_ir.CreateNodeWithValueInstruction(
+            tree_ir.BinaryInstruction(
+                tree_ir.LoadIndexInstruction(
+                    tree_ir.ReadEdgeInstruction(e),
+                    tree_ir.LiteralInstruction(0)),
+                'is not',
+                tree_ir.LiteralInstruction(None))),
+
+    # Dictionary operations
+    'dict_read' :
+        lambda dict_node, key:
+        tree_ir.ReadDictionaryValueInstruction(
+            dict_node, tree_ir.ReadValueInstruction(key)),
+
+    'dict_read_edge' :
+        lambda dict_node, key:
+        tree_ir.ReadDictionaryEdgeInstruction(
+            dict_node, tree_ir.ReadValueInstruction(key))
 }
 
 def register_intrinsics(target_jit):