xref: /openbmc/qemu/tests/fp/meson.build (revision 7d87775f)
1if 'CONFIG_TCG' not in config_all_accel
2  subdir_done()
3endif
4# There are namespace pollution issues on Windows, due to osdep.h
5# bringing in Windows headers that define a FLOAT128 type.
6if host_os == 'windows'
7  subdir_done()
8endif
9
10# By default tests run with the usual 30s timeout; particularly
11# slow tests can have that overridden here. The keys here are
12# the testnames without their fp-test- prefix.
13slow_fp_tests = {
14  'rem': 60,
15  'div': 60,
16  'mul': 60,
17  'mulAdd': 180,
18}
19
20sfcflags = [
21  # softfloat defines
22  '-DSOFTFLOAT_ROUND_ODD',
23  '-DINLINE_LEVEL=5',
24  '-DSOFTFLOAT_FAST_DIV32TO16',
25  '-DSOFTFLOAT_FAST_DIV64TO32',
26  '-DSOFTFLOAT_FAST_INT64',
27]
28tfcflags = [
29  # testfloat defines
30  '-DFLOAT16',
31  '-DFLOAT64',
32  '-DEXTFLOAT80',
33  '-DFLOAT128',
34  '-DFLOAT_ROUND_ODD',
35  '-DLONG_DOUBLE_IS_EXTFLOAT80',
36]
37
38libsoftfloat_proj = subproject('berkeley-softfloat-3', required: true,
39    default_options: 'defines=' + ','.join(sfcflags))
40libsoftfloat = libsoftfloat_proj.get_variable('libsoftfloat_dep')
41
42libtestfloat_proj = subproject('berkeley-testfloat-3', required: true,
43    default_options: 'defines=' + ','.join(tfcflags))
44libtestfloat = libtestfloat_proj.get_variable('libtestfloat_dep')
45libslowfloat = libtestfloat_proj.get_variable('libslowfloat_dep')
46
47fpcflags = [
48  # work around TARGET_* poisoning
49  '-DHW_POISON_H',
50  # define a target to match testfloat's implementation-defined choices, such as
51  # whether to raise the invalid flag when dealing with NaNs in muladd.
52  '-DTARGET_ARM',
53  # FIXME: uiZ may be used uninitialized in this function
54  '-Wno-uninitialized',
55]
56
57fptest = executable(
58  'fp-test',
59  ['fp-test.c', '../../fpu/softfloat.c'],
60  dependencies: [qemuutil, libsoftfloat, libtestfloat, libslowfloat],
61  c_args: fpcflags,
62)
63softfloat_conv_tests = {
64    'float-to-float': 'f16_to_f32 f16_to_f64 f16_to_extF80 f16_to_f128 ' +
65                      'f32_to_f16 f32_to_f64 f32_to_extF80 ' +
66                      'f64_to_f16 f64_to_f32 ' +
67                      'extF80_to_f16 extF80_to_f32 ' +
68                      'extF80_to_f64 extF80_to_f128 ' +
69                      'f128_to_f16',
70    'int-to-float': 'i32_to_f16 i64_to_f16 i32_to_f32 i64_to_f32 ' +
71                    'i32_to_f64 i64_to_f64 ' +
72                    'i32_to_extF80 i64_to_extF80 ' +
73                    'i32_to_f128 i64_to_f128',
74    'uint-to-float': 'ui32_to_f16 ui64_to_f16 ui32_to_f32 ui64_to_f32 ' +
75                     'ui32_to_f64 ui64_to_f64 ui64_to_f128 ' +
76                     'ui32_to_extF80 ui64_to_extF80',
77    'float-to-int': 'f16_to_i32 f16_to_i32_r_minMag ' +
78                    'f32_to_i32 f32_to_i32_r_minMag ' +
79                    'f64_to_i32 f64_to_i32_r_minMag ' +
80                    'extF80_to_i32 extF80_to_i32_r_minMag ' +
81                    'f128_to_i32 f128_to_i32_r_minMag ' +
82                    'f16_to_i64 f16_to_i64_r_minMag ' +
83                    'f32_to_i64 f32_to_i64_r_minMag ' +
84                    'f64_to_i64 f64_to_i64_r_minMag ' +
85                    'extF80_to_i64 extF80_to_i64_r_minMag ' +
86                    'f128_to_i64 f128_to_i64_r_minMag',
87    'float-to-uint': 'f16_to_ui32 f16_to_ui32_r_minMag ' +
88                     'f32_to_ui32 f32_to_ui32_r_minMag ' +
89                     'f64_to_ui32 f64_to_ui32_r_minMag ' +
90                     'extF80_to_ui32 extF80_to_ui32_r_minMag ' +
91                     'f128_to_ui32 f128_to_ui32_r_minMag ' +
92                     'f16_to_ui64 f16_to_ui64_r_minMag ' +
93                     'f32_to_ui64 f32_to_ui64_r_minMag ' +
94                     'f64_to_ui64 f64_to_ui64_r_minMag ' +
95                     'extF80_to_ui64 extF80_to_ui64_r_minMag ' +
96                     'f128_to_ui64 f128_to_ui64_r_minMag',
97    'round-to-integer': 'f16_roundToInt f32_roundToInt ' +
98                        'f64_roundToInt extF80_roundToInt f128_roundToInt'
99}
100softfloat_tests = {
101    'eq_signaling' : 'compare',
102    'le' : 'compare',
103    'le_quiet' : 'compare',
104    'lt_quiet' : 'compare',
105    'add': 'ops',
106    'sub': 'ops',
107    'mul': 'ops',
108    'div': 'ops',
109    'rem': 'ops',
110    'sqrt': 'ops'
111}
112# The full test suite can take a bit of time, default to a quick run
113# "-l 2 -r all" can take more than a day for some operations and is best
114# run manually
115fptest_args = ['-q', '-s', '-l', '1']
116fptest_rounding_args = ['-r', 'all']
117
118# Conversion Routines:
119foreach k, v : softfloat_conv_tests
120  test('fp-test-' + k, fptest,
121       args: fptest_args + fptest_rounding_args + v.split(),
122       timeout: slow_fp_tests.get(k, 30),
123       suite: ['softfloat', 'softfloat-conv'])
124endforeach
125
126foreach k, v : softfloat_tests
127  test('fp-test-' + k, fptest,
128       args: fptest_args + fptest_rounding_args +
129             ['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k, 'extF80_' + k],
130       timeout: slow_fp_tests.get(k, 30),
131       suite: ['softfloat', 'softfloat-' + v])
132endforeach
133
134# FIXME: extF80_{mulAdd} (missing)
135test('fp-test-mulAdd', fptest,
136     # no fptest_rounding_args
137     args: fptest_args +
138           ['f16_mulAdd', 'f32_mulAdd', 'f64_mulAdd', 'f128_mulAdd'],
139     timeout: slow_fp_tests.get('mulAdd', 30),
140     suite: ['softfloat-slow', 'softfloat-ops-slow', 'slow'])
141
142executable(
143  'fp-bench',
144  ['fp-bench.c', '../../fpu/softfloat.c'],
145  dependencies: [qemuutil, libtestfloat, libsoftfloat],
146  c_args: fpcflags,
147)
148
149fptestlog2 = executable(
150  'fp-test-log2',
151  ['fp-test-log2.c', '../../fpu/softfloat.c'],
152  dependencies: [qemuutil, libsoftfloat],
153  c_args: fpcflags,
154)
155test('fp-test-log2', fptestlog2,
156     timeout: slow_fp_tests.get('log2', 30),
157     suite: ['softfloat', 'softfloat-ops'])
158