code wiki / (root) / simd.nx

simd.nx

buildroot/runtime/simd.nx

6623 B203 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic simd
docsdependenciesstructsconstsfunctions

about

simd.nx -- SIMD vector types + intrinsics (spec + soft-fallback). Target: 8-16x speedup on every numeric routine NishiLang ships (sha256, chacha20, base64, CRCs, etc.) via target-native vector instructions (AVX-512, RVV, NEON). Two-phase approach: Phase A (this file): define the SIMD type API + soft-fallback implementation. Every SIMD op is a regular i64 function that manipulates an "8x i64" packed buffer one lane at a time. No speedup yet, but callers can write SIMD-shaped code today. Phase B (riscv.nx backend work, pending): pattern-match these functions during codegen and replace with single vector instructions. Same source code compiles to 8-16x faster machine code. Why this order: API commitment FIRST means library authors can start writing SIMD-shaped routines now. The speedup lands later without breaking any caller. Invariants: V1 Vec64 is 8x i64 = 64 bytes = one AVX-512 register / two AVX2 regs / one RVV VLEN-512 register / four NEON regs. V2 Ops are pure functions of operand lanes -- no side effects, no aliasing concerns. V3 Memory ops (load/store) take aligned pointers; caller ensures 64-byte alignment for max throughput.

dependencies 1 imports · 0 importers

syscalls.nx simd.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main vec64_zero vec64_splat vec64_zero ↻ vec64_add vec64_zero ↻ vec64_hsum vec64_xor vec64_zero ↻

structs

37struct Vec64 {

consts

42const VEC64_BYTES: i64 = 64

functions

46func vec64_zero() -> *Vec64 {
55func vec64_splat(x: i64) -> *Vec64 {
called by 1: main calls 1: vec64_zero
64func vec64_load(p: *i64) -> *Vec64 {
calls 1: vec64_zero
72func vec64_store(v: *Vec64, p: *i64) -> i64 {
81func vec64_add(a: *Vec64, b: *Vec64) -> *Vec64 {
called by 1: main calls 1: vec64_zero
95func vec64_sub(a: *Vec64, b: *Vec64) -> *Vec64 {
calls 1: vec64_zero
109func vec64_mul(a: *Vec64, b: *Vec64) -> *Vec64 {
calls 1: vec64_zero
124func vec64_and(a: *Vec64, b: *Vec64) -> *Vec64 {
calls 1: vec64_zero
137func vec64_or(a: *Vec64, b: *Vec64) -> *Vec64 {
calls 1: vec64_zero
150func vec64_xor(a: *Vec64, b: *Vec64) -> *Vec64 {
called by 1: main calls 1: vec64_zero
164func vec64_shl(v: *Vec64, n: i64) -> *Vec64 {
calls 1: vec64_zero
181func vec64_hsum(v: *Vec64) -> i64 {
called by 1: main
186func main() -> i64 {