We're currently using libm to implement the missing compiler builtins for f32 and f64 primitives. The libm crate implements these builtins in Rust. While it provides a very workable springboard to get started quickly, it leaves a lot to be desired with fast math.
The N64 CPU supports many of these operations natively through the floating point unit, COP1. Here's a table summarizing the builtin to FPU instruction relationships:
| builtin |
FPU instruction |
fabs |
abs.d |
fabsf |
abs.s |
ceil |
ceil.l.d, cvt.d.l |
ceilf |
ceil.w.s, cvt.s.w |
floor |
floor.l.d, cvt.d.l |
floorf |
floor.w.s, cvt.s.w |
round |
round.l.d, cvt.d.l |
roundf |
round.w.s, cvt.s.w |
sqrt |
sqrt.d |
sqrtf |
sqrt.s |
trunc |
trunc.l.d, cvt.d.l |
truncf |
trunc.w.s, cvt.s.w |
Another alternative is using LLVM intrinsics from rustc. (How?)
We're currently using
libmto implement the missing compiler builtins forf32andf64primitives. Thelibmcrate implements these builtins in Rust. While it provides a very workable springboard to get started quickly, it leaves a lot to be desired with fast math.The N64 CPU supports many of these operations natively through the floating point unit, COP1. Here's a table summarizing the builtin to FPU instruction relationships:
fabsabs.dfabsfabs.sceilceil.l.d, cvt.d.lceilfceil.w.s, cvt.s.wfloorfloor.l.d, cvt.d.lfloorffloor.w.s, cvt.s.wroundround.l.d, cvt.d.lroundfround.w.s, cvt.s.wsqrtsqrt.dsqrtfsqrt.strunctrunc.l.d, cvt.d.ltruncftrunc.w.s, cvt.s.wAnother alternative is using LLVM intrinsics from rustc. (How?)