struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-ashrdi-1.c
blob3c35132276e73008f7c5f4453f61c2fed277bd7e
1 /*
2 ashrdi-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #include <limits.h>
9 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_MODEL_LARGE) && defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk14) // Lack of memory// Lack of memory
10 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
12 #if LLONG_MAX == 9223372036854775807LL
13 #define BITS 64
15 static long long const zext[64] = {
16 0x7654321fedcba980LL,
17 0x3b2a190ff6e5d4c0LL,
18 0x1d950c87fb72ea60LL,
19 0xeca8643fdb97530LL,
20 0x7654321fedcba98LL,
21 0x3b2a190ff6e5d4cLL,
22 0x1d950c87fb72ea6LL,
23 0xeca8643fdb9753LL,
24 0x7654321fedcba9LL,
25 0x3b2a190ff6e5d4LL,
26 0x1d950c87fb72eaLL,
27 0xeca8643fdb975LL,
28 0x7654321fedcbaLL,
29 0x3b2a190ff6e5dLL,
30 0x1d950c87fb72eLL,
31 0xeca8643fdb97LL,
32 0x7654321fedcbLL,
33 0x3b2a190ff6e5LL,
34 0x1d950c87fb72LL,
35 0xeca8643fdb9LL,
36 0x7654321fedcLL,
37 0x3b2a190ff6eLL,
38 0x1d950c87fb7LL,
39 0xeca8643fdbLL,
40 0x7654321fedLL,
41 0x3b2a190ff6LL,
42 0x1d950c87fbLL,
43 0xeca8643fdLL,
44 0x7654321feLL,
45 0x3b2a190ffLL,
46 0x1d950c87fLL,
47 0xeca8643fLL,
48 0x7654321fLL,
49 0x3b2a190fLL,
50 0x1d950c87LL,
51 0xeca8643LL,
52 0x7654321LL,
53 0x3b2a190LL,
54 0x1d950c8LL,
55 0xeca864LL,
56 0x765432LL,
57 0x3b2a19LL,
58 0x1d950cLL,
59 0xeca86LL,
60 0x76543LL,
61 0x3b2a1LL,
62 0x1d950LL,
63 0xeca8LL,
64 0x7654LL,
65 0x3b2aLL,
66 0x1d95LL,
67 0xecaLL,
68 0x765LL,
69 0x3b2LL,
70 0x1d9LL,
71 0xecLL,
72 0x76LL,
73 0x3bLL,
74 0x1dLL,
75 0xeLL,
76 0x7LL,
77 0x3LL,
78 0x1LL,
79 0LL
82 static long long const sext[64] = {
83 0x8edcba9f76543210LL,
84 0xc76e5d4fbb2a1908LL,
85 0xe3b72ea7dd950c84LL,
86 0xf1db9753eeca8642LL,
87 0xf8edcba9f7654321LL,
88 0xfc76e5d4fbb2a190LL,
89 0xfe3b72ea7dd950c8LL,
90 0xff1db9753eeca864LL,
91 0xff8edcba9f765432LL,
92 0xffc76e5d4fbb2a19LL,
93 0xffe3b72ea7dd950cLL,
94 0xfff1db9753eeca86LL,
95 0xfff8edcba9f76543LL,
96 0xfffc76e5d4fbb2a1LL,
97 0xfffe3b72ea7dd950LL,
98 0xffff1db9753eeca8LL,
99 0xffff8edcba9f7654LL,
100 0xffffc76e5d4fbb2aLL,
101 0xffffe3b72ea7dd95LL,
102 0xfffff1db9753eecaLL,
103 0xfffff8edcba9f765LL,
104 0xfffffc76e5d4fbb2LL,
105 0xfffffe3b72ea7dd9LL,
106 0xffffff1db9753eecLL,
107 0xffffff8edcba9f76LL,
108 0xffffffc76e5d4fbbLL,
109 0xffffffe3b72ea7ddLL,
110 0xfffffff1db9753eeLL,
111 0xfffffff8edcba9f7LL,
112 0xfffffffc76e5d4fbLL,
113 0xfffffffe3b72ea7dLL,
114 0xffffffff1db9753eLL,
115 0xffffffff8edcba9fLL,
116 0xffffffffc76e5d4fLL,
117 0xffffffffe3b72ea7LL,
118 0xfffffffff1db9753LL,
119 0xfffffffff8edcba9LL,
120 0xfffffffffc76e5d4LL,
121 0xfffffffffe3b72eaLL,
122 0xffffffffff1db975LL,
123 0xffffffffff8edcbaLL,
124 0xffffffffffc76e5dLL,
125 0xffffffffffe3b72eLL,
126 0xfffffffffff1db97LL,
127 0xfffffffffff8edcbLL,
128 0xfffffffffffc76e5LL,
129 0xfffffffffffe3b72LL,
130 0xffffffffffff1db9LL,
131 0xffffffffffff8edcLL,
132 0xffffffffffffc76eLL,
133 0xffffffffffffe3b7LL,
134 0xfffffffffffff1dbLL,
135 0xfffffffffffff8edLL,
136 0xfffffffffffffc76LL,
137 0xfffffffffffffe3bLL,
138 0xffffffffffffff1dLL,
139 0xffffffffffffff8eLL,
140 0xffffffffffffffc7LL,
141 0xffffffffffffffe3LL,
142 0xfffffffffffffff1LL,
143 0xfffffffffffffff8LL,
144 0xfffffffffffffffcLL,
145 0xfffffffffffffffeLL,
146 0xffffffffffffffffLL
149 #elif LLONG_MAX == 2147483647LL
150 #define BITS 32
152 static long long const zext[32] = {
153 0x76543218LL,
154 0x3b2a190cLL,
155 0x1d950c86LL,
156 0xeca8643LL,
157 0x7654321LL,
158 0x3b2a190LL,
159 0x1d950c8LL,
160 0xeca864LL,
161 0x765432LL,
162 0x3b2a19LL,
163 0x1d950cLL,
164 0xeca86LL,
165 0x76543LL,
166 0x3b2a1LL,
167 0x1d950LL,
168 0xeca8LL,
169 0x7654LL,
170 0x3b2aLL,
171 0x1d95LL,
172 0xecaLL,
173 0x765LL,
174 0x3b2LL,
175 0x1d9LL,
176 0xecLL,
177 0x76LL,
178 0x3bLL,
179 0x1dLL,
180 0xeLL,
181 0x7LL,
182 0x3LL,
183 0x1LL,
187 static long long const sext[64] = {
188 0x87654321LL,
189 0xc3b2a190LL,
190 0xe1d950c8LL,
191 0xf0eca864LL,
192 0xf8765432LL,
193 0xfc3b2a19LL,
194 0xfe1d950cLL,
195 0xff0eca86LL,
196 0xff876543LL,
197 0xffc3b2a1LL,
198 0xffe1d950LL,
199 0xfff0eca8LL,
200 0xfff87654LL,
201 0xfffc3b2aLL,
202 0xfffe1d95LL,
203 0xffff0ecaLL,
204 0xffff8765LL,
205 0xffffc3b2LL,
206 0xffffe1d9LL,
207 0xfffff0ecLL,
208 0xfffff876LL,
209 0xfffffc3bLL,
210 0xfffffe1dLL,
211 0xffffff0eLL,
212 0xffffff87LL,
213 0xffffffc3LL,
214 0xffffffe1LL,
215 0xfffffff0LL,
216 0xfffffff8LL,
217 0xfffffffcLL,
218 0xfffffffeLL,
219 0xffffffffLL
222 #else
223 #error "Update the test case."
224 #endif
226 static long long
227 variable_shift(long long x, int i)
229 return x >> i;
232 static long long
233 constant_shift(long long x, int i)
235 switch (i)
237 case 0: x = x >> 0; break;
238 case 1: x = x >> 1; break;
239 case 2: x = x >> 2; break;
240 case 3: x = x >> 3; break;
241 case 4: x = x >> 4; break;
242 case 5: x = x >> 5; break;
243 case 6: x = x >> 6; break;
244 case 7: x = x >> 7; break;
245 case 8: x = x >> 8; break;
246 case 9: x = x >> 9; break;
247 case 10: x = x >> 10; break;
248 case 11: x = x >> 11; break;
249 case 12: x = x >> 12; break;
250 case 13: x = x >> 13; break;
251 case 14: x = x >> 14; break;
252 case 15: x = x >> 15; break;
253 case 16: x = x >> 16; break;
254 case 17: x = x >> 17; break;
255 case 18: x = x >> 18; break;
256 case 19: x = x >> 19; break;
257 case 20: x = x >> 20; break;
258 case 21: x = x >> 21; break;
259 case 22: x = x >> 22; break;
260 case 23: x = x >> 23; break;
261 case 24: x = x >> 24; break;
262 case 25: x = x >> 25; break;
263 case 26: x = x >> 26; break;
264 case 27: x = x >> 27; break;
265 case 28: x = x >> 28; break;
266 case 29: x = x >> 29; break;
267 case 30: x = x >> 30; break;
268 case 31: x = x >> 31; break;
269 #if BITS > 32
270 case 32: x = x >> 32; break;
271 case 33: x = x >> 33; break;
272 case 34: x = x >> 34; break;
273 case 35: x = x >> 35; break;
274 case 36: x = x >> 36; break;
275 case 37: x = x >> 37; break;
276 case 38: x = x >> 38; break;
277 case 39: x = x >> 39; break;
278 case 40: x = x >> 40; break;
279 case 41: x = x >> 41; break;
280 case 42: x = x >> 42; break;
281 case 43: x = x >> 43; break;
282 case 44: x = x >> 44; break;
283 case 45: x = x >> 45; break;
284 case 46: x = x >> 46; break;
285 case 47: x = x >> 47; break;
286 case 48: x = x >> 48; break;
287 case 49: x = x >> 49; break;
288 case 50: x = x >> 50; break;
289 case 51: x = x >> 51; break;
290 case 52: x = x >> 52; break;
291 case 53: x = x >> 53; break;
292 case 54: x = x >> 54; break;
293 case 55: x = x >> 55; break;
294 case 56: x = x >> 56; break;
295 case 57: x = x >> 57; break;
296 case 58: x = x >> 58; break;
297 case 59: x = x >> 59; break;
298 case 60: x = x >> 60; break;
299 case 61: x = x >> 61; break;
300 case 62: x = x >> 62; break;
301 case 63: x = x >> 63; break;
302 #endif
304 default:
305 ASSERT (0);
307 return x;
309 #endif
310 #endif
312 void
313 testTortureExecute (void)
315 #if !(defined(__SDCC_mcs51) && (defined(__SDCC_MODEL_SMALL) || defined(__SDCC_MODEL_MEDIUM) || defined(__SDCC_MODEL_LARGE) && defined(__SDCC_STACK_AUTO))) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory// Lack of memory
316 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
317 int i;
319 for (i = 0; i < BITS; ++i)
321 long long y = variable_shift (zext[0], i);
322 if (y != zext[i])
323 ASSERT (0);
325 for (i = 0; i < BITS; ++i)
327 long long y = variable_shift (sext[0], i);
328 if (y != sext[i])
329 ASSERT (0);
331 for (i = 0; i < BITS; ++i)
333 long long y = constant_shift (zext[0], i);
334 if (y != zext[i])
335 ASSERT (0);
337 for (i = 0; i < BITS; ++i)
339 long long y = constant_shift (sext[0], i);
340 if (y != sext[i])
341 ASSERT (0);
343 #endif
344 #endif
345 return;