summaryrefslogtreecommitdiffstats
path: root/tests/fp/meson.build
blob: 2b4f00b9165c691a84fd7b1731f07714476559cc (plain) (blame)
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
if 'CONFIG_TCG' not in config_all
  subdir_done()
endif
# There are namespace pollution issues on Windows, due to osdep.h
# bringing in Windows headers that define a FLOAT128 type.
if targetos == 'windows'
  subdir_done()
endif

fpcflags = [
  # softfloat defines
  '-DSOFTFLOAT_ROUND_ODD',
  '-DINLINE_LEVEL=5',
  '-DSOFTFLOAT_FAST_DIV32TO16',
  '-DSOFTFLOAT_FAST_DIV64TO32',
  '-DSOFTFLOAT_FAST_INT64',
  # testfloat defines
  '-DFLOAT16',
  '-DFLOAT64',
  '-DEXTFLOAT80',
  '-DFLOAT128',
  '-DFLOAT_ROUND_ODD',
  '-DLONG_DOUBLE_IS_EXTFLOAT80',
]

sfdir = 'berkeley-softfloat-3/source'
sfspedir = sfdir / '8086-SSE'
tfdir = 'berkeley-testfloat-3/source'

sfinc = include_directories(sfdir / 'include', sfspedir)

tfcflags = [
  '-Wno-implicit-fallthrough',
  '-Wno-strict-prototypes',
  '-Wno-unknown-pragmas',
  '-Wno-uninitialized',
  '-Wno-missing-prototypes',
  '-Wno-return-type',
  '-Wno-unused-function',
  '-Wno-error',
]

if cc.get_id() == 'clang'
  # Clang does not support '#pragma STDC FENV_ACCESS'
  tfcflags += [ '-Wno-ignored-pragmas' ]
endif

tfgencases = [
  tfdir / 'genCases_ui32.c',
  tfdir / 'genCases_ui64.c',
  tfdir / 'genCases_i32.c',
  tfdir / 'genCases_i64.c',
  tfdir / 'genCases_f16.c',
  tfdir / 'genCases_f32.c',
  tfdir / 'genCases_f64.c',
  tfdir / 'genCases_extF80.c',
  tfdir / 'genCases_f128.c',
]

tfwritecase = [
  tfdir / 'writeCase_a_ui32.c',
  tfdir / 'writeCase_a_ui64.c',
  tfdir / 'writeCase_a_f16.c',
  tfdir / 'writeCase_ab_f16.c',
  tfdir / 'writeCase_abc_f16.c',
  tfdir / 'writeCase_a_f32.c',
  tfdir / 'writeCase_ab_f32.c',
  tfdir / 'writeCase_abc_f32.c',
  tfdir / 'writeCase_a_f64.c',
  tfdir / 'writeCase_ab_f64.c',
  tfdir / 'writeCase_abc_f64.c',
  tfdir / 'writeCase_a_extF80M.c',
  tfdir / 'writeCase_ab_extF80M.c',
  tfdir / 'writeCase_a_f128M.c',
  tfdir / 'writeCase_ab_f128M.c',
  tfdir / 'writeCase_abc_f128M.c',
  tfdir / 'writeCase_z_bool.c',
  tfdir / 'writeCase_z_ui32.c',
  tfdir / 'writeCase_z_ui64.c',
  tfdir / 'writeCase_z_f16.c',
  tfdir / 'writeCase_z_f32.c',
  tfdir / 'writeCase_z_f64.c',
  tfdir / 'writeCase_z_extF80M.c',
  tfdir / 'writeCase_z_f128M.c',
]

