Skip to main content

generate_dispatcher

Function generate_dispatcher 

Source
pub fn generate_dispatcher(
    config: DispatcherConfig,
) -> Result<TokenStream, Error>
Expand description

Generate a cached runtime ISA dispatcher TokenStream.

The emitted code:

  1. Declares ISA constants (only once per invocation; the caller is responsible for deduplication if multiple sizes share a module).
  2. Declares a static DETECTED_ISA_{size}_{ty}: AtomicU8.
  3. Emits a private detect_isa_{size}_{ty}() -> u8 probe function.
  4. Emits a public codelet_simd_{size}_cached_{ty}(data, sign) dispatcher.

The dispatcher delegates to the same arch-specific inner functions that the basic (uncached) dispatcher in super uses, following the exact same naming convention: codelet_simd_{size}_{isa}_{ty}.

ยงErrors

Returns syn::Error when config.size is not one of 2, 4, 8, or 16.