code wiki / _hdl_build / nx_riscv_loop.nx
nx_riscv_loop.nx
buildroot/runtime/_hdl_build/nx_riscv_loop.nx
about
nx_riscv_loop.nx -- SOVEREIGN RISC-V backend, RUNG 3: CONTROL FLOW. Now uses the GENERAL nx_riscv_lib for the
shared toolchain (encoders, lower with control flow, build_header, emulator) -- only the loop-IR + tests are local.
Lowers/runs: acc=0; i=1; L0: acc += i; i += 1; if i <= N goto L0; return acc (triangular sum 1..N)
T1 the lowered loop contains a real back-edge branch (0x63) and ends in ecall.
T2 run N=5 -> exit 15. T3 (teeth) re-lower N=10 -> exit 55.
expect_exit: 0 Sovereign: nx_riscv_lib (+ nx_syscalls).
dependencies 2 imports · 0 importers
imports: nx_riscv_lib.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 10 | func build_loop_ir(irop: *i64, irdst: *i64, irs1: *i64, irs2: *i64, irimm: *i64, N: i64) -> i64 |
| 22 | func gen_and_run(N: i64) -> i64 |
| 34 | func main() -> i64 |