Skip to content

refactor(simd): Phase 4 — extract scalar backend to src/simd_scalar.rs#174

Merged
AdaWorldAPI merged 2 commits into
masterfrom
claude/pr-x-phase4-scalar-honesty
May 20, 2026
Merged

refactor(simd): Phase 4 — extract scalar backend to src/simd_scalar.rs#174
AdaWorldAPI merged 2 commits into
masterfrom
claude/pr-x-phase4-scalar-honesty

Conversation

@AdaWorldAPI
Copy link
Copy Markdown
Owner

Summary

Phase 4 of the integration plan in .claude/knowledge/simd-dispatch-architecture.md.

src/simd.rs shrinks from 1956 → 685 LoC by lifting the 1271-line inline pub(crate) mod scalar { ... } block out into its own file src/simd_scalar.rs.

The mod is declared from simd.rs with #[path = "simd_scalar.rs"] pub(crate) mod scalar; so the internal module name stays scalar and every pub use scalar::{...} re-export keeps resolving unchanged.

Behavior is byte-identical — zero semantic edits, just outdented one level and wrapped with a module-level doc comment explaining the file's role as the non-x86_64 fallback backend.

Why now

The dispatcher should read as a re-export catalog with cfg arms, not 1.6k LoC of macro expansions. Future tweaks to the scalar backend now live in a file named for what they are.

What moved

  • impl_float_type! / impl_int_type! macros
  • 11 type instantiations (F32x16, F64x8, F32x8, F64x4, U8x64, I32x16, I64x8, U16x32, U32x16, U64x8, plus the I8/I16 set)
  • Extra impl blocks for U8x64 byte ops (palette codec, nibble, byte scan), I32x16 math, I64x8 math, F32x16 / F64x8 bit casts, U16x32 widen/pack, U32x16 / U64x8 shifts, U8x64 × U8x64 multiply
  • Lowercase type aliases (f32x16 = F32x16, etc.)

Test plan

  • cargo build --target=thumbv6m-none-eabi — non-x86 path resolves scalar mod via #[path]
  • cargo build on x86_64 — mod scalar gated out, no impact
  • CI green — no behavior change

Generated by Claude Code

claude added 2 commits May 20, 2026 13:18
Phase 4 of the integration plan in `.claude/knowledge/
simd-dispatch-architecture.md`.

simd.rs shrinks from 1956 → 685 LoC by lifting the inline 1271-line
`pub(crate) mod scalar { ... }` block (impl_float_type! / impl_int_type!
macros + 11 type instantiations + 30+ extra impl blocks for U8x64 /
I8x*/I16x* / U16x32 / I32x16 / I64x8 / F32x16 / F64x8 / U32x16 / U64x8)
out into its own file `src/simd_scalar.rs`. Declared from `simd.rs`
with `#[path = "simd_scalar.rs"] pub(crate) mod scalar;` so the
internal module name stays `scalar` — every `pub use scalar::{...}`
re-export in `simd.rs` continues to resolve unchanged.

Behavior is byte-identical. The file move is mechanical: zero semantic
edits, just outdented one level and wrapped with a module-level doc
comment explaining its role as the non-x86_64 fallback backend.

Why now: the dispatcher should read as a re-export catalog with cfg
arms, not 1.6k LoC of macro expansions. Future tweaks to the scalar
backend (TD-SIMD-5 in the architecture doc) now live in a file named
for what they are.
`use core::ops::{...}` import list was wrapped at a slightly different
column than rustfmt prefers (post-extraction reflow). One-line fmt diff.
@AdaWorldAPI AdaWorldAPI force-pushed the claude/pr-x-phase4-scalar-honesty branch from 15945b6 to e0c99a3 Compare May 20, 2026 13:18
@AdaWorldAPI AdaWorldAPI merged commit b4190e3 into master May 20, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants