1project('berkeley-softfloat-3',  'c',
2        default_options: ['warning_level=1', 'c_std=gnu99'])
3
4fpcflags = get_option('defines')
5
6platform_data = configuration_data()
7platform_data.set('INLINE', 'static inline')
8platform_data.set('LITTLEENDIAN', host_machine.endian() == 'little')
9configure_file(output: 'platform.h', configuration: platform_data)
10
11sfdir = 'source'
12sfspedir = sfdir / '8086-SSE'
13sfinc = include_directories('.', sfdir / 'include', sfspedir)
14
15add_project_arguments([
16  '-Wno-implicit-fallthrough',
17  '-Wno-missing-prototypes',
18  '-Wno-redundant-decls',
19  '-Wno-return-type',
20  '-Wno-error',
21], native: false, language: 'c')
22
23libsoftfloat = static_library(
24  'softfloat',
25  files(
26    # primitives
27    sfdir / 's_eq128.c',
28    sfdir / 's_le128.c',
29    sfdir / 's_lt128.c',
30    sfdir / 's_shortShiftLeft128.c',
31    sfdir / 's_shortShiftRight128.c',
32    sfdir / 's_shortShiftRightJam64.c',
33    sfdir / 's_shortShiftRightJam64Extra.c',
34    sfdir / 's_shortShiftRightJam128.c',
35    sfdir / 's_shortShiftRightJam128Extra.c',
36    sfdir / 's_shiftRightJam32.c',
37    sfdir / 's_shiftRightJam64.c',
38    sfdir / 's_shiftRightJam64Extra.c',
39    sfdir / 's_shiftRightJam128.c',
40    sfdir / 's_shiftRightJam128Extra.c',
41    sfdir / 's_shiftRightJam256M.c',
42    sfdir / 's_countLeadingZeros8.c',
43    sfdir / 's_countLeadingZeros16.c',
44    sfdir / 's_countLeadingZeros32.c',
45    sfdir / 's_countLeadingZeros64.c',
46    sfdir / 's_add128.c',
47    sfdir / 's_add256M.c',
48    sfdir / 's_sub128.c',
49    sfdir / 's_sub256M.c',
50    sfdir / 's_mul64ByShifted32To128.c',
51    sfdir / 's_mul64To128.c',
52    sfdir / 's_mul128By32.c',
53    sfdir / 's_mul128To256M.c',
54    sfdir / 's_approxRecip_1Ks.c',
55    sfdir / 's_approxRecip32_1.c',
56    sfdir / 's_approxRecipSqrt_1Ks.c',
57    sfdir / 's_approxRecipSqrt32_1.c',
58    # others
59    sfdir / 's_roundToUI32.c',
60    sfdir / 's_roundToUI64.c',
61    sfdir / 's_roundToI32.c',
62    sfdir / 's_roundToI64.c',
63    sfdir / 's_normSubnormalF16Sig.c',
64    sfdir / 's_roundPackToF16.c',
65    sfdir / 's_normRoundPackToF16.c',
66    sfdir / 's_addMagsF16.c',
67    sfdir / 's_subMagsF16.c',
68    sfdir / 's_mulAddF16.c',
69    sfdir / 's_normSubnormalF32Sig.c',
70    sfdir / 's_roundPackToF32.c',
71    sfdir / 's_normRoundPackToF32.c',
72    sfdir / 's_addMagsF32.c',
73    sfdir / 's_subMagsF32.c',
74    sfdir / 's_mulAddF32.c',
75    sfdir / 's_normSubnormalF64Sig.c',
76    sfdir / 's_roundPackToF64.c',
77    sfdir / 's_normRoundPackToF64.c',
78    sfdir / 's_addMagsF64.c',
79    sfdir / 's_subMagsF64.c',
80    sfdir / 's_mulAddF64.c',
81    sfdir / 's_normSubnormalExtF80Sig.c',
82    sfdir / 's_roundPackToExtF80.c',
83    sfdir / 's_normRoundPackToExtF80.c',
84    sfdir / 's_addMagsExtF80.c',
85    sfdir / 's_subMagsExtF80.c',
86    sfdir / 's_normSubnormalF128Sig.c',
87    sfdir / 's_roundPackToF128.c',
88    sfdir / 's_normRoundPackToF128.c',
89    sfdir / 's_addMagsF128.c',
90    sfdir / 's_subMagsF128.c',
91    sfdir / 's_mulAddF128.c',
92    sfdir / 'softfloat_state.c',
93    sfdir / 'ui32_to_f16.c',
94    sfdir / 'ui32_to_f32.c',
95    sfdir / 'ui32_to_f64.c',
96    sfdir / 'ui32_to_extF80.c',
97    sfdir / 'ui32_to_extF80M.c',
98    sfdir / 'ui32_to_f128.c',
99    sfdir / 'ui32_to_f128M.c',
100    sfdir / 'ui64_to_f16.c',
101    sfdir / 'ui64_to_f32.c',
102    sfdir / 'ui64_to_f64.c',
103    sfdir / 'ui64_to_extF80.c',
104    sfdir / 'ui64_to_extF80M.c',
105    sfdir / 'ui64_to_f128.c',
106    sfdir / 'ui64_to_f128M.c',
107    sfdir / 'i32_to_f16.c',
108    sfdir / 'i32_to_f32.c',
109    sfdir / 'i32_to_f64.c',
110    sfdir / 'i32_to_extF80.c',
111    sfdir / 'i32_to_extF80M.c',
112    sfdir / 'i32_to_f128.c',
113    sfdir / 'i32_to_f128M.c',
114    sfdir / 'i64_to_f16.c',
115    sfdir / 'i64_to_f32.c',
116    sfdir / 'i64_to_f64.c',
117    sfdir / 'i64_to_extF80.c',
118    sfdir / 'i64_to_extF80M.c',
119    sfdir / 'i64_to_f128.c',
120    sfdir / 'i64_to_f128M.c',
121    sfdir / 'f16_to_ui32.c',
122    sfdir / 'f16_to_ui64.c',
123    sfdir / 'f16_to_i32.c',
124    sfdir / 'f16_to_i64.c',
125    sfdir / 'f16_to_ui32_r_minMag.c',
126    sfdir / 'f16_to_ui64_r_minMag.c',
127    sfdir / 'f16_to_i32_r_minMag.c',
128    sfdir / 'f16_to_i64_r_minMag.c',
129    sfdir / 'f16_to_f32.c',
130    sfdir / 'f16_to_f64.c',
131    sfdir / 'f16_to_extF80.c',
132    sfdir / 'f16_to_extF80M.c',
133    sfdir / 'f16_to_f128.c',
134    sfdir / 'f16_to_f128M.c',
135    sfdir / 'f16_roundToInt.c',
136    sfdir / 'f16_add.c',
137    sfdir / 'f16_sub.c',
138    sfdir / 'f16_mul.c',
139    sfdir / 'f16_mulAdd.c',
140    sfdir / 'f16_div.c',
141    sfdir / 'f16_rem.c',
142    sfdir / 'f16_sqrt.c',
143    sfdir / 'f16_eq.c',
144    sfdir / 'f16_le.c',
145    sfdir / 'f16_lt.c',
146    sfdir / 'f16_eq_signaling.c',
147    sfdir / 'f16_le_quiet.c',
148    sfdir / 'f16_lt_quiet.c',
149    sfdir / 'f16_isSignalingNaN.c',
150    sfdir / 'f32_to_ui32.c',
151    sfdir / 'f32_to_ui64.c',
152    sfdir / 'f32_to_i32.c',
153    sfdir / 'f32_to_i64.c',
154    sfdir / 'f32_to_ui32_r_minMag.c',
155    sfdir / 'f32_to_ui64_r_minMag.c',
156    sfdir / 'f32_to_i32_r_minMag.c',
157    sfdir / 'f32_to_i64_r_minMag.c',
158    sfdir / 'f32_to_f16.c',
159    sfdir / 'f32_to_f64.c',
160    sfdir / 'f32_to_extF80.c',
161    sfdir / 'f32_to_extF80M.c',
162    sfdir / 'f32_to_f128.c',
163    sfdir / 'f32_to_f128M.c',
164    sfdir / 'f32_roundToInt.c',
165    sfdir / 'f32_add.c',
166    sfdir / 'f32_sub.c',
167    sfdir / 'f32_mul.c',
168    sfdir / 'f32_mulAdd.c',
169    sfdir / 'f32_div.c',
170    sfdir / 'f32_rem.c',
171    sfdir / 'f32_sqrt.c',
172    sfdir / 'f32_eq.c',
173    sfdir / 'f32_le.c',
174    sfdir / 'f32_lt.c',
175    sfdir / 'f32_eq_signaling.c',
176    sfdir / 'f32_le_quiet.c',
177    sfdir / 'f32_lt_quiet.c',
178    sfdir / 'f32_isSignalingNaN.c',
179    sfdir / 'f64_to_ui32.c',
180    sfdir / 'f64_to_ui64.c',
181    sfdir / 'f64_to_i32.c',
182    sfdir / 'f64_to_i64.c',
183    sfdir / 'f64_to_ui32_r_minMag.c',
184    sfdir / 'f64_to_ui64_r_minMag.c',
185    sfdir / 'f64_to_i32_r_minMag.c',
186    sfdir / 'f64_to_i64_r_minMag.c',
187    sfdir / 'f64_to_f16.c',
188    sfdir / 'f64_to_f32.c',
189    sfdir / 'f64_to_extF80.c',
190    sfdir / 'f64_to_extF80M.c',
191    sfdir / 'f64_to_f128.c',
192    sfdir / 'f64_to_f128M.c',
193    sfdir / 'f64_roundToInt.c',
194    sfdir / 'f64_add.c',
195    sfdir / 'f64_sub.c',
196    sfdir / 'f64_mul.c',
197    sfdir / 'f64_mulAdd.c',
198    sfdir / 'f64_div.c',
199    sfdir / 'f64_rem.c',
200    sfdir / 'f64_sqrt.c',
201    sfdir / 'f64_eq.c',
202    sfdir / 'f64_le.c',
203    sfdir / 'f64_lt.c',
204    sfdir / 'f64_eq_signaling.c',
205    sfdir / 'f64_le_quiet.c',
206    sfdir / 'f64_lt_quiet.c',
207    sfdir / 'f64_isSignalingNaN.c',
208    sfdir / 'extF80_to_ui32.c',
209    sfdir / 'extF80_to_ui64.c',
210    sfdir / 'extF80_to_i32.c',
211    sfdir / 'extF80_to_i64.c',
212    sfdir / 'extF80_to_ui32_r_minMag.c',
213    sfdir / 'extF80_to_ui64_r_minMag.c',
214    sfdir / 'extF80_to_i32_r_minMag.c',
215    sfdir / 'extF80_to_i64_r_minMag.c',
216    sfdir / 'extF80_to_f16.c',
217    sfdir / 'extF80_to_f32.c',
218    sfdir / 'extF80_to_f64.c',
219    sfdir / 'extF80_to_f128.c',
220    sfdir / 'extF80_roundToInt.c',
221    sfdir / 'extF80_add.c',
222    sfdir / 'extF80_sub.c',
223    sfdir / 'extF80_mul.c',
224    sfdir / 'extF80_div.c',
225    sfdir / 'extF80_rem.c',
226    sfdir / 'extF80_sqrt.c',
227    sfdir / 'extF80_eq.c',
228    sfdir / 'extF80_le.c',
229    sfdir / 'extF80_lt.c',
230    sfdir / 'extF80_eq_signaling.c',
231    sfdir / 'extF80_le_quiet.c',
232    sfdir / 'extF80_lt_quiet.c',
233    sfdir / 'extF80_isSignalingNaN.c',
234    sfdir / 'extF80M_to_ui32.c',
235    sfdir / 'extF80M_to_ui64.c',
236    sfdir / 'extF80M_to_i32.c',
237    sfdir / 'extF80M_to_i64.c',
238    sfdir / 'extF80M_to_ui32_r_minMag.c',
239    sfdir / 'extF80M_to_ui64_r_minMag.c',
240    sfdir / 'extF80M_to_i32_r_minMag.c',
241    sfdir / 'extF80M_to_i64_r_minMag.c',
242    sfdir / 'extF80M_to_f16.c',
243    sfdir / 'extF80M_to_f32.c',
244    sfdir / 'extF80M_to_f64.c',
245    sfdir / 'extF80M_to_f128M.c',
246    sfdir / 'extF80M_roundToInt.c',
247    sfdir / 'extF80M_add.c',
248    sfdir / 'extF80M_sub.c',
249    sfdir / 'extF80M_mul.c',
250    sfdir / 'extF80M_div.c',
251    sfdir / 'extF80M_rem.c',
252    sfdir / 'extF80M_sqrt.c',
253    sfdir / 'extF80M_eq.c',
254    sfdir / 'extF80M_le.c',
255    sfdir / 'extF80M_lt.c',
256    sfdir / 'extF80M_eq_signaling.c',
257    sfdir / 'extF80M_le_quiet.c',
258    sfdir / 'extF80M_lt_quiet.c',
259    sfdir / 'f128_to_ui32.c',
260    sfdir / 'f128_to_ui64.c',
261    sfdir / 'f128_to_i32.c',
262    sfdir / 'f128_to_i64.c',
263    sfdir / 'f128_to_ui32_r_minMag.c',
264    sfdir / 'f128_to_ui64_r_minMag.c',
265    sfdir / 'f128_to_i32_r_minMag.c',
266    sfdir / 'f128_to_i64_r_minMag.c',
267    sfdir / 'f128_to_f16.c',
268    sfdir / 'f128_to_f32.c',
269    sfdir / 'f128_to_extF80.c',
270    sfdir / 'f128_to_f64.c',
271    sfdir / 'f128_roundToInt.c',
272    sfdir / 'f128_add.c',
273    sfdir / 'f128_sub.c',
274    sfdir / 'f128_mul.c',
275    sfdir / 'f128_mulAdd.c',
276    sfdir / 'f128_div.c',
277    sfdir / 'f128_rem.c',
278    sfdir / 'f128_sqrt.c',
279    sfdir / 'f128_eq.c',
280    sfdir / 'f128_le.c',
281    sfdir / 'f128_lt.c',
282    sfdir / 'f128_eq_signaling.c',
283    sfdir / 'f128_le_quiet.c',
284    sfdir / 'f128_lt_quiet.c',
285    sfdir / 'f128_isSignalingNaN.c',
286    sfdir / 'f128M_to_ui32.c',
287    sfdir / 'f128M_to_ui64.c',
288    sfdir / 'f128M_to_i32.c',
289    sfdir / 'f128M_to_i64.c',
290    sfdir / 'f128M_to_ui32_r_minMag.c',
291    sfdir / 'f128M_to_ui64_r_minMag.c',
292    sfdir / 'f128M_to_i32_r_minMag.c',
293    sfdir / 'f128M_to_i64_r_minMag.c',
294    sfdir / 'f128M_to_f16.c',
295    sfdir / 'f128M_to_f32.c',
296    sfdir / 'f128M_to_extF80M.c',
297    sfdir / 'f128M_to_f64.c',
298    sfdir / 'f128M_roundToInt.c',
299    sfdir / 'f128M_add.c',
300    sfdir / 'f128M_sub.c',
301    sfdir / 'f128M_mul.c',
302    sfdir / 'f128M_mulAdd.c',
303    sfdir / 'f128M_div.c',
304    sfdir / 'f128M_rem.c',
305    sfdir / 'f128M_sqrt.c',
306    sfdir / 'f128M_eq.c',
307    sfdir / 'f128M_le.c',
308    sfdir / 'f128M_lt.c',
309    sfdir / 'f128M_eq_signaling.c',
310    sfdir / 'f128M_le_quiet.c',
311    sfdir / 'f128M_lt_quiet.c',
312    # spe
313    sfspedir / 'softfloat_raiseFlags.c',
314    sfspedir / 's_f16UIToCommonNaN.c',
315    sfspedir / 's_commonNaNToF16UI.c',
316    sfspedir / 's_propagateNaNF16UI.c',
317    sfspedir / 's_f32UIToCommonNaN.c',
318    sfspedir / 's_commonNaNToF32UI.c',
319    sfspedir / 's_propagateNaNF32UI.c',
320    sfspedir / 's_f64UIToCommonNaN.c',
321    sfspedir / 's_commonNaNToF64UI.c',
322    sfspedir / 's_propagateNaNF64UI.c',
323    sfspedir / 'extF80M_isSignalingNaN.c',
324    sfspedir / 's_extF80UIToCommonNaN.c',
325    sfspedir / 's_commonNaNToExtF80UI.c',
326    sfspedir / 's_propagateNaNExtF80UI.c',
327    sfspedir / 'f128M_isSignalingNaN.c',
328    sfspedir / 's_f128UIToCommonNaN.c',
329    sfspedir / 's_commonNaNToF128UI.c',
330    sfspedir / 's_propagateNaNF128UI.c',
331  ),
332  include_directories: sfinc,
333  c_args: fpcflags,
334)
335
336libsoftfloat_dep = declare_dependency(
337    link_with: libsoftfloat,
338    include_directories: sfinc,
339    compile_args: fpcflags)
340