1 /* Check if sdata access is done correctly, specially
2    for variables which are having a different alignment
3    than the default data type indicates.  */
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -msdata" } */
6 
7 int g_a __attribute__ ((aligned (1)));
8 int g_b;
9 short g_c;
10 char g_d;
11 
12 #define TEST(name, optype)			\
13   optype testLD_ ## name (optype x)		\
14   {						\
15     return g_ ## name + x;			\
16   }						\
17   void testST_ ## name (optype x)		\
18   {						\
19     g_ ## name = x;				\
20   }
21 
22 TEST (a, int)
23 TEST (b, int)
24 TEST (c, short)
25 TEST (d, char)
26 
27 /* { dg-final { scan-assembler "ld\\s+r2,\\\[gp,@g_a@sda\\\]" } } */
28 /* { dg-final { scan-assembler "ld.as\\s+r2,\\\[gp,@g_b@sda\\\]" } } */
29 /* { dg-final { scan-assembler "ld\[hw\]\\\.as\\s+r2,\\\[gp,@g_c@sda\\\]" } } */
30 /* { dg-final { scan-assembler "ldb\\s+r2,\\\[gp,@g_d@sda\\\]" } } */
31 
32 /* { dg-final { scan-assembler "st\\s+r0,\\\[gp,@g_a@sda\\\]" } } */
33 /* { dg-final { scan-assembler "st_s\\s+r0,\\\[gp,@g_b@sda\\\]" { target { codedensity } } } } */
34 /* { dg-final { scan-assembler "st\\\.as\\s+r0,\\\[gp,@g_b@sda\\\]" { target { ! { codedensity } } } } } */
35 /* { dg-final { scan-assembler "st\[hw\]\\\.as\\s+r0,\\\[gp,@g_c@sda\\\]" } } */
36 /* { dg-final { scan-assembler "stb\\s+r0,\\\[gp,@g_d@sda\\\]" } } */
37