tftest = [
  tfdir / 'test_a_ui32_z_f16.c',
  tfdir / 'test_a_ui32_z_f32.c',
  tfdir / 'test_a_ui32_z_f64.c',
  tfdir / 'test_a_ui32_z_extF80.c',
  tfdir / 'test_a_ui32_z_f128.c',
  tfdir / 'test_a_ui64_z_f16.c',
  tfdir / 'test_a_ui64_z_f32.c',
  tfdir / 'test_a_ui64_z_f64.c',
  tfdir / 'test_a_ui64_z_extF80.c',
  tfdir / 'test_a_ui64_z_f128.c',
  tfdir / 'test_a_i32_z_f16.c',
  tfdir / 'test_a_i32_z_f32.c',
  tfdir / 'test_a_i32_z_f64.c',
  tfdir / 'test_a_i32_z_extF80.c',
  tfdir / 'test_a_i32_z_f128.c',
  tfdir / 'test_a_i64_z_f16.c',
  tfdir / 'test_a_i64_z_f32.c',
  tfdir / 'test_a_i64_z_f64.c',
  tfdir / 'test_a_i64_z_extF80.c',
  tfdir / 'test_a_i64_z_f128.c',
  tfdir / 'test_a_f16_z_ui32_rx.c',
  tfdir / 'test_a_f16_z_ui64_rx.c',
  tfdir / 'test_a_f16_z_i32_rx.c',
  tfdir / 'test_a_f16_z_i64_rx.c',
  tfdir / 'test_a_f16_z_ui32_x.c',
  tfdir / 'test_a_f16_z_ui64_x.c',
  tfdir / 'test_a_f16_z_i32_x.c',
  tfdir / 'test_a_f16_z_i64_x.c',
  tfdir / 'test_a_f16_z_f32.c',
  tfdir / 'test_a_f16_z_f64.c',
  tfdir / 'test_a_f16_z_extF80.c',
  tfdir / 'test_a_f16_z_f128.c',
  tfdir / 'test_az_f16.c',
  tfdir / 'test_az_f16_rx.c',
  tfdir / 'test_abz_f16.c',
  tfdir / 'test_abcz_f16.c',
  tfdir / 'test_ab_f16_z_bool.c',
  tfdir / 'test_a_f32_z_ui32_rx.c',
  tfdir / 'test_a_f32_z_ui64_rx.c',
  tfdir / 'test_a_f32_z_i32_rx.c',
  tfdir / 'test_a_f32_z_i64_rx.c',
  tfdir / 'test_a_f32_z_ui32_x.c',
  tfdir / 'test_a_f32_z_ui64_x.c',
  tfdir / 'test_a_f32_z_i32_x.c',
  tfdir / 'test_a_f32_z_i64_x.c',
  tfdir / 'test_a_f32_z_f16.c',
  tfdir / 'test_a_f32_z_f64.c',
  tfdir / 'test_a_f32_z_extF80.c',
  tfdir / 'test_a_f32_z_f128.c',
  tfdir / 'test_az_f32.c',
  tfdir / 'test_az_f32_rx.c',
  tfdir / 'test_abz_f32.c',
  tfdir / 'test_abcz_f32.c',
  tfdir / 'test_ab_f32_z_bool.c',
  tfdir / 'test_a_f64_z_ui32_rx.c',
  tfdir / 'test_a_f64_z_ui64_rx.c',
  tfdir / 'test_a_f64_z_i32_rx.c',
  tfdir / 'test_a_f64_z_i64_rx.c',
  tfdir / 'test_a_f64_z_ui32_x.c',
  tfdir / 'test_a_f64_z_ui64_x.c',
  tfdir / 'test_a_f64_z_i32_x.c',
  tfdir / 'test_a_f64_z_i64_x.c',
  tfdir / 'test_a_f64_z_f16.c',
  tfdir / 'test_a_f64_z_f32.c',
  tfdir / 'test_a_f64_z_extF80.c',
  tfdir / 'test_a_f64_z_f128.c',
  tfdir / 'test_az_f64.c',
  tfdir / 'test_az_f64_rx.c',
  tfdir / 'test_abz_f64.c',
  tfdir / 'test_abcz_f64.c',
  tfdir / 'test_ab_f64_z_bool.c',
  tfdir / 'test_a_extF80_z_ui32_rx.c',
  tfdir / 'test_a_extF80_z_ui64_rx.c',
  tfdir / 'test_a_extF80_z_i32_rx.c',
  tfdir / 'test_a_extF80_z_i64_rx.c',
  tfdir / 'test_a_extF80_z_ui32_x.c',
  tfdir / 'test_a_extF80_z_ui64_x.c',
  tfdir / 'test_a_extF80_z_i32_x.c',
  tfdir / 'test_a_extF80_z_i64_x.c',
  tfdir / 'test_a_extF80_z_f16.c',
  tfdir / 'test_a_extF80_z_f32.c',
  tfdir / 'test_a_extF80_z_f64.c',
  tfdir / 'test_a_extF80_z_f128.c',
  tfdir / 'test_az_extF80.c',
  tfdir / 'test_az_extF80_rx.c',
  tfdir / 'test_abz_extF80.c',
  tfdir / 'test_ab_extF80_z_bool.c',
  tfdir / 'test_a_f128_z_ui32_rx.c',
  tfdir / 'test_a_f128_z_ui64_rx.c',
  tfdir / 'test_a_f128_z_i32_rx.c',
  tfdir / 'test_a_f128_z_i64_rx.c',
  tfdir / 'test_a_f128_z_ui32_x.c',
  tfdir / 'test_a_f128_z_ui64_x.c',
  tfdir / 'test_a_f128_z_i32_x.c',
  tfdir / 'test_a_f128_z_i64_x.c',
  tfdir / 'test_a_f128_z_f16.c',
  tfdir / 'test_a_f128_z_f32.c',
  tfdir / 'test_a_f128_z_f64.c',
  tfdir / 'test_a_f128_z_extF80.c',
  tfdir / 'test_az_f128.c',
  tfdir / 'test_az_f128_rx.c',
  tfdir / 'test_abz_f128.c',
  tfdir / 'test_abcz_f128.c',
  tfdir / 'test_ab_f128_z_bool.c',
]

