Related articles |
---|
Native Code Generation from Abstract Stack Machine kevin@albrecht.net (Kevin Albrecht) (2004-02-27) |
Re: Native Code Generation from Abstract Stack Machine alex_mcd@btopenworld.com (Alex McDonald) (2004-03-02) |
Re: Native Code Generation from Abstract Stack Machine m.dentico@no-spam.it (Massimo Dentico) (2004-03-02) |
Re: Native Code Generation from Abstract Stack Machine bill@qswtools.com (Bill Cox) (2004-03-06) |
Re: Native Code Generation from Abstract Stack Machine peter@javamonkey.com (Peter Seibel) (2004-03-06) |
Re: Native Code Generation from Abstract Stack Machine peter@javamonkey.com (Peter Seibel) (2004-03-11) |
Re: Native Code Generation from Abstract Stack Machine samiam@moorecad.com (Scott Moore) (2004-03-11) |
Re: Native Code Generation from Abstract Stack Machine eliotm@pacbell.net (Eliot Miranda) (2004-03-11) |
Re: Native Code Generation from Abstract Stack Machine bonzini@gnu.org (2004-03-19) |
From: | Peter Seibel <peter@javamonkey.com> |
Newsgroups: | comp.compilers |
Date: | 11 Mar 2004 12:45:31 -0500 |
Organization: | SBC http://yahoo.sbc.com |
References: | 04-02-179 04-03-031 |
Keywords: | architecture, code |
Posted-Date: | 11 Mar 2004 12:45:31 EST |
Peter Seibel <peter@javamonkey.com> writes:
> I assume there are standard techniques for turning stack machine
> code into abstract register code. Are there any good references
> where I can read about them?
> [The simplest way is to treat the registers as a stack and run
> through each basic block assigning values to registers. -John]
Okay. If I understand you and what you mean by abstract register code
this means I take each basic block and for each value pushed on the
stack create a new abstract register (i.e. temporary variable). So if
one of my basic blocks is
push 1
push 2
goto C
That gets translated to:
t1 = 1
t2 = 2
goto C
Assuming that's right, now suppose I have three basic blocks A, B, and
C. A is as above. B is similar in stack code and gets translated to:
t3 = 10
t4 = 20
goto C
And C is simply an ADD instruction which pops two values. Presumably
we need to generate abstract registers to hold the "inputs" to a basic
block. So it gets translated to this:
t5 = t6 + t7
Since both A and B are predecessors of C but they are storing those
values into different abstract registers I need to somehow arrange to
get the correct values in t6 and t7. So do I generate A and B like this:
A:
t1 = 1
t2 = 2
t6 = t1
t7 = t2
goto C
B:
t3 = 10
t4 = 20
t6 = t3
t7 = t2
goto C
and then count on copy propagation and dead-code elimination to get
rid of some of the temporaries? Or am I making this too complicated?
-Peter
--
Peter Seibel peter@javamonkey.com
Return to the
comp.compilers page.
Search the
comp.compilers archives again.