2026-04-16 16:14 UTC
In a perfect world, we could write utility functions (and types, e.g. LookaheadBuffer or Base32Block) once across a set of SIMD feature sets, write a high-level function that ties them all together, and make copies of that function instantiated for different SIMD feature sets. Everything can be inlined into those copies of the top-level function, but not into their callers. And at any level, you can examine the current SIMD feature set and change the implementation in non-trivial ways (e.g. to use PSHUFB!).
Replies (1)
-
@bal4e@tech.lgbt 2026-04-16 16:15
A silly but straightforward way to get there would be: put that function in its own Rust library, compile it with all the different feature sets you want, link to the resulting binaries, then generate an ifunc-style wrapper. You could generate dylibs and only load the needed ones; you could even merge dylibs for the same feature set across different functions. This lets you use Rust's existing cfg machinery (plus cfg_select!).