Files
Odin/core/rexcode/arm64/reloc.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

47 lines
1.4 KiB
Odin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// rexcode · Brendan Punsky (dotbmp@github), original author
package rexcode_arm64
// =============================================================================
// AArch64 RELOCATIONS
// =============================================================================
//
// Per the cross-arch design (§2.4): each arch owns its own enum + struct.
// AArch64 has several PC-relative immediate widths plus the unusual
// ADR/ADRP pair where ADRP carries the page-aligned high bits and ADD
// (or LDR/STR) carries the low 12. PAC, GOT, and TLS relocations are
// follow-up work.
Relocation_Type :: enum u8 {
NONE = 0,
// PC-relative branches
B26, // 26-bit signed offset (×4) -- B / BL
B_COND19, // 19-bit signed offset (×4) -- B.cond, CBZ/CBNZ
TBZ14, // 14-bit signed offset (×4) -- TBZ / TBNZ
// PC-relative addressing
ADR_PCREL21, // ±1MB signed offset -- ADR
ADRP_PCREL21, // ±4GB signed offset on 4K page boundary -- ADRP
PCREL_LO12_I, // low 12 of (sym - page_of(ADRP)) -- ADD/LDR/STR after ADRP
PCREL_LO12_S, // S-form variant if needed for store-pair-style ops
// Load-literal (PC-relative 19-bit signed, scaled by 4)
LDR_LITERAL19,
// Absolute (filled by linker)
ABS64,
ABS32,
ABS16,
}
Relocation :: struct #packed {
offset: u32,
label_id: u32,
addend: i32,
type: Relocation_Type,
size: u8,
inst_idx: u16,
}
#assert(size_of(Relocation) == 16)