code wiki / _hdl_build / nx_riscv_codegen.nx

nx_riscv_codegen.nx

buildroot/runtime/_hdl_build/nx_riscv_codegen.nx

4433 B66 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tooltopic riscv
docsdependenciesstructsconstsfunctions

about

nx_riscv_codegen.nx -- SOVEREIGN RISC-V backend, RUNG 4: IR -> RISC-V CODEGEN. Now on the GENERAL nx_riscv_lib (shared encoders, lower w/ regalloc+instr-sel, build_header, emulator) -- only the qmul IR + tests are local. Lowers qmul(2.0,3.0)=(a*b)>>16 then >>16 (integer part), runs it; retargets when the IR input changes. T1 lowers to 8 words ending in ecall. T2 run -> exit 6 (2.0*3.0 int part). T3 (teeth) input 2.0->4.0 -> exit 12. expect_exit: 0 Sovereign: nx_riscv_lib (+ nx_syscalls).

dependencies 2 imports · 0 importers

nx_riscv_lib.nx nx_syscalls.nx nx_riscv_codegen.nx

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

main g_puts sys_write sys_mmap lower put32 enc_u enc_i enc_r enc_b g_pn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap ck g_puts ↻ gen sys_mmap ↻ lower ↻ build_header put32 ↻ put64 sys_openat_wr sys_write ↻ sys_close run sys_mmap ↻ memrd32 sext12 sext32 memrd64 memwr64 sext_b sys_openat_append sys_write ↻ sys_close ↻ sys_exit

structs

none

consts

8const K_MAGIC_196608: i64 = 196608
9const K_MAGIC_131072: i64 = 131072
10const K_MAGIC_262144: i64 = 262144

functions

12func gen(irimm0: i64) -> i64 { // build the qmul IR with input-a const = irimm0, lower + run, return exit
30func main() -> i64