2012/1/10 Georg-Johann Lay <a...@gjlay.de>:
> This patch extends the semantics of 24-bit __pgmx address space qualifier to
> cover RAM and Flash.
>
> RAM is represented by setting the high byte of 24-bit address to 0x80. The 
> code
> to read from 24-bit address space decides at runtime what instruction to use 
> to
> read by if-else decision depending on bit 23 of the address, i.e. the code
> looks like.
>
> if address.23
>    return LD reg, Z // read from RAM
> else
>    if have RAMPZ
>        RAMPZ = address.msb
>    return LPM reg, Z // read from Flash
>
> The code in avr.c actually gets simpler because more work is shifted to libgcc
> as the code to emit gets more complex.
>
> Moreover, there is better separation of 16-bit address spaces and 24-bit
> address spaces because even on small devices with just 1 flash segment 24-bit
> pointers make sense now.
>
> Ok for trunk?
>
> This should be the last patch for 4.7 from my side that adds new 
> functionality,
> so that all what remains is documentation and release note updates, test cases
> and bug fixes.
>
> Unfortunately, the address space implementation in GCC is odd from the user
> perspective, in particular when dealing with literals.
>
> Johann
>
> libgcc/
>        PR target/49868
>        Extend __pgmx semantics to linearize memory.
>        * config/avr/t-avr (LIB1ASMFUNCS): Add _xload_1, _movmemx.
>        * config/avr/lib1funcs.S (__xload_1): New function.
>        (__movmemx_qi, __movmemx_hi): New functions.
>        (__xload_2, __xload_3, __xload_4): Rewrite to fit new __pgmx
>        semantics.
>
> gcc/
>        PR target/49868
>        Extend __pgmx semantics to linearize memory.
>        * config/avr/avr.md (mov<mode>): Use avr_xload_libgcc_p to
>        determine if code comes inline or from libgcc.
>        (MOVMEM_r_d:HI): Add "w" to constraint for better preference.
>        (movmem_qi, movmem_qi): Set constraint #2 to "n".
>        (movmem_qi_elpm, movmem_hi_elpm): Remove insns.
>        (movmemx_qi, movmemx_hi): New insns.
>        (xload_<mode>_libgcc): Rewrite to new insn condition.
>        (xload_<mode>): Remove insns.
>        * config/avr/avr.c (avr_out_xload): Rewrite: Only need to handle
>        cases that don't satisfy avr_xload_libgcc_p().
>        (avr_addr_space_convert): Allow converting in any direction.
>        (avr_addr_space_subset_p): Return always true.
>        (avr_xload_libgcc_p): Rewrite to fit new __pgmx semantics.
>        (avr_emit_movmemhi): Ditto.
>        (avr_out_lpm): No need to handle ADDR_SPACE_PGMX any more.
>        (avr_out_movmem): Ditto.
>        (AVR_SYMBOL_FLAG_PROGMEM): New macro.
>        (AVR_SYMBOL_SET_ADDR_SPACE): New macro.
>        (AVR_SYMBOL_GET_ADDR_SPACE): New macro.
>        (avr_encode_section_info): Encode 'progmem' in symbol flags.
>        (output_reload_in_const): Don't zero-extend any 24-bit symbols.

Approved.

Denis.

Reply via email to