libtestfloat = static_library(
  'testfloat',
  files(
    tfdir / 'uint128_inline.c',
    tfdir / 'uint128.c',
    tfdir / 'fail.c',
    tfdir / 'functions_common.c',
    tfdir / 'functionInfos.c',
    tfdir / 'standardFunctionInfos.c',
    tfdir / 'random.c',
    tfdir / 'genCases_common.c',
    tfgencases,
    tfdir / 'genCases_writeTestsTotal.c',
    tfdir / 'verCases_inline.c',
    tfdir / 'verCases_common.c',
    tfdir / 'verCases_writeFunctionName.c',
    tfdir / 'readHex.c',
    tfdir / 'writeHex.c',
    tfwritecase,
    tfdir / 'testLoops_common.c',
    tftest,
  ),
  include_directories: sfinc,
  c_args: tfcflags + fpcflags,
)

sfcflags = [
  '-Wno-implicit-fallthrough',
  '-Wno-missing-prototypes',
  '-Wno-redundant-decls',
  '-Wno-return-type',
  '-Wno-error',
]

libsoftfloat = static_library(
  'softfloat',
  files(
    # primitives
    sfdir / 's_eq128.c',
    sfdir / 's_le128.c',
    sfdir / 's_lt128.c',
    sfdir / 's_shortShiftLeft128.c',
    sfdir / 's_shortShiftRight128.c',
    sfdir / 's_shortShiftRightJam64.c',
    sfdir / 's_shortShiftRightJam64Extra.c',
    sfdir / 's_shortShiftRightJam128.c',
    sfdir / 's_shortShiftRightJam128Extra.c',
    sfdir / 's_shiftRightJam32.c',
    sfdir / 's_shiftRightJam64.c',
    sfdir / 's_shiftRightJam64Extra.c',
    sfdir / 's_shiftRightJam128.c',
    sfdir / 's_shiftRightJam128Extra.c',
    sfdir / 's_shiftRightJam256M.c',
    sfdir / 's_countLeadingZeros8.c',
    sfdir / 's_countLeadingZeros16.c',
    sfdir / 's_countLeadingZeros32.c',
    sfdir / 's_countLeadingZeros64.c',
    sfdir / 's_add128.c',
    sfdir / 's_add256M.c',
    sfdir / 's_sub128.c',
    sfdir / 's_sub256M.c',
    sfdir / 's_mul64ByShifted32To128.c',
    sfdir / 's_mul64To128.c',
    sfdir / 's_mul128By32.c',
    sfdir / 's_mul128To256M.c',
    sfdir / 's_approxRecip_1Ks.c',
    sfdir / 's_approxRecip32_1.c',
    sfdir / 's_approxRecipSqrt_1Ks.c',
    sfdir / 's_approxRecipSqrt32_1.c',
    # others
    sfdir / 's_roundToUI32.c',
    sfdir / 's_roundToUI64.c',
    sfdir / 's_roundToI32.c',
    sfdir / 's_roundToI64.c',
    sfdir / 's_normSubnormalF16Sig.c',
    sfdir / 's_roundPackToF16.c',
    sfdir / 's_normRoundPackToF16.c',
    sfdir / 's_addMagsF16.c',
    sfdir / 's_subMagsF16.c',
    sfdir / 's_mulAddF16.c',
    sfdir / 's_normSubnormalF32Sig.c',
    sfdir / 's_roundPackToF32.c',
    sfdir / 's_normRoundPackToF32.c',
    sfdir / 's_addMagsF32.c',
    sfdir / 's_subMagsF32.c',
    sfdir / 's_mulAddF32.c',
    sfdir / 's_normSubnormalF64Sig.c',
    sfdir / 's_roundPackToF64.c',
    sfdir / 's_normRoundPackToF64.c',
    sfdir / 's_addMagsF64.c',
    sfdir / 's_subMagsF64.c',
    sfdir / 's_mulAddF64.c',
    sfdir / 's_normSubnormalExtF80Sig.c',
    sfdir / 's_roundPackToExtF80.c',
    sfdir / 's_normRoundPackToExtF80.c',
    sfdir / 's_addMagsExtF80.c',
    sfdir / 's_subMagsExtF80.c',
    sfdir / 's_normSubnormalF128Sig.c',
    sfdir / 's_roundPackToF128.c',
    sfdir / 's_normRoundPackToF128.c',
    sfdir / 's_addMagsF128.c',
    sfdir / 's_subMagsF128.c',
    sfdir / 's_mulAddF128.c',
    sfdir / 'softfloat_state.c',
    sfdir / 'ui32_to_f16.c',
    sfdir / 'ui32_to_f32.c',
    sfdir / 'ui32_to_f64.c',
    sfdir / 'ui32_to_extF80.c',
    sfdir / 'ui32_to_extF80M.c',
    sfdir / 'ui32_to_f128.c',
    sfdir / 'ui32_to_f128M.c',
    sfdir / 'ui64_to_f16.c',
    sfdir / 'ui64_to_f32.c',
    sfdir / 'ui64_to_f64.c',
    sfdir / 'ui64_to_extF80.c',
    sfdir / 'ui64_to_extF80M.c',
    sfdir / 'ui64_to_f128.c',
    sfdir / 'ui64_to_f128M.c',
    sfdir / 'i32_to_f16.c',
    sfdir / 'i32_to_f32.c',
    sfdir / 'i32_to_f64.c',
    sfdir / 'i32_to_extF80.c',
    sfdir / 'i32_to_extF80M.c',
    sfdir / 'i32_to_f128.c',
    sfdir / 'i32_to_f128M.c',
    sfdir / 'i64_to_f16.c',
    sfdir / 'i64_to_f32.c',
    sfdir / 'i64_to_f64.c',
    sfdir / 'i64_to_extF80.c',
    sfdir / 'i64_to_extF80M.c',
    sfdir / 'i64_to_f128.c',
    sfdir / 'i64_to_f128M.c',
    sfdir / 'f16_to_ui32.c',
    sfdir / 'f16_to_ui64.c',
    sfdir / 'f16_to_i32.c',
    sfdir / 'f16_to_i64.c',
    sfdir / 'f16_to_ui32_r_minMag.c',
    sfdir / 'f16_to_ui64_r_minMag.c',
    sfdir / 'f16_to_i32_r_minMag.c',
    sfdir / 'f16_to_i64_r_minMag.c',
    sfdir / 'f16_to_f32.c',
    sfdir / 'f16_to_f64.c',
    sfdir / 'f16_to_extF80.c',
    sfdir / 'f16_to_extF80M.c',
    sfdir / 'f16_to_f128.c',
    sfdir / 'f16_to_f128M.c',
    sfdir / 'f16_roundToInt.c',
    sfdir / 'f16_add.c',
    sfdir / 'f16_sub.c',
    sfdir / 'f16_mul.c',
    sfdir / 'f16_mulAdd.c',
    sfdir / 'f16_div.c',
    sfdir / 'f16_rem.c',
    sfdir / 'f16_sqrt.c',
    sfdir / 'f16_eq.c',
    sfdir / 'f16_le.c',
    sfdir / 'f16_lt.c',
    sfdir / 'f16_eq_signaling.c',
    sfdir / 'f16_le_quiet.c',
    sfdir / 'f16_lt_quiet.c',
    sfdir / 'f16_isSignalingNaN.c',
    sfdir / 'f32_to_ui32.c',
    sfdir / 'f32_to_ui64.c',
    sfdir / 'f32_to_i32.c',
    sfdir / 'f32_to_i64.c',
    sfdir / 'f32_to_ui32_r_minMag.c',
    sfdir / 'f32_to_ui64_r_minMag.c',
    sfdir / 'f32_to_i32_r_minMag.c',
    sfdir / 'f32_to_i64_r_minMag.c',
    sfdir / 'f32_to_f16.c',
    sfdir / 'f32_to_f64.c',
    sfdir / 'f32_to_extF80.c',
    sfdir / 'f32_to_extF80M.c',
    sfdir / 'f32_to_f128.c',
    sfdir / 'f32_to_f128M.c',
    sfdir / 'f32_roundToInt.c',
    sfdir / 'f32_add.c',
    sfdir / 'f32_sub.c',
    sfdir / 'f32_mul.c',
    sfdir / 'f32_mulAdd.c',
    sfdir / 'f32_div.c',
    sfdir / 'f32_rem.c',
    sfdir / 'f32_sqrt.c',
    sfdir / 'f32_eq.c',
    sfdir / 'f32_le.c',
    sfdir / 'f32_lt.c',
    sfdir / 'f32_eq_signaling.c',
    sfdir / 'f32_le_quiet.c',
    sfdir / 'f32_lt_quiet.c',
    sfdir / 'f32_isSignalingNaN.c',
    sfdir / 'f64_to_ui32.c',
    sfdir / 'f64_to_ui64.c',
    sfdir / 'f64_to_i32.c',
    sfdir / 'f64_to_i64.c',
    sfdir / 'f64_to_ui32_r_minMag.c',
    sfdir / 'f64_to_ui64_r_minMag.c',
    sfdir / 'f64_to_i32_r_minMag.c',
    sfdir / 'f64_to_i64_r_minMag.c',
    sfdir / 'f64_to_f16.c',
    sfdir / 'f64_to_f32.c',
    sfdir / 'f64_to_extF80.c',
    sfdir / 'f64_to_extF80M.c',
    sfdir / 'f64_to_f128.c',
    sfdir / 'f64_to_f128M.c',
    sfdir / 'f64_roundToInt.c',
    sfdir / 'f64_add.c',
    sfdir / 'f64_sub.c',
    sfdir / 'f64_mul.c',
    sfdir / 'f64_mulAdd.c',
    sfdir / 'f64_div.c',
    sfdir / 'f64_rem.c',
    sfdir / 'f64_sqrt.c',
    sfdir / 'f64_eq.c',
    sfdir / 'f64_le.c',
    sfdir / 'f64_lt.c',
    sfdir / 'f64_eq_signaling.c',
    sfdir / 'f64_le_quiet.c',
    sfdir / 'f64_lt_quiet.c',
    sfdir / 'f64_isSignalingNaN.c',
    sfdir / 'extF80_to_ui32.c',
    sfdir / 'extF80_to_ui64.c',
    sfdir / 'extF80_to_i32.c',
    sfdir / 'extF80_to_i64.c',
    sfdir / 'extF80_to_ui32_r_minMag.c',
    sfdir / 'extF80_to_ui64_r_minMag.c',
    sfdir / 'extF80_to_i32_r_minMag.c',
    sfdir / 'extF80_to_i64_r_minMag.c',
    sfdir / 'extF80_to_f16.c',
    sfdir / 'extF80_to_f32.c',
    sfdir / 'extF80_to_f64.c',
    sfdir / 'extF80_to_f128.c',
    sfdir / 'extF80_roundToInt.c',
    sfdir / 'extF80_add.c',
    sfdir / 'extF80_sub.c',
    sfdir / 'extF80_mul.c',
    sfdir / 'extF80_div.c',
    sfdir / 'extF80_rem.c',
    sfdir / 'extF80_sqrt.c',
    sfdir / 'extF80_eq.c',
    sfdir / 'extF80_le.c',
    sfdir / 'extF80_lt.c',
    sfdir / 'extF80_eq_signaling.c',
    sfdir / 'extF80_le_quiet.c',
    sfdir / 'extF80_lt_quiet.c',
    sfdir / 'extF80_isSignalingNaN.c',
    sfdir / 'extF80M_to_ui32.c',
    sfdir / 'extF80M_to_ui64.c',
    sfdir / 'extF80M_to_i32.c',
    sfdir / 'extF80M_to_i64.c',
    sfdir / 'extF80M_to_ui32_r_minMag.c',
    sfdir / 'extF80M_to_ui64_r_minMag.c',
    sfdir / 'extF80M_to_i32_r_minMag.c',
    sfdir / 'extF80M_to_i64_r_minMag.c',
    sfdir / 'extF80M_to_f16.c',
    sfdir / 'extF80M_to_f32.c',
    sfdir / 'extF80M_to_f64.c',
    sfdir / 'extF80M_to_f128M.c',
    sfdir / 'extF80M_roundToInt.c',
    sfdir / 'extF80M_add.c',
    sfdir / 'extF80M_sub.c',
    sfdir / 'extF80M_mul.c',
    sfdir / 'extF80M_div.c',
    sfdir / 'extF80M_rem.c',
    sfdir / 'extF80M_sqrt.c',
    sfdir / 'extF80M_eq.c',
    sfdir / 'extF80M_le.c',
    sfdir / 'extF80M_lt.c',
    sfdir / 'extF80M_eq_signaling.c',
    sfdir / 'extF80M_le_quiet.c',
    sfdir / 'extF80M_lt_quiet.c',
    sfdir / 'f128_to_ui32.c',
    sfdir / 'f128_to_ui64.c',
    sfdir / 'f128_to_i32.c',
    sfdir / 'f128_to_i64.c',
    sfdir / 'f128_to_ui32_r_minMag.c',
    sfdir / 'f128_to_ui64_r_minMag.c',
    sfdir / 'f128_to_i32_r_minMag.c',
    sfdir / 'f128_to_i64_r_minMag.c',
    sfdir / 'f128_to_f16.c',
    sfdir / 'f128_to_f32.c',
    sfdir / 'f128_to_extF80.c',
    sfdir / 'f128_to_f64.c',
    sfdir / 'f128_roundToInt.c',
    sfdir / 'f128_add.c',
    sfdir / 'f128_sub.c',
    sfdir / 'f128_mul.c',
    sfdir / 'f128_mulAdd.c',
    sfdir / 'f128_div.c',
    sfdir / 'f128_rem.c',
    sfdir / 'f128_sqrt.c',
    sfdir / 'f128_eq.c',
    sfdir / 'f128_le.c',
    sfdir / 'f128_lt.c',
    sfdir / 'f128_eq_signaling.c',
    sfdir / 'f128_le_quiet.c',
    sfdir / 'f128_lt_quiet.c',
    sfdir / 'f128_isSignalingNaN.c',
    sfdir / 'f128M_to_ui32.c',
    sfdir / 'f128M_to_ui64.c',
    sfdir / 'f128M_to_i32.c',
    sfdir / 'f128M_to_i64.c',
    sfdir / 'f128M_to_ui32_r_minMag.c',
    sfdir / 'f128M_to_ui64_r_minMag.c',
    sfdir / 'f128M_to_i32_r_minMag.c',
    sfdir / 'f128M_to_i64_r_minMag.c',
    sfdir / 'f128M_to_f16.c',
    sfdir / 'f128M_to_f32.c',
    sfdir / 'f128M_to_extF80M.c',
    sfdir / 'f128M_to_f64.c',
    sfdir / 'f128M_roundToInt.c',
    sfdir / 'f128M_add.c',
    sfdir / 'f128M_sub.c',
    sfdir / 'f128M_mul.c',
    sfdir / 'f128M_mulAdd.c',
    sfdir / 'f128M_div.c',
    sfdir / 'f128M_rem.c',
    sfdir / 'f128M_sqrt.c',
    sfdir / 'f128M_eq.c',
    sfdir / 'f128M_le.c',
    sfdir / 'f128M_lt.c',
    sfdir / 'f128M_eq_signaling.c',
    sfdir / 'f128M_le_quiet.c',
    sfdir / 'f128M_lt_quiet.c',
    # spe
    sfspedir / 'softfloat_raiseFlags.c',
    sfspedir / 's_f16UIToCommonNaN.c',
    sfspedir / 's_commonNaNToF16UI.c',
    sfspedir / 's_propagateNaNF16UI.c',
    sfspedir / 's_f32UIToCommonNaN.c',
    sfspedir / 's_commonNaNToF32UI.c',
    sfspedir / 's_propagateNaNF32UI.c',
    sfspedir / 's_f64UIToCommonNaN.c',
    sfspedir / 's_commonNaNToF64UI.c',
    sfspedir / 's_propagateNaNF64UI.c',
    sfspedir / 'extF80M_isSignalingNaN.c',
    sfspedir / 's_extF80UIToCommonNaN.c',
    sfspedir / 's_commonNaNToExtF80UI.c',
    sfspedir / 's_propagateNaNExtF80UI.c',
    sfspedir / 'f128M_isSignalingNaN.c',
    sfspedir / 's_f128UIToCommonNaN.c',
    sfspedir / 's_commonNaNToF128UI.c',
    sfspedir / 's_propagateNaNF128UI.c',
  ),
  include_directories: sfinc,
  c_args: sfcflags + fpcflags,
)

