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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [arm-eabi1.c] - Blame information for rev 149

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run { target arm*-*-symbianelf* arm*-*-eabi* } } */
2
/* { dg-options "" } */
3
 
4
/* This file tests most of the non-C++ run-time helper functions
5
   described in Section 4 of the "Run-Time ABI for the ARM
6
   Architecture".  These are basic tests; they do not try to validate
7
   all of the corner cases in these routines.
8
 
9
   The functions not tested here are:
10
 
11
     __aeabi_cdcmpeq
12
     __aeabi_cdcmple
13
     __aeabi_cdrcmple
14
     __aeabi_cfcmpeq
15
     __aeabi_cfcmple
16
     __aeabi_cfrcmple
17
     __aeabi_ldivmod
18
     __aeabi_uldivmod
19
     __aeabi_idivmod
20
     __aeabi_uidivmod
21
 
22
   These functions have non-standard calling conventions that would
23
   require the use of inline assembly to test.  It would be good to
24
   add such tests, but they have not yet been implemented.
25
 
26
   There are also no tests for the "division by zero", "memory copying,
27
   clearing, and setting" functions.  */
28
 
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <math.h>
32
 
33
#define decl_float(code, type)                                  \
34
  extern type __aeabi_ ## code ## add (type, type);             \
35
  extern type __aeabi_ ## code ## div (type, type);             \
36
  extern type __aeabi_ ## code ## mul (type, type);             \
37
  extern type __aeabi_ ## code ## neg (type);                   \
38
  extern type __aeabi_ ## code ## rsub (type, type);            \
39
  extern type __aeabi_ ## code ## sub (type, type);             \
40
  extern int __aeabi_ ## code ## cmpeq (type, type);            \
41
  extern int __aeabi_ ## code ## cmplt (type, type);            \
42
  extern int __aeabi_ ## code ## cmple (type, type);            \
43
  extern int __aeabi_ ## code ## cmpge (type, type);            \
44
  extern int __aeabi_ ## code ## cmpgt (type, type);            \
45
  extern int __aeabi_ ## code ## cmpun (type, type);            \
46
  extern int __aeabi_ ## code ## 2iz (type);                    \
47
  extern unsigned int __aeabi_ ## code ## 2uiz (type);          \
48
  extern long long __aeabi_ ## code ## 2lz (type);              \
49
  extern unsigned long long __aeabi_ ## code ## 2ulz (type);    \
50
  extern type __aeabi_i2 ## code (int);                         \
51
  extern type __aeabi_ui2 ## code (int);                        \
52
  extern type __aeabi_l2 ## code (long long);                   \
53
  extern type __aeabi_ul2 ## code (unsigned long long);         \
54
                                                                \
55
  type code ## zero = 0.0;                                      \
56
  type code ## one = 1.0;                                       \
57
  type code ## two = 2.0;                                       \
58
  type code ## four = 4.0;                                      \
59
  type code ## minus_one = -1.0;                                \
60
  type code ## minus_two = -2.0;                                \
61
  type code ## minus_four = -4.0;                               \
62
  type code ## epsilon = 1E-32;                                 \
63
  type code ## NaN = 0.0 / 0.0;                         
64
 
65
decl_float (d, double)
66
decl_float (f, float)
67
 
68
extern float __aeabi_d2f (double);
69
extern double __aeabi_f2d (float);
70
extern long long __aeabi_lmul (long long, long long);
71
extern long long __aeabi_llsl (long long, int);
72
extern long long __aeabi_llsr (long long, int);
73
extern long long __aeabi_lasr (long long, int);
74
extern int __aeabi_lcmp (long long, long long);
75
extern int __aeabi_ulcmp (unsigned long long, unsigned long long);
76
extern int __aeabi_idiv (int, int);
77
extern unsigned int __aeabi_uidiv (unsigned int, unsigned int);
78
extern int __eabi_uread4 (void *);
79
extern int __eabi_uwrite4 (int, void *);
80
extern long long __eabi_uread8 (void *);
81
extern long long __eabi_uwrite8 (long long, void *);
82
 
