nx_x86_64_ctx.nx
buildroot/runtime/nx_x86_64_ctx.nx
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
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
| 51 | struct X86Ctx |
consts
| 74 | const NX_X86CTX_BYTES: i64 = 144 |
| 79 | const X86_NEGCTL_G14_SIGNED: i64 = 0 |
| 85 | const X86_NEGCTL_LEA_WRONG_SCALE: i64 = 0 |
| 91 | const X86_NEGCTL_G21_COMMUTE_ANY: i64 = 0 |
| 99 | const X86_NEGCTL_G22_CMOV_INVERT: i64 = 0 |
| 100 | const X86_NEGCTL_G22_RIDE_ALWAYS: i64 = 0 |
| 107 | const X86_NEGCTL_G23_CMOV_INVERT: i64 = 0 |
| 1218 | const OP_TRUNC: i64 = 17 |
| 1219 | const OP_SEXT: i64 = 18 |
| 1220 | const OP_ZEXT: i64 = 19 |
| 1221 | const OP_BITCAST: i64 = 26 |
functions
| 129 | func _g1_is_rax(reg: *u8) -> i64 |
| 139 | func x86ctx_value_at(f: *Function, id: i64) -> *Value |
| 144 | func x86ctx_block_at(f: *Function, id: i64) -> *BasicBlock |
| 149 | func x86ctx_round_up_16(n: i64) -> i64 called by 1: x86ctx_init |
| 161 | func x86ctx_value_base(c: *X86Ctx) -> i64 |
| 167 | func x86ctx_result_reg(c: *X86Ctx, v_id: i64) -> *u8 |
| 179 | func x86ctx_emit_cs_save(c: *X86Ctx) -> i64 |
| 195 | func x86ctx_emit_cs_restore(c: *X86Ctx) -> i64 |
| 219 | func x86ctx_sib_scratch() -> *i64 |
| 225 | func x86ctx_count_uses(c: *X86Ctx) -> i64 |
| 251 | func x86ctx_sib_probe(c: *X86Ctx, addr_id: i64, out: *i64) -> i64 |
| 310 | func x86ctx_sib_prepass(c: *X86Ctx) -> i64 |
| 349 | func x86ctx_emit_sib_mem(c: *X86Ctx, base: *u8, index: *u8, scale: i64) -> i64 |
| 366 | func x86ctx_init(f: *Function, o: *OutBuf) -> *X86Ctx |
| 490 | func x86ctx_load_value(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 |
| 571 | func x86ctx_store_result(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 |
| 621 | func x86ctx_load_value_v(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 |
| 711 | func x86ctx_home_name_or_null(c: *X86Ctx, v_id: i64) -> *u8 called by 4: x86ctx_emit_binopx86ctx_emit_cmpx86ctx_emit_loadx86ctx_emit_store calls 1: x86_home_reg_name |
| 723 | func x86ctx_fwd_name_or_null(c: *X86Ctx, v_id: i64) -> *u8 called by 4: x86ctx_emit_binopx86ctx_emit_cmpx86ctx_emit_loadx86ctx_emit_store calls 1: x86_home_reg_name |
| 733 | func x86ctx_op1_direct_ok(op: i64) -> i64 called by 1: x86ctx_emit_binop |
| 746 | func x86ctx_log2_i64(v: i64) -> i64 called by 1: x86ctx_emit_binop |
| 753 | func x86ctx_emit_binop(c: *X86Ctx, i: *Instr) -> i64 |
| 1223 | func x86ctx_emit_unop(c: *X86Ctx, i: *Instr) -> i64 |
| 1278 | func x86ctx_emit_atomic(c: *X86Ctx, i: *Instr) -> i64 |
| 1323 | func x86ctx_emit_adc_acc(c: *X86Ctx, i: *Instr) -> i64 |
| 1345 | func x86ctx_emit_cpuid_ebx(c: *X86Ctx, i: *Instr) -> i64 |
| 1361 | func x86ctx_emit_clone_label(c: *X86Ctx, rid: i64) -> i64 |
| 1370 | func x86ctx_emit_thread_clone(c: *X86Ctx, i: *Instr) -> i64 |
| 1407 | func x86ctx_cmp_to_cc(op: i64) -> i64 called by 1: x86ctx_emit_cmp |
| 1417 | func x86ctx_emit_cmp(c: *X86Ctx, i: *Instr) -> i64 |
| 1521 | func x86ctx_emit_bb_label(c: *X86Ctx, bb_id: i64) -> i64 |
| 1530 | func x86ctx_emit_jmp_to_bb(c: *X86Ctx, bb_id: i64) -> i64 |
| 1537 | func x86ctx_emit_jcc_to_bb(c: *X86Ctx, cc: i64, bb_id: i64) -> i64 |
| 1548 | func x86ctx_cc_invert(cc: i64) -> i64 called by 1: x86ctx_emit_condjump |
| 1565 | func x86ctx_emit_condjump(c: *X86Ctx, cc: i64, t: i64, fjb: i64) -> i64 called by 1: x86ctx_emit_br_cond calls 3: x86ctx_emit_jcc_to_bbx86ctx_cc_invertx86ctx_emit_jmp_to_bb |
| 1583 | func x86ctx_br_target_block(c: *X86Ctx, id: i64) -> *BasicBlock calls 1: x86ctx_block_at |
| 1593 | func x86ctx_emit_br(c: *X86Ctx, i: *Instr) -> i64 |
| 1601 | func x86ctx_emit_br_cond(c: *X86Ctx, i: *Instr) -> i64 |
| 1624 | func x86ctx_type_size(t: *Type) -> i64 |
| 1631 | func x86ctx_type_signed(t: *Type) -> i64 |
| 1650 | func x86ctx_type_sext(t: *Type) -> i64 called by 1: x86ctx_emit_load |
| 1655 | func x86ctx_emit_load(c: *X86Ctx, i: *Instr) -> i64 |
| 1761 | func x86ctx_emit_store(c: *X86Ctx, i: *Instr) -> i64 |
| 1862 | func x86ctx_emit_gep(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 4: x86ctx_load_valuex86ctx_load_value_vx86_emit_gep_addx86ctx_store_result |
| 1903 | func x86ctx_rv64_to_x86_64_syscall(num: i64) -> i64 called by 1: x86ctx_emit_syscall |
| 2020 | func x86ctx_emit_syscall(c: *X86Ctx, i: *Instr) -> i64 |
| 2062 | func x86ctx_emit_call(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 5: x86ctx_load_value_vout_strx86_emit_call_labelx86ctx_store_resultout_i64 |
| 2146 | func x86ctx_emit_call_indirect(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 5: out_strx86ctx_load_value_vx86_emit_call_indirectx86ctx_store_resultout_i64 |
| 2223 | func x86ctx_emit_tail_call(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 4: out_strx86ctx_load_value_vx86ctx_emit_cs_restorex86_emit_tail_call_label |
| 2259 | func x86ctx_emit_copy(c: *X86Ctx, i: *Instr) -> i64 |
| 2267 | func x86ctx_emit_return(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 4: x86ctx_load_value_vx86_emit_movabsqx86ctx_emit_cs_restorex86_emit_epilogue |
| 2286 | func x86ctx_emit_f32(c: *X86Ctx, i: *Instr) -> i64 |
| 2329 | func x86ctx_emit_f64(c: *X86Ctx, i: *Instr) -> i64 |
| 2375 | func x86ctx_emit_float(c: *X86Ctx, i: *Instr) -> i64 |
| 2392 | func x86ctx_emit_f32x4_dot(c: *X86Ctx, i: *Instr) -> i64 |
| 2433 | func x86ctx_emit_q5unpack32(c: *X86Ctx, i: *Instr) -> i64 |
| 2491 | func x86ctx_emit_q8row_label(c: *X86Ctx, rid: i64) -> i64 |
| 2508 | func x86ctx_emit_q8rowdot(c: *X86Ctx, i: *Instr) -> i64 |
| 2556 | func x86ctx_emit_i8fma32(c: *X86Ctx, i: *Instr) -> i64 |
| 2576 | func x86ctx_emit_i8dot32a(c: *X86Ctx, i: *Instr) -> i64 |
| 2611 | func x86ctx_emit_i8dot32(c: *X86Ctx, i: *Instr) -> i64 |
| 2643 | func x86ctx_emit_f32x8_dot(c: *X86Ctx, i: *Instr) -> i64 |
| 2671 | func x86ctx_emit_f32x8_fma(c: *X86Ctx, i: *Instr) -> i64 |
| 2684 | func x86ctx_emit_f32x8_hsum(c: *X86Ctx, i: *Instr) -> i64 |
| 2708 | func x86ctx_emit_i16x16_madd(c: *X86Ctx, i: *Instr) -> i64 |
| 2725 | func x86ctx_emit_aesni(c: *X86Ctx, i: *Instr) -> i64 |
| 2753 | func x86ctx_emit_palignr(c: *X86Ctx, dst: i64, src: i64, imm: i64) -> i64 |
| 2770 | func x86ctx_emit_sha256_ni(c: *X86Ctx, i: *Instr) -> i64 |
| 2845 | func x86ctx_emit_sha_paddd(c: *X86Ctx, dst: i64, src: i64) -> i64 |
| 2850 | func x86ctx_emit_sha_movdqa(c: *X86Ctx, dst: i64, src: i64) -> i64 |
| 2855 | func x86ctx_emit_sha_msg1(c: *X86Ctx, src: i64, dst: i64) -> i64 |
| 2860 | func x86ctx_emit_sha_msg2(c: *X86Ctx, src: i64, dst: i64) -> i64 |
| 2873 | func x86ctx_emit_clmul(c: *X86Ctx, i: *Instr, imm: i64) -> i64 |
| 2899 | func x86ctx_mul256_reg(k: i64) -> *u8 called by 1: x86ctx_emit_mul256_wide |
| 2909 | func x86ctx_emit_mul256_wide(c: *X86Ctx, i: *Instr) -> i64 called by 1: x86ctx_emit_instr calls 5: x86ctx_load_value_vout_strout_i64x86ctx_mul256_regx86ctx_store_result |
| 2989 | func x86ctx_emit_instr(c: *X86Ctx, i: *Instr) -> i64 |
| 3107 | func x86ctx_emit_param_prologue(c: *X86Ctx) -> i64 called by 1: x86ctx_emit_function calls 5: x86ctx_value_atx86_arg_reg_namex86ctx_store_resultout_strout_i64 |
| 3141 | func x86ctx_emit_block(c: *X86Ctx, bb: *BasicBlock) -> i64 |
| 3161 | func x86ctx_emit_function(f: *Function, o: *OutBuf) -> i64 |
| 3236 | func x86ctx_emit_module_globals(m: *Module, o: *OutBuf) -> i64 |
| 3335 | func x86ctx_emit_module(m: *Module, o: *OutBuf) -> i64 |