Files
Odin/core/rexcode/rsp/mnemonics.odin
Flāvius a4f08f8307 Load rexcode encode/decode tables from committed binary blobs
Each ISA's hand-written ENCODING_TABLE (the single source of truth) now lives
in a per-arch tablegen/ metaprogram that flattens it and serializes committed
binary blobs; the library #loads those into @(rodata) at compile time rather
than compiling a table body. No arch keeps encoding_table.odin or
decoding_tables.odin -- only a generated tables.odin loader and tables/*.bin.

* Two-stage, type-checked pipeline: tablegen Stage A emits human-readable
  generated Odin, which compiles and serializes the blobs in Stage B.
* encode() goes through encoding_forms(m); decoders are unchanged apart from
  x86's flattened 2-D index. Decode tables are byte-identical to the old ones.
* build.lua: a LuaJIT driver for the metaprograms, validations, and tests,
  with cross-platform gating and a clear report.
* Docs refreshed; the obsolete forward-looking plan in cross_arch_design.md
  trimmed to what was actually built.
* Attribution headers added to all rexcode source files; the generators emit
  them so generated files keep them.
2026-06-15 07:43:29 -04:00

84 lines
2.2 KiB
Odin

// rexcode · Brendan Punsky (dotbmp@github), original author
package rexcode_rsp
// =============================================================================
// N64 RSP MNEMONICS
// =============================================================================
//
// Two halves: a strict MIPS I subset for the scalar core (no
// MULT/DIV/HI/LO/SYNC/LWL/LWR/SWL/SWR/64-bit), and the vector unit
// (VMULF.../VLT.../VRCP.../etc. + LBV..LTV loads, SBV..STV stores).
Mnemonic :: enum u16 {
INVALID = 0,
// -------------------------------------------------------------------------
// Scalar core — MIPS I subset
// -------------------------------------------------------------------------
// R-type arithmetic / logical / shift
ADD, ADDU, SUB, SUBU,
AND, OR, XOR, NOR,
SLT, SLTU,
SLL, SRL, SRA,
SLLV, SRLV, SRAV,
// I-type
ADDI, ADDIU,
SLTI, SLTIU,
ANDI, ORI, XORI,
LUI,
// Branches (with delay slot)
BEQ, BNE, BLEZ, BGTZ,
BLTZ, BGEZ, BLTZAL, BGEZAL,
// Jumps
J, JAL, JR, JALR,
// Load / Store (no LWL/LWR/SWL/SWR on the RSP).
LB, LH, LW, LBU, LHU,
SB, SH, SW,
// System
BREAK, NOP,
// Coprocessor moves
MFC0, MTC0,
MFC2, MTC2, CFC2, CTC2,
// -------------------------------------------------------------------------
// Vector ALU (COP2, CO=1; opcode 0x12 with funct selecting)
// -------------------------------------------------------------------------
VMULF, VMULU,
VMUDL, VMUDM, VMUDN, VMUDH,
VMACF, VMACU,
VMADL, VMADM, VMADN, VMADH,
VADD, VSUB, VABS,
VADDC, VSUBC,
VSAR,
VLT, VEQ, VNE, VGE,
VCL, VCH, VCR, VMRG,
VAND, VNAND, VOR, VNOR, VXOR, VNXOR,
VRCP, VRCPL, VRCPH,
VMOV,
VRSQ, VRSQL, VRSQH,
VNOP,
// -------------------------------------------------------------------------
// Vector loads (LWC2 = opcode 0x32 with op2 selector)
// -------------------------------------------------------------------------
LBV, LSV, LLV, LDV, LQV, LRV,
LPV, LUV, LHV, LFV, LWV, LTV,
// -------------------------------------------------------------------------
// Vector stores (SWC2 = opcode 0x3A with op2 selector)
// -------------------------------------------------------------------------
SBV, SSV, SLV, SDV, SQV, SRV,
SPV, SUV, SHV, SFV, SWV, STV,
}