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.
>
> If you have them, but conflate them when you describe what you are doing
> in your port, you are not only likely to confuse the listener/reader,
> but also your documentation, your code, and ultimately yourself.
>

Having a FRAME_POINTER_REGNUM and HARD_FRAME_POINTER_REGNUM will
trigger reloading of address. But for the following pattern

(insn 3 2 4 2 test.c:120 (set (mem/c/i:QI (plus:QI (reg/f:QI 35 SFP)
                         (const_int 1 [0x1])) [0 c+0 S1 A32])
            (reg:QI 0 g0 [ c ])) 7 {movqi_op} (nil))

where SFP is FRAME_POINTER_REGNUM, an elimination will result in

(insn 3 2 4 2 test.c:120 (set (mem/c/i:QI (plus:QI (reg/f:QI 27 as15)
                         (const_int 1 [0x1])) [0 c+0 S1 A32])
            (reg:QI 0 g0 [ c ])) 7 {movqi_op} (nil))

where as15 is the HARD_FRAME_POINTER_REGNUM. But remember this new
address is not valid (as only SP is allowed in this addressing mode).
When the above pattern is reloaded i get:

(insn 28 27 4 2 test.c:120 (set (mem/c/i:QI (plus:QI (reg:QI 28 a0)
                             (const_int 1 [0x1])) [0 c+0 S1 A32])
              (reg:QI 3 g3)) -1 (nil))

I get unrecognizable insn ICE, because this addressing mode is not
valid. I believe this happens because when the reload_pass get the
address of the form (reg + off), it assumes that the address is
invalid due to one of the following:

1. '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.

Is there any way to over come this one?

Any help is appreciated.

Shafi

Reply via email to