code wiki / (root) / nx_x86_64_ctx.nx

nx_x86_64_ctx.nx

buildroot/runtime/nx_x86_64_ctx.nx

220671 B4094 linesdepth 4pulls 7 transitivereach 4 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 6 imports · 4 importers

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

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

54struct X86Ctx {

consts

77const NX_X86CTX_BYTES: i64 = 144
82const X86_NEGCTL_G14_SIGNED: i64 = 0
88const X86_NEGCTL_LEA_WRONG_SCALE: i64 = 0
94const X86_NEGCTL_G21_COMMUTE_ANY: i64 = 0
102const X86_NEGCTL_G22_CMOV_INVERT: i64 = 0
103const X86_NEGCTL_G22_RIDE_ALWAYS: i64 = 0
110const X86_NEGCTL_G23_CMOV_INVERT: i64 = 0
119const X86_NEGCTL_F64_CMP_RAW: i64 = 0
1323const OP_TRUNC: i64 = 17
1324const OP_SEXT: i64 = 18
1325const OP_ZEXT: i64 = 19
1326const OP_BITCAST: i64 = 26

functions

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