[dynarmic] fix pre-SSE4.1 having errors on CMHI/CMLO, fix extra nuisances and add INTERP testcase (#4025)
Some checks are pending
tx-src / sources (push) Waiting to run
Check Strings / check-strings (push) Waiting to run

does a bit of code dedup
fixes pre-SSE4.1 having horrific CMHI/CMLO

Signed-off-by: lizzie <lizzie@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4025
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
lizzie 2026-06-03 22:53:21 +02:00 committed by crueter
parent f729dbb3c3
commit ad9af25027
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
6 changed files with 158 additions and 115 deletions

View file

@ -262,20 +262,16 @@ enum {
CMP_ORD = 7,
};
constexpr bool IsWithin2G(uintptr_t ref, uintptr_t target) {
const u64 distance = target - (ref + 5);
return !(distance >= 0x8000'0000ULL && distance <= ~0x8000'0000ULL);
}
inline bool IsWithin2G(const Xbyak::CodeGenerator& code, uintptr_t target) {
return IsWithin2G(reinterpret_cast<uintptr_t>(code.getCurr()), target);
constexpr bool IsWithin2G(uintptr_t ref, uintptr_t target) noexcept {
u64 const distance = target - (ref + 5);
return (distance & 0xffff'ffff) == distance;
}
template <typename T>
inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) {
static_assert(std::is_pointer_v<T>, "Argument must be a (function) pointer.");
size_t addr = reinterpret_cast<size_t>(f);
if (IsWithin2G(code, addr)) {
uintptr_t addr = uintptr_t(f);
if (IsWithin2G(uintptr_t(code.getCurr()), addr)) {
code.call(f);
} else {
// ABI_RETURN is a safe temp register to use before a call