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 6 imports · 4 importers
imports: nx_syscalls.nxnx_types.nxnx_linemap.nxnx_outbuf.nxnx_x86_64.nxnx_x86_regalloc.nx
imported by: nx_compile_field_candidate_t280.nxnx_compile_x86.nxnx_x86_64_ctx_test.nxnx_x86_64_module_test.nx
structs
| 54 | struct X86Ctx { |
consts
| 77 | const NX_X86CTX_BYTES: i64 = 144 |
| 82 | const X86_NEGCTL_G14_SIGNED: i64 = 0 |
| 88 | const X86_NEGCTL_LEA_WRONG_SCALE: i64 = 0 |
| 94 | const X86_NEGCTL_G21_COMMUTE_ANY: i64 = 0 |
| 102 | const X86_NEGCTL_G22_CMOV_INVERT: i64 = 0 |
| 103 | const X86_NEGCTL_G22_RIDE_ALWAYS: i64 = 0 |
| 110 | const X86_NEGCTL_G23_CMOV_INVERT: i64 = 0 |
| 119 | const X86_NEGCTL_F64_CMP_RAW: i64 = 0 |
| 1323 | const OP_TRUNC: i64 = 17 |
| 1324 | const OP_SEXT: i64 = 18 |
| 1325 | const OP_ZEXT: i64 = 19 |
| 1326 | const OP_BITCAST: i64 = 26 |
functions
| 145 | func _g1_is_rax(reg: *u8) -> i64 { |
| 155 | func x86ctx_value_at(f: *Function, id: i64) -> *Value { |
| 160 | func x86ctx_block_at(f: *Function, id: i64) -> *BasicBlock { |
| 165 | func x86ctx_round_up_16(n: i64) -> i64 { |
| 177 | func x86ctx_value_base(c: *X86Ctx) -> i64 { |
| 183 | func x86ctx_result_reg(c: *X86Ctx, v_id: i64) -> *u8 { |
| 195 | func x86ctx_emit_cs_save(c: *X86Ctx) -> i64 { |
| 211 | func x86ctx_emit_cs_restore(c: *X86Ctx) -> i64 { |
| 235 | func x86ctx_sib_scratch() -> *i64 { |
| 241 | func x86ctx_count_uses(c: *X86Ctx) -> i64 { |
| 267 | func x86ctx_sib_probe(c: *X86Ctx, addr_id: i64, out: *i64) -> i64 { |
| 326 | func x86ctx_sib_prepass(c: *X86Ctx) -> i64 { |
| 365 | func x86ctx_emit_sib_mem(c: *X86Ctx, base: *u8, index: *u8, scale: i64) -> i64 { |
| 382 | func x86ctx_init(f: *Function, o: *OutBuf) -> *X86Ctx { |
| 506 | func x86ctx_load_value(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 { |
| 587 | func x86ctx_store_result(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 { |
| 637 | func x86ctx_load_value_v(c: *X86Ctx, v_id: i64, reg: *u8) -> i64 { |
| 727 | func x86ctx_home_name_or_null(c: *X86Ctx, v_id: i64) -> *u8 { |
| 739 | func x86ctx_fwd_name_or_null(c: *X86Ctx, v_id: i64) -> *u8 { |
| 755 | func x86_use_regalloc(c: *X86Ctx, v_id: i64) -> *u8 { |
| 764 | func x86ctx_op1_direct_ok(op: i64) -> i64 { |
| 777 | func x86ctx_log2_i64(v: i64) -> i64 { |
| 797 | func x86ctx_ovf_pair(n: *Instr, x: i64, y: i64) -> i64 { |
| 802 | func x86ctx_ovf_single(c: *X86Ctx, v: i64) -> i64 { |
| 808 | func x86ctx_ovf_fuse(c: *X86Ctx, i: *Instr) -> i64 { |
| 858 | func x86ctx_emit_binop(c: *X86Ctx, i: *Instr) -> i64 { |
| 1328 | func x86ctx_emit_unop(c: *X86Ctx, i: *Instr) -> i64 { |
| 1383 | func x86ctx_emit_atomic(c: *X86Ctx, i: *Instr) -> i64 { |
| 1428 | func x86ctx_emit_adc_acc(c: *X86Ctx, i: *Instr) -> i64 { |
| 1450 | func x86ctx_emit_cpuid_ebx(c: *X86Ctx, i: *Instr) -> i64 { |
| 1466 | func x86ctx_emit_clone_label(c: *X86Ctx, rid: i64) -> i64 { |
| 1475 | func x86ctx_emit_thread_clone(c: *X86Ctx, i: *Instr) -> i64 { |
| 1556 | func x86ctx_emit_f64_ordkey(c: *X86Ctx, reg: *u8) -> i64 { |
| 1581 | func x86ctx_cmp_f64_operands(c: *X86Ctx, i: *Instr) -> i64 { |
| 1586 | func x86ctx_emit_f64_nan_label(c: *X86Ctx, i: *Instr, tag: *u8) -> i64 { |
| 1597 | func x86ctx_emit_f64_nan_guard(c: *X86Ctx, i: *Instr, reg: *u8, oktag: *u8) -> i64 { |
| 1619 | func x86ctx_emit_f64_cmp(c: *X86Ctx, i: *Instr, cc: i64) -> i64 { |
| 1655 | func x86ctx_cmp_is_f64(c: *X86Ctx, i: *Instr) -> i64 { |
| 1664 | func x86ctx_cmp_to_cc(op: i64) -> i64 { |
| 1674 | func x86ctx_emit_cmp(c: *X86Ctx, i: *Instr) -> i64 { |
| 1791 | func x86ctx_emit_bb_label(c: *X86Ctx, bb_id: i64) -> i64 { |
| 1800 | func x86ctx_emit_jmp_to_bb(c: *X86Ctx, bb_id: i64) -> i64 { |
| 1807 | func x86ctx_emit_jcc_to_bb(c: *X86Ctx, cc: i64, bb_id: i64) -> i64 { |
| 1818 | func x86ctx_cc_invert(cc: i64) -> i64 { |
| 1837 | func x86ctx_emit_condjump(c: *X86Ctx, cc: i64, t: i64, fjb: i64) -> i64 { |
| 1855 | func x86ctx_br_target_block(c: *X86Ctx, id: i64) -> *BasicBlock { |
| 1865 | func x86ctx_emit_br(c: *X86Ctx, i: *Instr) -> i64 { |
| 1873 | func x86ctx_emit_br_cond(c: *X86Ctx, i: *Instr) -> i64 { |
| 1896 | func x86ctx_type_size(t: *Type) -> i64 { |
| 1903 | func x86ctx_type_signed(t: *Type) -> i64 { |
| 1922 | func x86ctx_type_sext(t: *Type) -> i64 { |
| 1927 | func x86ctx_emit_load(c: *X86Ctx, i: *Instr) -> i64 { |
| 2042 | func x86ctx_emit_store(c: *X86Ctx, i: *Instr) -> i64 { |
| 2140 | func x86ctx_emit_gep(c: *X86Ctx, i: *Instr) -> i64 { |
| 2181 | func x86ctx_rv64_to_x86_64_syscall(num: i64) -> i64 { |
| 2321 | func x86ctx_emit_syscall(c: *X86Ctx, i: *Instr) -> i64 { |
| 2363 | func x86ctx_emit_call(c: *X86Ctx, i: *Instr) -> i64 { |
| 2447 | func x86ctx_emit_call_indirect(c: *X86Ctx, i: *Instr) -> i64 { |
| 2524 | func x86ctx_emit_tail_call(c: *X86Ctx, i: *Instr) -> i64 { |
| 2560 | func x86ctx_emit_copy(c: *X86Ctx, i: *Instr) -> i64 { |
| 2568 | func x86ctx_emit_return(c: *X86Ctx, i: *Instr) -> i64 { |
| 2587 | func x86ctx_emit_f32(c: *X86Ctx, i: *Instr) -> i64 { |
| 2630 | func x86ctx_emit_f64(c: *X86Ctx, i: *Instr) -> i64 { |
| 2676 | func x86ctx_emit_float(c: *X86Ctx, i: *Instr) -> i64 { |
| 2693 | func x86ctx_emit_f32x4_dot(c: *X86Ctx, i: *Instr) -> i64 { |
| 2734 | func x86ctx_emit_q5unpack32(c: *X86Ctx, i: *Instr) -> i64 { |
| 2784 | func x86ctx_emit_q4kunpack32s(c: *X86Ctx, i: *Instr) -> i64 { |
| 2829 | func x86ctx_emit_q4ksbdot(c: *X86Ctx, i: *Instr) -> i64 { |
| 2928 | func x86ctx_emit_q8row_label(c: *X86Ctx, rid: i64) -> i64 { |
| 2945 | func x86ctx_emit_q8rowdot(c: *X86Ctx, i: *Instr) -> i64 { |
| 2993 | func x86ctx_emit_i8fma32(c: *X86Ctx, i: *Instr) -> i64 { |
| 3013 | func x86ctx_emit_i8dot32a(c: *X86Ctx, i: *Instr) -> i64 { |
| 3048 | func x86ctx_emit_i8dot32(c: *X86Ctx, i: *Instr) -> i64 { |
| 3080 | func x86ctx_emit_f32x8_dot(c: *X86Ctx, i: *Instr) -> i64 { |
| 3108 | func x86ctx_emit_f32x8_fma(c: *X86Ctx, i: *Instr) -> i64 { |
| 3121 | func x86ctx_emit_f32x8_hsum(c: *X86Ctx, i: *Instr) -> i64 { |
| 3145 | func x86ctx_emit_i16dot_label(c: *X86Ctx, rid: i64) -> i64 { |
| 3166 | func x86ctx_emit_q8blkdot(c: *X86Ctx, i: *Instr) -> i64 { |
| 3195 | func x86ctx_emit_i16dot(c: *X86Ctx, i: *Instr) -> i64 { |
| 3232 | func x86ctx_emit_i16x16_madd(c: *X86Ctx, i: *Instr) -> i64 { |
| 3249 | func x86ctx_emit_aesni(c: *X86Ctx, i: *Instr) -> i64 { |
| 3277 | func x86ctx_emit_palignr(c: *X86Ctx, dst: i64, src: i64, imm: i64) -> i64 { |
| 3294 | func x86ctx_emit_sha256_ni(c: *X86Ctx, i: *Instr) -> i64 { |
| 3369 | func x86ctx_emit_sha_paddd(c: *X86Ctx, dst: i64, src: i64) -> i64 { |
| 3374 | func x86ctx_emit_sha_movdqa(c: *X86Ctx, dst: i64, src: i64) -> i64 { |
| 3379 | func x86ctx_emit_sha_msg1(c: *X86Ctx, src: i64, dst: i64) -> i64 { |
| 3384 | func x86ctx_emit_sha_msg2(c: *X86Ctx, src: i64, dst: i64) -> i64 { |
| 3397 | func x86ctx_emit_clmul(c: *X86Ctx, i: *Instr, imm: i64) -> i64 { |
| 3423 | func x86ctx_mul256_reg(k: i64) -> *u8 { |
| 3433 | func x86ctx_emit_mul256_wide(c: *X86Ctx, i: *Instr) -> i64 { |
| 3513 | func x86ctx_emit_instr(c: *X86Ctx, i: *Instr) -> i64 { |
| 3635 | func x86ctx_emit_param_prologue(c: *X86Ctx) -> i64 { |
| 3674 | func x86ctx_emit_block(c: *X86Ctx, bb: *BasicBlock) -> i64 { |
| 3725 | func x86ctx_emit_function(f: *Function, o: *OutBuf) -> i64 { |
| 3842 | func x86ctx_global_nonzero(g: *Global) -> i64 { |
| 3852 | func x86ctx_emit_module_globals(m: *Module, o: *OutBuf) -> i64 { |
| 4006 | func x86ctx_emit_module(m: *Module, o: *OutBuf) -> i64 { |
| 4017 | func x86ctx_emit_module_live(m: *Module, o: *OutBuf, live: *u8) -> i64 { |