code wiki / (root) / nx_x86_64_ctx.nx

nx_x86_64_ctx.nx

buildroot/runtime/nx_x86_64_ctx.nx

171467 B3382 linesdepth 4pulls 6 transitivereach 3 importersview sourcekind librarytopic x86
docsdependenciesstructsconstsfunctions

about

nx_x86_64_ctx.nx -- IR-driven codegen for x86_64 (session 6). Consumes a parsed/opt'd Function and emits AT&T x86_64 asm using the emit primitives in nx_x86_64.nx (sessions 1-5). Stack-machine layout per nxc2/x86_64.c: every SSA Value that needs storage gets a fixed [rbp - 8*slot] address. Constants are rematerialised at each use via movabsq; globals via leaq label(%rip). Per cardinal feedback-no-nxc2-c-extension-only-nishilang-forward: the C file stays the read-only comparator; new functionality lives here. nx_safety_envelope: intended_use: "IR-driven x86_64 SysV codegen. Walks a Function's blocks/instrs and emits asm via the sessions-1-5 emit primitives." sil_target: SIL3 (codegen correctness) asil_target: QM dal_target: DAL B iec_62304_class: NONE evidence: [no_floating_point_in_layout_logic, stack_machine_no_register_allocation, per_opcode_dispatch_explicit, 16_byte_frame_alignment_enforced, materialise_handles_const_global_spill] hazard_register: [bug-tape-slot-offset-vs-disp-sign, bug-tape-syscall-rax-overwritten-by-clobber, bug-tape-store-result-skipped-for-unused-value] residual_risk: "Subset coverage: arith/bitwise/cmp/branch/ call/load/store/GEP/syscall/alloca/copy. Float / SIMD / atomic / thread ops deferred to sessions 8+ (queued per migration index)." verdict: NOT_YET_EVALUATED

dependencies 5 imports · 3 importers

nx_syscalls.nx nx_types.nx nx_outbuf.nx nx_x86_64.nx nx_x86_regalloc.nx nx_x86_64_ctx.nx nx_compile_x86.nx nx_x86_64_ctx_test.nx nx_x86_64_module_test.nx

imports: nx_syscalls.nxnx_types.nxnx_outbuf.nxnx_x86_64.nxnx_x86_regalloc.nx

imported by: nx_compile_x86.nxnx_x86_64_ctx_test.nxnx_x86_64_module_test.nx

structs

51struct X86Ctx

consts

74const NX_X86CTX_BYTES: i64 = 144
79const X86_NEGCTL_G14_SIGNED: i64 = 0
85const X86_NEGCTL_LEA_WRONG_SCALE: i64 = 0
91const X86_NEGCTL_G21_COMMUTE_ANY: i64 = 0
99const X86_NEGCTL_G22_CMOV_INVERT: i64 = 0
100const X86_NEGCTL_G22_RIDE_ALWAYS: i64 = 0
107const X86_NEGCTL_G23_CMOV_INVERT: i64 = 0
1218const OP_TRUNC: i64 = 17
1219const OP_SEXT: i64 = 18
1220const OP_ZEXT: i64 = 19
1221const OP_BITCAST: i64 = 26

functions

