nx_isa_loongarch64_gate.nx
buildroot/runtime/nx_isa_loongarch64_gate.nx
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
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
structs
| none |
consts
| 64 | const LG_GUEST_BYTES: i64 = 1048576 // 1 MiB guest image |
| 65 | const LG_ENTRY: i64 = 0 // KAT code is loaded at guest vaddr 0 |
| 66 | const LG_SP: i64 = 983040 // 960 KiB: above the code, inside the image |
| 67 | const LG_MODE_FILE: i64 = 420 // 0644. Same constant as 0x1a4; a sweep |
| 76 | const LG_UNSUPPORTED: i64 = -1 |
| 77 | const LG_RANOFF: i64 = -2 |
| 78 | const LG_FAULT: i64 = -3 |
| 81 | const LG_O_PASS: i64 = 0 |
| 82 | const LG_O_WRONG: i64 = 1 |
| 83 | const LG_O_UNSUP: i64 = 2 |
| 84 | const LG_O_FAULT: i64 = 3 |
| 85 | const LG_O_RANOFF: i64 = 4 |
| 90 | const LG_NB_BYTES: i64 = 2048 |
| 91 | const LG_NB_OFF: i64 = 0 |
| 92 | const LG_NB_PTR: i64 = 1 |
| 93 | const LG_NB_ROW_MAX: i64 = 256 |
| 94 | const LG_BOX_BYTES: i64 = 32 |
| 96 | const LG_NL: i64 = 10 |
| 97 | const LG_SPACE: i64 = 32 |
| 98 | const LG_DIG_LO: i64 = 48 |
| 99 | const LG_DIG_HI: i64 = 57 |
| 100 | const LG_UNSEEDED: i64 = -1 |
| 103 | const LG_R_ZERO: i64 = 0 |
| 104 | const LG_R_RA: i64 = 1 |
| 105 | const LG_R_SP: i64 = 3 |
| 106 | const LG_R_A0: i64 = 4 |
| 107 | const LG_R_A1: i64 = 5 |
| 108 | const LG_R_A2: i64 = 6 |
| 109 | const LG_R_A7: i64 = 11 |
| 110 | const LG_R_T0: i64 = 12 |
| 111 | const LG_R_T1: i64 = 13 |
| 112 | const LG_R_T2: i64 = 14 |
| 122 | const LG_OP_ADD_D: i64 = 0x00108000 |
| 123 | const LG_OP_SUB_D: i64 = 0x00118000 |
| 124 | const LG_OP_SLT: i64 = 0x00120000 |
| 125 | const LG_OP_SLTU: i64 = 0x00128000 |
| 126 | const LG_OP_AND: i64 = 0x00148000 |
| 127 | const LG_OP_OR: i64 = 0x00150000 |
| 128 | const LG_OP_XOR: i64 = 0x00158000 |
| 129 | const LG_OP_SLL_D: i64 = 0x00188000 |
| 130 | const LG_OP_SRL_D: i64 = 0x00190000 |
| 131 | const LG_OP_SRA_D: i64 = 0x00198000 |
| 132 | const LG_OP_MUL_D: i64 = 0x001d8000 |
| 133 | const LG_OP_SLLI_D: i64 = 0x00410000 |
| 134 | const LG_OP_SRLI_D: i64 = 0x00450000 |
| 135 | const LG_OP_SRAI_D: i64 = 0x00490000 |
| 136 | const LG_OP_ADDI_D: i64 = 0x02c00000 |
| 137 | const LG_OP_ANDI: i64 = 0x03400000 |
| 138 | const LG_OP_ORI: i64 = 0x03800000 |
| 139 | const LG_OP_XORI: i64 = 0x03c00000 |
| 140 | const LG_OP_LD_D: i64 = 0x28c00000 |
| 141 | const LG_OP_ST_B: i64 = 0x29000000 |
| 142 | const LG_OP_ST_D: i64 = 0x29c00000 |
| 143 | const LG_OP_LD_BU: i64 = 0x2a000000 |
| 144 | const LG_OP_LU12I_W: i64 = 0x14000000 |
| 145 | const LG_OP_BEQZ: i64 = 0x40000000 |
| 146 | const LG_OP_BNEZ: i64 = 0x44000000 |
| 147 | const LG_OP_JIRL: i64 = 0x4c000000 |
| 148 | const LG_OP_B: i64 = 0x50000000 |
| 149 | const LG_OP_BL: i64 = 0x54000000 |
| 150 | const LG_OP_BEQ: i64 = 0x58000000 |
| 151 | const LG_OP_BNE: i64 = 0x5c000000 |
| 152 | const LG_OP_BLT: i64 = 0x60000000 |
| 153 | const LG_OP_BGE: i64 = 0x64000000 |
| 154 | const LG_OP_BLTU: i64 = 0x68000000 |
| 155 | const LG_OP_BGEU: i64 = 0x6c000000 |
| 156 | const LG_INSN_SYSCALL: i64 = 0x002B0000 |
| 157 | const LG_INSN_UNDEFINED: i64 = 0xFFFFFFFF // decodes to no class in any format |
| 159 | const LG_SYS_EXIT: i64 = 93 // Linux generic ABI, number in a7 |
| 598 | const LG_RATCHET: *u8 = "knowledge/status/isa_loongarch64.ratchet" |
| 599 | const LG_RATCHET_BYTES: i64 = 128 |
| 600 | const LG_ARCH_KEY: *u8 = "loongarch64" |
functions
| 163 | func lg_nl() -> i64 |
| 175 | func lg_put_le32(code: *u8, off: i64, w: i64) -> i64 |
| 183 | func lg_guest() -> *u8 { return sys_mmap(LG_GUEST_BYTES) } called by 22: lg_kat_imm_arithlg_kat_sublg_kat_mullg_kat_load_storelg_kat_shift_logicallg_kat_shift_arith+16 calls 1: sys_mmap |
| 186 | func lg_3r(op: i64, rd: i64, rj: i64, rk: i64) -> i64 |
| 189 | func lg_2ri12(op: i64, rd: i64, rj: i64, imm: i64) -> i64 |
| 192 | func lg_shift_d(op: i64, rd: i64, rj: i64, ui6: i64) -> i64 |
| 195 | func lg_1ri20(op: i64, rd: i64, si20: i64) -> i64 called by 1: lg_kat_lu12i |
| 200 | func lg_2ri16(op: i64, rj: i64, rd: i64, off: i64) -> i64 |
| 204 | func lg_1ri21(op: i64, rj: i64, off: i64) -> i64 |
| 208 | func lg_i26(op: i64, off: i64) -> i64 |
| 213 | func lg_exit(m: *u8, o0: i64) -> i64 |
| 221 | func lg_classify(got: i64, want: i64) -> i64 |
| 229 | func lg_outcome_name(o: i64) -> *u8 |
| 240 | func lg_report(kat: *u8, got: i64, want: i64, bx: *i64) -> i64 |
| 277 | func lg_kat_imm_arith() -> i64 |
| 289 | func lg_kat_sub() -> i64 |
| 301 | func lg_kat_mul() -> i64 |
| 315 | func lg_kat_load_store() -> i64 |
| 331 | func lg_kat_shift_logical() -> i64 |
| 344 | func lg_kat_shift_arith() -> i64 |
| 358 | func lg_kat_shifti_logical() -> i64 |
| 368 | func lg_kat_shifti_left() -> i64 |
| 379 | func lg_kat_logic() -> i64 |
| 396 | func lg_kat_ori_zero_extended() -> i64 |
| 411 | func lg_kat_slt_vs_sltu() -> i64 |
| 430 | func lg_kat_branch_loop() -> i64 |
| 445 | func lg_kat_beq_taken() -> i64 |
| 461 | func lg_kat_b_unconditional() -> i64 |
| 474 | func lg_kat_beqz_taken() -> i64 |
| 487 | func lg_kat_bnez_not_taken() -> i64 |
| 501 | func lg_kat_bltu_unsigned() -> i64 |
| 518 | func lg_kat_call_return() -> i64 |
| 533 | func lg_kat_lu12i() -> i64 |
| 547 | func lg_kat_byte_load_store() -> i64 |
| 568 | func lg_neg_undefined_opcode() -> i64 |
| 582 | func lg_neg_out_of_range_address() -> i64 |
| 602 | func lg_match_at(buf: *u8, n: i64, p: i64, s: *u8) -> i64 called by 1: lg_ratchet_read |
| 616 | func lg_digits_at(buf: *u8, n: i64, p0: i64) -> i64 called by 1: lg_ratchet_read |
| 640 | func lg_ratchet_read() -> i64 |
| 673 | func lg_ratchet_write(n: i64) -> i64 |
| 691 | func main(argc: i64, argv: *i64) -> i64 |