Browse Source

Support testing for instruction dominance

jonathanvdc 8 years ago
parent
commit
08e6a3ab2c
1 changed files with 10 additions and 1 deletions
  1. 10 1
      kernel/modelverse_jit/cfg_dominators.py

+ 10 - 1
kernel/modelverse_jit/cfg_dominators.py

@@ -118,6 +118,15 @@ class DominatorTree(object):
             self.dominator_sets[block] = results
             return results
 
-    def dominates(self, dominator, dominated):
+    def dominates_block(self, dominator, dominated):
         """Tests if the first block dominates the second."""
         return dominator in self.get_dominators(dominated)
+
+    def dominates_instruction(self, dominator, dominated):
+        """Tests if the first instruction dominates the second."""
+        dominator_block = dominator.block
+        dominated_block = dominated.block
+        if dominator_block == dominated_block:
+            return dominator.definition_index < dominated.definition_index
+        else:
+            return self.dominates_block(dominator_block, dominated_block)