Skip to main content

emit_map_kernel

Function emit_map_kernel 

Source
pub fn emit_map_kernel(body: &[MicroOp], plan: &MapPlan) -> Option<Vec<u8>>
Expand description

Emit a complete vectorized loop kernel for a recognized element-wise map, frame-ABI extern "C" fn(*mut i64) -> i64: it reads the induction i, limit n, and each array base pointer from their frame slots ([rdi + slot*8]), runs a 2-wide packed loop (i += 2) over full pairs, then a single-element scalar tail that REUSES the packed body (load one element with movsd so lane 1 is zero, run the same packed ops, store lane 0 with movsd — the junk lane is never stored and masked SSE faults are harmless), writes i = n back, and returns 0. Returns None (caller falls back to the scalar region) if the body needs more than 4 distinct arrays or 14 lane temps, or uses an op the kernel does not lower (e.g. LoadConst).

Register plan (all SysV caller-saved, no callee-save needed): rdi=frame, rsi=i, rdx=n, rcx=i*8 offset, rax=address scratch, r8..r11=array bases, xmm0..xmm13=lane temps, xmm15=arith scratch.