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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20020108-1.c] - Blame information for rev 301

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

Line No. Rev Author Line
1 297 jeremybenn
/* This file tests shifts in various integral modes.  */
2
 
3
#include <limits.h>
4
 
5
#define CAT(A, B) A ## B
6
 
7
#define REPEAT_8        \
8
REPEAT_FN ( 0)           \
9
REPEAT_FN ( 1)          \
10
REPEAT_FN ( 2)          \
11
REPEAT_FN ( 3)          \
12
REPEAT_FN ( 4)          \
13
REPEAT_FN ( 5)          \
14
REPEAT_FN ( 6)          \
15
REPEAT_FN ( 7)
16
 
17
#define REPEAT_16       \
18
REPEAT_8                \
19
REPEAT_FN ( 8)          \
20
REPEAT_FN ( 9)          \
21
REPEAT_FN (10)          \
22
REPEAT_FN (11)          \
23
REPEAT_FN (12)          \
24
REPEAT_FN (13)          \
25
REPEAT_FN (14)          \
26
REPEAT_FN (15)
27
 
28
#define REPEAT_32       \
29
REPEAT_16               \
30
REPEAT_FN (16)          \
31
REPEAT_FN (17)          \
32
REPEAT_FN (18)          \
33
REPEAT_FN (19)          \
34
REPEAT_FN (20)          \
35
REPEAT_FN (21)          \
36
REPEAT_FN (22)          \
37
REPEAT_FN (23)          \
38
REPEAT_FN (24)          \
39
REPEAT_FN (25)          \
40
REPEAT_FN (26)          \
41
REPEAT_FN (27)          \
42
REPEAT_FN (28)          \
43
REPEAT_FN (29)          \
44
REPEAT_FN (30)          \
45
REPEAT_FN (31)
46
 
47
/* Define 8-bit shifts.  */
48
#if CHAR_BIT == 8
49
typedef unsigned int u8 __attribute__((mode(QI)));
50
typedef signed int s8 __attribute__((mode(QI)));
51
 
52
#define REPEAT_FN(COUNT) \
53
u8 CAT (ashift_qi_, COUNT) (u8 n) { return n << COUNT; }
54
REPEAT_8
55
#undef REPEAT_FN
56
 
57
#define REPEAT_FN(COUNT) \
58
u8 CAT (lshiftrt_qi_, COUNT) (u8 n) { return n >> COUNT; }
59
REPEAT_8
60
#undef REPEAT_FN
61
 
62
#define REPEAT_FN(COUNT) \
63
s8 CAT (ashiftrt_qi_, COUNT) (s8 n) { return n >> COUNT; }
64
REPEAT_8
65
#undef REPEAT_FN
66
#endif /* CHAR_BIT == 8 */
67
 
68
/* Define 16-bit shifts.  */
69
#if CHAR_BIT == 8 || CHAR_BIT == 16
70
#if CHAR_BIT == 8
71
typedef unsigned int u16 __attribute__((mode(HI)));
72
typedef signed int s16 __attribute__((mode(HI)));
73
#elif CHAR_BIT == 16
74
typedef unsigned int u16 __attribute__((mode(QI)));
75
typedef signed int s16 __attribute__((mode(QI)));
76
#endif
77
 
78
#define REPEAT_FN(COUNT) \
79
u16 CAT (ashift_hi_, COUNT) (u16 n) { return n << COUNT; }
80
REPEAT_16
81
#undef REPEAT_FN
82
 
83
#define REPEAT_FN(COUNT) \
84
u16 CAT (lshiftrt_hi_, COUNT) (u16 n) { return n >> COUNT; }
85
REPEAT_16
86
#undef REPEAT_FN
87
 
88
#define REPEAT_FN(COUNT) \
89
s16 CAT (ashiftrt_hi_, COUNT) (s16 n) { return n >> COUNT; }
90
REPEAT_16
91
#undef REPEAT_FN
92
#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */
93
 
94
/* Define 32-bit shifts.  */
95
#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32
96
#if CHAR_BIT == 8
97
typedef unsigned int u32 __attribute__((mode(SI)));
98
typedef signed int s32 __attribute__((mode(SI)));
99
#elif CHAR_BIT == 16
100
typedef unsigned int u32 __attribute__((mode(HI)));
101
typedef signed int s32 __attribute__((mode(HI)));
102
#elif CHAR_BIT == 32
103
typedef unsigned int u32 __attribute__((mode(QI)));
104
typedef signed int s32 __attribute__((mode(QI)));
105
#endif
106
 
