OSDN Git Service

* gcc.target/powerpc/altivec-macros.c: Fix dg-message directives.
[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 #ifndef ARRAY_SIZE
41 #define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0]))
42 #endif
43
44 #ifdef DEBUG
45 #define PRINTF printf
46 #else
47 #define PRINTF(...)     
48 #endif
49
50 #define CHECK_EXP(UINON_TYPE, VALUE_TYPE, FMT)          \
51 static int                                              \
52 __attribute__((noinline, unused))                       \
53 check_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v)  \
54 {                                                       \
55   int i;                                                \
56   int err = 0;                                          \
57                                                         \
58   for (i = 0; i < ARRAY_SIZE (u.a); i++)                \
59     if (u.a[i] != v[i])                                 \
60       {                                                 \
61         err++;                                          \
62         PRINTF ("%i: " FMT " != " FMT "\n",             \
63                 i, v[i], u.a[i]);                       \
64       }                                                 \
65   return err;                                           \
66 }
67
68 CHECK_EXP (union128i_b, char, "%d")
69 CHECK_EXP (union128i_w, short, "%d")
70 CHECK_EXP (union128i_d, int, "0x%x")
71 CHECK_EXP (union128i_q, long long, "0x%llx")
72 CHECK_EXP (union128, float, "%f")
73 CHECK_EXP (union128d, double, "%f")