[Python-Dev] Rattlesnake progress
Mon, 25 Feb 2002 10:45:17 -0600
Tim> Excellent advice that almost nobody follows <0.5 wink>: choose a
Tim> flexible intermediate representation, then structure all your
Tim> transformations as independent passes, such that the output of
Tim> every pass is acceptable as the input to every pass.
I did this with my peephole optimizer. It worked great. Each peephole
optimization is a very simple subclass of an OptimizeFilter base class. The
IR is essentially the bytecode split into basic blocks, with each basic
block a list of (opcode argument) tuples. Jump targets are represented as
simple indexes into the block list. (In fact, my Rattlesnake converter was
just a "peephole optimizer" named InstructionSetConverter.) As Tim
mentioned about KISS, this means you sometimes have to run particular
optimizations or groups of optimizations multiple times.
I want to get it checked into the sandbox where others can play with it, but
time has shifted its foundation a tad and a couple optimizations don't work