Files
PS2Recomp/ps2xRecomp/include/ps2recomp/control_flow_utils.h
T
Ranieri 5196a6672a Refactor runtime for move speed and better code style (#140)
* feat: added guestBranchKind enum to categorize branch types
feat: added missingFunctionPolicy enum to define behaviors for missing function scenarios
refactor: added handle guest branches and report missing functions
feat lookupFunction to utilize new dispatch logic and improve error handling for unregistered functions

* fix: fix test conflict

* feat: added debug sound driver logs

* feat: emmiter for return

* feat: added recompiler reporter
feat: added strict diagnostics flag for heavy debug calls

* feat: staticc table insted of hashmap for runtime

* feat: back file to ignore

* feat: explode code across helpers and classes

* feat: update codegen test
feat: better guest nop check

* feat: fix link problem on linux

* feat: fix Segmentation fault
2026-07-04 00:43:22 -03:00

36 lines
955 B
C++

#ifndef PS2RECOMP_CONTROL_FLOW_UTILS_H
#define PS2RECOMP_CONTROL_FLOW_UTILS_H
#include "ps2recomp/instructions.h"
#include <cstdint>
namespace ps2recomp
{
inline uint32_t buildAbsoluteJumpTarget(uint32_t address, uint32_t target) noexcept
{
return ((address + 4u) & 0xF0000000u) | (target << 2);
}
inline bool isGuestNop(const Instruction &inst) noexcept
{
const bool sllZero =
inst.opcode == OPCODE_SPECIAL &&
inst.function == SPECIAL_SLL &&
inst.rd == 0u &&
inst.rt == 0u &&
inst.sa == 0u;
// Some tests and decoded streams represent a no-op as addiu $zero, $zero, 0.
const bool addiuZero =
inst.opcode == OPCODE_ADDIU &&
inst.rs == 0u &&
inst.rt == 0u &&
static_cast<int16_t>(inst.simmediate) == 0;
return sllZero || addiuZero;
}
}
#endif // PS2RECOMP_CONTROL_FLOW_UTILS_H