mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-19 16:42:33 +00:00
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.
34 lines
1.2 KiB
Odin
34 lines
1.2 KiB
Odin
// rexcode · Brendan Punsky (dotbmp@github), original author
|
|
|
|
package rexcode_mips
|
|
|
|
// =============================================================================
|
|
// MIPS RELOCATIONS
|
|
// =============================================================================
|
|
//
|
|
// Per the cross-arch design (§2.4): each arch owns its own Relocation_Type
|
|
// enum and Relocation struct. The struct shape mirrors ELF rela so an
|
|
// object emitter can consume it unchanged; the resolution semantics for
|
|
// each `type` value are MIPS-specific and live in encoder.odin's pass-2
|
|
// resolver.
|
|
|
|
Relocation_Type :: enum u8 {
|
|
NONE = 0,
|
|
REL16, // 16-bit signed PC-rel branch offset (BEQ/BNE/BLEZ/BGTZ/...)
|
|
REL21, // 21-bit signed PC-rel compact branch (R6 BEQZC/BNEZC)
|
|
REL26, // 26-bit signed PC-rel compact branch (R6 BC/BALC)
|
|
J26, // 26-bit J-type region target ((target_addr >> 2) & 0x3FFFFFF)
|
|
HI16, // upper 16 of 32-bit absolute (LUI rt, %hi(sym)+0x8000 if LO16 paired)
|
|
LO16, // lower 16 of 32-bit absolute (ADDIU rt, rt, %lo(sym))
|
|
}
|
|
|
|
Relocation :: struct #packed {
|
|
offset: u32,
|
|
label_id: u32,
|
|
addend: i32,
|
|
type: Relocation_Type,
|
|
size: u8,
|
|
inst_idx: u16,
|
|
}
|
|
#assert(size_of(Relocation) == 16)
|