This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch,AVR] Fix PR52505
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Denis Chertykov <chertykov at gmail dot com>, Eric Weddington <eric dot weddington at atmel dot com>
- Date: Tue, 06 Mar 2012 14:25:06 +0100
- Subject: [Patch,AVR] Fix PR52505
This is fix for __memx address space reads that might read from RAM or flash.
For flash reads, never read from RAM so that I/O latches don't get read out
unintentionally.
Ok for trunk?
Johann
libgcc/
PR target/52505
* config/avr/lib1funcs.S (__xload_1): Don't read unintentionally
from RAM.
gcc/
PR target/52505
* config/avr/avr.c (avr_out_xload): Don't read unintentionally
from RAM.
* config/avr/avr.md (xload_8): Adjust insn length.
Index: libgcc/config/avr/lib1funcs.S
===================================================================
--- libgcc/config/avr/lib1funcs.S (revision 184887)
+++ libgcc/config/avr/lib1funcs.S (working copy)
@@ -2119,6 +2119,7 @@ ENDF __load_4
#if defined (L_xload_1)
DEFUN __xload_1
#if defined (__AVR_HAVE_LPMX__) && !defined (__AVR_HAVE_RAMPZ__)
+ sbrc HHI8, 7
ld D0, Z
sbrs HHI8, 7
lpm D0, Z
Index: gcc/config/avr/avr.c
===================================================================
--- gcc/config/avr/avr.c (revision 184887)
+++ gcc/config/avr/avr.c (working copy)
@@ -2782,8 +2782,9 @@ avr_out_xload (rtx insn ATTRIBUTE_UNUSED
if (plen)
*plen = 0;
- avr_asm_len ("ld %3,%a2" CR_TAB
- "sbrs %1,7", xop, plen, 2);
+ avr_asm_len ("sbrc %1,7" CR_TAB
+ "ld %3,%a2" CR_TAB
+ "sbrs %1,7", xop, plen, 3);
avr_asm_len (AVR_HAVE_LPMX ? "lpm %3,%a2" : "lpm", xop, plen, 1);
Index: gcc/config/avr/avr.md
===================================================================
--- gcc/config/avr/avr.md (revision 184919)
+++ gcc/config/avr/avr.md (working copy)
@@ -363,6 +363,11 @@ (define_split
;;========================================================================
;; Move stuff around
+;; "loadqi_libgcc"
+;; "loadhi_libgcc"
+;; "loadpsi_libgcc"
+;; "loadsi_libgcc"
+;; "loadsf_libgcc"
(define_expand "load<mode>_libgcc"
[(set (match_dup 3)
(match_dup 2))
@@ -377,7 +382,12 @@ (define_expand "load<mode>_libgcc"
operands[1] = replace_equiv_address (operands[1], operands[3]);
set_mem_addr_space (operands[1], ADDR_SPACE_FLASH);
})
-
+
+;; "load_qi_libgcc"
+;; "load_hi_libgcc"
+;; "load_psi_libgcc"
+;; "load_si_libgcc"
+;; "load_sf_libgcc"
(define_insn "load_<mode>_libgcc"
[(set (reg:MOVMODE 22)
(match_operand:MOVMODE 0 "memory_operand" "m,m"))]
@@ -418,6 +428,11 @@ (define_insn_and_split "xload8_A"
DONE;
})
+;; "xloadqi_A"
+;; "xloadhi_A"
+;; "xloadpsi_A"
+;; "xloadsi_A"
+;; "xloadsf_A"
(define_insn_and_split "xload<mode>_A"
[(set (match_operand:MOVMODE 0 "register_operand" "=r")
(match_operand:MOVMODE 1 "memory_operand" "m"))
@@ -461,7 +476,7 @@ (define_insn "xload_8"
{
return avr_out_xload (insn, operands, NULL);
}
- [(set_attr "length" "3,4")
+ [(set_attr "length" "4,4")
(set_attr "adjust_len" "*,xload")
(set_attr "isa" "lpmx,lpm")
(set_attr "cc" "none")])