diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2012-01-10 09:42:10 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2012-01-10 09:42:10 +0000 |
commit | cba300dd7dfadf5069d9943c6a54c65a34614d20 (patch) | |
tree | 835d7eb99a52b9c049a452e8468cb7613fa1e7ed /libgcc | |
parent | 59c615478de5b0f61ee750b8e0d21b5219407aba (diff) | |
download | gcc-cba300dd7dfadf5069d9943c6a54c65a34614d20.zip gcc-cba300dd7dfadf5069d9943c6a54c65a34614d20.tar.gz gcc-cba300dd7dfadf5069d9943c6a54c65a34614d20.tar.bz2 |
re PR target/49868 (Implement named address space to place/access data in flash memory)
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.
From-SVN: r183058
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 10 | ||||
-rw-r--r-- | libgcc/config/avr/lib1funcs.S | 162 | ||||
-rw-r--r-- | libgcc/config/avr/t-avr | 3 |
3 files changed, 153 insertions, 22 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 778848b..c29925f 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,13 @@ +2012-01-10 Georg-Johann Lay <avr@gjlay.de> + + 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. + 2012-01-09 Eric Botcazou <ebotcazou@adacore.com> * config/sparc/sol2-unwind.h (sparc64_is_sighandler): Check that the diff --git a/libgcc/config/avr/lib1funcs.S b/libgcc/config/avr/lib1funcs.S index b519993..93ce228 100644 --- a/libgcc/config/avr/lib1funcs.S +++ b/libgcc/config/avr/lib1funcs.S @@ -2061,19 +2061,14 @@ ENDF __load_4 #endif /* L_load_3 || L_load_3 */ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Loading n bytes from Flash; n = 2,3,4 -;; R22... = Flash[R21:Z] +;; Loading n bytes from Flash or RAM; n = 1,2,3,4 +;; R22... = Flash[R21:Z] or RAM[Z] depending on R21.7 ;; Clobbers: __tmp_reg__, R21, R30, R31 -#if (defined (L_xload_2) \ +#if (defined (L_xload_1) \ + || defined (L_xload_2) \ || defined (L_xload_3) \ - || defined (L_xload_4)) \ - && defined (__AVR_HAVE_ELPM__) \ - && !defined (__AVR_HAVE_ELPMX__) - -#if !defined (__AVR_HAVE_RAMPZ__) -#error Need RAMPZ -#endif /* have RAMPZ */ + || defined (L_xload_4)) ;; Destination #define D0 22 @@ -2086,6 +2081,9 @@ ENDF __load_4 #define HHI8 21 .macro .xload dest, n +#if defined (__AVR_HAVE_ELPMX__) + elpm \dest, Z+ +#elif defined (__AVR_HAVE_ELPM__) elpm mov \dest, r0 .if \dest != D0+\n-1 @@ -2093,39 +2091,161 @@ ENDF __load_4 adc HHI8, __zero_reg__ out __RAMPZ__, HHI8 .endif -.endm +#elif defined (__AVR_HAVE_LPMX__) + lpm \dest, Z+ +#else + lpm + mov \dest, r0 +.if \dest != D0+\n-1 + adiw r30, 1 +.endif +#endif +.endm ; .xload + +#if defined (L_xload_1) +DEFUN __xload_1 +#if defined (__AVR_HAVE_LPMX__) && !defined (__AVR_HAVE_RAMPZ__) + ld D0, Z + sbrs HHI8, 7 + lpm D0, Z + ret +#else + sbrc HHI8, 7 + rjmp 1f +#if defined (__AVR_HAVE_RAMPZ__) + out __RAMPZ__, HHI8 +#endif /* __AVR_HAVE_RAMPZ__ */ + .xload D0, 1 + ret +1: ld D0, Z + ret +#endif /* LPMx && ! RAMPZ */ +ENDF __xload_1 +#endif /* L_xload_1 */ #if defined (L_xload_2) DEFUN __xload_2 + sbrc HHI8, 7 + rjmp 1f +#if defined (__AVR_HAVE_RAMPZ__) out __RAMPZ__, HHI8 - .xload D0, 2 - .xload D1, 2 +#endif /* __AVR_HAVE_RAMPZ__ */ + .xload D0, 2 + .xload D1, 2 + ret +1: ld D0, Z+ + ld D1, Z+ ret ENDF __xload_2 #endif /* L_xload_2 */ #if defined (L_xload_3) DEFUN __xload_3 + sbrc HHI8, 7 + rjmp 1f +#if defined (__AVR_HAVE_RAMPZ__) out __RAMPZ__, HHI8 - .xload D0, 3 - .xload D1, 3 - .xload D2, 3 +#endif /* __AVR_HAVE_RAMPZ__ */ + .xload D0, 3 + .xload D1, 3 + .xload D2, 3 + ret +1: ld D0, Z+ + ld D1, Z+ + ld D2, Z+ ret ENDF __xload_3 #endif /* L_xload_3 */ #if defined (L_xload_4) DEFUN __xload_4 + sbrc HHI8, 7 + rjmp 1f +#if defined (__AVR_HAVE_RAMPZ__) out __RAMPZ__, HHI8 - .xload D0, 4 - .xload D1, 4 - .xload D2, 4 - .xload D3, 4 +#endif /* __AVR_HAVE_RAMPZ__ */ + .xload D0, 4 + .xload D1, 4 + .xload D2, 4 + .xload D3, 4 + ret +1: ld D0, Z+ + ld D1, Z+ + ld D2, Z+ + ld D3, Z+ ret ENDF __xload_4 #endif /* L_xload_4 */ -#endif /* L_xload_{2|3|4} && ELPM */ +#endif /* L_xload_{1|2|3|4} */ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; memcopy from Address Space __pgmx to RAM +;; R23:Z = Source Address +;; X = Destination Address +;; Clobbers: __tmp_reg__, R23, R24, R25, X, Z + +#if defined (L_movmemx) + +#define HHI8 23 +#define LOOP 24 + +DEFUN __movmemx_qi + ;; #Bytes to copy fity in 8 Bits (1..255) + ;; Zero-extend Loop Counter + clr LOOP+1 + ;; FALLTHRU +ENDF __movmemx_qi + +DEFUN __movmemx_hi + +;; Read from where? + sbrc HHI8, 7 + rjmp 1f + +;; Read from Flash + +#if defined (__AVR_HAVE_RAMPZ__) + out __RAMPZ__, HHI8 +#endif + +0: ;; Load 1 Byte from Flash... + +#if defined (__AVR_HAVE_ELPMX__) + elpm r0, Z+ +#elif defined (__AVR_HAVE_ELPM__) + elpm + adiw r30, 1 + adc HHI8, __zero_reg__ + out __RAMPZ__, HHI8 +#elif defined (__AVR_HAVE_LPMX__) + lpm r0, Z+ +#else + lpm + adiw r30, 1 +#endif + + ;; ...and store that Byte to RAM Destination + st X+, r0 + sbiw LOOP, 1 + brne 0b + ret + +;; Read from RAM + +1: ;; Read 1 Byte from RAM... + ld r0, Z+ + ;; and store that Byte to RAM Destination + st X+, r0 + sbiw LOOP, 1 + brne 0b + ret +ENDF __movmemx_hi + +#undef HHI8 +#undef LOOP + +#endif /* L_movmemx */ .section .text.libgcc.builtins, "ax", @progbits diff --git a/libgcc/config/avr/t-avr b/libgcc/config/avr/t-avr index 6568160..43caa94 100644 --- a/libgcc/config/avr/t-avr +++ b/libgcc/config/avr/t-avr @@ -27,7 +27,8 @@ LIB1ASMFUNCS = \ _tablejump \ _tablejump_elpm \ _load_3 _load_4 \ - _xload_2 _xload_3 _xload_4 \ + _xload_1 _xload_2 _xload_3 _xload_4 \ + _movmemx \ _copy_data \ _clear_bss \ _ctors \ |