Skip to content

Commit 7bd1072

Browse files
committed
simd: generator doc says what it emits (NEON per-quad intrinsics); probe fns crate-private
Two CodeRabbit nits on #306. The generator's module doc still described the NEON output as "plain `u32` for NEON's per-lane loop" — the shape that scalarised and was replaced by per-128-bit-quad `vandq/vorrq/veorq/vbicq` bodies. `safe_intrinsic_probe`'s functions are not an API and are never called (the observable is whether `cargo check` accepts each arm), so they are `pub(crate)` with the dead-code lint silenced rather than given doc examples that would have to be cfg-gated per architecture. `--check` is still green; the probe still reproduces E0133 on the C arm. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
1 parent 0458e4f commit 7bd1072

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

tools/gen_ternlog_bodies.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
an 8-bit truth table into a minimal Boolean DAG, checks it against a
1313
bit-serial reference for all 256 tables, and then PRINTS each backend's body
1414
in that backend's own vocabulary (operator traits on the array-backed lane
15-
types; plain `u32` for NEON's per-lane loop; `v128_*` intrinsics for WASM).
15+
types; `vandq/vorrq/veorq/vbicq_u{32,64}` NEON intrinsics per 128-bit quad —
16+
NOT a per-lane `u32` loop, which LLVM scalarised (536 scalar / 4 vector ops
17+
measured); `v128_*` intrinsics for WASM).
1618
The emitted text is pasted into the backend file between GEN markers by
1719
`--apply`; it is committed source, and the generator is its provenance.
1820
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
#![forbid(unsafe_code)]
22
//! Which SIMD intrinsics are callable from SAFE code on rustc 1.98.1, per arch.
3+
//!
4+
//! Nothing here is an API and nothing calls these functions: the OBSERVABLE
5+
//! is whether `cargo check` accepts or rejects each arm (E0133), so they are
6+
//! crate-private and the dead-code lint is silenced rather than satisfied by
7+
//! fake callers or doc examples that would have to be `#[cfg]`-gated per arch.
8+
#![allow(dead_code)]
39
#[cfg(target_arch = "aarch64")]
410
pub mod a64 {
511
use core::arch::aarch64::*;
612
/// A: plain fn, baseline-feature intrinsic (neon).
713
#[cfg(probe_a)]
8-
pub fn plain_neon(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { vandq_u32(a, b) }
14+
pub(crate) fn plain_neon(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { vandq_u32(a, b) }
915
/// B: annotated fn, same call.
1016
#[target_feature(enable = "neon")]
11-
pub fn annotated_neon(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { vandq_u32(a, b) }
17+
pub(crate) fn annotated_neon(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { vandq_u32(a, b) }
1218
/// C: plain fn calling the annotated SAFE fn.
1319
#[cfg(probe_c)]
14-
pub fn plain_calls_annotated(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { annotated_neon(a, b) }
20+
pub(crate) fn plain_calls_annotated(a: uint32x4_t, b: uint32x4_t) -> uint32x4_t { annotated_neon(a, b) }
1521
}
1622
#[cfg(target_arch = "x86_64")]
1723
pub mod x86 {
1824
use core::arch::x86_64::*;
1925
/// A: plain fn, sse2 (baseline for x86_64).
2026
#[cfg(probe_a)]
21-
pub fn plain_sse2(a: __m128i, b: __m128i) -> __m128i { _mm_and_si128(a, b) }
27+
pub(crate) fn plain_sse2(a: __m128i, b: __m128i) -> __m128i { _mm_and_si128(a, b) }
2228
/// A2: plain fn, avx2 (baseline only under -Ctarget-cpu=x86-64-v3).
2329
#[cfg(probe_a2)]
24-
pub fn plain_avx2(a: __m256i, b: __m256i) -> __m256i { _mm256_and_si256(a, b) }
30+
pub(crate) fn plain_avx2(a: __m256i, b: __m256i) -> __m256i { _mm256_and_si256(a, b) }
2531
/// A3: plain fn, avx512f ternarylogic (baseline only under x86-64-v4).
2632
#[cfg(probe_a3)]
27-
pub fn plain_avx512(a: __m512i, b: __m512i, c: __m512i) -> __m512i { _mm512_ternarylogic_epi64::<0x96>(a, b, c) }
33+
pub(crate) fn plain_avx512(a: __m512i, b: __m512i, c: __m512i) -> __m512i { _mm512_ternarylogic_epi64::<0x96>(a, b, c) }
2834
/// B: annotated fn.
2935
#[target_feature(enable = "avx2")]
30-
pub fn annotated_avx2(a: __m256i, b: __m256i) -> __m256i { _mm256_and_si256(a, b) }
36+
pub(crate) fn annotated_avx2(a: __m256i, b: __m256i) -> __m256i { _mm256_and_si256(a, b) }
3137
/// C: plain fn calling annotated safe fn.
3238
#[cfg(probe_c)]
33-
pub fn plain_calls_annotated(a: __m256i, b: __m256i) -> __m256i { annotated_avx2(a, b) }
39+
pub(crate) fn plain_calls_annotated(a: __m256i, b: __m256i) -> __m256i { annotated_avx2(a, b) }
3440
}
3541
#[cfg(target_arch = "wasm32")]
3642
pub mod w {
3743
use core::arch::wasm32::*;
3844
/// A: plain fn, simd128 intrinsic.
3945
#[cfg(probe_a)]
40-
pub fn plain_wasm(a: v128, b: v128) -> v128 { v128_and(a, b) }
46+
pub(crate) fn plain_wasm(a: v128, b: v128) -> v128 { v128_and(a, b) }
4147
}

0 commit comments

Comments
 (0)