code wiki / (root) / nx_isa_loongarch64_gate.nx

nx_isa_loongarch64_gate.nx

buildroot/runtime/nx_isa_loongarch64_gate.nx

39691 B915 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind gate/prooftopic isa
docsdependenciesstructsconstsfunctions

about

nx_isa_loongarch64_gate.nx -- THE LOONGARCH64 CONFORMANCE RULER. WHY IT EXISTS: the estate carries ten sovereign ISA interpreters in NishiLang. On 2026-09-03 nx_isa_conform_gate measured five of them and printed, in its own output, the list of the five it could not speak for: "UNMEASURED: armv7a cortexm loongarch64 s390x sparc64 -- each owes a manual-derived KAT block here". This organ pays the loongarch64 half of that debt. LoongArch is a sovereign national ISA and therefore a first-class deploy target for a sovereign estate: "we can run LoongArch" has to be a measurement, not a claim. WHY A SEPARATE ORGAN AND NOT A BLOCK INSIDE nx_isa_conform_gate: five ISA lanes were working concurrently on 2026-09-03 and this estate loses concurrent edits to one file silently. One arch, one organ, one ratchet file, one owner -- the same "one subject per row, and the writer owns its own file" rule that split the shared gatereg log. The SHAPE is copied from the incumbent deliberately, so a reader who knows one knows all of them. THE LAW THIS ORGAN OBEYS: expectations come FROM THE LOONGARCH REFERENCE MANUAL, never from reading nx_emu_loongarch64.nx and writing down what it happens to do -- that would calibrate the ruler to the subject it exists to judge. Every opcode constant below is declared HERE, independently of the interpreter's own constant table, so a disagreement between the two is a finding rather than a shared typo. The interpreter's decoder was read only to learn which classes are IMPLEMENTED versus MISSING, which is a question about coverage and not about expected values. FIVE OUTCOMES, NEVER ONE: PASS ran and matched the manual-derived expectation WRONG-ANSWER ran to completion and computed the wrong value UNSUPPORTED hit an instruction class the interpreter does not decode RAN-OFF-END the loop ended with no exit syscall / step budget spent FAULT bad pc, or a guest address outside the arena An unimplemented class and a miscomputed result need OPPOSITE fixes, and only the first is a missing feature. Collapsing them into FAIL is what makes a gap unactionable. WHAT THIS RULER FOUND, 2026-09-03, and what was then fixed in the

dependencies 3 imports · 0 importers

nx_gate_verdict.nx nx_syscalls.nx nx_emu_loongarch64.nx nx_isa_loongarch64_gate.nx

imports: nx_gate_verdict.nxnx_syscalls.nxnx_emu_loongarch64.nx

imported by: nobody (leaf or entry point)

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

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mmap ↻ gv_puts ↻ lg_nl sys_mmap ↻ sys_write ↻ lg_report lg_classify gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap lg_outcome_name lg_nl ↻ gv_cat gv_catn sys_mmap ↻ sys_munmap ↻ lg_kat_imm_arith lg_guest

structs

none

consts

