Related articles |
---|
Generating Static Single Assignment ? kevin.phillips83@yahoo.com (kphillips) (2008-02-29) |
Re: Generating Static Single Assignment ? rich@pennware.com (Richard Pennington) (2008-03-01) |
Re: Generating Static Single Assignment ? roland.leissa@googlemail.com (=?ISO-8859-1?Q?Roland_Lei=DFa?=) (2008-03-02) |
Re: Generating Static Single Assignment ? parthaspanda22@gmail.com (2008-03-03) |
From: | "=?ISO-8859-1?Q?Roland_Lei=DFa?=" <roland.leissa@googlemail.com> |
Newsgroups: | comp.compilers |
Date: | Sun, 2 Mar 2008 04:01:05 -0800 (PST) |
Organization: | Compilers Central |
References: | 08-03-004 |
Keywords: | SSA |
Posted-Date: | 02 Mar 2008 09:46:12 EST |
Hi,
> Hi, I am currently building my first compiler through the help of a
> few books. So far I have my grammar and most of the front-end ready,
> up to the AST.
I am currently building my own compiler as a fun project, too. Perhaps
you want to take a look:
http://swiftc.berlios.de/
My front-end and middle-end is more or less ready. I am working at the
register allocation at the moment.
> Next step is to convert to intermediate code. What I am not sure
> about is whether to generate Three Address Code, or SSA. Most books
> introduce triples and quadruples, and then talk about SSA later on,
> stating that it can be used for many optimization/transformation
> techniques and is preferred over 3ac/etc.
First of all you must know that SSA form does not mean, that your
instructions do not have a form like this:
a = b + c
In SSA form it is just important that 'a' is only defined once.
Here some reading related to SSA form:
http://grothoff.org/christian/teaching/2007/3353/papers/ssa.pdf
http://www.hipersoft.rice.edu/grads/publications/dom14.pdf
I would advise you building SSA form.
> Can I generate SSA immediately from the AST?
I am doing it like this:
First I am building intermediate code where not all vars have SSA
property. Building this is pretty straightforward. For every var
stored in the middle-end I store a var nr. Negative values mean, that
these vars are defined at least once. Positive values mean, that these
vars are defined exactly once. The latter can be the case for instance
when temporary vars have to be created as my instructions are three
address code. Vars with the same var nr correspond to the same var.
Then the algorithms in the above papers transform my intermediate code
to real SSA form. This is the "most directly" way I found for doing
his. However depending on your language you can even directly generate
SSA form. This is the case for a Lisp/Scheme like language. But AFAIK
this is not the case for most languages.
Greetz,
R. Lei_a
Return to the
comp.compilers page.
Search the
comp.compilers archives again.