Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide optimised math library #237

Closed
9names opened this issue Dec 11, 2021 · 1 comment · Fixed by #288
Closed

Provide optimised math library #237

9names opened this issue Dec 11, 2021 · 1 comment · Fixed by #288
Labels
enhancement New feature or request

Comments

@9names
Copy link
Member

9names commented Dec 11, 2021

The Pico C toolchain uses optimised versions of common math functions where the hardware does not natively support those operations (eg integer division, all floating point math)
Provide our own version of this.

References:
https://github.com/raspberrypi/pico-sdk/tree/2062372d203b372849d573f252cf7c6dc2800c0a/src/rp2_common/pico_float

https://www.segger.com/doc/UM12008_FloatingPointLibrary.html#Arm_AEABI_library_API

rust-lang/libm#257

https://github.com/rust-lang/compiler-builtins/blob/dab437981078f052a87ff7a435005b276be68770/src/int/udiv.rs

@9names
Copy link
Member Author

9names commented Dec 11, 2021

Non-exhaustive list of Arm library symbol names we might want to implement.
Note that the floating point functions represent the floating point values as u32/u64 respectively

__aeabi_fadd 	Add, float. (u32,u32) -> u32
__aeabi_dadd 	Add, double. (u64,u64) -> u64
__aeabi_fsub 	Subtract, float. (u32,u32) -> u32
__aeabi_dsub 	Subtract, double. (u64,u64) -> u64
__aeabi_frsub 	Reverse subtract, float. (u32,u32) -> u32
__aeabi_drsub 	Reverse subtract, double. (u64,u64) -> u64
__aeabi_fmul 	Multiply, float. (u32,u32) -> u32
__aeabi_dmul 	Multiply, double. (u64,u64) -> u64
__aeabi_fdiv 	Divide, float. (u32,u32) -> u32
__aeabi_ddiv 	Divide, double. (u64,u64) -> u64

__aeabi_f2iz 	Convert float to int. (u32) -> i32
__aeabi_d2iz 	Convert double to int. (u64) -> i32
__aeabi_f2uiz 	Convert float to unsigned int. (u32) -> u32
__aeabi_d2uiz 	Convert double to unsigned. (u64) -> u32
__aeabi_f2lz 	Convert float to long long. (u32) -> i64
__aeabi_d2lz 	Convert double to long long. (u64) -> i64
__aeabi_f2ulz 	Convert float to unsigned long long. (u32) -> u64
__aeabi_d2ulz 	Convert double to unsigned long long. (u64) -> u64
__aeabi_i2f 	Convert int to float. (i32) -> u32
__aeabi_i2d 	Convert int to double. (i32) -> u64
__aeabi_ui2f 	Convert unsigned to float.  (u32) -> u32
__aeabi_ui2d 	Convert unsigned to double. (u32) -> u64
__aeabi_l2f 	Convert long long to float. (i64) -> u32
__aeabi_l2d 	Convert long long to double. (i64) -> u64
__aeabi_ul2f 	Convert unsigned long long to float. (u64) -> u32
__aeabi_ul2d 	Convert unsigned long long to double. (uc) -> u64
__aeabi_f2d 	Extend float to double. (u32) -> u64
__aeabi_d2f 	Truncate double to float. (u64) -> u32
__aeabi_f2h 	Truncate float to IEEE half-precision float. (u32) -> u16
__aeabi_d2h 	Truncate double to IEEE half-precision float. (u64) -> u16
__aeabi_h2f 	Convert IEEE half-precision float to float. (u16) -> u32
__aeabi_h2d 	Convert IEEE half-precision float to double. (u16) -> u64 

__aeabi_fcmpeq 	Equal, float. (u32,u32) -> int
__aeabi_dcmpeq 	Equal, double. (u64,u64) -> int
__aeabi_fcmplt 	Less than, float. (u32,u32) -> int
__aeabi_dcmplt 	Less than, double. (u64,u64) -> int
__aeabi_fcmple 	Less than or equal, float. (u32,u32) -> int
__aeabi_dcmple 	Less than, double. (u64,u64) -> int
__aeabi_fcmpgt 	Less than, float. (u32,u32) -> int
__aeabi_dcmpgt 	Less than, double. (u64,u64) -> int
__aeabi_fcmpge 	Less than, float. (u32,u32) -> int
__aeabi_dcmpge 	Less than, double. (u64,u64) -> int

__aeabi_idiv    Signed integer divide (i32, i32) -> i32
__aeabi_uidiv   Unsigned integer divide (u32, u32) -> u32

@9names 9names added the enhancement New feature or request label Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant