[pypy-svn] pypy enable-opts: add simplify

fijal commits-noreply at bitbucket.org
Sat Mar 12 17:51:52 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: enable-opts
Changeset: r42527:ea37f19f93a8
Date: 2011-03-12 11:51 -0500
http://bitbucket.org/pypy/pypy/changeset/ea37f19f93a8/

Log:	add simplify

diff --git a/pypy/jit/metainterp/optimizeopt/simplify.py b/pypy/jit/metainterp/optimizeopt/simplify.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/optimizeopt/simplify.py
@@ -0,0 +1,32 @@
+
+from pypy.jit.metainterp.resoperation import ResOperation, rop
+from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
+from pypy.jit.metainterp.optimizeutil import _findall
+
+class OptSimplify(Optimization):
+    def optimize_CALL_PURE(self, op):
+        args = op.getarglist()[1:]
+        self.emit_operation(ResOperation(rop.CALL, args, op.result,
+                                         op.getdescr()))
+
+    def optimize_CALL_LOOPINVARIANT(self, op):
+        op = op.copy_and_change(rop.CALL)
+        self.emit_operation(op)
+
+    def optimize_VIRTUAL_REF_FINISH(self, op):
+        pass
+
+    def optimize_VIRTUAL_REF(self, op):
+        op = ResOperation(rop.SAME_AS, [op.getarg(0)], op.result)
+        self.emit_operation(op)
+
+    def propagate_forward(self, op):
+        opnum = op.getopnum()
+        for value, func in optimize_ops:
+            if opnum == value:
+                func(self, op)
+                break
+        else:
+            self.emit_operation(op)
+
+optimize_ops = _findall(OptSimplify, 'optimize_')


More information about the Pypy-commit mailing list