2011/10/28 Georg-Johann Lay <a...@gjlay.de>:
> Georg-Johann Lay schrieb:
>
>> This patch adds named address space support to read data from flash (aka.
>> progmem) to target AVR.
>>
>> The patch has two parts:
>>
>> The first part is a repost of Ulrich's work from
>>    http://gcc.gnu.org/ml/gcc/2011-08/msg00131.html
>> with the needed changes to ./gcc and ./gcc/doc
>>
>> This patch is needed because the target hooks MODE_CODE_BASE_REG_CLASS and
>> REGNO_MODE_CODE_OK_FOR_BASE_P don't distinguish between different address
>> spaces.  Ulrich's patch adds respective support to these hooks.
>>
>> The second part is the AVR dependent part that adds __pgm as address space
>> qualifier for address space AS1.
>>
>> The AVR part is just the worker code.  If there is agreement that AS support
>> for AVR is okay in principle and Ulrich's work will go into GCC, I will 
>> supply
>> test programs and updates to the user manual, of course.
>>
>> The major drawbacks of the current AS implementation are:
>>
>> - It works only for C.
>>   For C++, a language extension would be needed as indicated in
>>      ISO/IEC DTR 18037
>>      Annex F - C++ Compatibility and Migration issues
>>      F.2 Multiple Address Spaces Support
>>
>> - Register allocation does not a good job. AS1 can only be addressed
>>   byte-wise by one single address register (Z) as per *Z or *Z++.
>
> This flaw from register allocator are filed as PR50775 now.
>
>> The AVR part does several things:
>>
>> - It locates data in AS1 into appropriate section, i.e. somewhere in
>>   .progmem
>>
>> - It does early sanity checks to ensure that __pgm is always accompanied
>>   with const so that writing to AS1 in not possible.
>>
>> - It prints LPM instructions to access flash memory.
>
> The attached patch is an update merge so that it fits without conflicts.
>
> The patch requires Ulrich's works which is still in review
>   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50775
>
> The regression tests run with this patch and the new ChangeLog enttry si
> written as if Ulrich's patch was applied.
>
> Tests pass without regression.
>
> Besides the update to a nor up-to-date SVN version, the patch sets a built-in
> define __PGM so that it is easy for users to test if or if not the feature is
> available.
>
> Documentation and test cases will follow in separate patch.
>
> Ok for trunk after Ulrich's work has been approved?
>
> Johann
>
>        PR target/49868
>        * config/avr/avr.h (ADDR_SPACE_PGM): New define for address space AS1.
>        (REGISTER_TARGET_PRAGMAS): New define.
>        * config/avr/avr-protos.h (avr_mem_pgm_p): New prototype.
>        (avr_register_target_pragmas): New prototype.
>        (avr_log_t): Add field "progmem".  Order alphabetically.
>        * config/avr/avr-log.c (avr_log_set_avr_log): Set avr_log.progmem.
>        * config/avr/avr-c.c (langhooks.h): New include.
>        (avr_register_target_pragmas): New function. Register address
>        space AS1 as "__pgm".
>        (avr_cpu_cpp_builtins): Add built-in define __PGM.
>        * config/avr/avr.c: Include "c-family/c-common.h".
>        (TARGET_LEGITIMATE_ADDRESS_P): Remove define.
>        (TARGET_LEGITIMIZE_ADDRESS): Remove define.
>        (TARGET_ADDR_SPACE_SUBSET_P): Define to...
>        (avr_addr_space_subset_p): ...this new static function.
>        (TARGET_ADDR_SPACE_CONVERT): Define to...
>        (avr_addr_space_convert): ...this new static function.
>        (TARGET_ADDR_SPACE_ADDRESS_MODE): Define to...
>        (avr_addr_space_address_mode): ...this new static function.
>        (TARGET_ADDR_SPACE_POINTER_MODE): Define to...
>        (avr_addr_space_pointer_mode): ...this new static function.
>        (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Define to...
>        (avr_addr_space_legitimate_address_p): ...this new static function.
>        (TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS): Define to...
>        (avr_addr_space_legitimize_address): ...this new static function.
>        (avr_mode_code_base_reg_class): Handle AS1.
>        (avr_regno_mode_code_ok_for_base_p): Handle AS1.
>        (lpm_addr_reg_rtx, lpm_reg_rtx): New static GTYed variables.
>        (avr_decl_pgm_p): New static function.
>        (avr_mem_pgm_p): New function.
>        (avr_asm_len): Return always "" instead of void.
>        (avr_out_lpm_no_lpmx): New static function.
>        (avr_out_lpm): New static function.
>        (output_movqi, output_movhi, output_movsisf): Call avr_out_lpm to
>        handle loads from progmem.
>        (avr_progmem_p): Test if decl is in AS1.
>        (avr_pgm_pointer_const_p): New static function.
>        (avr_pgm_check_var_decl): New static function.
>        (avr_insert_attributes): Use it.  Change error message to report
>        cause (progmem or AS1) when code wants to write to AS1.
>        (avr_section_type_flags): Unset section flag SECTION_BSS for
>        data in progmem.
>        * config/avr/avr.md (LPM_REGNO): New define_constants.
>        (movqi, movhi, movsi, movsf): Skip if code would write to AS1.
>        (movmemhi): Ditto.  Propagate address space information to newly
>        created MEM.
>        (split-lpmx): New split.
>

Approved.

Denis.

Reply via email to