HLL expression -> ASM

"Alexei A. Frounze" <alexfru@chat.ru>
26 Mar 2001 13:55:46 -0500

          From comp.compilers

Related articles
HLL expression -> ASM alexfru@chat.ru (Alexei A. Frounze) (2001-03-26)
Re: HLL expression -> ASM danb2k@hotmail.com (Dan Bishop) (2001-03-27)
Re: HLL expression -> ASM dummy_addressee@hotmail.com (Alexei A. Frounze) (2001-03-31)
Re: HLL expression -> ASM titzer@expert.cc.purdue.edu (Ben L. Titzer) (2001-03-31)
Re: HLL expression -> ASM rhyde@transdimension.com (Randall Hyde) (2001-03-31)
Re: HLL expression -> ASM marcov@stack.nl (Marco van de Voort) (2001-04-04)
Re: HLL expression -> ASM dummy_addressee@hotmail.com (Alexei A. Frounze) (2001-04-10)
[2 later articles]
| List of all articles for this month |

From: "Alexei A. Frounze" <alexfru@chat.ru>
Newsgroups: comp.compilers
Date: 26 Mar 2001 13:55:46 -0500
Organization: Global Crossing Telecommunications
Keywords: code, question
Posted-Date: 26 Mar 2001 13:55:46 EST

Hi guys.....
I've got a question...

I know how to parse the source, how to evaluate expressions several
similar ways: recursively or using stack(s). OK, that works perfectly,
no problems. And I can create a tree for the expression as well.

Now, how do I transform the tree/whatever (let's say only integer
values/vars involved in the expression) into an ASM piece of code w/o
consuming extra memory for partial results, just using CPU registers?
Is there any basic idea/algorithm which I'm missing? It must be
simple, I guess...

Alexei A. Frounze
alexfru [AT] chat [DOT] ru
[A simple approach is to walk the tree depth first, passing up the
register at each stage that has the result, and tracking which
registers are available. If you have three or four free registers,
this works in a remarkably large number of cases. Beyond that you
have to preprocess the tree to look for subtrees that won't fit in the
available registers and either reorganize or spill results to memory.
Most compiler texts should cover this. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.