OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20040709-1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* Test arithmetics on bitfields.  */
2
 
3
extern void abort (void);
4
extern void exit (int);
5
 
6
unsigned int
7
myrnd (void)
8
{
9
  static unsigned int s = 1388815473;
10
  s *= 1103515245;
11
  s += 12345;
12
  return (s / 65536) % 2048;
13
}
14
 
15
#define T(S)                                    \
16
struct S s##S;                                  \
17
struct S retme##S (struct S x)                  \
18
{                                               \
19
  return x;                                     \
20
}                                               \
21
                                                \
22
unsigned int fn1##S (unsigned int x)            \
23
{                                               \
24
  struct S y = s##S;                            \
25
  y.k += x;                                     \
26
  y = retme##S (y);                             \
27
  return y.k;                                   \
28
}                                               \
29
                                                \
30
unsigned int fn2##S (unsigned int x)            \
31
{                                               \
32
  struct S y = s##S;                            \
33
  y.k += x;                                     \
34
  y.k %= 15;                                    \
35
  return y.k;                                   \
36
}                                               \
37
                                                \
38
unsigned int retit##S (void)                    \
39
{                                               \
40
  return s##S.k;                                \
41
}                                               \
42
                                                \
43
unsigned int fn3##S (unsigned int x)            \
44
{                                               \
45
  s##S.k += x;                                  \
46
  return retit##S ();                           \
47
}                                               \
48
                                                \
49
void test##S (void)                             \
50
{                                               \
51
  int i;                                        \
52
  unsigned int mask, v, a, r;                   \
53
  struct S x;                                   \
54
  char *p = (char *) &s##S;                     \
55
  for (i = 0; i < sizeof (s##S); ++i)            \
56
    *p++ = myrnd ();                            \
57
  if (__builtin_classify_type (s##S.l) == 8)    \
58
    s##S.l = 5.25;                              \
59
  s##S.k = -1;                                  \
60
  mask = s##S.k;                                \
61
  v = myrnd ();                                 \
62
  a = myrnd ();                                 \
63
  s##S.k = v;                                   \
64
  x = s##S;                                     \
65
  r = fn1##S (a);                               \
66
  if (x.i != s##S.i || x.j != s##S.j            \
67
      || x.k != s##S.k || x.l != s##S.l         \
68
      || ((v + a) & mask) != r)                 \
69
    abort ();                                   \
70
  v = myrnd ();                                 \
71
  a = myrnd ();                                 \
72
  s##S.k = v;                                   \
73
  x = s##S;                                     \
74
  r = fn2##S (a);                               \
75
  if (x.i != s##S.i || x.j != s##S.j            \
76
      || x.k != s##S.k || x.l != s##S.l         \
77
      || ((((v + a) & mask) % 15) & mask) != r) \
78
    abort ();                                   \
79
  v = myrnd ();                                 \
80
  a = myrnd ();                                 \
81
  s##S.k = v;                                   \
82
  x = s##S;                                     \
83
  r = fn3##S (a);                               \
84
  if (x.i != s##S.i || x.j != s##S.j            \
85
      || s##S.k != r || x.l != s##S.l           \
86
      || ((v + a) & mask) != r)                 \
87
    abort ();                                   \
88
}
89
 
90
struct A { unsigned int i : 6, l : 1, j : 10, k : 15; }; T(A)
91
struct B { unsigned int i : 6, j : 11, k : 15; unsigned int l; }; T(B)
92
struct C { unsigned int l; unsigned int i : 6, j : 11, k : 15; }; T(C)
93
struct D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)
94
struct E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)
95
struct F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)
96
struct G { unsigned int i : 12, j : 13, k : 7; unsigned long long l; }; T(G)
97
struct H { unsigned int i : 12, j : 11, k : 9; unsigned long long l; }; T(H)
98
struct I { unsigned short i : 1, j : 6, k : 9; unsigned long long l; }; T(I)
99
struct J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)
100
struct K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)
101
struct L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)
102
struct M { unsigned int l; unsigned int k : 6, j : 11, i : 15; }; T(M)
103
struct N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)
104
struct O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)
105
struct P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)
106
struct Q { unsigned int k : 12, j : 13, i : 7; unsigned long long l; }; T(Q)
107
struct R { unsigned int k : 12, j : 11, i : 9; unsigned long long l; }; T(R)
108
struct S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)
109
struct T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)
110
struct U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)
111
struct V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)
112
struct W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)
113
struct X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)
114
struct Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)
115
struct Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)
116
 
117
int
118
main (void)
119
{
120
  testA ();
121
  testB ();
122
  testC ();
123
  testD ();
124
  testE ();
125
  testF ();
126
  testG ();
127
  testH ();
128
  testI ();
129
  testJ ();
130
  testK ();
131
  testL ();
132
  testM ();
133
  testN ();
134
  testO ();
135
  testP ();
136
  testQ ();
137
  testR ();
138
  testS ();
139
  testT ();
140
  testU ();
141
  testV ();
142
  testW ();
143
  testX ();
144
  testY ();
145
  testZ ();
146
  exit (0);
147
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.