CPU/Recompiler/AArch64: Use PC-relative branches to far code

This commit is contained in:
Connor McLaughlin 2019-12-27 20:37:38 +10:00
parent 9f45c67b1d
commit 620284f7d1
1 changed files with 7 additions and 13 deletions

View File

@ -209,11 +209,7 @@ void CodeGenerator::EmitExceptionExitOnBool(const Value& value)
// TODO: This is... not great.
a64::Label skip_branch;
m_emit->Cbz(GetHostReg64(value.host_reg), &skip_branch);
{
Value temp = m_register_cache.AllocateScratch(RegSize_64);
m_emit->Mov(GetHostReg64(temp), reinterpret_cast<intptr_t>(GetCurrentFarCodePointer()));
m_emit->Br(GetHostReg64(temp));
}
EmitBranch(GetCurrentFarCodePointer());
m_emit->Bind(&skip_branch);
SwitchToFarCode();
@ -1238,14 +1234,13 @@ Value CodeGenerator::EmitLoadGuestMemory(const Value& address, RegSize size)
break;
}
m_register_cache.PushState();
a64::Label load_okay;
m_emit->Tbz(GetHostReg64(result.host_reg), 63, &load_okay);
m_emit->Mov(GetHostReg64(result.host_reg), reinterpret_cast<intptr_t>(GetCurrentFarCodePointer()));
m_emit->Br(GetHostReg64(result.host_reg));
EmitBranch(GetCurrentFarCodePointer());
m_emit->Bind(&load_okay);
m_register_cache.PushState();
// load exception path
SwitchToFarCode();
EmitExceptionExit();
@ -1299,14 +1294,13 @@ void CodeGenerator::EmitStoreGuestMemory(const Value& address, const Value& valu
break;
}
m_register_cache.PushState();
a64::Label store_okay;
m_emit->Cbnz(GetHostReg64(result.host_reg), &store_okay);
m_emit->Mov(GetHostReg64(result.host_reg), reinterpret_cast<intptr_t>(GetCurrentFarCodePointer()));
m_emit->Br(GetHostReg64(result.host_reg));
EmitBranch(GetCurrentFarCodePointer());
m_emit->Bind(&store_okay);
m_register_cache.PushState();
// store exception path
SwitchToFarCode();
EmitExceptionExit();