Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/memcpy-ax.h

raw
1 typedef unsigned int __attribute__ ((mode (QI))) int08_t;
2 typedef unsigned int __attribute__ ((mode (HI))) int16_t;
3 typedef unsigned int __attribute__ ((mode (SI))) int32_t;
4 typedef unsigned int __attribute__ ((mode (DI))) int64_t;
5
6 typedef union
7 {
8 int08_t v[88];
9 }
10 a1_t;
11
12 typedef union
13 {
14 int08_t v[88];
15 int16_t a;
16 }
17 a2_t;
18
19 typedef union
20 {
21 int08_t v[88];
22 int32_t a;
23 }
24 a4_t;
25
26 typedef union
27 {
28 int08_t v[88];
29 int64_t a;
30 }
31 a8_t;
32
33 ax_t src = {{
34 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
35 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
36 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
37 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
38 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
39 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
40 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
41 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x70,
42 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
43 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
44 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
45 }};
46
47 #define MEMCPY_DEFINE_ONE(align, offset, count) \
48 static void __attribute__ ((noinline)) \
49 memcpy_check_one_ ## align ## offset ## count (void) \
50 { \
51 static a ## align ## _t dst = {{ [0 ... 87] = 0xaa }}; \
52 int i; \
53 \
54 __builtin_memcpy (dst.v + 8 + offset, src.v + 8 + offset, count); \
55 asm ("" : : : "memory"); \
56 for (i = 0; i < 8 + offset; i++) \
57 if (dst.v[i] != 0xaa) \
58 __builtin_abort (); \
59 for (; i < 8 + offset + count; i++) \
60 if (dst.v[i] != src.v[i]) \
61 __builtin_abort (); \
62 for (; i < sizeof (dst.v); i++) \
63 if (dst.v[i] != 0xaa) \
64 __builtin_abort (); \
65 }
66
67 #define MEMCPY_DEFINE_ONE_ALIGN_OFFSET(align, offset) \
68 MEMCPY_DEFINE_ONE (align, offset, 1) \
69 MEMCPY_DEFINE_ONE (align, offset, 2) \
70 MEMCPY_DEFINE_ONE (align, offset, 3) \
71 MEMCPY_DEFINE_ONE (align, offset, 4) \
72 MEMCPY_DEFINE_ONE (align, offset, 5) \
73 MEMCPY_DEFINE_ONE (align, offset, 6) \
74 MEMCPY_DEFINE_ONE (align, offset, 7) \
75 MEMCPY_DEFINE_ONE (align, offset, 8) \
76 MEMCPY_DEFINE_ONE (align, offset, 9) \
77 MEMCPY_DEFINE_ONE (align, offset, 10) \
78 MEMCPY_DEFINE_ONE (align, offset, 11) \
79 MEMCPY_DEFINE_ONE (align, offset, 12) \
80 MEMCPY_DEFINE_ONE (align, offset, 13) \
81 MEMCPY_DEFINE_ONE (align, offset, 14) \
82 MEMCPY_DEFINE_ONE (align, offset, 15) \
83 MEMCPY_DEFINE_ONE (align, offset, 16) \
84 MEMCPY_DEFINE_ONE (align, offset, 17) \
85 MEMCPY_DEFINE_ONE (align, offset, 18) \
86 MEMCPY_DEFINE_ONE (align, offset, 19) \
87 MEMCPY_DEFINE_ONE (align, offset, 20) \
88 MEMCPY_DEFINE_ONE (align, offset, 21) \
89 MEMCPY_DEFINE_ONE (align, offset, 22) \
90 MEMCPY_DEFINE_ONE (align, offset, 23) \
91 MEMCPY_DEFINE_ONE (align, offset, 24) \
92 MEMCPY_DEFINE_ONE (align, offset, 25) \
93 MEMCPY_DEFINE_ONE (align, offset, 26) \
94 MEMCPY_DEFINE_ONE (align, offset, 27) \
95 MEMCPY_DEFINE_ONE (align, offset, 28) \
96 MEMCPY_DEFINE_ONE (align, offset, 29) \
97 MEMCPY_DEFINE_ONE (align, offset, 30) \
98 MEMCPY_DEFINE_ONE (align, offset, 31) \
99 MEMCPY_DEFINE_ONE (align, offset, 32) \
100 MEMCPY_DEFINE_ONE (align, offset, 33) \
101 MEMCPY_DEFINE_ONE (align, offset, 34) \
102 MEMCPY_DEFINE_ONE (align, offset, 35) \
103 MEMCPY_DEFINE_ONE (align, offset, 36) \
104 MEMCPY_DEFINE_ONE (align, offset, 37) \
105 MEMCPY_DEFINE_ONE (align, offset, 38) \
106 MEMCPY_DEFINE_ONE (align, offset, 39) \
107 MEMCPY_DEFINE_ONE (align, offset, 40) \
108 MEMCPY_DEFINE_ONE (align, offset, 41) \
109 MEMCPY_DEFINE_ONE (align, offset, 42) \
110 MEMCPY_DEFINE_ONE (align, offset, 43) \
111 MEMCPY_DEFINE_ONE (align, offset, 44) \
112 MEMCPY_DEFINE_ONE (align, offset, 45) \
113 MEMCPY_DEFINE_ONE (align, offset, 46) \
114 MEMCPY_DEFINE_ONE (align, offset, 47) \
115 MEMCPY_DEFINE_ONE (align, offset, 48) \
116 MEMCPY_DEFINE_ONE (align, offset, 49) \
117 MEMCPY_DEFINE_ONE (align, offset, 50) \
118 MEMCPY_DEFINE_ONE (align, offset, 51) \
119 MEMCPY_DEFINE_ONE (align, offset, 52) \
120 MEMCPY_DEFINE_ONE (align, offset, 53) \
121 MEMCPY_DEFINE_ONE (align, offset, 54) \
122 MEMCPY_DEFINE_ONE (align, offset, 55) \
123 MEMCPY_DEFINE_ONE (align, offset, 56) \
124 MEMCPY_DEFINE_ONE (align, offset, 57) \
125 MEMCPY_DEFINE_ONE (align, offset, 58) \
126 MEMCPY_DEFINE_ONE (align, offset, 59) \
127 MEMCPY_DEFINE_ONE (align, offset, 60) \
128 MEMCPY_DEFINE_ONE (align, offset, 61) \
129 MEMCPY_DEFINE_ONE (align, offset, 62) \
130 MEMCPY_DEFINE_ONE (align, offset, 63) \
131 MEMCPY_DEFINE_ONE (align, offset, 64)
132
133 #define MEMCPY_DEFINE_ONE_ALIGN(align) \
134 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 0) \
135 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 1) \
136 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 2) \
137 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 3) \
138 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 4) \
139 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 5) \
140 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 6) \
141 MEMCPY_DEFINE_ONE_ALIGN_OFFSET (align, 7)
142
143 MEMCPY_DEFINE_ONE_ALIGN (1)
144 MEMCPY_DEFINE_ONE_ALIGN (2)
145 MEMCPY_DEFINE_ONE_ALIGN (4)
146 MEMCPY_DEFINE_ONE_ALIGN (8)
147
148 #define MEMCPY_CHECK_ONE(align, offset, count) \
149 memcpy_check_one_ ## align ## offset ## count ();
150
151 #define MEMCPY_CHECK_ONE_ALIGN_OFFSET(align, offset) \
152 do \
153 { \
154 MEMCPY_CHECK_ONE (align, offset, 1); \
155 MEMCPY_CHECK_ONE (align, offset, 2); \
156 MEMCPY_CHECK_ONE (align, offset, 3); \
157 MEMCPY_CHECK_ONE (align, offset, 4); \
158 MEMCPY_CHECK_ONE (align, offset, 5); \
159 MEMCPY_CHECK_ONE (align, offset, 6); \
160 MEMCPY_CHECK_ONE (align, offset, 7); \
161 MEMCPY_CHECK_ONE (align, offset, 8); \
162 MEMCPY_CHECK_ONE (align, offset, 9); \
163 MEMCPY_CHECK_ONE (align, offset, 10); \
164 MEMCPY_CHECK_ONE (align, offset, 11); \
165 MEMCPY_CHECK_ONE (align, offset, 12); \
166 MEMCPY_CHECK_ONE (align, offset, 13); \
167 MEMCPY_CHECK_ONE (align, offset, 14); \
168 MEMCPY_CHECK_ONE (align, offset, 15); \
169 MEMCPY_CHECK_ONE (align, offset, 16); \
170 MEMCPY_CHECK_ONE (align, offset, 17); \
171 MEMCPY_CHECK_ONE (align, offset, 18); \
172 MEMCPY_CHECK_ONE (align, offset, 19); \
173 MEMCPY_CHECK_ONE (align, offset, 20); \
174 MEMCPY_CHECK_ONE (align, offset, 21); \
175 MEMCPY_CHECK_ONE (align, offset, 22); \
176 MEMCPY_CHECK_ONE (align, offset, 23); \
177 MEMCPY_CHECK_ONE (align, offset, 24); \
178 MEMCPY_CHECK_ONE (align, offset, 25); \
179 MEMCPY_CHECK_ONE (align, offset, 26); \
180 MEMCPY_CHECK_ONE (align, offset, 27); \
181 MEMCPY_CHECK_ONE (align, offset, 28); \
182 MEMCPY_CHECK_ONE (align, offset, 29); \
183 MEMCPY_CHECK_ONE (align, offset, 30); \
184 MEMCPY_CHECK_ONE (align, offset, 31); \
185 MEMCPY_CHECK_ONE (align, offset, 32); \
186 MEMCPY_CHECK_ONE (align, offset, 33); \
187 MEMCPY_CHECK_ONE (align, offset, 34); \
188 MEMCPY_CHECK_ONE (align, offset, 35); \
189 MEMCPY_CHECK_ONE (align, offset, 36); \
190 MEMCPY_CHECK_ONE (align, offset, 37); \
191 MEMCPY_CHECK_ONE (align, offset, 38); \
192 MEMCPY_CHECK_ONE (align, offset, 39); \
193 MEMCPY_CHECK_ONE (align, offset, 40); \
194 MEMCPY_CHECK_ONE (align, offset, 41); \
195 MEMCPY_CHECK_ONE (align, offset, 42); \
196 MEMCPY_CHECK_ONE (align, offset, 43); \
197 MEMCPY_CHECK_ONE (align, offset, 44); \
198 MEMCPY_CHECK_ONE (align, offset, 45); \
199 MEMCPY_CHECK_ONE (align, offset, 46); \
200 MEMCPY_CHECK_ONE (align, offset, 47); \
201 MEMCPY_CHECK_ONE (align, offset, 48); \
202 MEMCPY_CHECK_ONE (align, offset, 49); \
203 MEMCPY_CHECK_ONE (align, offset, 50); \
204 MEMCPY_CHECK_ONE (align, offset, 51); \
205 MEMCPY_CHECK_ONE (align, offset, 52); \
206 MEMCPY_CHECK_ONE (align, offset, 53); \
207 MEMCPY_CHECK_ONE (align, offset, 54); \
208 MEMCPY_CHECK_ONE (align, offset, 55); \
209 MEMCPY_CHECK_ONE (align, offset, 56); \
210 MEMCPY_CHECK_ONE (align, offset, 57); \
211 MEMCPY_CHECK_ONE (align, offset, 58); \
212 MEMCPY_CHECK_ONE (align, offset, 59); \
213 MEMCPY_CHECK_ONE (align, offset, 60); \
214 MEMCPY_CHECK_ONE (align, offset, 61); \
215 MEMCPY_CHECK_ONE (align, offset, 62); \
216 MEMCPY_CHECK_ONE (align, offset, 63); \
217 MEMCPY_CHECK_ONE (align, offset, 64); \
218 } \
219 while (0);
220
221 #define MEMCPY_CHECK_ONE_ALIGN(align) \
222 do \
223 { \
224 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 0); \
225 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 1); \
226 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 2); \
227 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 3); \
228 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 4); \
229 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 5); \
230 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 6); \
231 MEMCPY_CHECK_ONE_ALIGN_OFFSET (align, 7); \
232 } \
233 while (0);
234
235 int
236 main (void)
237 {
238 MEMCPY_CHECK_ONE_ALIGN (1);
239 MEMCPY_CHECK_ONE_ALIGN (2);
240 MEMCPY_CHECK_ONE_ALIGN (4);
241 MEMCPY_CHECK_ONE_ALIGN (8);
242 return 0;
243 }