#[rite]Expand description
Annotate inner SIMD helpers called from #[arcane] functions.
Unlike #[arcane], which creates an inner #[target_feature] function behind
a safe boundary, #[rite] adds #[target_feature] and #[inline] directly.
LLVM inlines it into any caller with matching features — no boundary crossing.
§Three Modes
Token-based: Reads the token type from the function signature.
#[rite]
fn helper(_: X64V3Token, v: __m256) -> __m256 { _mm256_add_ps(v, v) }Tier-based: Specify the tier name directly, no token parameter needed.
#[rite(v3)]
fn helper(v: __m256) -> __m256 { _mm256_add_ps(v, v) }Both produce identical code. The token form can be easier to remember if you already have the token in scope.
Multi-tier: Specify multiple tiers to generate suffixed variants.
#[rite(v3, v4)]
fn process(data: &[f32; 4]) -> f32 { data.iter().sum() }
// Generates: process_v3() and process_v4()Each variant gets its own #[target_feature] and #[cfg(target_arch)].
Since Rust 1.85, calling these from a matching #[arcane] or #[rite]
context is safe — no unsafe needed when the caller has matching or
superset features.
§Safety
#[rite] functions can only be safely called from contexts where the
required CPU features are enabled:
- From within
#[arcane]functions with matching/superset tokens - From within other
#[rite]functions with matching/superset tokens - From code compiled with
-Ctarget-cputhat enables the features
Calling from other contexts requires unsafe and the caller must ensure
the CPU supports the required features.
§Cross-Architecture Behavior
Like #[arcane], defaults to cfg-out (no function on wrong arch).
Use #[rite(stub)] to generate an unreachable stub instead.
§Options
| Option | Effect |
|---|---|
| tier name(s) | v3, neon, etc. One = single function; multiple = suffixed variants |
stub | Generate unreachable!() stub on wrong architecture |
import_intrinsics | Auto-import archmage::intrinsics::{arch}::* (includes safe memory ops) |
import_magetypes | Auto-import magetypes::simd::{ns}::* and magetypes::simd::backends::* |
See #[arcane] docs for the full namespace mapping table.
§Comparison with #[arcane]
| Aspect | #[arcane] | #[rite] |
|---|---|---|
| Creates wrapper | Yes | No |
| Entry point | Yes | No |
| Inlines into caller | No (barrier) | Yes |
| Safe to call anywhere | Yes (with token) | Only from feature-enabled context |
| Multi-tier variants | No | Yes (#[rite(v3, v4, neon)]) |
stub param | Yes | Yes |
import_intrinsics | Yes | Yes |
import_magetypes | Yes | Yes |