code wiki / (root) / nx_compile_x86.nx

nx_compile_x86.nx

buildroot/runtime/nx_compile_x86.nx

10178 B258 linesdepth 6pulls 18 transitivereach 0 importersview sourcekind tooltopic compile
docsdependenciesstructsconstsfunctions

about

nx_compile_x86.nx -- source-file driver for the NishiLang x86_64 backend. Reads .nx source on stdin (pre-expanded; imports already inlined), runs: lex_source -> parse_module -> opt_run (per function) -> x86ctx_emit_module and writes the AT&T x86_64 asm to stdout. The bash wrapper (bench/nx_compile_x86.sh) drives the source -> native ELF pipeline: nxc2.exe --target asm runtime/nx_compile_x86.nx (build driver) riscv64-as + ld -> nx_compile_x86.elf cat source.nx | qemu-riscv64-static nx_compile_x86.elf -> x86_64 asm on stdout gcc -nostdlib -static asm -o native.elf run natively Per cardinal feedback-no-nxc2-c-extension-only-nishilang-forward: this driver is the NishiLang counterpart of nxc2.exe's --target x86_64 path. No C-side modifications. nx_safety_envelope: intended_use: "Compile a .nx source (pre-import-expanded) to native x86_64 SysV asm via the IR-driven x86_64 backend." sil_target: SIL3 asil_target: QM dal_target: DAL B iec_62304_class: NONE evidence: [no_floating_point, bounded_stdin_read_per_jpl_rule_2, sealed_pipeline_verdict_codes, opt_optional_via_env] hazard_register: [bug-tape-source-exceeds-cap-silently-truncated, bug-tape-opcode-not-yet-wired-passes-through] residual_risk: "Hard 2 MiB source cap; pasting larger files truncates silently. Streaming follow-up when needed." verdict: NOT_YET_EVALUATED

dependencies 14 imports · 0 importers

nx_syscalls.nx nx_types.nx nx_lex_kinds.nx nx_outbuf.nx nx_ir.nx nx_tokenizer.nx nx_parse.nx nx_opt.nx nx_x86_64.nx nx_ir_dump.nx nx_compile_x86.nx

diagram shows first 10 each side; +4 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_types.nxnx_lex_kinds.nxnx_outbuf.nxnx_ir.nxnx_tokenizer.nxnx_parse.nxnx_opt.nxnx_x86_64.nxnx_ir_dump.nxnx_ir_validate.nxnx_x86_regalloc.nxnx_x86_64_ctx.nxnx_import.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap expand_ctx_new sys_mmap ↻ expand_imports expand_imports_inner nxcx_log sys_write nxcx_read_stdin sys_read nx_diag_set_source lex_source sys_mmap ↻ lexm_expand lexm_prescan lexm_isid is_alnum is_alpha is_digit lexm_body_end lexm_define lexm_init sys_mmap ↻ lexm_warn_body_too_long lexm_diag_cell lexm_emit_str lexm_emit_dec sys_write ↻ lexm_name_at lexm_body_at sys_mmap ↻ lexm_isid ↻ lexm_body_end ↻ lexm_for_expand lexm_isid ↻ lexm_body_end ↻ lexm_for_emit lexm_isid ↻ sys_mmap ↻ lexm_for_bound

structs

none

consts

56const NX_MAGIC_4096: i64 = 4096
57const NX_MAGIC_262144: i64 = 262144
59const NX_COMPILE_X86_SRC_CAP: i64 = 2097152 // 2 MiB
60const NX_COMPILE_X86_OUT_CAP: i64 = 16777216 // 16 MiB
61const NX_COMPILE_X86_EXPAND_CAP: i64 = 4194304 // 4 MiB import-expanded
63const NX_COMPILE_X86_OK: i64 = 0
64const NX_COMPILE_X86_EMPTY: i64 = 1
65const NX_COMPILE_X86_LEX_FAIL: i64 = 2
66const NX_COMPILE_X86_PARSE_FAIL: i64 = 3
67const NX_COMPILE_X86_NO_FN: i64 = 4

functions

69func nxcx_read_stdin(buf: *u8, cap: i64) -> i64
called by 1: main calls 1: sys_read
92func nxcx_log(msg: *u8, n: i64) -> i64
called by 1: main calls 1: sys_write
96func main(argc: i64, argv: *i64) -> i64