This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Stocking temporaries in memory instead of registers?


Hi everybody,

In order to get a first working draft of my port to a register-less
architecture, I'd need to find a way to store temporaries into memory
instead of registers.

For example, the following C code:
res = a + b + c;

Gets for now compiled into:
.Temp res
.Temp a
.Temp b
.Temp c

....

rg4 <- a + b
res <- rg4 + c

(rg4 being the first available "dummy" register I've declared)

while I'd like to have:
.Temp res
.Temp a
.Temp b
.Temp c
.Temp temp0

....

temp0 <- a + b
res <- temp0 + c

I've thought of several ways to do so, but none seemed right:
        * Suppressing all the non-fixed registers caused the INSNs not
          to match - GCC seems to absolutely want the temporaries to be
          stocked into registers.
        * Maintaining a table of used registers within the block and
          declaring .Temps at FUNCTION_PROLOGUE time might do it, but is
          nothing else but a dirty hack.

The ideal solution would be to get GCC to allocate storage on the frame
for temporaries - that way I'd just need to examine the memory allocated
for the frame, find out the type of the temporary by looking at the
insns and/or parse tree, and I'm done. Is there a way to do so? Or does
any of you have a nicer trick than what I've described above?

My (yet incomplete) MD files are available at
http://www.gnurou.org/camille.h
http://www.gnurou.org/camille.md
http://www.gnurou.org/camille.c

in case you'd want to have a look at this weird port! ;)

Thanks in advance for any help!
Alex.
-- 
http://www.gnurou.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]