code wiki / (root) / nx_nx86.nx

nx_nx86.nx

buildroot/runtime/nx_nx86.nx

15740 B323 linesdepth 7pulls 8 transitivereach 8 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_nx86.nx -- x86_64 assembly emitter from nx_nir IR, in NishiLang. FOURTH AND FINAL CONCRETE STEP of the nxc2 self-hosting pipeline (subset). Walks the IR produced by nx_nir and emits valid AT&T- syntax x86_64 assembly into a string buffer. Closes the loop: NishiLang source -> tokens -> AST -> IR -> asm. All four steps written in NishiLang. Compiler-piece self-hosting demonstrated. Minimum opcode support: NX_IR_CONST_I64 -> movabsq $val, %rax NX_IR_RETURN -> mov %rbp, %rsp; popq %rbp; ret (epilogue) Function emission: .globl main main: pushq %rbp movq %rsp, %rbp <body> <epilogue> Output: byte buffer with assembly text + length.

dependencies 2 imports · 8 importers

syscalls.nx nx_nir.nx nx_nx86.nx _a2a_selfhost_binop.nx _a2a_selfhost_let.nx _selfhost_compile_42.nx _selfhost_compile_binop.nx _selfhost_compile_if.nx _selfhost_compile_if_false.nx _selfhost_compile_let.nx nx_nx86_test.nx

imports: syscalls.nxnx_nir.nx

imported by: _a2a_selfhost_binop.nx_a2a_selfhost_let.nx_selfhost_compile_42.nx_selfhost_compile_binop.nx_selfhost_compile_if.nx_selfhost_compile_if_false.nx_selfhost_compile_let.nxnx_nx86_test.nx

structs

28struct NxAsmBuf

consts

none

functions

34func nx_asm_new(cap: i64) -> *NxAsmBuf
43func nx_asm_putc(a: *NxAsmBuf, c: i64) -> i64
50func nx_asm_puts(a: *NxAsmBuf, s: *u8, n: i64) -> i64
called by 1: nx_asm_emit_static calls 1: nx_asm_putc
60func nx_asm_put_i64(a: *NxAsmBuf, v: i64) -> i64
88func nx_asm_emit_static(a: *NxAsmBuf, b: *u8, n: i64) -> i64
calls 1: nx_asm_puts
94func nx_nx86_emit_instr(a: *NxAsmBuf, ins: *NxInstr) -> i64
276func nx_nx86_emit_func(a: *NxAsmBuf, src: *u8, f: *NxIrFunc) -> i64