64const LG_GUEST_BYTES: i64 = 1048576 // 1 MiB guest image
65const LG_ENTRY: i64 = 0 // KAT code is loaded at guest vaddr 0
66const LG_SP: i64 = 983040 // 960 KiB: above the code, inside the image
67const LG_MODE_FILE: i64 = 420 // 0644. Same constant as 0x1a4; a sweep
76const LG_UNSUPPORTED: i64 = -1
77const LG_RANOFF: i64 = -2
78const LG_FAULT: i64 = -3
81const LG_O_PASS: i64 = 0
82const LG_O_WRONG: i64 = 1
83const LG_O_UNSUP: i64 = 2
84const LG_O_FAULT: i64 = 3
85const LG_O_RANOFF: i64 = 4
90const LG_NB_BYTES: i64 = 2048
91const LG_NB_OFF: i64 = 0
92const LG_NB_PTR: i64 = 1
93const LG_NB_ROW_MAX: i64 = 256
94const LG_BOX_BYTES: i64 = 32
96const LG_NL: i64 = 10
97const LG_SPACE: i64 = 32
98const LG_DIG_LO: i64 = 48
99const LG_DIG_HI: i64 = 57
100const LG_UNSEEDED: i64 = -1
103const LG_R_ZERO: i64 = 0
104const LG_R_RA: i64 = 1
105const LG_R_SP: i64 = 3
106const LG_R_A0: i64 = 4
107const LG_R_A1: i64 = 5
108const LG_R_A2: i64 = 6
109const LG_R_A7: i64 = 11
110const LG_R_T0: i64 = 12
111const LG_R_T1: i64 = 13
112const LG_R_T2: i64 = 14
122const LG_OP_ADD_D: i64 = 0x00108000
123const LG_OP_SUB_D: i64 = 0x00118000
124const LG_OP_SLT: i64 = 0x00120000
125const LG_OP_SLTU: i64 = 0x00128000
126const LG_OP_AND: i64 = 0x00148000
127const LG_OP_OR: i64 = 0x00150000
128const LG_OP_XOR: i64 = 0x00158000
129const LG_OP_SLL_D: i64 = 0x00188000
130const LG_OP_SRL_D: i64 = 0x00190000
131const LG_OP_SRA_D: i64 = 0x00198000
132const LG_OP_MUL_D: i64 = 0x001d8000
133const LG_OP_SLLI_D: i64 = 0x00410000
134const LG_OP_SRLI_D: i64 = 0x00450000
135const LG_OP_SRAI_D: i64 = 0x00490000
136const LG_OP_ADDI_D: i64 = 0x02c00000
137const LG_OP_ANDI: i64 = 0x03400000
138const LG_OP_ORI: i64 = 0x03800000
139const LG_OP_XORI: i64 = 0x03c00000
140const LG_OP_LD_D: i64 = 0x28c00000
141const LG_OP_ST_B: i64 = 0x29000000
142const LG_OP_ST_D: i64 = 0x29c00000
143const LG_OP_LD_BU: i64 = 0x2a000000
144const LG_OP_LU12I_W: i64 = 0x14000000
145const LG_OP_BEQZ: i64 = 0x40000000
146const LG_OP_BNEZ: i64 = 0x44000000
147const LG_OP_JIRL: i64 = 0x4c000000
148const LG_OP_B: i64 = 0x50000000
149const LG_OP_BL: i64 = 0x54000000
150const LG_OP_BEQ: i64 = 0x58000000
151const LG_OP_BNE: i64 = 0x5c000000
152const LG_OP_BLT: i64 = 0x60000000
153const LG_OP_BGE: i64 = 0x64000000
154const LG_OP_BLTU: i64 = 0x68000000
155const LG_OP_BGEU: i64 = 0x6c000000
156const LG_INSN_SYSCALL: i64 = 0x002B0000
157const LG_INSN_UNDEFINED: i64 = 0xFFFFFFFF // decodes to no class in any format
159const LG_SYS_EXIT: i64 = 93 // Linux generic ABI, number in a7
598const LG_RATCHET: *u8 = "knowledge/status/isa_loongarch64.ratchet"
599const LG_RATCHET_BYTES: i64 = 128
600const LG_ARCH_KEY: *u8 = "loongarch64"

functions

163func lg_nl() -> i64
called by 2: lg_reportmain calls 2: sys_mmapsys_write
175func lg_put_le32(code: *u8, off: i64, w: i64) -> i64
183func lg_guest() -> *u8 { return sys_mmap(LG_GUEST_BYTES) }
186func lg_3r(op: i64, rd: i64, rj: i64, rk: i64) -> i64
189func lg_2ri12(op: i64, rd: i64, rj: i64, imm: i64) -> i64
192func lg_shift_d(op: i64, rd: i64, rj: i64, ui6: i64) -> i64
195func lg_1ri20(op: i64, rd: i64, si20: i64) -> i64
called by 1: lg_kat_lu12i
200func lg_2ri16(op: i64, rj: i64, rd: i64, off: i64) -> i64
204func lg_1ri21(op: i64, rj: i64, off: i64) -> i64
208func lg_i26(op: i64, off: i64) -> i64
213func lg_exit(m: *u8, o0: i64) -> i64
221func lg_classify(got: i64, want: i64) -> i64
called by 2: lg_reportmain
229func lg_outcome_name(o: i64) -> *u8
called by 2: lg_reportmain
240func lg_report(kat: *u8, got: i64, want: i64, bx: *i64) -> i64
277func lg_kat_imm_arith() -> i64
289func lg_kat_sub() -> i64
301func lg_kat_mul() -> i64
315func lg_kat_load_store() -> i64
331func lg_kat_shift_logical() -> i64
344func lg_kat_shift_arith() -> i64
358func lg_kat_shifti_logical() -> i64
368func lg_kat_shifti_left() -> i64
379func lg_kat_logic() -> i64
396func lg_kat_ori_zero_extended() -> i64
411func lg_kat_slt_vs_sltu() -> i64
430func lg_kat_branch_loop() -> i64
445func lg_kat_beq_taken() -> i64
461func lg_kat_b_unconditional() -> i64
474func lg_kat_beqz_taken() -> i64
487func lg_kat_bnez_not_taken() -> i64
501func lg_kat_bltu_unsigned() -> i64
518func lg_kat_call_return() -> i64
533func lg_kat_lu12i() -> i64
547func lg_kat_byte_load_store() -> i64
568func lg_neg_undefined_opcode() -> i64
582func lg_neg_out_of_range_address() -> i64
602func lg_match_at(buf: *u8, n: i64, p: i64, s: *u8) -> i64
called by 1: lg_ratchet_read
616func lg_digits_at(buf: *u8, n: i64, p0: i64) -> i64
called by 1: lg_ratchet_read
640func lg_ratchet_read() -> i64
673func lg_ratchet_write(n: i64) -> i64
691func main(argc: i64, argv: *i64) -> i64