83
#define eq(a, b, type, abs, epsilon, format)                    \
84
  {                                                             \
85
    type a1;                                                    \
86
    type b1;                                                    \
87
                                                                \
88
    fprintf (stderr, "%d: Test %s == %s\n", __LINE__, #a, #b);  \
89
    a1 = a;                                                     \
90
    b1 = b;                                                     \
91
    if (abs (a1 - b1) > epsilon)                                \
92
    {                                                           \
93
      fprintf (stderr, "%d: " format " != " format "\n",        \
94
               __LINE__, a1, b1);                               \
95
      abort ();                                                 \
96
    }                                                           \
97
  }
98
 
99
#define ieq(a, b) eq (a, b, int, abs, 0, "%d")
100
#define ueq(a, b) eq (a, b, unsigned int, abs, 0, "%u")
101
#define leq(a, b) eq (a, b, long long, abs, 0, "%lld")
102
#define uleq(a, b) eq (a, b, unsigned long long, abs, 0, "%llu")
103
#define feq(a, b) eq (a, b, float, fabs, fepsilon, "%f")
104
#define deq(a, b) eq (a, b, double, fabs, depsilon, "%g")
105
 
106
int main () {
107
  unsigned char bytes[256];
108
  int i;
109
 
110
  /* Table 2.  Double-precision floating-point arithmetic.  */
111
  deq (__aeabi_dadd (dzero, done), done);
112
  deq (__aeabi_dadd (done, done), dtwo);
113
  deq (__aeabi_ddiv (dminus_four, dminus_two), dtwo);
114
  deq (__aeabi_ddiv (dminus_two, dtwo), dminus_one);
115
  deq (__aeabi_dmul (dtwo, dtwo), dfour);
116
  deq (__aeabi_dmul (dminus_one, dminus_two), dtwo);
117
  deq (__aeabi_dneg (dminus_one), done);
118
  deq (__aeabi_dneg (dfour), dminus_four);
119
  deq (__aeabi_drsub (done, dzero), dminus_one);
120
  deq (__aeabi_drsub (dtwo, dminus_two), dminus_four);
121
  deq (__aeabi_dsub (dzero, done), dminus_one);
122
  deq (__aeabi_dsub (dminus_two, dtwo), dminus_four);
123
 
124
  /* Table 3.  Double-precision floating-point comparisons.  */
125
  ieq (__aeabi_dcmpeq (done, done), 1);
126
  ieq (__aeabi_dcmpeq (done, dzero), 0);
127
  ieq (__aeabi_dcmpeq (dNaN, dzero), 0);
128
  ieq (__aeabi_dcmpeq (dNaN, dNaN), 0);
129
 
130
  ieq (__aeabi_dcmplt (dzero, done), 1);
131
  ieq (__aeabi_dcmplt (done, dzero), 0);
132
  ieq (__aeabi_dcmplt (dzero, dzero), 0);
133
  ieq (__aeabi_dcmplt (dzero, dNaN), 0);
134
  ieq (__aeabi_dcmplt (dNaN, dNaN), 0);
135
 
136
  ieq (__aeabi_dcmple (dzero, done), 1);
137
  ieq (__aeabi_dcmple (done, dzero), 0);
138
  ieq (__aeabi_dcmple (dzero, dzero), 1);
139
  ieq (__aeabi_dcmple (dzero, dNaN), 0);
140
  ieq (__aeabi_dcmple (dNaN, dNaN), 0);
141
 
142
  ieq (__aeabi_dcmpge (dzero, done), 0);
143
  ieq (__aeabi_dcmpge (done, dzero), 1);
144
  ieq (__aeabi_dcmpge (dzero, dzero), 1);
145
  ieq (__aeabi_dcmpge (dzero, dNaN), 0);
146
  ieq (__aeabi_dcmpge (dNaN, dNaN), 0);
147
 
148
  ieq (__aeabi_dcmpgt (dzero, done), 0);
149
  ieq (__aeabi_dcmpgt (done, dzero), 1);
150
  ieq (__aeabi_dcmplt (dzero, dzero), 0);
151
  ieq (__aeabi_dcmpgt (dzero, dNaN), 0);
152
  ieq (__aeabi_dcmpgt (dNaN, dNaN), 0);
153
 
154
  ieq (__aeabi_dcmpun (done, done), 0);
155
  ieq (__aeabi_dcmpun (done, dzero), 0);
156
  ieq (__aeabi_dcmpun (dNaN, dzero), 1);
157
  ieq (__aeabi_dcmpun (dNaN, dNaN), 1);
158
 
159
  /* Table 4.  Single-precision floating-point arithmetic.  */
160
  feq (__aeabi_fadd (fzero, fone), fone);
161
  feq (__aeabi_fadd (fone, fone), ftwo);
162
  feq (__aeabi_fdiv (fminus_four, fminus_two), ftwo);
163
  feq (__aeabi_fdiv (fminus_two, ftwo), fminus_one);
164
  feq (__aeabi_fmul (ftwo, ftwo), ffour);
165
  feq (__aeabi_fmul (fminus_one, fminus_two), ftwo);
166
  feq (__aeabi_fneg (fminus_one), fone);
167
  feq (__aeabi_fneg (ffour), fminus_four);
168
  feq (__aeabi_frsub (fone, fzero), fminus_one);
169
  feq (__aeabi_frsub (ftwo, fminus_two), fminus_four);
170
  feq (__aeabi_fsub (fzero, fone), fminus_one);
171
  feq (__aeabi_fsub (fminus_two, ftwo), fminus_four);
172
 
173
  /* Table 5.  Single-precision floating-point comparisons.  */
174
  ieq (__aeabi_fcmpeq (fone, fone), 1);
175
  ieq (__aeabi_fcmpeq (fone, fzero), 0);
176
  ieq (__aeabi_fcmpeq (fNaN, fzero), 0);
177
  ieq (__aeabi_fcmpeq (fNaN, fNaN), 0);
178
 
179
  ieq (__aeabi_fcmplt (fzero, fone), 1);
180
  ieq (__aeabi_fcmplt (fone, fzero), 0);
181
  ieq (__aeabi_fcmplt (fzero, fzero), 0);
182
  ieq (__aeabi_fcmplt (fzero, fNaN), 0);
183
  ieq (__aeabi_fcmplt (fNaN, fNaN), 0);
184
 
185
  ieq (__aeabi_fcmple (fzero, fone), 1);
186
  ieq (__aeabi_fcmple (fone, fzero), 0);
187
  ieq (__aeabi_fcmple (fzero, fzero), 1);
188
  ieq (__aeabi_fcmple (fzero, fNaN), 0);
189
  ieq (__aeabi_fcmple (fNaN, fNaN), 0);
190
 
191
  ieq (__aeabi_fcmpge (fzero, fone), 0);
192
  ieq (__aeabi_fcmpge (fone, fzero), 1);
193
  ieq (__aeabi_fcmpge (fzero, fzero), 1);
194
  ieq (__aeabi_fcmpge (fzero, fNaN), 0);
195
  ieq (__aeabi_fcmpge (fNaN, fNaN), 0);
196
 
197
  ieq (__aeabi_fcmpgt (fzero, fone), 0);
198
  ieq (__aeabi_fcmpgt (fone, fzero), 1);
199
  ieq (__aeabi_fcmplt (fzero, fzero), 0);
200
  ieq (__aeabi_fcmpgt (fzero, fNaN), 0);
201
  ieq (__aeabi_fcmpgt (fNaN, fNaN), 0);
202
 
203
  ieq (__aeabi_fcmpun (fone, fone), 0);
204
  ieq (__aeabi_fcmpun (fone, fzero), 0);
205
  ieq (__aeabi_fcmpun (fNaN, fzero), 1);
206
  ieq (__aeabi_fcmpun (fNaN, fNaN), 1);
207
 
208
  /* Table 6.  Floating-point to integer conversions.  */
209
  ieq (__aeabi_d2iz (dminus_one), -1);
210
  ueq (__aeabi_d2uiz (done), 1);
211
  leq (__aeabi_d2lz (dminus_two), -2LL);
212
  uleq (__aeabi_d2ulz (dfour), 4LL);
213
  ieq (__aeabi_f2iz (fminus_one), -1);
214
  ueq (__aeabi_f2uiz (fone), 1);
215
  leq (__aeabi_f2lz (fminus_two), -2LL);
216
  uleq (__aeabi_f2ulz (ffour), 4LL);
217
 
218
  /* Table 7.  Conversions between floating types.  */
219
  feq (__aeabi_d2f (dtwo), ftwo);
220
  deq (__aeabi_f2d (fminus_four), dminus_four);
221
 
222
  /* Table 8.  Integer to floating-point conversions.  */
223
  deq (__aeabi_i2d (-1), dminus_one);
224
  deq (__aeabi_ui2d (2), dtwo);
225
  deq (__aeabi_l2d (-1), dminus_one);
226
  deq (__aeabi_ul2d (2ULL), dtwo);
227
  feq (__aeabi_i2f (-1), fminus_one);
228
  feq (__aeabi_ui2f (2), ftwo);
229
  feq (__aeabi_l2f (-1), fminus_one);
230
  feq (__aeabi_ul2f (2ULL), ftwo);
231
 
232
  /* Table 9.  Long long functions.  */
233
  leq (__aeabi_lmul (4LL, -1LL), -4LL);
234
  leq (__aeabi_llsl (2LL, 1), 4LL);
235
  leq (__aeabi_llsr (-1LL, 63), 1);
236
  leq (__aeabi_lasr (-1LL, 63), -1);
237
  ieq (__aeabi_lcmp (0LL, 1LL), -1);
238
  ieq (__aeabi_lcmp (0LL, 0LL), 0);
239
  ieq (__aeabi_lcmp (1LL, 0LL), 1);
240
  ieq (__aeabi_ulcmp (0LL, 1LL), -1);
241
  ieq (__aeabi_ulcmp (0LL, 0LL), 0);
242
  ieq (__aeabi_ulcmp (1LL, 0LL), 1);
243
 
244
  ieq (__aeabi_idiv (-550, 11), -50);
245
  ueq (__aeabi_uidiv (4000000000U, 1000000U), 4000U);
246
 
247
  for (i = 0; i < 256; i++)
248
    bytes[i] = i;
249
 
250
#ifdef __ARMEB__
251
  ieq (__aeabi_uread4 (bytes + 1), 0x01020304U);
252
  leq (__aeabi_uread8 (bytes + 3), 0x030405060708090aLL);
253
  ieq (__aeabi_uwrite4 (0x66778899U, bytes + 5), 0x66778899U);
254
  leq (__aeabi_uwrite8 (0x2030405060708090LL, bytes + 15),
255
       0x2030405060708090LL);
256
#else
257
  ieq (__aeabi_uread4 (bytes + 1), 0x04030201U);
258
  leq (__aeabi_uread8 (bytes + 3), 0x0a09080706050403LL);
259
  ieq (__aeabi_uwrite4 (0x99887766U, bytes + 5), 0x99887766U);
260
  leq (__aeabi_uwrite8 (0x9080706050403020LL, bytes + 15),
261
       0x9080706050403020LL);
262
#endif
263
 
264
  for (i = 0; i < 4; i++)
265
    ieq (bytes[5 + i], (6 + i) * 0x11);
266
 
267
  for (i = 0; i < 8; i++)
268
    ieq (bytes[15 + i], (2 + i) * 0x10);
269
 
270
  exit (0);
271
}

powered by: WebSVN 2.1.0

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