]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.c
2 * Copyright (c) 2015 - 2019, Linaro Limited
4 * SPDX-License-Identifier: BSD-2-Clause-Patent
11 * On ARM32 EABI defines both a soft-float ABI and a hard-float ABI,
12 * hard-float is basically a super set of soft-float. Hard-float requires
13 * all the support routines provided for soft-float, but the compiler may
14 * choose to optimize to not use some of them.
16 * The AEABI functions uses soft-float calling convention even if the
17 * functions are compiled for hard-float. So where float and double would
18 * have been expected we use aeabi_float_t and aeabi_double_t respectively
21 typedef uint32_t aeabi_float_t
;
22 typedef uint64_t aeabi_double_t
;
25 * Helpers to convert between float32 and aeabi_float_t, and float64 and
26 * aeabi_double_t used by the AEABI functions below.
69 * From ARM Run-time ABI for ARM Architecture
70 * ARM IHI 0043D, current through ABI release 2.09
72 * 4.1.2 The floating-point helper functions
76 * Table 2, Standard aeabi_double_t precision floating-point arithmetic helper
85 return f64_to_d (f64_add (f64_from_d (a
), f64_from_d (b
)));
94 return f64_to_d (f64_div (f64_from_d (a
), f64_from_d (b
)));
103 return f64_to_d (f64_mul (f64_from_d (a
), f64_from_d (b
)));
112 return f64_to_d (f64_sub (f64_from_d (b
), f64_from_d (a
)));
121 return f64_to_d (f64_sub (f64_from_d (a
), f64_from_d (b
)));
125 * Table 3, double precision floating-point comparison helper functions
133 return f64_eq (f64_from_d (a
), f64_from_d (b
));
142 return f64_lt (f64_from_d (a
), f64_from_d (b
));
151 return f64_le (f64_from_d (a
), f64_from_d (b
));
160 return f64_le (f64_from_d (b
), f64_from_d (a
));
169 return f64_lt (f64_from_d (b
), f64_from_d (a
));
173 * Table 4, Standard single precision floating-point arithmetic helper
182 return f32_to_f (f32_add (f32_from_f (a
), f32_from_f (b
)));
191 return f32_to_f (f32_div (f32_from_f (a
), f32_from_f (b
)));
200 return f32_to_f (f32_mul (f32_from_f (a
), f32_from_f (b
)));
209 return f32_to_f (f32_sub (f32_from_f (b
), f32_from_f (a
)));
218 return f32_to_f (f32_sub (f32_from_f (a
), f32_from_f (b
)));
222 * Table 5, Standard single precision floating-point comparison helper
231 return f32_eq (f32_from_f (a
), f32_from_f (b
));
240 return f32_lt (f32_from_f (a
), f32_from_f (b
));
249 return f32_le (f32_from_f (a
), f32_from_f (b
));
258 return f32_le (f32_from_f (b
), f32_from_f (a
));
267 return f32_lt (f32_from_f (b
), f32_from_f (a
));
271 * Table 6, Standard floating-point to integer conversions
278 return f64_to_i32_r_minMag (f64_from_d (a
), false);
286 return f64_to_ui32_r_minMag (f64_from_d (a
), false);
294 return f64_to_i64_r_minMag (f64_from_d (a
), false);
302 return f64_to_ui64_r_minMag (f64_from_d (a
), false);
310 return f32_to_i32_r_minMag (f32_from_f (a
), false);
318 return f32_to_ui32_r_minMag (f32_from_f (a
), false);
326 return f32_to_i64_r_minMag (f32_from_f (a
), false);
334 return f32_to_ui64_r_minMag (f32_from_f (a
), false);
338 * Table 7, Standard conversions between floating types
345 return f32_to_f (f64_to_f32 (f64_from_d (a
)));
353 return f64_to_d (f32_to_f64 (f32_from_f (a
)));
357 * Table 8, Standard integer to floating-point conversions
364 return f64_to_d (i32_to_f64 (a
));
372 return f64_to_d (ui32_to_f64 (a
));
380 return f64_to_d (i64_to_f64 (a
));
388 return f64_to_d (ui64_to_f64 (a
));
396 return f32_to_f (i32_to_f32 (a
));
404 return f32_to_f (ui32_to_f32 (a
));
412 return f32_to_f (i64_to_f32 (a
));
420 return f32_to_f (ui64_to_f32 (a
));