Ulrich Weigand wrote:
> Georg-Johann Lay wrote:
> 
>> Trying to make named address space support work for target AVR,
>> I am facing the following problem:
>>
>> For generic AS, there are three valid base pointer registers
>> X , Y and Z.
>>
>> For the new __pgm AS, only Z is available without offset.
>>
>> The problem is now that addresses.h:base_reg_class() does not
>> pass down AS information, i.e. addr_space_t down to target hook
>> MODE_CODE_BASE_REG_CLASS.
>>
>> Likewise for REGNO_MODE_CODE_OK_FOR_BASE_P.
>>
>> The MODE argument that both of these get describe the mode of
>> the MEM but not the mode associated with the AS.
>>
>> Thus, it is not possible to provide proper implementations of
>> these hooks.  IRA/reload choses the wrong hard register so
>> that in postreload no constraints match, i.e.
>> TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P returns wrong for that
>> hard register (which is right) so that postreload busts.
>>
>> I'd just like to reassure me that I didn't do something fundamentally
>> wrong and named address space support if not yet smoothly supported
>> in GCC.
> 
> No, you're correct.  The only target supporting named address spaces
> today is spu-elf, and here we're eliminating any reference to the
> non-default space during expand, so that reload never sees any.

So a solution for me would be to expand as inline asm instead of as
proper insns.  Yes, it's hack.  But before AS support I tried it via
builtin that expanded as unspec and IRA created horribly bloated code.

The annoyance is that only POST_INC addresses for one single hard reg
is supported by the device.  Greetings from spill fails...


> This means that problems like the one you're seeing have been hidden
> so far.  I've started looking into fixing this, but since I don't
> have a target where this is needed, this effort never really went
> anywhere.  I'll append below a patch I did a year or so ago; just
> as something to look at, it probably will not even apply to the
> current sources any more.

Sounds great that you tried to fix it!  Much work below... wow.

> I'd be happy to bring this up to date if you're willing to work with
> me to get this tested on a target that needs this support ...

Just attached a patch to bugzilla because an AVR user wanted to play
with the AS support and asked me to supply my changes. It's still in
a mess but you could get a more reasonable base than on a target where
all named addresses vanish at expand.

The patch is fresh and attached to the enhancement PR49868, just BE stuff.
There is also some sample code.

http://gcc.gnu.org/PR49868

Johann


> Bye,
> Ulrich
> 
> 
> 
> ChangeLog:
> 
>       * doc/tm.texi (MODE_CODE_BASE_REG_CLASS): Add address space
>       argument.
>       (REGNO_MODE_CODE_OK_FOR_BASE_P): Likewise.
> 
>       * config/cris/cris.h (MODE_CODE_BASE_REG_CLASS): Add address
>       space argument.
>       (REGNO_MODE_CODE_OK_FOR_BASE_P): Likewise.
>       * config/bfin/bfin.h (MODE_CODE_BASE_REG_CLASS): Likewise.
>       (REGNO_MODE_CODE_OK_FOR_BASE_P): Likewise.
> 
>       * addresses.h (base_reg_class): Add address space argument.
>       Pass to MODE_CODE_BASE_REG_CLASS.
>       (ok_for_base_p_1): Add address space argument.  Pass to
>       REGNO_MODE_CODE_OK_FOR_BASE_P.
>       (regno_ok_for_base_p): Add address space argument.  Pass to
>       ok_for_base_p_1.
> 
>       * regrename.c (scan_rtx_address): Add address space argument.
>       Pass address space to regno_ok_for_base_p and base_reg_class.
>       Update recursive calls.
>       (scan_rtx): Pass address space to scan_rtx_address.
>       (build_def_use): Likewise.
>       * regcprop.c (replace_oldest_value_addr): Add address space
>       argument.  Pass to regno_ok_for_base_p and base_reg_class.
>       Update recursive calls.
>       (replace_oldest_value_mem): Pass address space to
>       replace_oldest_value_addr.
>       (copyprop_hardreg_forward_1): Likewise.
> 
>       * reload.c (find_reloads_address_1): Add address space argument.
>       Pass address space to base_reg_class and regno_ok_for_base_p.
>       Update recursive calls.
>       (find_reloads_address): Pass address space to base_reg_class,
>       regno_ok_for_base_p, and find_reloads_address_1.
>       (find_reloads): Pass address space to base_reg_class.
>       (find_reloads_subreg_address): Likewise.
> 
>       * ira-costs.c (record_reg_classes): Update calls to base_reg_class.
>       (ok_for_base_p_nonstrict): Add address space argument.  Pass to
>       ok_for_base_p_1.
>       (record_address_regs): Add address space argument.  Pass to
>       base_reg_class and ok_for_base_p_nonstrict.  Update recursive calls.
>       (record_operand_costs): Pass address space to record_address_regs.
>       (scan_one_insn): Likewise.
> 
>       * caller-save.c (init_caller_save): Update call to base_reg_class.
>       * ira-conflicts.c (ira_build_conflicts): Likewise.
>       * reload1.c (maybe_fix_stack_asms): Likewise.

Reply via email to