Re: x86 register allocation

"Charles E. Bortle, Jr." <cbrtjr@ix.netcom.com>
28 Mar 1999 17:10:01 -0500

          From comp.compilers

Related articles
x86 register allocation dplass@yahoo.com (1999-03-23)
Re: x86 register allocation dwight@pentasoft.com (1999-03-28)
Re: x86 register allocation rsherry@home.com (Robert Sherry) (1999-03-28)
x86 register allocation postiffm@umich.edu (Matt Postiff) (1999-03-28)
Re: x86 register allocation bcombee@metrowerks.com (1999-03-28)
Re: x86 register allocation sander@haldjas.folklore.ee (Sander Vesik) (1999-03-28)
Re: x86 register allocation cbrtjr@ix.netcom.com (Charles E. Bortle, Jr.) (1999-03-28)
| List of all articles for this month |

From: "Charles E. Bortle, Jr." <cbrtjr@ix.netcom.com>
Newsgroups: comp.compilers
Date: 28 Mar 1999 17:10:01 -0500
Organization: Netcom
References: 99-03-080
Keywords: 386, registers, comment

For what my opinion is worth, I found when I wrote a FORTRAN compiler
for MS-DOS on 8088/8086 CPU, that, since, as you have observed, there
are so many register-specific instructions, that you really can't
implement true register allocation. I more-or-less hardwired the
register allocation into the code generated. For the FPU instructions
this is normally the stack registers.


For each instruction, such as ADD I look at each operand's type, and
based on the specific instruction (ADD, SUB, etc.) I emit the code
that accesses the data in a specific way, such as St(0), st(1), etc.


Loop instructions use CX so if you use the loop instructions you have
no choice.


I was going to post an example here, but decided it was rather long
and might offend someone, so instead I will email it to you. If
others want to see it they can email me requesting it.


As an example I was going to present a listing created by my compiler,
and the assembly language code generated: (It's not the cleanest or
most efficient, but it actually runs...most of the work is done by the
FPU but the CPU registers come into play too) but it was so long that
I did not want to offend anyone by posting it here...so I will
email-attached it to you. If others want to see it they can email a
request to me.
--
Charles cbrtjr@ix.netcom.com
[I believe that on the more recent Pentiums, you're often better off using
simple instructions than the specialized loop ones. For example JCXZ is
generally slower than CMP ECX,$0 and JZ. -John]


Post a followup to this message

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