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]

Re: Problems with register elimination


On 7/28/13 8:16 AM, David Given wrote:
I am having a great deal of trouble getting register elimination (and
stack frame layouts in general) working properly on my architecture.
There is some fundamental issue I'm simply not getting here.
[...]
Weirdness (1): I never see ARG_POINTER_REGNUM used to access arguments.
The compiler seems to want to access function arguments via
FRAME_POINTER_REGNUM plus a small value, which means they overlap the
locals. (It's definitely using the same numeric ranges. It looks like
it's trying to use ARG_POINTER_REGNUM but is getting the wrong register.)


Internally, ARG_POINTER_REGNUM is a pointer to the incoming arguments
which is pushed into stack by caller, and FRAME_POINTER_REGNUM is a
pointer to the first location of local variables.

                            |    |
       old stack pointer ->  ----
                            |    | \
                            |    |   incoming arguments pushed by caller
                            |    | /
        argument pointer ->   --
                            |    |
                            |    |
                            |    |
           frame pointer ->   --
                            |    | \
                            |    |   local variables
                            |    | /
                              --
                            |    | \
                            |    |   outgoing arguments
                            |    | /
           stack pointer ->  ----
                            |    |


Weirdness (2): the following test function generates code with tries to
copy AP_REG into a register without eliminating it.

[...]

I don't know whether this is just talking about the MCore, or gcc in
general --- I find it interesting that most backends which use a fake
frame pointer seem to end up with FRAME_POINTER_REGNO and
HARD_FRAME_POINTER_REGNO pointing at different addresses.

If anyone can offer any suggestions as to what I'm doing wrong --- or,
better still, point me at more in-depth reading on how all this is
supposed to work!


Did you implement TARGET_CAN_ELIMINATE and INITIAL_ELIMINATION_OFFSET ??

You need to implement these two target macros to eliminate ARG_POINTER_REGNUM
and FRAME_POINTER_REGNUM into HARD_FRAME_POINTER_REGNUM.


Best regards,
jasonwucj


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