Skip to content

libm optimizations #41

@parasyte

Description

@parasyte

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?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions