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