[antlr-interest] Non-local optimizations with treewalker?

Loring Craymer lgcraymer at yahoo.com
Sat Sep 15 11:22:03 PDT 2007


The answer, of course, is "yes and no".  Yes, because
capturing the semantics on which you base your
optimizations on in a tree makes it easier to carry
out a series of transformations.  No, because you need
to impose a control flow graph on top of the tree
(easy to do) and add other data structures to capture
relationships between distant nodes in the tree during
analysis.  Transformation passes over trees are
interspersed with analysis passes; analysis passes
invariably require additional data structures,
including symbol tables, to capture the results of the
analysis for the next transformation or code
generation pass.

So:  trees are central to syntactic/semantic
transformation, but they are not the only tool needed
for analysis.

--Loring

--- Sohail Somani <sohail at taggedtype.net> wrote:

> Hi,
> 
> Is it feasible/intelligent to do non-local
> optimizations with an antlr
> (2.7.6) treewalker? I specify 2.7.6 because the
> readme for antlr3 says
> that it might crash on syntax errors!
> 
> For example, assuming immutable variables and no
> side-effects:
> 
> v = f(x)
> ...
> w = f(x)
> 
> I'd like to transform into:
> 
> temp = f(x)
> v = temp
> ...
> w = temp
> 
> I think it isn't the smartest thing to use
> treewalkers for this but I'd
> like to be wrong, preferably with a verbose beat
> down as to why.
> 
> Thanks,
> 
> Sohail
> 



       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/


More information about the antlr-interest mailing list