Related articles |
---|
Is it just me or... jaycole@bgn.mindspring.com (1997-01-22) |
Re: Is it just me or... genew@mindlink.bc.ca (1997-01-25) |
Re: Is it just me or... anton@a0.complang.tuwien.ac.at (1997-01-25) |
Re: Is it just me or... mslamm@pluto.mscc.huji.ac.il (1997-01-25) |
Re: Is it just me or... preston@tera.com (1997-01-26) |
Re: Is it just me or... kers@hplb.hpl.hp.com (1997-01-29) |
Re: Is it just me or... tim@novelty.demon.co.uk (Tim Roberts) (1997-01-30) |
Re: Is it just me or... baynes@ukpsshp1.serigate.philips.com (1997-02-07) |
Re: Is it just me or... andrei@iastate.edu (1997-02-08) |
Re: Is it just me or... cdc@cosc.canterbury.ac.nz (Carl Cerecke) (1997-02-11) |
Re: Is it just me or... 100440.2732@CompuServe.COM (Robert Taylor) (1997-02-16) |
Re: Is it just me or... amoroso@mclink.it (1997-02-22) |
Re: Is it just me or... topher@vivid.com (1997-03-01) |
From: | baynes@ukpsshp1.serigate.philips.com |
Newsgroups: | comp.compilers |
Date: | 7 Feb 1997 23:32:13 -0500 |
Organization: | Compilers Central |
References: | 97-01-180 |
Keywords: | optimize, practice |
Jay Cole (jaycole@bgn.mindspring.com) wrote:
: 2) Am I one of the few people in the compiler world that prefers to
: generate and optimize code from a tree-type structure rather than
: tuples? I find optimization and manipulation much easier in the tree
: format. I just have a difficult time generating real good code from
: the tuple format. Is there a good book on tuple based code
: generation?
Having worked on a tree based C compiler I can say it has both
advantages and disadvantages. A lot depends on what your language is
like.
A tree based compiler is great for a well structured language and can
produce good code. It may even be better than a tuple based compiler
as on does not have the same division between inter- and intra- basic
block optimizations. For example:
x = 1;
if( a ) b = c;
y = 2 * x;
In a tuple based compiler the two uses of would be in different basic
blocks (because of the 'if'). In a tree based compiler they are in the
same block (with the if introducing sub blocks).
The problem comes when you have to handle strucure breaking statements
such as goto. I have not found a good solution to this. What we did
was to deal with a few special cases and then for anything else to
turn of the register optimization for the function containing the
problem construct. The special cases were 'switch' where a
conventionally written switch statement was recognized as a properly
structured construct and embeded 'return' where this was handled by
flushing registers at that point. Things like 'goto' could have been
handled better by flushing registers at that point and at the
destination lable rather than turning of optimization but it was not
worth the effort.
As the vast majority of the code we wanted to compile was well written
the occasional unoptimized function was not a problem. In fact the
warning that the optimization had been turned off was often useful to
users when it pointed out things like a mistake in a switch statment
like a missing break.
Tuple based compilers are better for unstructured languages such as
fortran and as these have been the majority in the past a body of
expertise has built up and I would expect this is why the majority
still work this way.
--
Stephen Baynes MBCS CEng Stephen.Baynes@soton.sc.philips.com
Philips Semiconductors Ltd
Southampton SO15 0DJ +44 (01703) 316431
United Kingdom
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.