1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
/*
* Copyright(c) 2020-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* This test checks various FP operations performed on Hexagon
*/
#include <stdio.h>
const int FPINVF_BIT = 1; /* Invalid */
const int FPINVF = 1 << FPINVF_BIT;
const int FPDBZF_BIT = 2; /* Divide by zero */
const int FPDBZF = 1 << FPDBZF_BIT;
const int FPOVFF_BIT = 3; /* Overflow */
const int FPOVFF = 1 << FPOVFF_BIT;
const int FPUNFF_BIT = 4; /* Underflow */
const int FPUNFF = 1 << FPUNFF_BIT;
const int FPINPF_BIT = 5; /* Inexact */
const int FPINPF = 1 << FPINPF_BIT;
const int SF_ZERO = 0x00000000;
const int SF_NaN = 0x7fc00000;
const int SF_NaN_special = 0x7f800001;
const int SF_ANY = 0x3f800000;
const int SF_HEX_NAN = 0xffffffff;
const int SF_small_neg = 0xab98fba8;
const int SF_denorm = 0x00000001;
const int SF_random = 0x346001d6;
const int SF_neg_zero = 0x80000000;
const long long DF_QNaN = 0x7ff8000000000000ULL;
const long long DF_SNaN = 0x7ff7000000000000ULL;
const long long DF_ANY = 0x3f80000000000000ULL;
const long long DF_HEX_NAN = 0xffffffffffffffffULL;
const long long DF_small_neg = 0xbd731f7500000000ULL;
int err;
#define CLEAR_FPSTATUS \
"r2 = usr\n\t" \
"r2 = clrbit(r2, #1)\n\t" \
"r2 = clrbit(r2, #2)\n\t" \
"r2 = clrbit(r2, #3)\n\t" \
"r2 = clrbit(r2, #4)\n\t" \
"r2 = clrbit(r2, #5)\n\t" \
"usr = r2\n\t"
static void check_fpstatus_bit(int usr, int expect, int flag, const char *n)
{
int bit = 1 << flag;
if ((usr & bit) != (expect & bit)) {
printf("ERROR %s: usr = %d, expect = %d\n", n,
(usr >> flag) & 1, (expect >> flag) & 1);
err++;
}
}
static void check_fpstatus(int usr, int expect)
{
check_fpstatus_bit(usr, expect, FPINVF_BIT, "Invalid");
check_fpstatus_bit(usr, expect, FPDBZF_BIT, "Div by zero");
check_fpstatus_bit(usr, expect, FPOVFF_BIT, "Overflow");
check_fpstatus_bit(usr, expect, FPUNFF_BIT, "Underflow");
check_fpstatus_bit(usr, expect, FPINPF_BIT, "Inexact");
}
static void check32(int val, int expect)
{
if (val != expect) {
printf("ERROR: 0x%x != 0x%x\n", val, expect);
err++;
}
}
static void check64(unsigned long long val, unsigned long long expect)
{
if (val != expect) {
printf("ERROR: 0x%llx != 0x%llx\n", val, expect);
err++;
}
}
static void check_compare_exception(void)
{
int cmp;
int usr;
/* Check that FP compares are quiet (don't raise any execptions) */
asm (CLEAR_FPSTATUS
"p0 = sfcmp.eq(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"p0 = sfcmp.gt(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"p0 = sfcmp.ge(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"p0 = dfcmp.eq(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"p0 = dfcmp.gt(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"p0 = dfcmp.ge(%2, %3)\n\t"
"%0 = p0\n\t"
"%1 = usr\n\t"
: "=r"(cmp), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "p0", "usr");
check32(cmp, 0);
check_fpstatus(usr, 0);
}
static void check_sfminmax(void)
{
int minmax;
int usr;
/*
* Execute sfmin/sfmax instructions with one operand as NaN
* Check that
* Result is the other operand
* Invalid bit in USR is not set
*/
asm (CLEAR_FPSTATUS
"%0 = sfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check64(minmax, SF_ANY);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0 = sfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check64(minmax, SF_ANY);
check_fpstatus(usr, 0);
/*
* Execute sfmin/sfmax instructions with both operands NaN
* Check that
* Result is SF_HEX_NAN
* Invalid bit in USR is set
*/
asm (CLEAR_FPSTATUS
"%0 = sfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(SF_NaN), "r"(SF_NaN)
: "r2", "usr");
check64(minmax, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0 = sfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(SF_NaN), "r"(SF_NaN)
: "r2", "usr");
check64(minmax, SF_HEX_NAN);
check_fpstatus(usr, 0);
}
static void check_dfminmax(void)
{
unsigned long long minmax;
int usr;
/*
* Execute dfmin/dfmax instructions with one operand as SNaN
* Check that
* Result is the other operand
* Invalid bit in USR is set
*/
asm (CLEAR_FPSTATUS
"%0 = dfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_SNaN), "r"(DF_ANY)
: "r2", "usr");
check64(minmax, DF_ANY);
check_fpstatus(usr, FPINVF);
asm (CLEAR_FPSTATUS
"%0 = dfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_SNaN), "r"(DF_ANY)
: "r2", "usr");
check64(minmax, DF_ANY);
check_fpstatus(usr, FPINVF);
/*
* Execute dfmin/dfmax instructions with one operand as QNaN
* Check that
* Result is the other operand
* No bit in USR is set
*/
asm (CLEAR_FPSTATUS
"%0 = dfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "usr");
check64(minmax, DF_ANY);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0 = dfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "usr");
check64(minmax, DF_ANY);
check_fpstatus(usr, 0);
/*
* Execute dfmin/dfmax instructions with both operands SNaN
* Check that
* Result is DF_HEX_NAN
* Invalid bit in USR is set
*/
asm (CLEAR_FPSTATUS
"%0 = dfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_SNaN), "r"(DF_SNaN)
: "r2", "usr");
check64(minmax, DF_HEX_NAN);
check_fpstatus(usr, FPINVF);
asm (CLEAR_FPSTATUS
"%0 = dfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_SNaN), "r"(DF_SNaN)
: "r2", "usr");
check64(minmax, DF_HEX_NAN);
check_fpstatus(usr, FPINVF);
/*
* Execute dfmin/dfmax instructions with both operands QNaN
* Check that
* Result is DF_HEX_NAN
* No bit in USR is set
*/
asm (CLEAR_FPSTATUS
"%0 = dfmin(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_QNaN), "r"(DF_QNaN)
: "r2", "usr");
check64(minmax, DF_HEX_NAN);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0 = dfmax(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(minmax), "=r"(usr) : "r"(DF_QNaN), "r"(DF_QNaN)
: "r2", "usr");
check64(minmax, DF_HEX_NAN);
check_fpstatus(usr, 0);
}
static void check_sfrecipa(void)
{
int result;
int usr;
int pred;
/*
* Check that sfrecipa doesn't set status bits when
* a NaN with bit 22 non-zero is passed
*/
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_ANY), "r"(SF_NaN)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %2)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_NaN)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, 0);
/*
* Check that sfrecipa doesn't set status bits when
* a NaN with bit 22 zero is passed
*/
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_NaN_special), "r"(SF_ANY)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, FPINVF);
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_ANY), "r"(SF_NaN_special)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, FPINVF);
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %2)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(SF_NaN_special)
: "r2", "p0", "usr");
check32(result, SF_HEX_NAN);
check_fpstatus(usr, FPINVF);
/*
* Check that sfrecipa properly sets divid-by-zero
*/
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(0x885dc960), "r"(0x80000000)
: "r2", "p0", "usr");
check32(result, 0x3f800000);
check_fpstatus(usr, FPDBZF);
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(result), "=r"(usr) : "r"(0x7f800000), "r"(SF_ZERO)
: "r2", "p0", "usr");
check32(result, 0x3f800000);
check_fpstatus(usr, 0);
/*
* Check that sfrecipa properly handles denorm
*/
asm (CLEAR_FPSTATUS
"%0,p0 = sfrecipa(%2, %3)\n\t"
"%1 = p0\n\t"
: "=r"(result), "=r"(pred) : "r"(SF_denorm), "r"(SF_random)
: "p0", "usr");
check32(result, 0x6a920001);
check32(pred, 0x80);
}
static void check_canonical_NaN(void)
{
int sf_result;
unsigned long long df_result;
int usr;
/* Check that each FP instruction properly returns SF_HEX_NAN/DF_HEX_NAN */
asm(CLEAR_FPSTATUS
"%0 = sfadd(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = sfsub(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = sfmpy(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
sf_result = SF_ZERO;
asm(CLEAR_FPSTATUS
"%0 += sfmpy(%2, %3)\n\t"
"%1 = usr\n\t"
: "+r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
sf_result = SF_ZERO;
asm(CLEAR_FPSTATUS
"p0 = !cmp.eq(r0, r0)\n\t"
"%0 += sfmpy(%2, %3, p0):scale\n\t"
"%1 = usr\n\t"
: "+r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr", "p0");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
sf_result = SF_ZERO;
asm(CLEAR_FPSTATUS
"%0 -= sfmpy(%2, %3)\n\t"
"%1 = usr\n\t"
: "+r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
sf_result = SF_ZERO;
asm(CLEAR_FPSTATUS
"%0 += sfmpy(%2, %3):lib\n\t"
"%1 = usr\n\t"
: "+r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
sf_result = SF_ZERO;
asm(CLEAR_FPSTATUS
"%0 -= sfmpy(%2, %3):lib\n\t"
"%1 = usr\n\t"
: "+r"(sf_result), "=r"(usr) : "r"(SF_NaN), "r"(SF_ANY)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = convert_df2sf(%2)\n\t"
"%1 = usr\n\t"
: "=r"(sf_result), "=r"(usr) : "r"(DF_QNaN)
: "r2", "usr");
check32(sf_result, SF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = dfadd(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(df_result), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "usr");
check64(df_result, DF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = dfsub(%2, %3)\n\t"
"%1 = usr\n\t"
: "=r"(df_result), "=r"(usr) : "r"(DF_QNaN), "r"(DF_ANY)
: "r2", "usr");
check64(df_result, DF_HEX_NAN);
check_fpstatus(usr, 0);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2df(%2)\n\t"
"%1 = usr\n\t"
: "=r"(df_result), "=r"(usr) : "r"(SF_NaN)
: "r2", "usr");
check64(df_result, DF_HEX_NAN);
check_fpstatus(usr, 0);
}
static void check_invsqrta(void)
{
int result;
int predval;
asm volatile("%0,p0 = sfinvsqrta(%2)\n\t"
"%1 = p0\n\t"
: "+r"(result), "=r"(predval)
: "r"(0x7f800000)
: "p0");
check32(result, 0xff800000);
check32(predval, 0x0);
}
static void check_sffixupn(void)
{
int result;
/* Check that sffixupn properly deals with denorm */
asm volatile("%0 = sffixupn(%1, %2)\n\t"
: "=r"(result)
: "r"(SF_random), "r"(SF_denorm));
check32(result, 0x246001d6);
}
static void check_sffixupd(void)
{
int result;
/* Check that sffixupd properly deals with denorm */
asm volatile("%0 = sffixupd(%1, %2)\n\t"
: "=r"(result)
: "r"(SF_denorm), "r"(SF_random));
check32(result, 0x146001d6);
}
static void check_sffms(void)
{
int result;
/* Check that sffms properly deals with -0 */
result = SF_neg_zero;
asm ("%0 -= sfmpy(%1 , %2)\n\t"
: "+r"(result)
: "r"(SF_ZERO), "r"(SF_ZERO)
: "r12", "r8");
check32(result, SF_neg_zero);
result = SF_ZERO;
asm ("%0 -= sfmpy(%1 , %2)\n\t"
: "+r"(result)
: "r"(SF_neg_zero), "r"(SF_ZERO)
: "r12", "r8");
check32(result, SF_ZERO);
result = SF_ZERO;
asm ("%0 -= sfmpy(%1 , %2)\n\t"
: "+r"(result)
: "r"(SF_ZERO), "r"(SF_neg_zero)
: "r12", "r8");
check32(result, SF_ZERO);
}
static void check_float2int_convs()
{
int res32;
long long res64;
int usr;
/*
* Check that the various forms of float-to-unsigned
* check sign before rounding
*/
asm(CLEAR_FPSTATUS
"%0 = convert_sf2uw(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(SF_small_neg)
: "r2", "usr");
check32(res32, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2uw(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(SF_small_neg)
: "r2", "usr");
check32(res32, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2ud(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(SF_small_neg)
: "r2", "usr");
check64(res64, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2ud(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(SF_small_neg)
: "r2", "usr");
check64(res64, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2uw(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(DF_small_neg)
: "r2", "usr");
check32(res32, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2uw(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(DF_small_neg)
: "r2", "usr");
check32(res32, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2ud(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(DF_small_neg)
: "r2", "usr");
check64(res64, 0);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2ud(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(DF_small_neg)
: "r2", "usr");
check64(res64, 0);
check_fpstatus(usr, FPINVF);
/*
* Check that the various forms of float-to-signed return -1 for NaN
*/
asm(CLEAR_FPSTATUS
"%0 = convert_sf2w(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(SF_NaN)
: "r2", "usr");
check32(res32, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2w(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(SF_NaN)
: "r2", "usr");
check32(res32, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2d(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(SF_NaN)
: "r2", "usr");
check64(res64, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_sf2d(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(SF_NaN)
: "r2", "usr");
check64(res64, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2w(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(DF_QNaN)
: "r2", "usr");
check32(res32, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2w(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res32), "=r"(usr) : "r"(DF_QNaN)
: "r2", "usr");
check32(res32, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2d(%2)\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(DF_QNaN)
: "r2", "usr");
check64(res64, -1);
check_fpstatus(usr, FPINVF);
asm(CLEAR_FPSTATUS
"%0 = convert_df2d(%2):chop\n\t"
"%1 = usr\n\t"
: "=r"(res64), "=r"(usr) : "r"(DF_QNaN)
: "r2", "usr");
check64(res64, -1);
check_fpstatus(usr, FPINVF);
}
int main()
{
check_compare_exception();
check_sfminmax();
check_dfminmax();
check_sfrecipa();
check_canonical_NaN();
check_invsqrta();
check_sffixupn();
check_sffixupd();
check_sffms();
check_float2int_convs();
puts(err ? "FAIL" : "PASS");
return err ? 1 : 0;
}
|