mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 04:55:56 +00:00
Log the first guest write of a directed FPCR rounding mode, with its caller
Diagnostic only. The lifted MSR FPCR (recomp/lifter.py) now also tests the stored RMode bits (cpu.h RT_FPCR_NOTE); the first nonzero one is logged once by main.c rt_fpcr_rmode with the caller of the writing function. The write itself behaves as before. Whether the line ever shows decides if the directed-rounding slow paths of runtime/simd.h are dead in the game. 10 MSR FPCR sites on 1.4.3; nothing on the other paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d5879f9e2
commit
99878f3c55
4 files changed
+19
-1
No files matched your search
+2
-1
@@ -352,7 +352,8 @@ class Lifter:
|
||||
dst = {
|
||||
(3, 3, 13, 0, 2): 'c->tpidr = {v};',
|
||||
(3, 3, 4, 2, 0): 'c->nzcv = {v} & 0xf0000000ull;',
|
||||
(3, 3, 4, 4, 0): 'c->fpcr = {v} & 0x7c00000ull; rt_fpcr_sync(c);' if self.sc else 'rt_set_fpcr({v});',
|
||||
(3, 3, 4, 4, 0): ('c->fpcr = {v} & 0x7c00000ull; rt_fpcr_sync(c); RT_FPCR_NOTE(c, c->x[30]);' if self.sc
|
||||
else 'rt_set_fpcr({v});'),
|
||||
(3, 3, 4, 4, 1): 'c->fpsr = {v} & 0xf800009full;' if self.sc else 'rt_set_fpsr({v});',
|
||||
}.get(key)
|
||||
if dst is None:
|
||||
|
||||
@@ -62,6 +62,12 @@ static inline void rt_fpcr_sync(const Cpu *c) {
|
||||
if (cur != want) __builtin_ia32_ldmxcsr(want);
|
||||
}
|
||||
#endif
|
||||
// MSR FPCR (recomp/lifter.py): the first guest write of a directed rounding mode (FPCR.RMode, bits 22-23) is logged
|
||||
// once with the caller (main.c rt_fpcr_rmode), to learn whether the game ever leaves round-to-nearest. A test of the
|
||||
// value just stored, at the MSR sites only.
|
||||
void rt_fpcr_rmode(uint64_t fpcr, uint64_t lr);
|
||||
#define RT_FPCR_NOTE(c, lr) \
|
||||
do { if (__builtin_expect((c)->fpcr & (3ull << 22), 0)) rt_fpcr_rmode((c)->fpcr, lr); } while (0)
|
||||
|
||||
// ---- memory: guest addresses are host addresses
|
||||
typedef uint16_t __attribute__((aligned(1), may_alias)) u16u;
|
||||
|
||||
@@ -161,6 +161,16 @@ const RtConfig *rt_config(void) { return &cfg; }
|
||||
volatile int g_fnprof = 0; // resolution.c switches it on until the game sets its render size (res_fn_hit)
|
||||
void fnprof_hit(uint64_t addr, uint64_t lr, uint64_t x0) { (void)lr, res_fn_hit(addr, x0); }
|
||||
|
||||
// cpu.h RT_FPCR_NOTE: diagnostic only, the write itself takes effect as before (runtime/simd.h slow paths).
|
||||
void rt_fpcr_rmode(uint64_t fpcr, uint64_t lr) {
|
||||
static int seen;
|
||||
if (__atomic_exchange_n(&seen, 1, __ATOMIC_RELAXED)) return;
|
||||
static const char *const mode[] = {"nearest", "+inf", "-inf", "zero"};
|
||||
char at[128];
|
||||
rt_log("fpcr: guest code set rounding mode %s (FPCR %#llx), in a function called from %s", mode[(fpcr >> 22) & 3],
|
||||
(unsigned long long)fpcr, ldr_describe(lr, at, sizeof at));
|
||||
}
|
||||
|
||||
void rt_brk(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
char at[128], lr[128];
|
||||
rt_fatal("brk #%#x at %s (lr %s)", imm, ldr_describe(pc, at, sizeof at), ldr_describe(c->x[30], lr, sizeof lr));
|
||||
|
||||
@@ -69,6 +69,7 @@ void rt_udf(Cpu *c, uint64_t pc) { (void)c; (void)pc; abort(); }
|
||||
uint64_t rt_ticks(void) { return 0; }
|
||||
volatile int g_fnprof;
|
||||
void fnprof_hit(uint64_t addr, uint64_t lr, uint64_t x0) { (void)addr; (void)lr; (void)x0; }
|
||||
void rt_fpcr_rmode(uint64_t fpcr, uint64_t lr) { (void)fpcr; (void)lr; }
|
||||
|
||||
static void *map_at(uint64_t addr, size_t len) {
|
||||
len = (len + 0xffff) & ~(size_t)0xffff;
|
||||
|
||||
Reference in new issue
Block a user