DSPAnalyzer: Disable update SR analysis

It doesn't work right in all situations, including in the cond_test hardware test.  It could definitely be fixed, but it would be a hassle to do so.
This commit is contained in:
Pokechu22 2021-08-19 10:04:42 -07:00
parent 464575702b
commit 105d8860fb
2 changed files with 15 additions and 0 deletions

View File

@ -91,7 +91,9 @@ void Analyzer::FindInstructionStarts(const SDSP& dsp, u16 start_addr, u16 end_ad
{ {
// This may not be 100% accurate in case of jump tables! // This may not be 100% accurate in case of jump tables!
// It could get desynced, which would be bad. We'll see if that's an issue. // It could get desynced, which would be bad. We'll see if that's an issue.
#ifndef DISABLE_UPDATE_SR_ANALYSIS
u16 last_arithmetic = 0; u16 last_arithmetic = 0;
#endif
for (u16 addr = start_addr; addr < end_addr;) for (u16 addr = start_addr; addr < end_addr;)
{ {
const UDSPInstruction inst = dsp.ReadIMEM(addr); const UDSPInstruction inst = dsp.ReadIMEM(addr);
@ -117,6 +119,7 @@ void Analyzer::FindInstructionStarts(const SDSP& dsp, u16 start_addr, u16 end_ad
m_code_flags[static_cast<u16>(addr + 1u)] |= CODE_LOOP_END; m_code_flags[static_cast<u16>(addr + 1u)] |= CODE_LOOP_END;
} }
#ifndef DISABLE_UPDATE_SR_ANALYSIS
// Mark the last arithmetic/multiplier instruction before a branch. // Mark the last arithmetic/multiplier instruction before a branch.
// We must update the SR reg at these instructions // We must update the SR reg at these instructions
if (opcode->updates_sr) if (opcode->updates_sr)
@ -128,6 +131,7 @@ void Analyzer::FindInstructionStarts(const SDSP& dsp, u16 start_addr, u16 end_ad
{ {
m_code_flags[last_arithmetic] |= CODE_UPDATE_SR; m_code_flags[last_arithmetic] |= CODE_UPDATE_SR;
} }
#endif
// If an instruction potentially raises exceptions, mark the following // If an instruction potentially raises exceptions, mark the following
// instruction as needing to check for exceptions // instruction as needing to check for exceptions

View File

@ -6,6 +6,13 @@
#include <array> #include <array>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
// The update SR analysis is not perfect: it does not properly handle modified SR values if SR is
// only read within a function call, and it's possible that a previous instruction sets SR (e.g. the
// logical zero bit, or the sticky overflow bit) but is marked as not changing SR as a later
// instruction sets it. When this flag is set, we always treat instructions as updating SR, and
// disable the analysis for if SR needs to be set.
#define DISABLE_UPDATE_SR_ANALYSIS
namespace DSP namespace DSP
{ {
struct SDSP; struct SDSP;
@ -63,7 +70,11 @@ public:
// Whether or not the address describes an instruction that requires updating the SR register. // Whether or not the address describes an instruction that requires updating the SR register.
[[nodiscard]] bool IsUpdateSR(u16 address) const [[nodiscard]] bool IsUpdateSR(u16 address) const
{ {
#ifdef DISABLE_UPDATE_SR_ANALYSIS
return true;
#else
return (GetCodeFlags(address) & CODE_UPDATE_SR) != 0; return (GetCodeFlags(address) & CODE_UPDATE_SR) != 0;
#endif
} }
// Whether or not the address describes instructions that potentially raise exceptions. // Whether or not the address describes instructions that potentially raise exceptions.