Re: x86 register allocation

Robert Sherry <>
28 Mar 1999 16:59:49 -0500

          From comp.compilers

Related articles
x86 register allocation (1999-03-23)
Re: x86 register allocation (1999-03-28)
Re: x86 register allocation (Robert Sherry) (1999-03-28)
x86 register allocation (Matt Postiff) (1999-03-28)
Re: x86 register allocation (1999-03-28)
Re: x86 register allocation (Sander Vesik) (1999-03-28)
Re: x86 register allocation (Charles E. Bortle, Jr.) (1999-03-28)
| List of all articles for this month |

From: Robert Sherry <>
Newsgroups: comp.compilers
Date: 28 Mar 1999 16:59:49 -0500
Organization: @Home Network
References: 99-03-080
Keywords: 386, registers


Here are my thoughts on your question. I believe you are
correct in concluding that the register coloring idea will not work
well on this processor family. I would leave DX and AX as scratch
registers. This still leaves BX, CX , SI and DI for use.

My experience indicates to me that allocating registers on the
basic block level is the way to go. By a basic block on mean a section
of code with a single entry and single exit. You might want to
allocate BX and CX at the basic block level.

You did not mention the source language. Some languages have a
register key word in the language, which is an hint to the compiler
that this variable should be allocated to a fast register. If your
source language has such a feature you may want to allocate those
variables to SI and DI. You might also want to allocate SI and DI to
variable that are used the most throughout a single
subroutine/function. This can be done by simple counting the number of
times the variable is used/referenced in a function. This count can be
weighted for variables inside loops. One draw back is that your
compiler must either process the entire subroutine/function all at
once or be 2 passes. If this approach seems like to much work then you
could allocate SI and DI at the basic block level also.

I hope this helps.

Robert Sherry wrote:
> Can anyone give me a pointer to help me with x86 register allocation?

Post a followup to this message

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