mirror of
https://github.com/libretro/parallel-n64.git
synced 2026-11-07 23:02:26 -10:00
Wires offset-generation so the x86-64 dynarec's asm_defines headers are produced
from the shared C struct (struct new_dynarec_hot_state) rather than hand-written,
keeping the assembly's struct offsets locked to the C definition as a single
source of truth. Build-tooling only -- NO runtime change: the linkage does not
yet include the generated headers (that is Phase 2d), and the dynarec still uses
the flat globals.
Mechanism (adopted from mupen64plus-next, the string-embed variant rather than
the recomp_dbg runtime table):
- src/asm_defines/asm_defines.c: compiled with the core's flags, it bakes each
requested struct offset into the object as a printable string of the form
"@ASM_DEFINE offsetof_struct_<s>_<m> 0xXXXXXXXX". A negative-array-bound in
the macro also asserts each offset fits in 32 bits (rel32 reach). No program
is run; the values are read from the object with strings, so it works
cross-compiled and without objdump/nm/dumpbin.
- tools/gen_asm_defines.awk: extracts the @ASM_DEFINE strings and emits
x64/asm_defines_nasm.h (%define) and x64/asm_defines_gas.h (#define).
- Makefile: compiles asm_defines.o, runs strings|tr|awk to (re)generate the
headers, and makes linkage_x64.o depend on the gas header so a struct change
regenerates the offsets. Gated on ASM_DEFINES_X64 (x86_64 + HAVE_ARI64_X64),
so no other build path is affected. Adds AWK/STRINGS/TR tool vars.
- x64/asm_defines_{nasm,gas}.h: the generated headers, committed.
Verification: the generated hot_state field offsets match the Phase-2a static
asserts exactly and match next's committed x64 asm_defines byte-for-byte across
all 23 shared fields (0 mismatches); regeneration is reproducible. The
parallel-n64-specific extensions land after memory_map as expected. Full-core
sweep clean (76 TUs, including asm_defines.c).
Only the within-hot_state field offsets are emitted here; the structural offsets
(device->r4300, r4300->new_dynarec_hot_state, r4300->extra_memory) are added in
Phase 2c, when the struct + JIT code cache are embedded into struct r4300_core.