PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / arm / thumb1-ual-1.c
bloba2e439c6c4bbf688f4aa182df51910dfea93dc5d
1 /* Test Thumb1 insn pattern addsi3_cbranch_scratch. */
2 /* { dg-options "-O2" } */
3 /* { dg-skip-if "" { ! { arm_thumb1 } } } */
5 struct real_value {
7 unsigned int cl : 2;
8 unsigned int decimal : 1;
9 unsigned int sign : 1;
10 unsigned int signalling : 1;
11 unsigned int canonical : 1;
12 unsigned int uexp : (32 - 6);
13 unsigned long sig[((128 + (8 * 4)) / (8 * 4))];
16 enum real_value_class {
17 rvc_zero,
18 rvc_normal,
19 rvc_inf,
20 rvc_nan
23 extern void exit(int);
24 extern int foo(long long *, int, int);
26 int
27 real_to_integer (const struct real_value *r, int *fail, int precision)
29 long long val[2 * (((64*(8)) + 64) / 64)];
30 int exp;
31 int words, w;
32 int result;
34 switch (r->cl)
36 case rvc_zero:
37 underflow:
38 return 100;
40 case rvc_inf:
41 case rvc_nan:
42 overflow:
43 *fail = 1;
45 if (r->sign)
46 return 200;
47 else
48 return 300;
50 case rvc_normal:
51 if (r->decimal)
52 return 400;
54 exp = ((int)((r)->uexp ^ (unsigned int)(1 << ((32 - 6) - 1))) - (1 << ((32 - 6) - 1)));
55 if (exp <= 0)
56 goto underflow;
59 if (exp > precision)
60 goto overflow;
61 words = (precision + 64 - 1) / 64;
62 w = words * 64;
63 for (int i = 0; i < words; i++)
65 int j = ((128 + (8 * 4)) / (8 * 4)) - (words * 2) + (i * 2);
66 if (j < 0)
67 val[i] = 0;
68 else
69 val[i] = r->sig[j];
70 j += 1;
71 if (j >= 0)
72 val[i] |= (unsigned long long) r->sig[j] << (8 * 4);
76 result = foo(val, words, w);
78 if (r->sign)
79 return -result;
80 else
81 return result;
83 default:
84 exit(2);