| 1 |
from __future__ import print_function |
| 2 |
|
| 3 |
from rpython.jit.metainterp.optimizeopt.rewrite import OptRewrite |
| 4 |
from rpython.jit.metainterp.optimizeopt.intbounds import OptIntBounds |
| 5 |
from rpython.jit.metainterp.optimizeopt.virtualize import OptVirtualize |
| 6 |
from rpython.jit.metainterp.optimizeopt.heap import OptHeap |
| 7 |
from rpython.jit.metainterp.optimizeopt.vstring import OptString |
| 8 |
from rpython.jit.metainterp.optimizeopt.simplify import OptSimplify |
| 9 |
from rpython.jit.metainterp.optimizeopt.pure import OptPure |
| 10 |
from rpython.jit.metainterp.optimizeopt.earlyforce import OptEarlyForce |
| 11 |
from rpython.rlib.jit import PARAMETERS, ENABLE_ALL_OPTS |
| 12 |
from rpython.rlib.unroll import unrolling_iterable |
| 13 |
|
| 14 |
|
| 15 |
ALL_OPTS = [('intbounds', OptIntBounds), |
| 16 |
('rewrite', OptRewrite), |
| 17 |
('virtualize', OptVirtualize), |
| 18 |
('string', OptString), |
| 19 |
('pure', OptPure), |
| 20 |
('earlyforce', OptEarlyForce), |
| 21 |
('heap', OptHeap), |
| 22 |
('unroll', None)] |
| 23 |
|
| 24 |
unroll_all_opts = unrolling_iterable(ALL_OPTS) |
| 25 |
|
| 26 |
ALL_OPTS_DICT = dict.fromkeys([name for name, _ in ALL_OPTS]) |
| 27 |
ALL_OPTS_LIST = [name for name, _ in ALL_OPTS] |
| 28 |
ALL_OPTS_NAMES = ':'.join([name for name, _ in ALL_OPTS]) |
| 29 |
|
| 30 |
assert ENABLE_ALL_OPTS == ALL_OPTS_NAMES, ( |
| 31 |
'please fix rlib/jit.py to say ENABLE_ALL_OPTS = %r' % (ALL_OPTS_NAMES,)) |
| 32 |
|
| 33 |
def build_opt_chain(enable_opts): |
| 34 |
optimizations = [] |
| 35 |
for name, opt in unroll_all_opts: |
| 36 |
if name in enable_opts: |
| 37 |
if opt is not None: |
| 38 |
o = opt() |
| 39 |
optimizations.append(o) |
| 40 |
if ('rewrite' not in enable_opts or 'virtualize' not in enable_opts or |
| 41 |
'heap' not in enable_opts or 'pure' not in enable_opts): |
| 42 |
optimizations.append(OptSimplify()) |
| 43 |
return optimizations |
| 44 |
|
| 45 |
if __name__ == '__main__': |
| 46 |
print(ALL_OPTS_NAMES) |