Browse Source

Implement simplify in more IR nodes

jonathanvdc 8 years ago
parent
commit
9c157185e0
1 changed files with 10 additions and 0 deletions
  1. 10 0
      kernel/modelverse_jit/ir.py

+ 10 - 0
kernel/modelverse_jit/ir.py

@@ -156,6 +156,11 @@ class ReturnInstruction(VoidInstruction):
         Instruction.__init__(self)
         Instruction.__init__(self)
         self.value = value
         self.value = value
 
 
+    def simplify(self):
+        """Applies basic simplification to this instruction and its children."""
+
+        return LoopInstruction(self.value.simplify())
+
     def generate_python_def(self, code_generator):
     def generate_python_def(self, code_generator):
         """Generates Python code for this instruction."""
         """Generates Python code for this instruction."""
 
 
@@ -171,6 +176,11 @@ class LoopInstruction(VoidInstruction):
         Instruction.__init__(self)
         Instruction.__init__(self)
         self.body = body
         self.body = body
 
 
+    def simplify(self):
+        """Applies basic simplification to this instruction and its children."""
+
+        return LoopInstruction(self.body.simplify())
+
     def generate_python_def(self, code_generator):
     def generate_python_def(self, code_generator):
         """Generates Python code for this instruction."""
         """Generates Python code for this instruction."""