|Generating Static Single Assignment ? email@example.com (kphillips) (2008-02-29)|
|Re: Generating Static Single Assignment ? firstname.lastname@example.org (Richard Pennington) (2008-03-01)|
|Re: Generating Static Single Assignment ? email@example.com (=?ISO-8859-1?Q?Roland_Lei=DFa?=) (2008-03-02)|
|Re: Generating Static Single Assignment ? firstname.lastname@example.org (2008-03-03)|
|Date:||Sun, 2 Mar 2008 04:01:05 -0800 (PST)|
|Posted-Date:||02 Mar 2008 09:46:12 EST|
> 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:
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:
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.
Return to the
Search the comp.compilers archives again.