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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20040629-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Test arithmetics on bitfields.  */
2
#ifndef T
3
 
4
extern void abort (void);
5
extern void exit (int);
6
 
7
#ifndef FIELDS1
8
#define FIELDS1
9
#endif
10
#ifndef FIELDS2
11
#define FIELDS2
12
#endif
13
 
14
struct { FIELDS1 unsigned int i : 6, j : 11, k : 15; FIELDS2 } b;
15
struct { FIELDS1 unsigned int i : 5, j : 1, k : 26; FIELDS2 } c;
16
struct { FIELDS1 unsigned int i : 16, j : 8, k : 8; FIELDS2 } d;
17
 
18
unsigned int ret1 (void) { return b.i; }
19
unsigned int ret2 (void) { return b.j; }
20
unsigned int ret3 (void) { return b.k; }
21
unsigned int ret4 (void) { return c.i; }
22
unsigned int ret5 (void) { return c.j; }
23
unsigned int ret6 (void) { return c.k; }
24
unsigned int ret7 (void) { return d.i; }
25
unsigned int ret8 (void) { return d.j; }
26
unsigned int ret9 (void) { return d.k; }
27
 
28
#define T(n, pre, post, op)                                     \
29
void fn1_##n (unsigned int x) { pre b.i post; }                 \
30
void fn2_##n (unsigned int x) { pre b.j post; }                 \
31
void fn3_##n (unsigned int x) { pre b.k post; }                 \
32
void fn4_##n (unsigned int x) { pre c.i post; }                 \
33
void fn5_##n (unsigned int x) { pre c.j post; }                 \
34
void fn6_##n (unsigned int x) { pre c.k post; }                 \
35
void fn7_##n (unsigned int x) { pre d.i post; }                 \
36
void fn8_##n (unsigned int x) { pre d.j post; }                 \
37
void fn9_##n (unsigned int x) { pre d.k post; }
38
 
39
#include "20040629-1.c"
40
#undef T
41
 
42
#define FAIL(n, i) abort ()
43
 
44
int
45
main (void)
46
{
47
#define T(n, pre, post, op)                                     \
48
  b.i = 51;                                                     \
49
  b.j = 636;                                                    \
50
  b.k = 31278;                                                  \
51
  c.i = 21;                                                     \
52
  c.j = 1;                                                      \
53
  c.k = 33554432;                                               \
54
  d.i = 26812;                                                  \
55
  d.j = 156;                                                    \
56
  d.k = 187;                                                    \
57
  fn1_##n (3);                                                  \
58
  if (ret1 () != (op (51, 3) & ((1 << 6) - 1)))                 \
59
    FAIL (n, 1);                                                \
60
  b.i = 51;                                                     \
61
  fn2_##n (251);                                                \
62
  if (ret2 () != (op (636, 251) & ((1 << 11) - 1)))             \
63
    FAIL (n, 2);                                                \
64
  b.j = 636;                                                    \
65
  fn3_##n (13279);                                              \
66
  if (ret3 () != (op (31278, 13279) & ((1 << 15) - 1)))         \
67
    FAIL (n, 3);                                                \
68
  b.j = 31278;                                                  \
69
  fn4_##n (24);                                                 \
70
  if (ret4 () != (op (21, 24) & ((1 << 5) - 1)))                \
71
    FAIL (n, 4);                                                \
72
  c.i = 21;                                                     \
73
  fn5_##n (1);                                                  \
74
  if (ret5 () != (op (1, 1) & ((1 << 1) - 1)))                  \
75
    FAIL (n, 5);                                                \
76
  c.j = 1;                                                      \
77
  fn6_##n (264151);                                             \
78
  if (ret6 () != (op (33554432, 264151) & ((1 << 26) - 1)))     \
79
    FAIL (n, 6);                                                \
80
  c.k = 33554432;                                               \
81
  fn7_##n (713);                                                \
82
  if (ret7 () != (op (26812, 713) & ((1 << 16) - 1)))           \
83
    FAIL (n, 7);                                                \
84
  d.i = 26812;                                                  \
85
  fn8_##n (17);                                                 \
86
  if (ret8 () != (op (156, 17) & ((1 << 8) - 1)))               \
87
    FAIL (n, 8);                                                \
88
  d.j = 156;                                                    \
89
  fn9_##n (199);                                                \
90
  if (ret9 () != (op (187, 199) & ((1 << 8) - 1)))              \
91
    FAIL (n, 9);                                                \
92
  d.k = 187;
93
 
94
#include "20040629-1.c"
95
#undef T
96
  return 0;
97
}
98
 
99
#else
100
 
101
#ifndef opadd
102
#define opadd(x, y) (x + y)
103
#define opsub(x, y) (x - y)
104
#define opinc(x, y) (x + 1)
105
#define opdec(x, y) (x - 1)
106
#define opand(x, y) (x & y)
107
#define opior(x, y) (x | y)
108
#define opxor(x, y) (x ^ y)
109
#define opdiv(x, y) (x / y)
110
#define oprem(x, y) (x % y)
111
#define opadd3(x, y) (x + 3)
112
#define opsub7(x, y) (x - 7)
113
#define opand21(x, y) (x & 21)
114
#define opior19(x, y) (x | 19)
115
#define opxor37(x, y) (x ^ 37)
116
#define opdiv17(x, y) (x / 17)
117
#define oprem19(x, y) (x % 19)
118
#endif
119
 
120
T(1, , += x, opadd)
121
T(2, ++, , opinc)
122
T(3, , ++, opinc)
123
T(4, , -= x, opsub)
124
T(5, --, , opdec)
125
T(6, , --, opdec)
126
T(7, , &= x, opand)
127
T(8, , |= x, opior)
128
T(9, , ^= x, opxor)
129
T(a, , /= x, opdiv)
130
T(b, , %= x, oprem)
131
T(c, , += 3, opadd3)
132
T(d, , -= 7, opsub7)
133
T(e, , &= 21, opand21)
134
T(f, , |= 19, opior19)
135
T(g, , ^= 37, opxor37)
136
T(h, , /= 17, opdiv17)
137
T(i, , %= 19, oprem19)
138
 
139
#endif

powered by: WebSVN 2.1.0

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