|HLL expression -> ASM email@example.com (Alexei A. Frounze) (2001-03-26)|
|Re: HLL expression -> ASM firstname.lastname@example.org (Dan Bishop) (2001-03-27)|
|Re: HLL expression -> ASM email@example.com (Alexei A. Frounze) (2001-03-31)|
|Re: HLL expression -> ASM firstname.lastname@example.org (Ben L. Titzer) (2001-03-31)|
|Re: HLL expression -> ASM email@example.com (Randall Hyde) (2001-03-31)|
|Re: HLL expression -> ASM firstname.lastname@example.org (Marco van de Voort) (2001-04-04)|
|Re: HLL expression -> ASM email@example.com (Alexei A. Frounze) (2001-04-10)|
|Re: HLL expression -> ASM firstname.lastname@example.org (Bill A.) (2001-04-10)|
|Re: HLL expression -> ASM email@example.com (2001-04-10)|
|From:||"Randall Hyde" <firstname.lastname@example.org>|
|Date:||31 Mar 2001 02:48:29 -0500|
|Organization:||Posted via Supernews, http://www.supernews.com|
|Posted-Date:||31 Mar 2001 02:48:29 EST|
"Dan Bishop" <email@example.com> wrote in message
> Do a postorder transversal of the tree. When a value/variable is reached,
> emit code to push it on to the CPU stack. For "operator" nodes, pop two
> values from the stack, perform the operation, and push the result back
> onto the stack.
> [If you pretend the registers are the stack and assign the "pushed"
> values to registers, you can get code that's not bad considering how
> easy this technique is. -John]
Note, btw, that Alex failed to mention that the target platform is
the x86 which has limited registers and each register has some
special uses that may or may not be needed for certain calculations
in the expression (e.g., EDX:EAX for DIV/IDIV, CL for SHL/SHR,
etc). Having read his posts in CLAX, I can assure you that using
the hardware stack in place of the registers is unacceptable (except,
of course, for spilling the registers if an expression gets too complex).
Suitable questions are:
(1) is it better to reserve certain registers for specific purposes or
treat them all as general purpose and deal with the exceptions
as they arise?
(2) How to choose which register to use (e.g., I suggested using
a powerset, extracting and returning registers as needed).
(3) How best to handle spilling register to memory.
Return to the
Search the comp.compilers archives again.