mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-20 09:02:32 +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.
65 lines
1.6 KiB
Odin
65 lines
1.6 KiB
Odin
// rexcode · Brendan Punsky (dotbmp@github), original author
|
|
|
|
package rexcode_ppc_vle
|
|
|
|
// =============================================================================
|
|
// PowerPC VLE Operands
|
|
// =============================================================================
|
|
|
|
Operand_Kind :: enum u8 {
|
|
NONE,
|
|
REGISTER,
|
|
IMMEDIATE,
|
|
MEMORY,
|
|
RELATIVE,
|
|
}
|
|
|
|
Memory :: struct #packed {
|
|
base: Register,
|
|
index: Register,
|
|
disp: i64,
|
|
}
|
|
#assert(size_of(Memory) == 12)
|
|
|
|
@(require_results)
|
|
mem_d :: #force_inline proc "contextless" (base: Register, disp: i64) -> Memory {
|
|
return Memory{base = base, index = NONE, disp = disp}
|
|
}
|
|
@(require_results)
|
|
mem_x :: #force_inline proc "contextless" (base, index: Register) -> Memory {
|
|
return Memory{base = base, index = index, disp = 0}
|
|
}
|
|
|
|
Operand :: struct #packed {
|
|
using _: struct #raw_union {
|
|
reg: Register,
|
|
mem: Memory,
|
|
immediate: i64,
|
|
relative: i64,
|
|
},
|
|
kind: Operand_Kind,
|
|
size: u8,
|
|
_: [2]u8,
|
|
}
|
|
|
|
@(require_results)
|
|
op_reg :: #force_inline proc "contextless" (r: Register) -> Operand {
|
|
return Operand{reg = r, kind = .REGISTER}
|
|
}
|
|
@(require_results)
|
|
op_imm :: #force_inline proc "contextless" (v: i64) -> Operand {
|
|
return Operand{immediate = v, kind = .IMMEDIATE}
|
|
}
|
|
@(require_results)
|
|
op_mem :: #force_inline proc "contextless" (m: Memory) -> Operand {
|
|
return Operand{mem = m, kind = .MEMORY}
|
|
}
|
|
@(require_results)
|
|
op_label :: #force_inline proc "contextless" (label_id: u32) -> Operand {
|
|
return Operand{relative = i64(label_id), kind = .RELATIVE}
|
|
}
|
|
@(require_results)
|
|
op_rel_offset :: #force_inline proc "contextless" (off: i64) -> Operand {
|
|
return Operand{relative = off, kind = .RELATIVE}
|
|
}
|