fpcflags += [
  # work around TARGET_* poisoning
  '-DHW_POISON_H',
  # define a target to match testfloat's implementation-defined choices, such as
  # whether to raise the invalid flag when dealing with NaNs in muladd.
  '-DTARGET_ARM',
  # FIXME: uiZ may be used uninitialized in this function
  '-Wno-uninitialized',
]

fptest = executable(
  'fp-test',
  ['fp-test.c', tfdir / 'slowfloat.c', '../../fpu/softfloat.c'],
  link_with: [libtestfloat, libsoftfloat],
  dependencies: [qemuutil],
  include_directories: [sfinc, include_directories(tfdir)],
  c_args: fpcflags,
)
softfloat_conv_tests = {
    'float-to-float': 'f16_to_f32 f16_to_f64 f16_to_extF80 f16_to_f128 ' +
                      'f32_to_f16 f32_to_f64 f32_to_extF80 ' +
                      'f64_to_f16 f64_to_f32 ' +
                      'extF80_to_f16 extF80_to_f32 ' +
                      'extF80_to_f64 extF80_to_f128 ' +
                      'f128_to_f16',
    'int-to-float': 'i32_to_f16 i64_to_f16 i32_to_f32 i64_to_f32 ' +
                    'i32_to_f64 i64_to_f64 ' +
                    'i32_to_extF80 i64_to_extF80 ' +
                    'i32_to_f128 i64_to_f128',
    'uint-to-float': 'ui32_to_f16 ui64_to_f16 ui32_to_f32 ui64_to_f32 ' +
                     'ui32_to_f64 ui64_to_f64 ui64_to_f128 ' +
                     'ui32_to_extF80 ui64_to_extF80',
    'float-to-int': 'f16_to_i32 f16_to_i32_r_minMag ' +
                    'f32_to_i32 f32_to_i32_r_minMag ' +
                    'f64_to_i32 f64_to_i32_r_minMag ' +
                    'extF80_to_i32 extF80_to_i32_r_minMag ' +
                    'f128_to_i32 f128_to_i32_r_minMag ' +
                    'f16_to_i64 f16_to_i64_r_minMag ' +
                    'f32_to_i64 f32_to_i64_r_minMag ' +
                    'f64_to_i64 f64_to_i64_r_minMag ' +
                    'extF80_to_i64 extF80_to_i64_r_minMag ' +
                    'f128_to_i64 f128_to_i64_r_minMag',
    'float-to-uint': 'f16_to_ui32 f16_to_ui32_r_minMag ' +
                     'f32_to_ui32 f32_to_ui32_r_minMag ' +
                     'f64_to_ui32 f64_to_ui32_r_minMag ' +
                     'extF80_to_ui32 extF80_to_ui32_r_minMag ' +
                     'f128_to_ui32 f128_to_ui32_r_minMag ' +
                     'f16_to_ui64 f16_to_ui64_r_minMag ' +
                     'f32_to_ui64 f32_to_ui64_r_minMag ' +
                     'f64_to_ui64 f64_to_ui64_r_minMag ' +
                     'extF80_to_ui64 extF80_to_ui64_r_minMag ' +
                     'f128_to_ui64 f128_to_ui64_r_minMag',
    'round-to-integer': 'f16_roundToInt f32_roundToInt ' +
                        'f64_roundToInt extF80_roundToInt f128_roundToInt'
}
softfloat_tests = {
    'eq_signaling' : 'compare',
    'le' : 'compare',
    'le_quiet' : 'compare',
    'lt_quiet' : 'compare',
    'add': 'ops',
    'sub': 'ops',
    'mul': 'ops',
    'div': 'ops',
    'rem': 'ops',
    'sqrt': 'ops'
}
# The full test suite can take a bit of time, default to a quick run
# "-l 2 -r all" can take more than a day for some operations and is best
# run manually
fptest_args = ['-s', '-l', '1']
fptest_rounding_args = ['-r', 'all']

