On Fri, 14 Mar 2014 12:52:35 +0100
David Guillen <da...@davidgf.net> wrote:

> If I allow also a 'PLUS' expression to be a valid address (adding the
> restriction that the two addends are a register and a constant) it
> happens (sometimes) that gcc comes up with an expression like this
> one:
> 
>      (plus:SI (plus:SI (reg:SI somereg)
>       (const_int 4))
>      (const_int 8))
> 
> 
> After taking a look at the 386 backend (and others) I just discovered
> that there is a function called LEGITIMIZE_RELOAD_ADDRESS which is
> responsible for handling this case. My issue is that this function is
> not being called and, from what I saw while debugging, it seems that
> the offending RTX expression is created after the address_reload pass,
> and thus impossible for this pass to legitimize the address.

Look at how e.g. the ARM backend and others handle the "strict"
parameter to the legitimate_address hook -- you need to use that to
forbid pseudo registers being allowed in RTXs in the strict case.
LEGITIMIZE_RELOAD_ADDRESS is probably a red herring (at least for the
simple cases you're probably dealing with to start with), and isn't used
for LRA anyway. Getting these bits right can be very fiddly! The (plus
(reg) (const)) operands can arise before/during during register
elimination, IIRC. (You might need to get the register-elimination bits
right, too...)

Just a guess, anyway. (http://gcc.gnu.org/wiki/reload might be helpful
if you've not read it.)

Julian

Reply via email to