From 199489b23bf390d7f5fcf45fab2a7e694b4b8601 Mon Sep 17 00:00:00 2001 From: gjl Date: Tue, 20 Mar 2012 17:38:29 +0000 Subject: [PATCH] * gcc.target/avr/progmem.h (pgm_read_char): Define depending on __AVR_HAVE_LPMX__ git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185583 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/avr/progmem.h | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dfdee37..124ea72 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-03-20 Georg-Johann Lay + * gcc.target/avr/progmem.h (pgm_read_char): Define depending on + __AVR_HAVE_LPMX__ + +2012-03-20 Georg-Johann Lay + PR target/49868 * gcc.target/avr/torture/addr-space-2.h: New file. * gcc.target/avr/torture/addr-space-2-g.h: New test. diff --git a/gcc/testsuite/gcc.target/avr/progmem.h b/gcc/testsuite/gcc.target/avr/progmem.h index d5e86c9..17bb771 100644 --- a/gcc/testsuite/gcc.target/avr/progmem.h +++ b/gcc/testsuite/gcc.target/avr/progmem.h @@ -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); \ @@ -12,3 +13,13 @@ __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 -- 2.7.4