129func _g1_is_rax(reg: *u8) -> i64
139func x86ctx_value_at(f: *Function, id: i64) -> *Value
144func x86ctx_block_at(f: *Function, id: i64) -> *BasicBlock
149func x86ctx_round_up_16(n: i64) -> i64
called by 1: x86ctx_init
161func x86ctx_value_base(c: *X86Ctx) -> i64
167func x86ctx_result_reg(c: *X86Ctx, v_id: i64) -> *u8
179func x86ctx_emit_cs_save(c: *X86Ctx) -> i64
195func x86ctx_emit_cs_restore(c: *X86Ctx) -> i64
219func x86ctx_sib_scratch() -> *i64
225func x86ctx_count_uses(c: *X86Ctx) -> i64
251func x86ctx_sib_probe(c: *X86Ctx, addr_id: i64, out: *i64) -> i64
310func x86ctx_sib_prepass(c: *X86Ctx) -> i64
349func x86ctx_emit_sib_mem(c: *X86Ctx, base: *u8, index: *u8, scale: i64) -> i64
366func x86ctx_init(f: *Function, o: *OutBuf) -> *X86Ctx
490func x86ctx_load_value(c: *X86Ctx, v_id: i64, reg: *u8) -> i64
571func x86ctx_store_result(c: *X86Ctx, v_id: i64, reg: *u8) -> i64
621func x86ctx_load_value_v(c: *X86Ctx, v_id: i64, reg: *u8) -> i64
711func x86ctx_home_name_or_null(c: *X86Ctx, v_id: i64) -> *u8
723func x86ctx_fwd_name_or_null(c: *X86Ctx, v_id: i64) -> *u8
733func x86ctx_op1_direct_ok(op: i64) -> i64
called by 1: x86ctx_emit_binop
746func x86ctx_log2_i64(v: i64) -> i64
called by 1: x86ctx_emit_binop
753func x86ctx_emit_binop(c: *X86Ctx, i: *Instr) -> i64
1223func x86ctx_emit_unop(c: *X86Ctx, i: *Instr) -> i64
1278func x86ctx_emit_atomic(c: *X86Ctx, i: *Instr) -> i64
1323func x86ctx_emit_adc_acc(c: *X86Ctx, i: *Instr) -> i64
1345func x86ctx_emit_cpuid_ebx(c: *X86Ctx, i: *Instr) -> i64
1361func x86ctx_emit_clone_label(c: *X86Ctx, rid: i64) -> i64
1370func x86ctx_emit_thread_clone(c: *X86Ctx, i: *Instr) -> i64
1407func x86ctx_cmp_to_cc(op: i64) -> i64
called by 1: x86ctx_emit_cmp
1417func x86ctx_emit_cmp(c: *X86Ctx, i: *Instr) -> i64
1521func x86ctx_emit_bb_label(c: *X86Ctx, bb_id: i64) -> i64
1530func x86ctx_emit_jmp_to_bb(c: *X86Ctx, bb_id: i64) -> i64
1537func x86ctx_emit_jcc_to_bb(c: *X86Ctx, cc: i64, bb_id: i64) -> i64
1548func x86ctx_cc_invert(cc: i64) -> i64
1565func x86ctx_emit_condjump(c: *X86Ctx, cc: i64, t: i64, fjb: i64) -> i64
1583func x86ctx_br_target_block(c: *X86Ctx, id: i64) -> *BasicBlock
calls 1: x86ctx_block_at
1593func x86ctx_emit_br(c: *X86Ctx, i: *Instr) -> i64
1601func x86ctx_emit_br_cond(c: *X86Ctx, i: *Instr) -> i64
1624func x86ctx_type_size(t: *Type) -> i64
1631func x86ctx_type_signed(t: *Type) -> i64
1650func x86ctx_type_sext(t: *Type) -> i64
called by 1: x86ctx_emit_load
1655func x86ctx_emit_load(c: *X86Ctx, i: *Instr) -> i64
1761func x86ctx_emit_store(c: *X86Ctx, i: *Instr) -> i64
1862func x86ctx_emit_gep(c: *X86Ctx, i: *Instr) -> i64
1903func x86ctx_rv64_to_x86_64_syscall(num: i64) -> i64
called by 1: x86ctx_emit_syscall
2020func x86ctx_emit_syscall(c: *X86Ctx, i: *Instr) -> i64
2062func x86ctx_emit_call(c: *X86Ctx, i: *Instr) -> i64
2146func x86ctx_emit_call_indirect(c: *X86Ctx, i: *Instr) -> i64
2223func x86ctx_emit_tail_call(c: *X86Ctx, i: *Instr) -> i64
2259func x86ctx_emit_copy(c: *X86Ctx, i: *Instr) -> i64
2267func x86ctx_emit_return(c: *X86Ctx, i: *Instr) -> i64
2286func x86ctx_emit_f32(c: *X86Ctx, i: *Instr) -> i64
2329func x86ctx_emit_f64(c: *X86Ctx, i: *Instr) -> i64
2375func x86ctx_emit_float(c: *X86Ctx, i: *Instr) -> i64
2392func x86ctx_emit_f32x4_dot(c: *X86Ctx, i: *Instr) -> i64
2433func x86ctx_emit_q5unpack32(c: *X86Ctx, i: *Instr) -> i64
2491func x86ctx_emit_q8row_label(c: *X86Ctx, rid: i64) -> i64
2508func x86ctx_emit_q8rowdot(c: *X86Ctx, i: *Instr) -> i64
2556func x86ctx_emit_i8fma32(c: *X86Ctx, i: *Instr) -> i64
2576func x86ctx_emit_i8dot32a(c: *X86Ctx, i: *Instr) -> i64
2611func x86ctx_emit_i8dot32(c: *X86Ctx, i: *Instr) -> i64
2643func x86ctx_emit_f32x8_dot(c: *X86Ctx, i: *Instr) -> i64
2671func x86ctx_emit_f32x8_fma(c: *X86Ctx, i: *Instr) -> i64
2684func x86ctx_emit_f32x8_hsum(c: *X86Ctx, i: *Instr) -> i64
2708func x86ctx_emit_i16x16_madd(c: *X86Ctx, i: *Instr) -> i64
2725func x86ctx_emit_aesni(c: *X86Ctx, i: *Instr) -> i64
2753func x86ctx_emit_palignr(c: *X86Ctx, dst: i64, src: i64, imm: i64) -> i64
2770func x86ctx_emit_sha256_ni(c: *X86Ctx, i: *Instr) -> i64
2845func x86ctx_emit_sha_paddd(c: *X86Ctx, dst: i64, src: i64) -> i64
2850func x86ctx_emit_sha_movdqa(c: *X86Ctx, dst: i64, src: i64) -> i64
2855func x86ctx_emit_sha_msg1(c: *X86Ctx, src: i64, dst: i64) -> i64
2860func x86ctx_emit_sha_msg2(c: *X86Ctx, src: i64, dst: i64) -> i64
2873func x86ctx_emit_clmul(c: *X86Ctx, i: *Instr, imm: i64) -> i64
2899func x86ctx_mul256_reg(k: i64) -> *u8
2909func x86ctx_emit_mul256_wide(c: *X86Ctx, i: *Instr) -> i64
2989func x86ctx_emit_instr(c: *X86Ctx, i: *Instr) -> i64
3107func x86ctx_emit_param_prologue(c: *X86Ctx) -> i64
3141func x86ctx_emit_block(c: *X86Ctx, bb: *BasicBlock) -> i64
3161func x86ctx_emit_function(f: *Function, o: *OutBuf) -> i64
3236func x86ctx_emit_module_globals(m: *Module, o: *OutBuf) -> i64
3335func x86ctx_emit_module(m: *Module, o: *OutBuf) -> i64