[pypy-svn] r9868 - pypy/dist/pypy/translator
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 17 19:53:33 CET 2005
Author: arigo
Date: Thu Mar 17 19:53:33 2005
New Revision: 9868
Modified:
pypy/dist/pypy/translator/simplify.py
Log:
Exhaustive list of operations that can't have side-effects in R-Python.
Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py (original)
+++ pypy/dist/pypy/translator/simplify.py Thu Mar 17 19:53:33 2005
@@ -128,15 +128,22 @@
traverse(visit, graph)
return transform_dead_op_vars_in_blocks(blocks)
+# the set of operations that can safely be removed
+# (they have no side effects, at least in R-Python)
+CanRemove = {}
+for _op in '''
+ newtuple newlist newdict newslice is_true
+ is_ id type issubtype repr str len hash getattr getitem
+ pos neg nonzero abs hex oct round ord invert add sub mul
+ truediv floordiv div mod divmod pow lshift rshift and_ or_
+ xor int float long lt le eq ne gt ge cmp coerce contains
+ iter get '''.split():
+ CanRemove[_op] = True
+del _op
+
def transform_dead_op_vars_in_blocks(blocks):
"""Remove dead operations and variables that are passed over a link
but not used in the target block. Input is a set of blocks"""
- # the set of operations that can safely be removed (no side effects)
- CanRemove = {'newtuple': True,
- 'newlist': True,
- 'newdict': True,
- 'is_': True,
- 'is_true': True}
read_vars = {} # set of variables really used
variable_flow = {} # map {Var: list-of-Vars-it-depends-on}
More information about the Pypy-commit
mailing list