* gcc.target/avr/progmem.h (pgm_read_char): Define depending on
authorgjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Mar 2012 17:38:29 +0000 (17:38 +0000)
committergjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Mar 2012 17:38:29 +0000 (17:38 +0000)
__AVR_HAVE_LPMX__

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185583 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/avr/progmem.h

index dfdee37..124ea72 100644 (file)
@@ -1,5 +1,10 @@
 2012-03-20  Georg-Johann Lay  <avr@gjlay.de>
 
+       * gcc.target/avr/progmem.h (pgm_read_char): Define depending on
+       __AVR_HAVE_LPMX__
+
+2012-03-20  Georg-Johann Lay  <avr@gjlay.de>
+
        PR target/49868
        * gcc.target/avr/torture/addr-space-2.h: New file.
        * gcc.target/avr/torture/addr-space-2-g.h: New test.
index d5e86c9..17bb771 100644 (file)
@@ -5,6 +5,7 @@
             static const char __c[] PROGMEM = (s);          \
             &__c[0];}))
 
+#ifdef __AVR_HAVE_LPMX__
 #define pgm_read_char(addr)                                 \
     (__extension__({                                        \
             unsigned int __addr16 = (unsigned int)(addr);   \
             __asm__ ("lpm %0, %a1"                          \
                      : "=r" (__result) : "z" (__addr16));   \
             __result; }))
+#else
+#define pgm_read_char(addr)                                 \
+    (__extension__({                                        \
+            unsigned int __addr16 = (unsigned int)(addr);   \
+            char __result;                                  \
+            __asm__ ("lpm" "\n\t"                           \
+                     "mov %0, r0"                           \
+                     : "=r" (__result) : "z" (__addr16));   \
+            __result; }))
+#endif