| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
typedef __UINT16_TYPE__ uint16_t; |
| 4 |
typedef __UINT32_TYPE__ uint32_t; |
| 5 |
|
| 6 |
typedef uint32_t T; |
| 7 |
|
| 8 |
#define NI __attribute__((noipa)) |
| 9 |
|
| 10 |
|
| 11 |
#ifndef __AVR_TINY__ |
| 12 |
#define read_u32(X) \ |
| 13 |
(__extension__( \ |
| 14 |
{ \ |
| 15 |
uint16_t __addr16 = (uint16_t)(X); \ |
| 16 |
uint32_t __result; \ |
| 17 |
__asm__ __volatile__ ("lpm %A0, Z+" "\n\t" \ |
| 18 |
"lpm %B0, Z+" "\n\t" \ |
| 19 |
"lpm %C0, Z+" "\n\t" \ |
| 20 |
"lpm %D0, Z" "\n\t" \ |
| 21 |
: "=r" (__result), "+z" (__addr16)); \ |
| 22 |
__result; \ |
| 23 |
})) |
| 24 |
#else |
| 25 |
NI uint32_t read_u32 (const uint32_t *p) |
| 26 |
{ |
| 27 |
return *p; |
| 28 |
} |
| 29 |
#endif |
| 30 |
|
| 31 |
static const __attribute((progmem)) T xyz_prog[] = { 123, 123, 123 }; |
| 32 |
T xyz[] = { 123, 123, 123 }; |
| 33 |
volatile int x = 0; |
| 34 |
|
| 35 |
NI void prf (T f) |
| 36 |
{ |
| 37 |
if (f != 123) |
| 38 |
__builtin_abort(); |
| 39 |
} |
| 40 |
|
| 41 |
NI void func_progmem() |
| 42 |
{ |
| 43 |
prf (read_u32 (&xyz_prog[0])); |
| 44 |
} |
| 45 |
|
| 46 |
NI void func_ram() |
| 47 |
{ |
| 48 |
prf (xyz[x]); |
| 49 |
} |
| 50 |
|
| 51 |
int main (void) |
| 52 |
{ |
| 53 |
func_progmem(); |
| 54 |
func_ram(); |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |