[dynarmic] exclude r13 and r14 from regsel

This commit is contained in:
lizzie 2025-07-27 06:54:46 +01:00 committed by crueter
parent 8548ac8125
commit e447e2b099
6 changed files with 14 additions and 8 deletions

View file

@ -109,12 +109,12 @@ A32EmitX64::BlockDescriptor A32EmitX64::Emit(IR::Block& block) {
const boost::container::static_vector<HostLoc, 28> gpr_order = [this] { const boost::container::static_vector<HostLoc, 28> gpr_order = [this] {
boost::container::static_vector<HostLoc, 28> gprs{any_gpr}; boost::container::static_vector<HostLoc, 28> gprs{any_gpr};
if (conf.page_table) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R14));
}
if (conf.fastmem_pointer) { if (conf.fastmem_pointer) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R13)); gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R13));
} }
if (conf.page_table) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R14));
}
return gprs; return gprs;
}(); }();

View file

@ -80,12 +80,12 @@ A64EmitX64::BlockDescriptor A64EmitX64::Emit(IR::Block& block) noexcept {
const boost::container::static_vector<HostLoc, 28> gpr_order = [this] { const boost::container::static_vector<HostLoc, 28> gpr_order = [this] {
boost::container::static_vector<HostLoc, 28> gprs{any_gpr}; boost::container::static_vector<HostLoc, 28> gprs{any_gpr};
if (conf.page_table) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R14));
}
if (conf.fastmem_pointer) { if (conf.fastmem_pointer) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R13)); gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R13));
} }
if (conf.page_table) {
gprs.erase(std::find(gprs.begin(), gprs.end(), HostLoc::R14));
}
return gprs; return gprs;
}(); }();

View file

@ -331,6 +331,8 @@ void BlockOfCode::GenRunCode(std::function<void(BlockOfCode&)> rcp) {
mov(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], ABI_RETURN); mov(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], ABI_RETURN);
} }
// r14 = page table
// r13 = fastmem pointer
rcp(*this); rcp(*this);
cmp(dword[r15 + jsi.offsetof_halt_reason], 0); cmp(dword[r15 + jsi.offsetof_halt_reason], 0);

View file

@ -432,6 +432,11 @@ HostLoc RegAlloc::SelectARegister(const boost::container::static_vector<HostLoc,
// Abstain from using upper registers unless absolutely nescesary // Abstain from using upper registers unless absolutely nescesary
if (loc_info.IsLocked()) { if (loc_info.IsLocked()) {
// skip, not suitable for allocation // skip, not suitable for allocation
// While R13 and R14 are technically available, we avoid allocating for them
// at all costs, because theoretically skipping them is better than spilling
// all over the place - it also fixes bugs with high reg pressure
} else if (*it >= HostLoc::R13 && *it <= HostLoc::R15) {
// skip, do not touch
} else { } else {
if (loc_info.lru_counter < min_lru_counter) { if (loc_info.lru_counter < min_lru_counter) {
if (loc_info.IsEmpty()) if (loc_info.IsEmpty())

View file

@ -8,7 +8,6 @@
#include "./testenv.h" #include "./testenv.h"
#include "dynarmic/common/fp/fpsr.h" #include "dynarmic/common/fp/fpsr.h"
#include "dynarmic/common/llvm_disassemble.h"
#include "dynarmic/interface/exclusive_monitor.h" #include "dynarmic/interface/exclusive_monitor.h"
using namespace Dynarmic; using namespace Dynarmic;

File diff suppressed because one or more lines are too long