# Conversion Routines:
foreach k, v : softfloat_conv_tests
  test('fp-test-' + k, fptest,
       args: fptest_args + fptest_rounding_args + v.split(),
       suite: ['softfloat', 'softfloat-conv'])
endforeach

foreach k, v : softfloat_tests
  test('fp-test-' + k, fptest,
       args: fptest_args + fptest_rounding_args +
             ['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k, 'extF80_' + k],
       suite: ['softfloat', 'softfloat-' + v])
endforeach

# FIXME: extF80_{mulAdd} (missing)
test('fp-test-mulAdd', fptest,
     # no fptest_rounding_args
     args: fptest_args +
           ['f16_mulAdd', 'f32_mulAdd', 'f64_mulAdd', 'f128_mulAdd'],
     suite: ['softfloat-slow', 'softfloat-ops-slow', 'slow'], timeout: 90)

fpbench = executable(
  'fp-bench',
  ['fp-bench.c', '../../fpu/softfloat.c'],
  link_with: [libtestfloat, libsoftfloat],
  dependencies: [qemuutil],
  include_directories: [sfinc, include_directories(tfdir)],
  c_args: fpcflags,
)

fptestlog2 = executable(
  'fp-test-log2',
  ['fp-test-log2.c', '../../fpu/softfloat.c'],
  link_with: [libsoftfloat],
  dependencies: [qemuutil],
  include_directories: [sfinc],
  c_args: fpcflags,
)
test('fp-test-log2', fptestlog2,
     suite: ['softfloat', 'softfloat-ops'])