Permalink
Browse files

Remove RIP access from some matrix ops, SafeMem

  • Loading branch information...
hrydgard committed Jul 5, 2017
1 parent 2e9a9f2 commit 102be8654fcbdcf9da82e412675f28d29083d2cc
Showing with 22 additions and 9 deletions.
  1. +17 −4 Core/MIPS/x86/CompVFPU.cpp
  2. +5 −5 Core/MIPS/x86/JitSafeMem.cpp
View
@@ -2086,6 +2086,7 @@ void Jit::Comp_Vbfy(MIPSOpcode op) {
fpr.ReleaseSpillLocks();
}
static float sincostemp[2];
union u32float {
@@ -2473,19 +2474,29 @@ void Jit::Comp_VMatrixInit(MIPSOpcode op) {
VectorSize vsz = GetVectorSize(sz);
u8 vecs[4];
GetMatrixColumns(_VD, sz, vecs);
switch ((op >> 16) & 0xF) {
case 3:
MOV(PTRBITS, R(TEMPREG), ImmPtr(&identityMatrix[0]));
break;
case 7:
MOV(PTRBITS, R(TEMPREG), ImmPtr(&oneOneOneOne));
MOVAPS(XMM0, MatR(TEMPREG));
break;
}
for (int i = 0; i < n; i++) {
u8 vec[4];
GetVectorRegs(vec, vsz, vecs[i]);
fpr.MapRegsVS(vec, vsz, MAP_NOINIT | MAP_DIRTY);
switch ((op >> 16) & 0xF) {
case 3:
MOVAPS(fpr.VSX(vec), M(&identityMatrix[i]));
MOVAPS(fpr.VSX(vec), MDisp(TEMPREG, 16 * i));
break;
case 6:
XORPS(fpr.VSX(vec), fpr.VS(vec));
break;
case 7:
MOVAPS(fpr.VSX(vec), M(&oneOneOneOne));
MOVAPS(fpr.VSX(vec), R(XMM0));
break;
}
}
@@ -2502,7 +2513,8 @@ void Jit::Comp_VMatrixInit(MIPSOpcode op) {
switch ((op >> 16) & 0xF) {
case 3: // vmidt
XORPS(XMM0, R(XMM0));
MOVSS(XMM1, M(&one));
MOV(PTRBITS, R(TEMPREG), ImmPtr(&one));
MOVSS(XMM1, MatR(TEMPREG));
for (int a = 0; a < n; a++) {
for (int b = 0; b < n; b++) {
MOVSS(fpr.V(dregs[a * 4 + b]), a == b ? XMM1 : XMM0);
@@ -2518,7 +2530,8 @@ void Jit::Comp_VMatrixInit(MIPSOpcode op) {
}
break;
case 7: // vmone
MOVSS(XMM0, M(&one));
MOV(PTRBITS, R(TEMPREG), ImmPtr(&one));
MOVSS(XMM0, MatR(TEMPREG));
for (int a = 0; a < n; a++) {
for (int b = 0; b < n; b++) {
MOVSS(fpr.V(dregs[a * 4 + b]), XMM0);
@@ -268,7 +268,7 @@ void JitSafeMem::DoSlowWrite(const void *safeFunc, const OpArg& src, int suboffs
jit_->MOV(32, R(EDX), src);
}
if (!g_Config.bIgnoreBadMemAccess) {
jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->GetCompilerPC()));
jit_->MOV(32, MIPSSTATE_VAR(pc), Imm32(jit_->GetCompilerPC()));
}
// This is a special jit-ABI'd function.
jit_->CALL(safeFunc);
@@ -298,7 +298,7 @@ bool JitSafeMem::PrepareSlowRead(const void *safeFunc)
}
if (!g_Config.bIgnoreBadMemAccess) {
jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->GetCompilerPC()));
jit_->MOV(32, MIPSSTATE_VAR(pc), Imm32(jit_->GetCompilerPC()));
}
// This is a special jit-ABI'd function.
jit_->CALL(safeFunc);
@@ -332,7 +332,7 @@ void JitSafeMem::NextSlowRead(const void *safeFunc, int suboffset)
}
if (!g_Config.bIgnoreBadMemAccess) {
jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->GetCompilerPC()));
jit_->MOV(32, MIPSSTATE_VAR(pc), Imm32(jit_->GetCompilerPC()));
}
// This is a special jit-ABI'd function.
jit_->CALL(safeFunc);
@@ -364,7 +364,7 @@ void JitSafeMem::MemCheckImm(MemoryOpType type)
if (!(check->cond & MEMCHECK_WRITE) && type == MEM_WRITE)
return;
jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->GetCompilerPC()));
jit_->MOV(32, MIPSSTATE_VAR(pc), Imm32(jit_->GetCompilerPC()));
jit_->CallProtectedFunction(&JitMemCheck, iaddr_, size_, type == MEM_WRITE ? 1 : 0);
// CORE_RUNNING is <= CORE_NEXTFRAME.
@@ -404,7 +404,7 @@ void JitSafeMem::MemCheckAsm(MemoryOpType type)
// Keep the stack 16-byte aligned, just PUSH/POP 4 times.
for (int i = 0; i < 4; ++i)
jit_->PUSH(xaddr_);
jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->GetCompilerPC()));
jit_->MOV(32, MIPSSTATE_VAR(pc), Imm32(jit_->GetCompilerPC()));
jit_->ADD(32, R(xaddr_), Imm32(offset_));
jit_->CallProtectedFunction(&JitMemCheck, R(xaddr_), size_, type == MEM_WRITE ? 1 : 0);
for (int i = 0; i < 4; ++i)

0 comments on commit 102be86

Please sign in to comment.