[LLVMdev] Saving one part of a register pair in the callee-saved list.

Borja Ferrer borja.ferav at gmail.com
Tue Jul 10 18:26:35 PDT 2012


Hello,

I would like to know if there's a way of setting the callee-saved register
list inside getCalleeSavedRegs() to make the PEI pass save/restore only one
half of a register pair if the other half is not being used, instead of
saving the whole pair. Here is an example of what I try to explain to make
things more clear:

Suppose this situation where we have a register file of 8bit regs, and that
you can form regpairs by joining two adjacent regs. Pairs are pseudo regs
that are formed by two 8 bit subregisters, with their lo and hi parts
defined in the register.td file. Both 8 and 16bit types are legal.
In the following function: char foo(char a, char b, char c, int d)
Arguments are passed this way: a=R10, b=R8, c=R6, d=R5:R4, so first three
come in a single reg while the last argument comes in a pair. Since all
registers are callee clobbered they have to be saved/restored in the
function. The current situation is that I've listed in the the callee-saved
register list the whole pairs of registers instead of their parts, so I'm
getting saved and restored R11:R10, R9:R8, R7:R6 and R5:R4 which is
expected. However, what I would like is to not save the first 3 pairs, but
only their low register parts, since the high register part is not being
used (push R10+push R8+push R6+push R5:R4).

I've tried listing both the pairs and their parts, but if a pair and one of
it's parts are used separately then I get both the pair and the part saved
(ie: push R1:R0+push R1+push R0) duplicating code. Also, only listing the
8bit regs works BUT I'm getting machine verifier errors because registers
are appearing twice in the live-ins list so I'm getting an error like this:
*** Bad machine code: Using an undefined physical register ***

I would like to know if it's possible to handle this situation.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120711/25003326/attachment.html>


More information about the llvm-dev mailing list