On 30 October 2010 05:45, Joern Rennecke <joern.renne...@embecosm.com> wrote: > Quoting Mohamed Shafi <shafi...@gmail.com>: > >> On 29 October 2010 00:06, Joern Rennecke <joern.renne...@embecosm.com> >> wrote: >>> >>> Quoting Mohamed Shafi <shafi...@gmail.com>: >>> >>>> Hi, >>>> >>>> I am doing a port in GCC 4.5.1. For the port >>>> >>>> 1. there is only (reg + offset) addressing mode only when reg is SP. >>>> Other base registers are not allowed >>>> 2. FP cannot be used as a base register. (FP based addressing is done >>>> by copying it into a base register) >>>> In order to take advantage of FP elimination (this will create SP + >>>> offset addressing), what i did the following >>>> >>>> 1. Created a new register class (address registers + FP) and used this >>>> new class as the BASE_REG_CLASS >>> >>> Stop right there. You need to distinguish between FRAME_POINTER_REGNUM >>> and HARD_FRAME_POINTER_REGNUM. >>> >> >> From the description given in the internals, i am not able to >> understand why you suggested this. Could you please explain this? > > In order to trigger reloading of the address, you have to have a register > elimination, even if the stack pointer is not a suitable destinatination > for the elimination. Also, if you want to reload do the work for you, > you must not lie to it about the addressing capabilities of an actual hard > register. Hence, you need separate hard and soft frame pointers. >
Debugging sessions of the reload pass tells me that if the reload_pass get the address of the form (reg + off), it assumes one of the following: 1. the address is invalid because 'reg' is not a suitable base register 2. the offset is out of range 3. the address has an eliminatable register as a base register. Depending on what it finds, reload_pass reloads the address accordingly. So for my target when the pass encounters the address of the form: (plus:QI (reg/f:QI 33 ArgP) (const_int -2 [0xfffffffffffffffe])) it eliminates the arg pointer to either stack or frame pointer and reloads it. If the base register is FP, during reloading it just reloads the FP with a valid base register, but then the address becomes invalid. Relaod_pass cannot figure out that the addressing mode itself is invalid due to wrong base register. Since SP is the only valid register among the base registers that can form (reg + off) addressing mode, for the reload to work properly i will have to allow this addressing mode only when SP is base register - even in non-strict mode. But then i will loose lot of oppurtunities when elimination happens in favour of SP. Hence i allow the above form of address for all frame related pesudos. So to respond to your comments, i agree that as far as possible the port has to be truthful to reload pass about the addressing mode capabilities, but then i am not sure if distinguishing between FRAME_POINTER_REGNUM and HARD_FRAME_POINTER_REGNUM will help my cause. Do you agree? Or am i not understanding what your suggestion implies? Shafi