VirtualBox

source: vbox/trunk/src/libs/softfloat-3e/testfloat/source/genCases_extF80.c@ 106842

Last change on this file since 106842 was 94551, checked in by vboxsync, 3 years ago

libs/softfloat: Copied TestFloat-3e from vendor branch and to testfloat subdir. bugref:9898

  • Property svn:eol-style set to native
File size: 29.0 KB
Line 
1
2/*============================================================================
3
4This C source file is part of TestFloat, Release 3e, a package of programs for
5testing the correctness of floating-point arithmetic complying with the IEEE
6Standard for Floating-Point, by John R. Hauser.
7
8Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
9All rights reserved.
10
11Redistribution and use in source and binary forms, with or without
12modification, are permitted provided that the following conditions are met:
13
14 1. Redistributions of source code must retain the above copyright notice,
15 this list of conditions, and the following disclaimer.
16
17 2. Redistributions in binary form must reproduce the above copyright notice,
18 this list of conditions, and the following disclaimer in the documentation
19 and/or other materials provided with the distribution.
20
21 3. Neither the name of the University nor the names of its contributors may
22 be used to endorse or promote products derived from this software without
23 specific prior written permission.
24
25THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
26EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
28DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
29DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36=============================================================================*/
37
38#include <stdbool.h>
39#include <stdint.h>
40#include "platform.h"
41#include "random.h"
42#include "softfloat.h"
43#include "genCases.h"
44
45#ifdef EXTFLOAT80
46
47struct sequence {
48 int expNum, term1Num, term2Num;
49 bool done;
50};
51
52enum {
53 extF80NumQIn = 22,
54 extF80NumQOut = 76,
55 extF80NumP1 = 4,
56 extF80NumP2 = 248
57};
58static const uint16_t extF80QIn[extF80NumQIn] = {
59 0x0000, /* positive, subnormal */
60 0x0001, /* positive, -16382 */
61 0x3FBF, /* positive, -64 */
62 0x3FFD, /* positive, -2 */
63 0x3FFE, /* positive, -1 */
64 0x3FFF, /* positive, 0 */
65 0x4000, /* positive, 1 */
66 0x4001, /* positive, 2 */
67 0x403F, /* positive, 64 */
68 0x7FFE, /* positive, 16383 */
69 0x7FFF, /* positive, infinity or NaN */
70 0x8000, /* negative, subnormal */
71 0x8001, /* negative, -16382 */
72 0xBFBF, /* negative, -64 */
73 0xBFFD, /* negative, -2 */
74 0xBFFE, /* negative, -1 */
75 0xBFFF, /* negative, 0 */
76 0xC000, /* negative, 1 */
77 0xC001, /* negative, 2 */
78 0xC03F, /* negative, 64 */
79 0xFFFE, /* negative, 16383 */
80 0xFFFF /* negative, infinity or NaN */
81};
82static const uint16_t extF80QOut[extF80NumQOut] = {
83 0x0000, /* positive, subnormal */
84 0x0001, /* positive, -16382 */
85 0x0002, /* positive, -16381 */
86 0x3BFE, /* positive, -1025 */
87 0x3BFF, /* positive, -1024 */
88 0x3C00, /* positive, -1023 */
89 0x3C01, /* positive, -1022 */
90 0x3F7E, /* positive, -129 */
91 0x3F7F, /* positive, -128 */
92 0x3F80, /* positive, -127 */
93 0x3F81, /* positive, -126 */
94 0x3FBF, /* positive, -64 */
95 0x3FFB, /* positive, -4 */
96 0x3FFC, /* positive, -3 */
97 0x3FFD, /* positive, -2 */
98 0x3FFE, /* positive, -1 */
99 0x3FFF, /* positive, 0 */
100 0x4000, /* positive, 1 */
101 0x4001, /* positive, 2 */
102 0x4002, /* positive, 3 */
103 0x4003, /* positive, 4 */
104 0x401C, /* positive, 29 */
105 0x401D, /* positive, 30 */
106 0x401E, /* positive, 31 */
107 0x401F, /* positive, 32 */
108 0x403C, /* positive, 61 */
109 0x403D, /* positive, 62 */
110 0x403E, /* positive, 63 */
111 0x403F, /* positive, 64 */
112 0x407E, /* positive, 127 */
113 0x407F, /* positive, 128 */
114 0x4080, /* positive, 129 */
115 0x43FE, /* positive, 1023 */
116 0x43FF, /* positive, 1024 */
117 0x4400, /* positive, 1025 */
118 0x7FFD, /* positive, 16382 */
119 0x7FFE, /* positive, 16383 */
120 0x7FFF, /* positive, infinity or NaN */
121 0x8000, /* negative, subnormal */
122 0x8001, /* negative, -16382 */
123 0x8002, /* negative, -16381 */
124 0xBBFE, /* negative, -1025 */
125 0xBBFF, /* negative, -1024 */
126 0xBC00, /* negative, -1023 */
127 0xBC01, /* negative, -1022 */
128 0xBF7E, /* negative, -129 */
129 0xBF7F, /* negative, -128 */
130 0xBF80, /* negative, -127 */
131 0xBF81, /* negative, -126 */
132 0xBFBF, /* negative, -64 */
133 0xBFFB, /* negative, -4 */
134 0xBFFC, /* negative, -3 */
135 0xBFFD, /* negative, -2 */
136 0xBFFE, /* negative, -1 */
137 0xBFFF, /* negative, 0 */
138 0xC000, /* negative, 1 */
139 0xC001, /* negative, 2 */
140 0xC002, /* negative, 3 */
141 0xC003, /* negative, 4 */
142 0xC01C, /* negative, 29 */
143 0xC01D, /* negative, 30 */
144 0xC01E, /* negative, 31 */
145 0xC01F, /* negative, 32 */
146 0xC03C, /* negative, 61 */
147 0xC03D, /* negative, 62 */
148 0xC03E, /* negative, 63 */
149 0xC03F, /* negative, 64 */
150 0xC07E, /* negative, 127 */
151 0xC07F, /* negative, 128 */
152 0xC080, /* negative, 129 */
153 0xC3FE, /* negative, 1023 */
154 0xC3FF, /* negative, 1024 */
155 0xC400, /* negative, 1025 */
156 0xFFFD, /* negative, 16382 */
157 0xFFFE, /* negative, 16383 */
158 0xFFFF /* negative, infinity or NaN */
159};
160static const uint64_t extF80P1[extF80NumP1] = {
161 UINT64_C( 0x0000000000000000 ),
162 UINT64_C( 0x0000000000000001 ),
163 UINT64_C( 0x7FFFFFFFFFFFFFFF ),
164 UINT64_C( 0x7FFFFFFFFFFFFFFE )
165};
166static const uint64_t extF80P2[extF80NumP2] = {
167 UINT64_C( 0x0000000000000000 ),
168 UINT64_C( 0x0000000000000001 ),
169 UINT64_C( 0x0000000000000002 ),
170 UINT64_C( 0x0000000000000004 ),
171 UINT64_C( 0x0000000000000008 ),
172 UINT64_C( 0x0000000000000010 ),
173 UINT64_C( 0x0000000000000020 ),
174 UINT64_C( 0x0000000000000040 ),
175 UINT64_C( 0x0000000000000080 ),
176 UINT64_C( 0x0000000000000100 ),
177 UINT64_C( 0x0000000000000200 ),
178 UINT64_C( 0x0000000000000400 ),
179 UINT64_C( 0x0000000000000800 ),
180 UINT64_C( 0x0000000000001000 ),
181 UINT64_C( 0x0000000000002000 ),
182 UINT64_C( 0x0000000000004000 ),
183 UINT64_C( 0x0000000000008000 ),
184 UINT64_C( 0x0000000000010000 ),
185 UINT64_C( 0x0000000000020000 ),
186 UINT64_C( 0x0000000000040000 ),
187 UINT64_C( 0x0000000000080000 ),
188 UINT64_C( 0x0000000000100000 ),
189 UINT64_C( 0x0000000000200000 ),
190 UINT64_C( 0x0000000000400000 ),
191 UINT64_C( 0x0000000000800000 ),
192 UINT64_C( 0x0000000001000000 ),
193 UINT64_C( 0x0000000002000000 ),
194 UINT64_C( 0x0000000004000000 ),
195 UINT64_C( 0x0000000008000000 ),
196 UINT64_C( 0x0000000010000000 ),
197 UINT64_C( 0x0000000020000000 ),
198 UINT64_C( 0x0000000040000000 ),
199 UINT64_C( 0x0000000080000000 ),
200 UINT64_C( 0x0000000100000000 ),
201 UINT64_C( 0x0000000200000000 ),
202 UINT64_C( 0x0000000400000000 ),
203 UINT64_C( 0x0000000800000000 ),
204 UINT64_C( 0x0000001000000000 ),
205 UINT64_C( 0x0000002000000000 ),
206 UINT64_C( 0x0000004000000000 ),
207 UINT64_C( 0x0000008000000000 ),
208 UINT64_C( 0x0000010000000000 ),
209 UINT64_C( 0x0000020000000000 ),
210 UINT64_C( 0x0000040000000000 ),
211 UINT64_C( 0x0000080000000000 ),
212 UINT64_C( 0x0000100000000000 ),
213 UINT64_C( 0x0000200000000000 ),
214 UINT64_C( 0x0000400000000000 ),
215 UINT64_C( 0x0000800000000000 ),
216 UINT64_C( 0x0001000000000000 ),
217 UINT64_C( 0x0002000000000000 ),
218 UINT64_C( 0x0004000000000000 ),
219 UINT64_C( 0x0008000000000000 ),
220 UINT64_C( 0x0010000000000000 ),
221 UINT64_C( 0x0020000000000000 ),
222 UINT64_C( 0x0040000000000000 ),
223 UINT64_C( 0x0080000000000000 ),
224 UINT64_C( 0x0100000000000000 ),
225 UINT64_C( 0x0200000000000000 ),
226 UINT64_C( 0x0400000000000000 ),
227 UINT64_C( 0x0800000000000000 ),
228 UINT64_C( 0x1000000000000000 ),
229 UINT64_C( 0x2000000000000000 ),
230 UINT64_C( 0x4000000000000000 ),
231 UINT64_C( 0x6000000000000000 ),
232 UINT64_C( 0x7000000000000000 ),
233 UINT64_C( 0x7800000000000000 ),
234 UINT64_C( 0x7C00000000000000 ),
235 UINT64_C( 0x7E00000000000000 ),
236 UINT64_C( 0x7F00000000000000 ),
237 UINT64_C( 0x7F80000000000000 ),
238 UINT64_C( 0x7FC0000000000000 ),
239 UINT64_C( 0x7FE0000000000000 ),
240 UINT64_C( 0x7FF0000000000000 ),
241 UINT64_C( 0x7FF8000000000000 ),
242 UINT64_C( 0x7FFC000000000000 ),
243 UINT64_C( 0x7FFE000000000000 ),
244 UINT64_C( 0x7FFF000000000000 ),
245 UINT64_C( 0x7FFF800000000000 ),
246 UINT64_C( 0x7FFFC00000000000 ),
247 UINT64_C( 0x7FFFE00000000000 ),
248 UINT64_C( 0x7FFFF00000000000 ),
249 UINT64_C( 0x7FFFF80000000000 ),
250 UINT64_C( 0x7FFFFC0000000000 ),
251 UINT64_C( 0x7FFFFE0000000000 ),
252 UINT64_C( 0x7FFFFF0000000000 ),
253 UINT64_C( 0x7FFFFF8000000000 ),
254 UINT64_C( 0x7FFFFFC000000000 ),
255 UINT64_C( 0x7FFFFFE000000000 ),
256 UINT64_C( 0x7FFFFFF000000000 ),
257 UINT64_C( 0x7FFFFFF800000000 ),
258 UINT64_C( 0x7FFFFFFC00000000 ),
259 UINT64_C( 0x7FFFFFFE00000000 ),
260 UINT64_C( 0x7FFFFFFF00000000 ),
261 UINT64_C( 0x7FFFFFFF80000000 ),
262 UINT64_C( 0x7FFFFFFFC0000000 ),
263 UINT64_C( 0x7FFFFFFFE0000000 ),
264 UINT64_C( 0x7FFFFFFFF0000000 ),
265 UINT64_C( 0x7FFFFFFFF8000000 ),
266 UINT64_C( 0x7FFFFFFFFC000000 ),
267 UINT64_C( 0x7FFFFFFFFE000000 ),
268 UINT64_C( 0x7FFFFFFFFF000000 ),
269 UINT64_C( 0x7FFFFFFFFF800000 ),
270 UINT64_C( 0x7FFFFFFFFFC00000 ),
271 UINT64_C( 0x7FFFFFFFFFE00000 ),
272 UINT64_C( 0x7FFFFFFFFFF00000 ),
273 UINT64_C( 0x7FFFFFFFFFF80000 ),
274 UINT64_C( 0x7FFFFFFFFFFC0000 ),
275 UINT64_C( 0x7FFFFFFFFFFE0000 ),
276 UINT64_C( 0x7FFFFFFFFFFF0000 ),
277 UINT64_C( 0x7FFFFFFFFFFF8000 ),
278 UINT64_C( 0x7FFFFFFFFFFFC000 ),
279 UINT64_C( 0x7FFFFFFFFFFFE000 ),
280 UINT64_C( 0x7FFFFFFFFFFFF000 ),
281 UINT64_C( 0x7FFFFFFFFFFFF800 ),
282 UINT64_C( 0x7FFFFFFFFFFFFC00 ),
283 UINT64_C( 0x7FFFFFFFFFFFFE00 ),
284 UINT64_C( 0x7FFFFFFFFFFFFF00 ),
285 UINT64_C( 0x7FFFFFFFFFFFFF80 ),
286 UINT64_C( 0x7FFFFFFFFFFFFFC0 ),
287 UINT64_C( 0x7FFFFFFFFFFFFFE0 ),
288 UINT64_C( 0x7FFFFFFFFFFFFFF0 ),
289 UINT64_C( 0x7FFFFFFFFFFFFFF8 ),
290 UINT64_C( 0x7FFFFFFFFFFFFFFC ),
291 UINT64_C( 0x7FFFFFFFFFFFFFFE ),
292 UINT64_C( 0x7FFFFFFFFFFFFFFF ),
293 UINT64_C( 0x7FFFFFFFFFFFFFFD ),
294 UINT64_C( 0x7FFFFFFFFFFFFFFB ),
295 UINT64_C( 0x7FFFFFFFFFFFFFF7 ),
296 UINT64_C( 0x7FFFFFFFFFFFFFEF ),
297 UINT64_C( 0x7FFFFFFFFFFFFFDF ),
298 UINT64_C( 0x7FFFFFFFFFFFFFBF ),
299 UINT64_C( 0x7FFFFFFFFFFFFF7F ),
300 UINT64_C( 0x7FFFFFFFFFFFFEFF ),
301 UINT64_C( 0x7FFFFFFFFFFFFDFF ),
302 UINT64_C( 0x7FFFFFFFFFFFFBFF ),
303 UINT64_C( 0x7FFFFFFFFFFFF7FF ),
304 UINT64_C( 0x7FFFFFFFFFFFEFFF ),
305 UINT64_C( 0x7FFFFFFFFFFFDFFF ),
306 UINT64_C( 0x7FFFFFFFFFFFBFFF ),
307 UINT64_C( 0x7FFFFFFFFFFF7FFF ),
308 UINT64_C( 0x7FFFFFFFFFFEFFFF ),
309 UINT64_C( 0x7FFFFFFFFFFDFFFF ),
310 UINT64_C( 0x7FFFFFFFFFFBFFFF ),
311 UINT64_C( 0x7FFFFFFFFFF7FFFF ),
312 UINT64_C( 0x7FFFFFFFFFEFFFFF ),
313 UINT64_C( 0x7FFFFFFFFFDFFFFF ),
314 UINT64_C( 0x7FFFFFFFFFBFFFFF ),
315 UINT64_C( 0x7FFFFFFFFF7FFFFF ),
316 UINT64_C( 0x7FFFFFFFFEFFFFFF ),
317 UINT64_C( 0x7FFFFFFFFDFFFFFF ),
318 UINT64_C( 0x7FFFFFFFFBFFFFFF ),
319 UINT64_C( 0x7FFFFFFFF7FFFFFF ),
320 UINT64_C( 0x7FFFFFFFEFFFFFFF ),
321 UINT64_C( 0x7FFFFFFFDFFFFFFF ),
322 UINT64_C( 0x7FFFFFFFBFFFFFFF ),
323 UINT64_C( 0x7FFFFFFF7FFFFFFF ),
324 UINT64_C( 0x7FFFFFFEFFFFFFFF ),
325 UINT64_C( 0x7FFFFFFDFFFFFFFF ),
326 UINT64_C( 0x7FFFFFFBFFFFFFFF ),
327 UINT64_C( 0x7FFFFFF7FFFFFFFF ),
328 UINT64_C( 0x7FFFFFEFFFFFFFFF ),
329 UINT64_C( 0x7FFFFFDFFFFFFFFF ),
330 UINT64_C( 0x7FFFFFBFFFFFFFFF ),
331 UINT64_C( 0x7FFFFF7FFFFFFFFF ),
332 UINT64_C( 0x7FFFFEFFFFFFFFFF ),
333 UINT64_C( 0x7FFFFDFFFFFFFFFF ),
334 UINT64_C( 0x7FFFFBFFFFFFFFFF ),
335 UINT64_C( 0x7FFFF7FFFFFFFFFF ),
336 UINT64_C( 0x7FFFEFFFFFFFFFFF ),
337 UINT64_C( 0x7FFFDFFFFFFFFFFF ),
338 UINT64_C( 0x7FFFBFFFFFFFFFFF ),
339 UINT64_C( 0x7FFF7FFFFFFFFFFF ),
340 UINT64_C( 0x7FFEFFFFFFFFFFFF ),
341 UINT64_C( 0x7FFDFFFFFFFFFFFF ),
342 UINT64_C( 0x7FFBFFFFFFFFFFFF ),
343 UINT64_C( 0x7FF7FFFFFFFFFFFF ),
344 UINT64_C( 0x7FEFFFFFFFFFFFFF ),
345 UINT64_C( 0x7FDFFFFFFFFFFFFF ),
346 UINT64_C( 0x7FBFFFFFFFFFFFFF ),
347 UINT64_C( 0x7F7FFFFFFFFFFFFF ),
348 UINT64_C( 0x7EFFFFFFFFFFFFFF ),
349 UINT64_C( 0x7DFFFFFFFFFFFFFF ),
350 UINT64_C( 0x7BFFFFFFFFFFFFFF ),
351 UINT64_C( 0x77FFFFFFFFFFFFFF ),
352 UINT64_C( 0x6FFFFFFFFFFFFFFF ),
353 UINT64_C( 0x5FFFFFFFFFFFFFFF ),
354 UINT64_C( 0x3FFFFFFFFFFFFFFF ),
355 UINT64_C( 0x1FFFFFFFFFFFFFFF ),
356 UINT64_C( 0x0FFFFFFFFFFFFFFF ),
357 UINT64_C( 0x07FFFFFFFFFFFFFF ),
358 UINT64_C( 0x03FFFFFFFFFFFFFF ),
359 UINT64_C( 0x01FFFFFFFFFFFFFF ),
360 UINT64_C( 0x00FFFFFFFFFFFFFF ),
361 UINT64_C( 0x007FFFFFFFFFFFFF ),
362 UINT64_C( 0x003FFFFFFFFFFFFF ),
363 UINT64_C( 0x001FFFFFFFFFFFFF ),
364 UINT64_C( 0x000FFFFFFFFFFFFF ),
365 UINT64_C( 0x0007FFFFFFFFFFFF ),
366 UINT64_C( 0x0003FFFFFFFFFFFF ),
367 UINT64_C( 0x0001FFFFFFFFFFFF ),
368 UINT64_C( 0x0000FFFFFFFFFFFF ),
369 UINT64_C( 0x00007FFFFFFFFFFF ),
370 UINT64_C( 0x00003FFFFFFFFFFF ),
371 UINT64_C( 0x00001FFFFFFFFFFF ),
372 UINT64_C( 0x00000FFFFFFFFFFF ),
373 UINT64_C( 0x000007FFFFFFFFFF ),
374 UINT64_C( 0x000003FFFFFFFFFF ),
375 UINT64_C( 0x000001FFFFFFFFFF ),
376 UINT64_C( 0x000000FFFFFFFFFF ),
377 UINT64_C( 0x0000007FFFFFFFFF ),
378 UINT64_C( 0x0000003FFFFFFFFF ),
379 UINT64_C( 0x0000001FFFFFFFFF ),
380 UINT64_C( 0x0000000FFFFFFFFF ),
381 UINT64_C( 0x00000007FFFFFFFF ),
382 UINT64_C( 0x00000003FFFFFFFF ),
383 UINT64_C( 0x00000001FFFFFFFF ),
384 UINT64_C( 0x00000000FFFFFFFF ),
385 UINT64_C( 0x000000007FFFFFFF ),
386 UINT64_C( 0x000000003FFFFFFF ),
387 UINT64_C( 0x000000001FFFFFFF ),
388 UINT64_C( 0x000000000FFFFFFF ),
389 UINT64_C( 0x0000000007FFFFFF ),
390 UINT64_C( 0x0000000003FFFFFF ),
391 UINT64_C( 0x0000000001FFFFFF ),
392 UINT64_C( 0x0000000000FFFFFF ),
393 UINT64_C( 0x00000000007FFFFF ),
394 UINT64_C( 0x00000000003FFFFF ),
395 UINT64_C( 0x00000000001FFFFF ),
396 UINT64_C( 0x00000000000FFFFF ),
397 UINT64_C( 0x000000000007FFFF ),
398 UINT64_C( 0x000000000003FFFF ),
399 UINT64_C( 0x000000000001FFFF ),
400 UINT64_C( 0x000000000000FFFF ),
401 UINT64_C( 0x0000000000007FFF ),
402 UINT64_C( 0x0000000000003FFF ),
403 UINT64_C( 0x0000000000001FFF ),
404 UINT64_C( 0x0000000000000FFF ),
405 UINT64_C( 0x00000000000007FF ),
406 UINT64_C( 0x00000000000003FF ),
407 UINT64_C( 0x00000000000001FF ),
408 UINT64_C( 0x00000000000000FF ),
409 UINT64_C( 0x000000000000007F ),
410 UINT64_C( 0x000000000000003F ),
411 UINT64_C( 0x000000000000001F ),
412 UINT64_C( 0x000000000000000F ),
413 UINT64_C( 0x0000000000000007 ),
414 UINT64_C( 0x0000000000000003 )
415};
416
417static const uint_fast32_t extF80NumQInP1 = extF80NumQIn * extF80NumP1;
418static const uint_fast32_t extF80NumQOutP1 = extF80NumQOut * extF80NumP1;
419
420static void extF80NextQInP1( struct sequence *sequencePtr, extFloat80_t *zPtr )
421{
422 struct extFloat80M *zSPtr;
423 int expNum, sigNum;
424 uint_fast16_t uiZ64;
425 uint_fast64_t uiZ0;
426
427 zSPtr = (struct extFloat80M *) zPtr;
428 expNum = sequencePtr->expNum;
429 sigNum = sequencePtr->term1Num;
430 uiZ64 = extF80QIn[expNum];
431 uiZ0 = extF80P1[sigNum];
432 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
433 zSPtr->signExp = uiZ64;
434 zSPtr->signif = uiZ0;
435 ++sigNum;
436 if ( extF80NumP1 <= sigNum ) {
437 sigNum = 0;
438 ++expNum;
439 if ( extF80NumQIn <= expNum ) {
440 expNum = 0;
441 sequencePtr->done = true;
442 }
443 sequencePtr->expNum = expNum;
444 }
445 sequencePtr->term1Num = sigNum;
446
447}
448
449static
450 void extF80NextQOutP1( struct sequence *sequencePtr, extFloat80_t *zPtr )
451{
452 struct extFloat80M *zSPtr;
453 int expNum, sigNum;
454 uint_fast16_t uiZ64;
455 uint_fast64_t uiZ0;
456
457 zSPtr = (struct extFloat80M *) zPtr;
458 expNum = sequencePtr->expNum;
459 sigNum = sequencePtr->term1Num;
460 uiZ64 = extF80QOut[expNum];
461 uiZ0 = extF80P1[sigNum];
462 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
463 zSPtr->signExp = uiZ64;
464 zSPtr->signif = uiZ0;
465 ++sigNum;
466 if ( extF80NumP1 <= sigNum ) {
467 sigNum = 0;
468 ++expNum;
469 if ( extF80NumQOut <= expNum ) {
470 expNum = 0;
471 sequencePtr->done = true;
472 }
473 sequencePtr->expNum = expNum;
474 }
475 sequencePtr->term1Num = sigNum;
476
477}
478
479static const uint_fast32_t extF80NumQInP2 = extF80NumQIn * extF80NumP2;
480static const uint_fast32_t extF80NumQOutP2 = extF80NumQOut * extF80NumP2;
481
482static void extF80NextQInP2( struct sequence *sequencePtr, extFloat80_t *zPtr )
483{
484 struct extFloat80M *zSPtr;
485 int expNum, sigNum;
486 uint_fast16_t uiZ64;
487 uint_fast64_t uiZ0;
488
489 zSPtr = (struct extFloat80M *) zPtr;
490 expNum = sequencePtr->expNum;
491 sigNum = sequencePtr->term1Num;
492 uiZ64 = extF80QIn[expNum];
493 uiZ0 = extF80P2[sigNum];
494 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
495 zSPtr->signExp = uiZ64;
496 zSPtr->signif = uiZ0;
497 ++sigNum;
498 if ( extF80NumP2 <= sigNum ) {
499 sigNum = 0;
500 ++expNum;
501 if ( extF80NumQIn <= expNum ) {
502 expNum = 0;
503 sequencePtr->done = true;
504 }
505 sequencePtr->expNum = expNum;
506 }
507 sequencePtr->term1Num = sigNum;
508
509}
510
511static
512 void extF80NextQOutP2( struct sequence *sequencePtr, extFloat80_t *zPtr )
513{
514 struct extFloat80M *zSPtr;
515 int expNum, sigNum;
516 uint_fast16_t uiZ64;
517 uint_fast64_t uiZ0;
518
519 zSPtr = (struct extFloat80M *) zPtr;
520 expNum = sequencePtr->expNum;
521 sigNum = sequencePtr->term1Num;
522 uiZ64 = extF80QOut[expNum];
523 uiZ0 = extF80P2[sigNum];
524 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
525 zSPtr->signExp = uiZ64;
526 zSPtr->signif = uiZ0;
527 ++sigNum;
528 if ( extF80NumP2 <= sigNum ) {
529 sigNum = 0;
530 ++expNum;
531 if ( extF80NumQOut <= expNum ) {
532 expNum = 0;
533 sequencePtr->done = true;
534 }
535 sequencePtr->expNum = expNum;
536 }
537 sequencePtr->term1Num = sigNum;
538
539}
540
541static void extF80RandomQOutP3( extFloat80_t *zPtr )
542{
543 struct extFloat80M *zSPtr;
544 uint_fast16_t uiZ64;
545 uint_fast64_t uiZ0;
546
547 zSPtr = (struct extFloat80M *) zPtr;
548 uiZ64 = extF80QOut[randomN_ui8( extF80NumQOut )];
549 uiZ0 =
550 (extF80P2[randomN_ui8( extF80NumP2 )]
551 + extF80P2[randomN_ui8( extF80NumP2 )])
552 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
553 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
554 zSPtr->signExp = uiZ64;
555 zSPtr->signif = uiZ0;
556
557}
558
559static void extF80RandomQOutPInf( extFloat80_t *zPtr )
560{
561 struct extFloat80M *zSPtr;
562 uint_fast16_t uiZ64;
563 uint_fast64_t uiZ0;
564
565 zSPtr = (struct extFloat80M *) zPtr;
566 uiZ64 = extF80QOut[randomN_ui8( extF80NumQOut )];
567 uiZ0 = random_ui64() & UINT64_C( 0x7FFFFFFFFFFFFFFF );
568 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
569 zSPtr->signExp = uiZ64;
570 zSPtr->signif = uiZ0;
571
572}
573
574enum { extF80NumQInfWeightMasks = 14 };
575static const uint16_t extF80QInfWeightMasks[extF80NumQInfWeightMasks] = {
576 0xFFFF,
577 0xFFFF,
578 0xBFFF,
579 0x9FFF,
580 0x87FF,
581 0x87FF,
582 0x83FF,
583 0x81FF,
584 0x80FF,
585 0x807F,
586 0x803F,
587 0x801F,
588 0x800F,
589 0x8007
590};
591static const uint16_t extF80QInfWeightOffsets[extF80NumQInfWeightMasks] = {
592 0x0000,
593 0x0000,
594 0x2000,
595 0x3000,
596 0x3800,
597 0x3C00,
598 0x3E00,
599 0x3F00,
600 0x3F80,
601 0x3FC0,
602 0x3FE0,
603 0x3FF0,
604 0x3FF8,
605 0x3FFC
606};
607
608static void extF80RandomQInfP3( extFloat80_t *zPtr )
609{
610 struct extFloat80M *zSPtr;
611 int weightMaskNum;
612 uint_fast16_t uiZ64;
613 uint_fast64_t uiZ0;
614
615 zSPtr = (struct extFloat80M *) zPtr;
616 weightMaskNum = randomN_ui8( extF80NumQInfWeightMasks );
617 uiZ64 =
618 (random_ui16() & extF80QInfWeightMasks[weightMaskNum])
619 + extF80QInfWeightOffsets[weightMaskNum];
620 uiZ0 =
621 (extF80P2[randomN_ui8( extF80NumP2 )]
622 + extF80P2[randomN_ui8( extF80NumP2 )])
623 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
624 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
625 zSPtr->signExp = uiZ64;
626 zSPtr->signif = uiZ0;
627
628}
629
630static void extF80RandomQInfPInf( extFloat80_t *zPtr )
631{
632 struct extFloat80M *zSPtr;
633 int weightMaskNum;
634 uint_fast16_t uiZ64;
635 uint_fast64_t uiZ0;
636
637 zSPtr = (struct extFloat80M *) zPtr;
638 weightMaskNum = randomN_ui8( extF80NumQInfWeightMasks );
639 uiZ64 =
640 (random_ui16() & extF80QInfWeightMasks[weightMaskNum])
641 + extF80QInfWeightOffsets[weightMaskNum];
642 uiZ0 = random_ui64() & UINT64_C( 0x7FFFFFFFFFFFFFFF );
643 if ( uiZ64 & 0x7FFF ) uiZ0 |= UINT64_C( 0x8000000000000000 );
644 zSPtr->signExp = uiZ64;
645 zSPtr->signif = uiZ0;
646
647}
648
649static void extF80Random( extFloat80_t *zPtr )
650{
651
652 switch ( random_ui8() & 7 ) {
653 case 0:
654 case 1:
655 case 2:
656 extF80RandomQOutP3( zPtr );
657 break;
658 case 3:
659 extF80RandomQOutPInf( zPtr );
660 break;
661 case 4:
662 case 5:
663 case 6:
664 extF80RandomQInfP3( zPtr );
665 break;
666 case 7:
667 extF80RandomQInfPInf( zPtr );
668 break;
669 }
670
671}
672
673static struct sequence sequenceA, sequenceB, sequenceC;
674static extFloat80_t currentA, currentB, currentC;
675static int subcase;
676
677extFloat80_t genCases_extF80_a, genCases_extF80_b, genCases_extF80_c;
678
679void genCases_extF80_a_init( void )
680{
681
682 sequenceA.expNum = 0;
683 sequenceA.term1Num = 0;
684 sequenceA.term2Num = 0;
685 sequenceA.done = false;
686 subcase = 0;
687 genCases_total =
688 (genCases_level == 1) ? 3 * extF80NumQOutP1 : 2 * extF80NumQOutP2;
689 genCases_done = false;
690
691}
692
693void genCases_extF80_a_next( void )
694{
695
696 if ( genCases_level == 1 ) {
697 switch ( subcase ) {
698 case 0:
699 case 1:
700 extF80Random( &genCases_extF80_a );
701 break;
702 case 2:
703 extF80NextQOutP1( &sequenceA, &genCases_extF80_a );
704 genCases_done = sequenceA.done;
705 subcase = -1;
706 break;
707 }
708 } else {
709 switch ( subcase ) {
710 case 0:
711 extF80Random( &genCases_extF80_a );
712 break;
713 case 1:
714 extF80NextQOutP2( &sequenceA, &genCases_extF80_a );
715 genCases_done = sequenceA.done;
716 subcase = -1;
717 break;
718 }
719 }
720 ++subcase;
721
722}
723
724void genCases_extF80_ab_init( void )
725{
726
727 sequenceA.expNum = 0;
728 sequenceA.term1Num = 0;
729 sequenceA.term2Num = 0;
730 sequenceA.done = false;
731 sequenceB.expNum = 0;
732 sequenceB.term1Num = 0;
733 sequenceB.term2Num = 0;
734 sequenceB.done = false;
735 subcase = 0;
736 if ( genCases_level == 1 ) {
737 genCases_total = 6 * extF80NumQInP1 * extF80NumQInP1;
738 extF80NextQInP1( &sequenceA, &currentA );
739 } else {
740 genCases_total = 2 * extF80NumQInP2 * extF80NumQInP2;
741 extF80NextQInP2( &sequenceA, &currentA );
742 }
743 genCases_done = false;
744
745}
746
747void genCases_extF80_ab_next( void )
748{
749
750 if ( genCases_level == 1 ) {
751 switch ( subcase ) {
752 case 0:
753 if ( sequenceB.done ) {
754 sequenceB.done = false;
755 extF80NextQInP1( &sequenceA, &currentA );
756 }
757 extF80NextQInP1( &sequenceB, &currentB );
758 case 2:
759 case 4:
760 extF80Random( &genCases_extF80_a );
761 extF80Random( &genCases_extF80_b );
762 break;
763 case 1:
764 genCases_extF80_a = currentA;
765 extF80Random( &genCases_extF80_b );
766 break;
767 case 3:
768 extF80Random( &genCases_extF80_a );
769 genCases_extF80_b = currentB;
770 break;
771 case 5:
772 genCases_extF80_a = currentA;
773 genCases_extF80_b = currentB;
774 genCases_done = sequenceA.done & sequenceB.done;
775 subcase = -1;
776 break;
777 }
778 } else {
779 switch ( subcase ) {
780 case 0:
781 extF80Random( &genCases_extF80_a );
782 extF80Random( &genCases_extF80_b );
783 break;
784 case 1:
785 if ( sequenceB.done ) {
786 sequenceB.done = false;
787 extF80NextQInP2( &sequenceA, &currentA );
788 }
789 genCases_extF80_a = currentA;
790 extF80NextQInP2( &sequenceB, &genCases_extF80_b );
791 genCases_done = sequenceA.done & sequenceB.done;
792 subcase = -1;
793 break;
794 }
795 }
796 ++subcase;
797
798}
799
800void genCases_extF80_abc_init( void )
801{
802
803 sequenceA.expNum = 0;
804 sequenceA.term1Num = 0;
805 sequenceA.term2Num = 0;
806 sequenceA.done = false;
807 sequenceB.expNum = 0;
808 sequenceB.term1Num = 0;
809 sequenceB.term2Num = 0;
810 sequenceB.done = false;
811 sequenceC.expNum = 0;
812 sequenceC.term1Num = 0;
813 sequenceC.term2Num = 0;
814 sequenceC.done = false;
815 subcase = 0;
816 if ( genCases_level == 1 ) {
817 genCases_total = 9 * extF80NumQInP1 * extF80NumQInP1 * extF80NumQInP1;
818 extF80NextQInP1( &sequenceA, &currentA );
819 extF80NextQInP1( &sequenceB, &currentB );
820 } else {
821 genCases_total = 2 * extF80NumQInP2 * extF80NumQInP2 * extF80NumQInP2;
822 extF80NextQInP2( &sequenceA, &currentA );
823 extF80NextQInP2( &sequenceB, &currentB );
824 }
825 genCases_done = false;
826
827}
828
829void genCases_extF80_abc_next( void )
830{
831
832 if ( genCases_level == 1 ) {
833 switch ( subcase ) {
834 case 0:
835 if ( sequenceC.done ) {
836 sequenceC.done = false;
837 if ( sequenceB.done ) {
838 sequenceB.done = false;
839 extF80NextQInP1( &sequenceA, &currentA );
840 }
841 extF80NextQInP1( &sequenceB, &currentB );
842 }
843 extF80NextQInP1( &sequenceC, &currentC );
844 extF80Random( &genCases_extF80_a );
845 extF80Random( &genCases_extF80_b );
846 genCases_extF80_c = currentC;
847 break;
848 case 1:
849 genCases_extF80_a = currentA;
850 genCases_extF80_b = currentB;
851 extF80Random( &genCases_extF80_c );
852 break;
853 case 2:
854 extF80Random( &genCases_extF80_a );
855 extF80Random( &genCases_extF80_b );
856 extF80Random( &genCases_extF80_c );
857 break;
858 case 3:
859 extF80Random( &genCases_extF80_a );
860 genCases_extF80_b = currentB;
861 genCases_extF80_c = currentC;
862 break;
863 case 4:
864 genCases_extF80_a = currentA;
865 extF80Random( &genCases_extF80_b );
866 extF80Random( &genCases_extF80_c );
867 break;
868 case 5:
869 extF80Random( &genCases_extF80_a );
870 genCases_extF80_b = currentB;
871 extF80Random( &genCases_extF80_c );
872 break;
873 case 6:
874 genCases_extF80_a = currentA;
875 extF80Random( &genCases_extF80_b );
876 genCases_extF80_c = currentC;
877 break;
878 case 7:
879 extF80Random( &genCases_extF80_a );
880 extF80Random( &genCases_extF80_b );
881 extF80Random( &genCases_extF80_c );
882 break;
883 case 8:
884 genCases_extF80_a = currentA;
885 genCases_extF80_b = currentB;
886 genCases_extF80_c = currentC;
887 genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;
888 subcase = -1;
889 break;
890 }
891 } else {
892 switch ( subcase ) {
893 case 0:
894 extF80Random( &genCases_extF80_a );
895 extF80Random( &genCases_extF80_b );
896 extF80Random( &genCases_extF80_c );
897 break;
898 case 1:
899 if ( sequenceC.done ) {
900 sequenceC.done = false;
901 if ( sequenceB.done ) {
902 sequenceB.done = false;
903 extF80NextQInP2( &sequenceA, &currentA );
904 }
905 extF80NextQInP2( &sequenceB, &currentB );
906 }
907 genCases_extF80_a = currentA;
908 genCases_extF80_b = currentB;
909 extF80NextQInP2( &sequenceC, &genCases_extF80_c );
910 genCases_done = sequenceA.done & sequenceB.done & sequenceC.done;
911 subcase = -1;
912 break;
913 }
914 }
915 ++subcase;
916
917}
918
919#endif
920
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette