mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-25 18:05:12 -04:00
7342e6bcd1
Beetle's ReadInstruction never fills an I-cache line for a fetch at 0xA0000000 or above: every such fetch costs +4 and clears the pending load give-back. The dirty-RAM interpreter charges that by fetching at every PC. Both static emitters emitted psx_icache_fetch only at cache-line leaders, which is exact for cached code only. In OpenBIOS, 5,477 of the 9,592 in-place ROM (KSEG1) instruction sites were uncharged: 21,908 cycles short per pass through that code, each also missing its give-back clear. Both emitters now charge a fetch before every instruction whose runtime PC is uncached. The predicate is psx_fetch_uncached in psx_instr_cost.h, which psx_icache.c now uses too. The A0/B0/C0 call-vector native stubs charge one fetch per executed word, so a KSEG1 call pays like the interpreter. Cached code keeps the leader rule. R4's regenerated game C is byte-identical, and the OpenBIOS diff is insertions only. psx_instr_cost.h joins the codegen hash list, since the emitters fold it into emitted code. Tests: - ctest uncached_fetch_charge runs psxrecomp-bios on OpenBIOS and compares per-instruction fetch charges three ways: the compiled fetches, the interpreter's fetch path (psx_icache_fetch_interp) at every PC, and a Beetle transcription. - uncached_fetch_codegen_test checks the game emitter at KSEG1 and KSEG0. Both tests fail on master. This closes bios-kseg1-fetch-charge in the segment_aware_codegen ledger (#419). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
5.1 KiB
CMake
79 lines
5.1 KiB
CMake
# codegen_hash_sources.cmake — the CANONICAL list of recompiler codegen sources
|
|
# folded into the overlay cache tag hash (hash_codegen.cmake).
|
|
#
|
|
# Included from BOTH:
|
|
# - runtime/runtime.cmake (bakes the hash into the runtime's cg tag)
|
|
# - recompiler/CMakeLists.txt (bakes the SAME hash into psxrecomp-game,
|
|
# exposed via `--codegen-hash`)
|
|
# so the two hash computations can never drift by list divergence. Any file
|
|
# added to the emitter pipeline must be added HERE, once.
|
|
#
|
|
# Input: PSXRECOMP_CODEGEN_HASH_ROOT — the psxrecomp repo root.
|
|
# Output: PSXRECOMP_CODEGEN_HASH_SRCS — absolute paths to hash.
|
|
|
|
# NOTE: include the emitter .cpp translation units, not just their headers. A
|
|
# change confined to full_function_emitter.cpp (e.g. the 2026-07-03 Class-A
|
|
# shell-window overlay-dispatch fix) alters both generated dispatch and overlay
|
|
# code but left the hash unchanged when only the .h files were listed — a stale
|
|
# overlay-cache hazard (same class as the "ws emission not in cg hash" gap).
|
|
set(PSXRECOMP_CODEGEN_HASH_SRCS
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/code_generator.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/mips_decoder.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/control_flow.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/basic_block.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_analysis.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/recompiler_patch.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/recompiler_patch.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/full_function_emitter.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/full_function_emitter.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/strict_translator.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/strict_translator.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/pgxp_hook_emitter.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/pgxp_hook_emitter.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_discovery.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/function_discovery.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/gte_register_classification.h
|
|
# Shared instruction detector changes alter emitted overlay substitutions.
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/ws_backdrop_detect.h
|
|
# The shared cycle-cost header decides emitted code too: both emitters fold
|
|
# psx_cyc_dep_res_mask into literals and gate fetch-charge emission on
|
|
# psx_fetch_uncached.
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/psx_instr_cost.h
|
|
|
|
# --- image view + walker headers ------------------------------------------
|
|
# Same gap as the .cpp/.h note above, one level down. The image VIEW decides
|
|
# what the emitter is even allowed to see: ps1_exe_parser.h now carries two
|
|
# distinct bounds (the READ bound end_address() and the ANALYSIS bound
|
|
# analysis_end_address(), which stops short of an overlay capture's trailing
|
|
# delay-slot guard words), and ps1_exe_parser.cpp decodes the producer's
|
|
# guard-byte declaration. A change confined to either would move every
|
|
# overlay shard's CFG while leaving the cg tag untouched — precisely the
|
|
# stale-but-same-tag hazard this list exists to prevent. The walker/analysis
|
|
# headers are listed for the same reason: their structs and bounds helpers
|
|
# are part of the emitter contract even when the .cpp files do not move.
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/ps1_exe_parser.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/src/ps1_exe_parser.cpp
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/control_flow.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/function_analysis.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/basic_block.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/recompiler/include/code_generator.h
|
|
|
|
# --- Shard COMPILE surface -------------------------------------------------
|
|
# The cg tag must invalidate on anything a shard compiles/links against, not
|
|
# just what the emitter WRITES. A change to the overlay ABI header, the
|
|
# CPUState layout, or the dispatch-shim link contract leaves the emitter
|
|
# sources untouched — so without these the tag stayed put, existing DLLs kept
|
|
# loading, and every NEW shard silently failed to compile against the moved-on
|
|
# runtime (the recurring "header change broke the shards" class). Folding the
|
|
# compile surface in makes such a change reshard SAME-TREE instead of breaking
|
|
# silently. overlay_api.h pulls cpu_state.h and its cycle-helper headers; the
|
|
# .inc is the shim every shard links against; ws_cull_edge.h is the edge-cull
|
|
# math the .inc includes.
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/overlay_api.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/cpu_state.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/pgxp_hooks.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/psx_cyc.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/psx_cycles.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/ws_cull_edge.h
|
|
${PSXRECOMP_CODEGEN_HASH_ROOT}/runtime/include/overlay_dispatch_preamble.c.inc)
|