Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/pr88236-pr115726.c

raw
1 /* { dg-do run { target { ! avr_tiny } } } */
2 /* { dg-additional-options "-std=gnu99" } */
3
4 const __flash char fvals8[] = { 1, 2, 3 };
5 char rvals8[] = { 0, 2, 4 };
6
7 const __flash int fvals16[] = { 1, 2, 3 };
8 int rvals16[] = { 0, 2, 4 };
9
10 __attribute__((noipa))
11 char xload8_r30 (const __memx char *pc)
12 {
13 register char c __asm ("r30");
14 c = *pc;
15 __asm (";;" : "+r" (c));
16 return c;
17 }
18
19 __attribute__((noipa))
20 int xload16_r30 (const __memx int *pc)
21 {
22 register int c __asm ("r30");
23 c = *pc;
24 __asm (";;" : "+r" (c));
25 return c;
26 }
27
28 __attribute__((noipa))
29 char xload8_r22 (const __memx char *pc)
30 {
31 register char c __asm ("r22");
32 c = *pc;
33 __asm (";;" : "+r" (c));
34 return c;
35 }
36
37 __attribute__((noipa))
38 int xload16_r22 (const __memx int *pc)
39 {
40 register int c __asm ("r22");
41 c = *pc;
42 __asm (";;" : "+r" (c));
43 return c;
44 }
45
46 __attribute__((noipa))
47 int xload16_r20 (const __memx int *pc)
48 {
49 register int c __asm ("r20");
50 c = *pc;
51 __asm (";;" : "+r" (c));
52 return c;
53 }
54
55 void test8 (void)
56 {
57 char c;
58 for (int i = 0; i < 3; ++i)
59 {
60 c = xload8_r30 (fvals8 + i);
61 if (c != 1 + i)
62 __builtin_exit (__LINE__);
63
64 c = xload8_r22 (fvals8 + i);
65 if (c != 1 + i)
66 __builtin_exit (__LINE__);
67
68 c = xload8_r30 (rvals8 + i);
69 if (c != 2 * i)
70 __builtin_exit (__LINE__);
71
72 c = xload8_r22 (rvals8 + i);
73 if (c != 2 * i)
74 __builtin_exit (__LINE__);
75 }
76 }
77
78 void test16 (void)
79 {
80 int c;
81 for (int i = 0; i < 3; ++i)
82 {
83 c = xload16_r30 (fvals16 + i);
84 if (c != 1 + i)
85 __builtin_exit (__LINE__);
86
87 c = xload16_r22 (fvals16 + i);
88 if (c != 1 + i)
89 __builtin_exit (__LINE__);
90
91 c = xload16_r20 (fvals16 + i);
92 if (c != 1 + i)
93 __builtin_exit (__LINE__);
94
95 c = xload16_r30 (rvals16 + i);
96 if (c != 2 * i)
97 __builtin_exit (__LINE__);
98
99 c = xload16_r22 (rvals16 + i);
100 if (c != 2 * i)
101 __builtin_exit (__LINE__);
102
103 c = xload16_r20 (rvals16 + i);
104 if (c != 2 * i)
105 __builtin_exit (__LINE__);
106 }
107 }
108
109 int main (void)
110 {
111 test8();
112 test16();
113
114 return 0;
115 }