Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42993 )
Change subject: libpayload: Add simple 32.32 fixed-point math API ......................................................................
Patch Set 3:
(1 comment)
I would have always thought, the current devices come with corresponding instructions, and the compiler will create fast code (by for example providing lookup tables itself).
I am not aware of any any architecture that has hardware support for fixed-point math, and it's not available as a normal data type in C. For the sine stuff, x86 has hardware support for it but only for floats. (Now why we're not using floats for this in the first place is a good question, but not one I want to answer right now. Maybe we should just enable floats in firmware and everything would be fine, but it's something that would have to be investigated for each architecture individually. If anyone ever wants to do that, it would be easy to get rid of this again and rewrite my graphics stuff to use floats instead.)
Without hardware support sine functions are normally available in libm, so just like we write our own libc functions we have to write those ourselves as well. An advantage of that is that we can fine tune the size and precision of the table (e.g. don't need to waste 16KB pulling in a super precise table from some standard library that is way more than our use cases would need).
https://review.coreboot.org/c/coreboot/+/42993/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42993/2//COMMIT_MSG@14 PS2, Line 14:
It’d be great if you added concrete numbers, how much faster it is.
Done