Re: HLL expression -> ASM

"Randall Hyde" <rhyde@transdimension.com>
31 Mar 2001 02:48:29 -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)
Re: HLL expression -> ASM bill@megahits.com (Bill A.) (2001-04-10)
Re: HLL expression -> ASM henry@spsystems.net (2001-04-10)
| List of all articles for this month |

From: "Randall Hyde" <rhyde@transdimension.com>
Newsgroups: comp.compilers
Date: 31 Mar 2001 02:48:29 -0500
Organization: Posted via Supernews, http://www.supernews.com
References: 01-03-131 01-03-153
Keywords: code, assembler
Posted-Date: 31 Mar 2001 02:48:29 EST

"Dan Bishop" <danb2k@hotmail.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.
etc.
Randy Hyde


Post a followup to this message

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