107
#define REPEAT_FN(COUNT) \
108
u32 CAT (ashift_si_, COUNT) (u32 n) { return n << COUNT; }
109
REPEAT_32
110
#undef REPEAT_FN
111
 
112
#define REPEAT_FN(COUNT) \
113
u32 CAT (lshiftrt_si_, COUNT) (u32 n) { return n >> COUNT; }
114
REPEAT_32
115
#undef REPEAT_FN
116
 
117
#define REPEAT_FN(COUNT) \
118
s32 CAT (ashiftrt_si_, COUNT) (s32 n) { return n >> COUNT; }
119
REPEAT_32
120
#undef REPEAT_FN
121
#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */
122
 
123
extern void abort (void);
124
extern void exit (int);
125
 
126
int
127
main ()
128
{
129
  /* Test 8-bit shifts.  */
130
#if CHAR_BIT == 8
131
# define REPEAT_FN(COUNT) \
132
  if (CAT (ashift_qi_, COUNT) (0xff) != (u8) ((u8)0xff << COUNT)) abort ();
133
  REPEAT_8;
134
# undef REPEAT_FN
135
 
136
# define REPEAT_FN(COUNT) \
137
  if (CAT (lshiftrt_qi_, COUNT) (0xff) != (u8) ((u8)0xff >> COUNT)) abort ();
138
  REPEAT_8;
139
# undef REPEAT_FN
140
 
141
# define REPEAT_FN(COUNT) \
142
  if (CAT (ashiftrt_qi_, COUNT) (-1) != -1) abort ();
143
  REPEAT_8;
144
# undef REPEAT_FN
145
 
146
# define REPEAT_FN(COUNT) \
147
  if (CAT (ashiftrt_qi_, COUNT) (0) != 0) abort ();
148
  REPEAT_8;
149
# undef REPEAT_FN
150
#endif /* CHAR_BIT == 8 */
151
 
152
  /* Test 16-bit shifts.  */
153
#if CHAR_BIT == 8 || CHAR_BIT == 16
154
# define REPEAT_FN(COUNT)                       \
155
  if (CAT (ashift_hi_, COUNT) (0xffff)          \
156
      != (u16) ((u16) 0xffff << COUNT)) abort ();
157
  REPEAT_16;
158
# undef REPEAT_FN
159
 
160
# define REPEAT_FN(COUNT)                       \
161
  if (CAT (lshiftrt_hi_, COUNT) (0xffff)        \
162
      != (u16) ((u16) 0xffff >> COUNT)) abort ();
163
  REPEAT_16;
164
# undef REPEAT_FN
165
 
166
# define REPEAT_FN(COUNT) \
167
  if (CAT (ashiftrt_hi_, COUNT) (-1) != -1) abort ();
168
  REPEAT_16;
169
# undef REPEAT_FN
170
 
171
# define REPEAT_FN(COUNT) \
172
  if (CAT (ashiftrt_hi_, COUNT) (0) != 0) abort ();
173
  REPEAT_16;
174
# undef REPEAT_FN
175
#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */
176
 
177
  /* Test 32-bit shifts.  */
178
#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32
179
# define REPEAT_FN(COUNT)                               \
180
  if (CAT (ashift_si_, COUNT) (0xffffffff)              \
181
      != (u32) ((u32) 0xffffffff << COUNT)) abort ();
182
  REPEAT_32;
183
# undef REPEAT_FN
184
 
185
# define REPEAT_FN(COUNT)                               \
186
  if (CAT (lshiftrt_si_, COUNT) (0xffffffff)            \
187
      != (u32) ((u32) 0xffffffff >> COUNT)) abort ();
188
  REPEAT_32;
189
# undef REPEAT_FN
190
 
191
# define REPEAT_FN(COUNT) \
192
  if (CAT (ashiftrt_si_, COUNT) (-1) != -1) abort ();
193
  REPEAT_32;
194
# undef REPEAT_FN
195
 
196
# define REPEAT_FN(COUNT) \
197
  if (CAT (ashiftrt_si_, COUNT) (0) != 0) abort ();
198
  REPEAT_32;
199
# undef REPEAT_FN
200
#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */
201
 
202
  exit (0);
203
}

powered by: WebSVN 2.1.0

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