Commit b30e10ab by Georg-Johann Lay Committed by Georg-Johann Lay

re PR target/52461 ([avr] XMEGA+EBI: RAMPZ clobbered while reading from flash)

libgcc/
	PR target/52461
	PR target/52508
	* config/avr/lib1funcs.S (__do_copy_data): Clear RAMPZ after usage
	if RAMPZ affects reading from RAM.
	(__tablejump_elpm__): Ditto.
	(.xload): Ditto.
	(__movmemx_hi): Ditto.
	(__do_global_ctors): Right condition for RAMPZ usage is "have ELPM".
	(__do_global_dtors): Ditto.
	(__xload_1, __xload_2, __xload_3, __xload_4): Ditto.
	(__movmemx_hi): Ditto.
gcc/	
	PR target/52461
	* gcc/config/avr/avr.c (avr_out_lpm): Clear RAMPZ after usage
	if RAMPZ affects reading from RAM.

From-SVN: r185030
parent eb3e63cc
2012-03-07 Georg-Johann Lay <avr@gjlay.de>
PR target/52461
* gcc/config/avr/avr.c (avr_out_lpm): Clear RAMPZ after usage
if RAMPZ affects reading from RAM.
2012-03-07 Richard Guenther <rguenther@suse.de> 2012-03-07 Richard Guenther <rguenther@suse.de>
PR pch/52518 PR pch/52518
......
...@@ -2762,7 +2762,14 @@ avr_out_lpm (rtx insn, rtx *op, int *plen) ...@@ -2762,7 +2762,14 @@ avr_out_lpm (rtx insn, rtx *op, int *plen)
break; /* POST_INC */ break; /* POST_INC */
} /* switch CODE (addr) */ } /* switch CODE (addr) */
if (xop[4] == xstring_e && AVR_HAVE_RAMPD)
{
/* Reset RAMPZ to 0 so that EBI devices don't read garbage from RAM */
avr_asm_len ("out __RAMPZ__,__zero_reg__", xop, plen, 1);
}
return ""; return "";
} }
......
2012-03-07 Georg-Johann Lay <avr@gjlay.de>
PR target/52461
PR target/52508
* config/avr/lib1funcs.S (__do_copy_data): Clear RAMPZ after usage
if RAMPZ affects reading from RAM.
(__tablejump_elpm__): Ditto.
(.xload): Ditto.
(__movmemx_hi): Ditto.
(__do_global_ctors): Right condition for RAMPZ usage is "have ELPM".
(__do_global_dtors): Ditto.
(__xload_1, __xload_2, __xload_3, __xload_4): Ditto.
(__movmemx_hi): Ditto.
2012-03-05 Richard Henderson <rth@redhat.com> 2012-03-05 Richard Henderson <rth@redhat.com>
* longlong.h [ARM] (umul_ppmm): Use umull for arm3m and later. * longlong.h [ARM] (umul_ppmm): Use umull for arm3m and later.
......
...@@ -1893,6 +1893,10 @@ DEFUN __do_copy_data ...@@ -1893,6 +1893,10 @@ DEFUN __do_copy_data
cpc r27, r17 cpc r27, r17
brne .L__do_copy_data_loop brne .L__do_copy_data_loop
#endif /* !defined(__AVR_HAVE_ELPMX__) && !defined(__AVR_HAVE_ELPM__) */ #endif /* !defined(__AVR_HAVE_ELPMX__) && !defined(__AVR_HAVE_ELPM__) */
#if defined (__AVR_HAVE_ELPM__) && defined (__AVR_HAVE_RAMPD__)
;; Reset RAMPZ to 0 so that EBI devices don't read garbage from RAM
out __RAMPZ__, __zero_reg__
#endif /* ELPM && RAMPD */
ENDF __do_copy_data ENDF __do_copy_data
#endif /* L_copy_data */ #endif /* L_copy_data */
...@@ -1920,7 +1924,7 @@ ENDF __do_clear_bss ...@@ -1920,7 +1924,7 @@ ENDF __do_clear_bss
#ifdef L_ctors #ifdef L_ctors
.section .init6,"ax",@progbits .section .init6,"ax",@progbits
DEFUN __do_global_ctors DEFUN __do_global_ctors
#if defined(__AVR_HAVE_RAMPZ__) #if defined(__AVR_HAVE_ELPM__)
ldi r17, hi8(__ctors_start) ldi r17, hi8(__ctors_start)
ldi r28, lo8(__ctors_end) ldi r28, lo8(__ctors_end)
ldi r29, hi8(__ctors_end) ldi r29, hi8(__ctors_end)
...@@ -1953,14 +1957,14 @@ DEFUN __do_global_ctors ...@@ -1953,14 +1957,14 @@ DEFUN __do_global_ctors
cpi r28, lo8(__ctors_start) cpi r28, lo8(__ctors_start)
cpc r29, r17 cpc r29, r17
brne .L__do_global_ctors_loop brne .L__do_global_ctors_loop
#endif /* defined(__AVR_HAVE_RAMPZ__) */ #endif /* defined(__AVR_HAVE_ELPM__) */
ENDF __do_global_ctors ENDF __do_global_ctors
#endif /* L_ctors */ #endif /* L_ctors */
#ifdef L_dtors #ifdef L_dtors
.section .fini6,"ax",@progbits .section .fini6,"ax",@progbits
DEFUN __do_global_dtors DEFUN __do_global_dtors
#if defined(__AVR_HAVE_RAMPZ__) #if defined(__AVR_HAVE_ELPM__)
ldi r17, hi8(__dtors_end) ldi r17, hi8(__dtors_end)
ldi r28, lo8(__dtors_start) ldi r28, lo8(__dtors_start)
ldi r29, hi8(__dtors_start) ldi r29, hi8(__dtors_start)
...@@ -1993,7 +1997,7 @@ DEFUN __do_global_dtors ...@@ -1993,7 +1997,7 @@ DEFUN __do_global_dtors
cpi r28, lo8(__dtors_end) cpi r28, lo8(__dtors_end)
cpc r29, r17 cpc r29, r17
brne .L__do_global_dtors_loop brne .L__do_global_dtors_loop
#endif /* defined(__AVR_HAVE_RAMPZ__) */ #endif /* defined(__AVR_HAVE_ELPM__) */
ENDF __do_global_dtors ENDF __do_global_dtors
#endif /* L_dtors */ #endif /* L_dtors */
...@@ -2001,18 +2005,21 @@ ENDF __do_global_dtors ...@@ -2001,18 +2005,21 @@ ENDF __do_global_dtors
#ifdef L_tablejump_elpm #ifdef L_tablejump_elpm
DEFUN __tablejump_elpm__ DEFUN __tablejump_elpm__
#if defined (__AVR_HAVE_ELPM__) #if defined (__AVR_HAVE_ELPMX__)
#if defined (__AVR_HAVE_LPMX__)
elpm __tmp_reg__, Z+ elpm __tmp_reg__, Z+
elpm r31, Z elpm r31, Z
mov r30, __tmp_reg__ mov r30, __tmp_reg__
#if defined (__AVR_HAVE_RAMPD__)
;; Reset RAMPZ to 0 so that EBI devices don't read garbage from RAM
out __RAMPZ__, __zero_reg__
#endif /* RAMPD */
#if defined (__AVR_HAVE_EIJMP_EICALL__) #if defined (__AVR_HAVE_EIJMP_EICALL__)
eijmp eijmp
#else #else
ijmp ijmp
#endif #endif
#else #elif defined (__AVR_HAVE_ELPM__)
elpm elpm
adiw r30, 1 adiw r30, 1
push r0 push r0
...@@ -2024,7 +2031,6 @@ DEFUN __tablejump_elpm__ ...@@ -2024,7 +2031,6 @@ DEFUN __tablejump_elpm__
#endif #endif
ret ret
#endif #endif
#endif /* defined (__AVR_HAVE_ELPM__) */
ENDF __tablejump_elpm__ ENDF __tablejump_elpm__
#endif /* defined (L_tablejump_elpm) */ #endif /* defined (L_tablejump_elpm) */
...@@ -2114,11 +2120,17 @@ ENDF __load_4 ...@@ -2114,11 +2120,17 @@ ENDF __load_4
adiw r30, 1 adiw r30, 1
.endif .endif
#endif #endif
#if defined (__AVR_HAVE_ELPM__) && defined (__AVR_HAVE_RAMPD__)
.if \dest == D0+\n-1
;; Reset RAMPZ to 0 so that EBI devices don't read garbage from RAM
out __RAMPZ__, __zero_reg__
.endif
#endif
.endm ; .xload .endm ; .xload
#if defined (L_xload_1) #if defined (L_xload_1)
DEFUN __xload_1 DEFUN __xload_1
#if defined (__AVR_HAVE_LPMX__) && !defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_LPMX__) && !defined (__AVR_HAVE_ELPM__)
ld D0, Z ld D0, Z
sbrs HHI8, 7 sbrs HHI8, 7
lpm D0, Z lpm D0, Z
...@@ -2126,14 +2138,14 @@ DEFUN __xload_1 ...@@ -2126,14 +2138,14 @@ DEFUN __xload_1
#else #else
sbrc HHI8, 7 sbrc HHI8, 7
rjmp 1f rjmp 1f
#if defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_ELPM__)
out __RAMPZ__, HHI8 out __RAMPZ__, HHI8
#endif /* __AVR_HAVE_RAMPZ__ */ #endif /* __AVR_HAVE_ELPM__ */
.xload D0, 1 .xload D0, 1
ret ret
1: ld D0, Z 1: ld D0, Z
ret ret
#endif /* LPMx && ! RAMPZ */ #endif /* LPMx && ! ELPM */
ENDF __xload_1 ENDF __xload_1
#endif /* L_xload_1 */ #endif /* L_xload_1 */
...@@ -2141,9 +2153,9 @@ ENDF __xload_1 ...@@ -2141,9 +2153,9 @@ ENDF __xload_1
DEFUN __xload_2 DEFUN __xload_2
sbrc HHI8, 7 sbrc HHI8, 7
rjmp 1f rjmp 1f
#if defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_ELPM__)
out __RAMPZ__, HHI8 out __RAMPZ__, HHI8
#endif /* __AVR_HAVE_RAMPZ__ */ #endif /* __AVR_HAVE_ELPM__ */
.xload D0, 2 .xload D0, 2
.xload D1, 2 .xload D1, 2
ret ret
...@@ -2157,9 +2169,9 @@ ENDF __xload_2 ...@@ -2157,9 +2169,9 @@ ENDF __xload_2
DEFUN __xload_3 DEFUN __xload_3
sbrc HHI8, 7 sbrc HHI8, 7
rjmp 1f rjmp 1f
#if defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_ELPM__)
out __RAMPZ__, HHI8 out __RAMPZ__, HHI8
#endif /* __AVR_HAVE_RAMPZ__ */ #endif /* __AVR_HAVE_ELPM__ */
.xload D0, 3 .xload D0, 3
.xload D1, 3 .xload D1, 3
.xload D2, 3 .xload D2, 3
...@@ -2175,9 +2187,9 @@ ENDF __xload_3 ...@@ -2175,9 +2187,9 @@ ENDF __xload_3
DEFUN __xload_4 DEFUN __xload_4
sbrc HHI8, 7 sbrc HHI8, 7
rjmp 1f rjmp 1f
#if defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_ELPM__)
out __RAMPZ__, HHI8 out __RAMPZ__, HHI8
#endif /* __AVR_HAVE_RAMPZ__ */ #endif /* __AVR_HAVE_ELPM__ */
.xload D0, 4 .xload D0, 4
.xload D1, 4 .xload D1, 4
.xload D2, 4 .xload D2, 4
...@@ -2219,7 +2231,7 @@ DEFUN __movmemx_hi ...@@ -2219,7 +2231,7 @@ DEFUN __movmemx_hi
;; Read from Flash ;; Read from Flash
#if defined (__AVR_HAVE_RAMPZ__) #if defined (__AVR_HAVE_ELPM__)
out __RAMPZ__, HHI8 out __RAMPZ__, HHI8
#endif #endif
...@@ -2243,6 +2255,10 @@ DEFUN __movmemx_hi ...@@ -2243,6 +2255,10 @@ DEFUN __movmemx_hi
st X+, r0 st X+, r0
sbiw LOOP, 1 sbiw LOOP, 1
brne 0b brne 0b
#if defined (__AVR_HAVE_ELPM__) && defined (__AVR_HAVE_RAMPD__)
;; Reset RAMPZ to 0 so that EBI devices don't read garbage from RAM
out __RAMPZ__, __zero_reg__
#endif /* ELPM && RAMPD */
ret ret
;; Read from RAM ;; Read from RAM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment