OSDN Git Service

3231c079009db7327b9a681b7dc72445c8a77b09
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / m128-check.h
1 #include <stdio.h>
2 #include <emmintrin.h>
3
4 typedef union
5 {
6   __m128i x;
7   char a[16];
8 } union128i_b;
9
10 typedef union
11 {
12   __m128i x;
13   short a[8];
14 } union128i_w;
15
16 typedef union
17 {
18   __m128i x;
19   int a[4];
20 } union128i_d;
21
22 typedef union
23 {
24   __m128i x;
25   long long a[2];
26 } union128i_q;
27
28 typedef union
29 {
30   __m128  x;
31   float a[4];
32 } union128;
33
34 typedef union
35 {
36   __m128d x;
37   double a[2];
38 } union128d;
39
40 #ifdef DEBUG
41 #define PRINTF printf
42 #else
43 #define PRINTF(...)     
44 #endif
45
46 #define CHECK_EXP(UINON_TYPE, VALUE_TYPE, FMT)          \
47 static int                                              \
48 __attribute__((noinline, unused))                       \
49 check_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v)  \
50 {                                                       \
51   int i;                                                \
52   int err = 0;                                          \
53                                                         \
54   for (i = 0; i < sizeof (u.a) / sizeof (u.a[0]); i++)  \
55     if (u.a[i] != v[i])                                 \
56       {                                                 \
57         err++;                                          \
58         PRINTF ("%i: " FMT " != " FMT "\n",             \
59                 i, v[i], u.a[i]);                       \
60       }                                                 \
61   return err;                                           \
62 }
63
64 CHECK_EXP (union128i_b, char, "%d")
65 CHECK_EXP (union128i_w, short, "%d")
66 CHECK_EXP (union128i_d, int, "0x%x")
67 CHECK_EXP (union128i_q, long long, "0x%llx")
68 CHECK_EXP (union128, float, "%f")
69 CHECK_EXP (union128d, double, "%f")