Permalink
Browse files

More RIP removal

  • Loading branch information...
hrydgard committed Jul 5, 2017
1 parent 78538ff commit d82f90f1b2084d5cc170645c9c7a2656545b93ff
Showing with 25 additions and 22 deletions.
  1. +8 −0 Common/x64Emitter.h
  2. +10 −7 Core/MIPS/x86/CompVFPU.cpp
  3. +6 −11 Core/MIPS/x86/Jit.cpp
  4. +1 −4 Core/System.h
View
@@ -1073,6 +1073,14 @@ class XEmitter
class XCodeBlock : public CodeBlock<XEmitter> {
public:
void PoisonMemory(int offset) override;
bool RipAccessible(void *ptr) const {
#ifdef _M_IX86
return true;
#else
ptrdiff_t diff = GetCodePtr() - (const uint8_t *)ptr;
return diff > -0x7FFFFFFF && diff < 0x7FFFFFFF;
#endif
}
};
} // namespace
View
@@ -61,7 +61,6 @@ using namespace X64JitConstants;
static const float one = 1.0f;
static const float minus_one = -1.0f;
static const float zero = 0.0f;
const u32 MEMORY_ALIGNED16( noSignMask[4] ) = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
const u32 MEMORY_ALIGNED16( signBitAll[4] ) = {0x80000000, 0x80000000, 0x80000000, 0x80000000};
@@ -172,7 +171,8 @@ void Jit::ApplyPrefixD(const u8 *vregs, VectorSize sz) {
// Zero out XMM0 if it was <= +0.0f (but skip NAN.)
MOVSS(R(XMM0), fpr.VX(vregs[i]));
CMPLESS(XMM0, M(&zero));
XORPS(XMM1, R(XMM1));
CMPLESS(XMM0, R(XMM1));
ANDNPS(XMM0, fpr.V(vregs[i]));
// Retain a NAN in XMM0 (must be second operand.)
@@ -3200,21 +3200,22 @@ void Jit::Comp_Vhoriz(MIPSOpcode op) {
GetVectorRegsPrefixD(dregs, V_Single, _VD);
if (fpr.TryMapDirtyInVS(dregs, V_Single, sregs, sz)) {
if (cpu_info.bSSE4_1) {
MOV(PTRBITS, R(TEMPREG), ImmPtr(&oneOneOneOne));
switch (sz) {
case V_Pair:
MOVAPS(XMM0, fpr.VS(sregs));
DPPS(XMM0, M(&oneOneOneOne), 0x31);
DPPS(XMM0, MatR(TEMPREG), 0x31);
MOVAPS(fpr.VSX(dregs), R(XMM0));
break;
case V_Triple:
MOVAPS(XMM0, fpr.VS(sregs));
DPPS(XMM0, M(&oneOneOneOne), 0x71);
DPPS(XMM0, MatR(TEMPREG), 0x71);
MOVAPS(fpr.VSX(dregs), R(XMM0));
break;
case V_Quad:
XORPS(XMM1, R(XMM1));
MOVAPS(XMM0, fpr.VS(sregs));
DPPS(XMM0, M(&oneOneOneOne), 0xF1);
DPPS(XMM0, MatR(TEMPREG), 0xF1);
// In every other case, +0.0 is selected by the mask and added.
// But, here we need to manually add it to the result.
ADDPS(XMM0, R(XMM1));
@@ -3260,7 +3261,8 @@ void Jit::Comp_Vhoriz(MIPSOpcode op) {
}
}
if (((op >> 16) & 31) == 7) { // vavg
MULSS(fpr.VSX(dregs), M(&vavg_table[n - 1]));
MOV(PTRBITS, R(TEMPREG), ImmPtr(&vavg_table[n - 1]));
MULSS(fpr.VSX(dregs), MatR(TEMPREG));
}
ApplyPrefixD(dregs, V_Single);
fpr.ReleaseSpillLocks();
@@ -3288,7 +3290,8 @@ void Jit::Comp_Vhoriz(MIPSOpcode op) {
case 6: // vfad
break;
case 7: // vavg
MULSS(reg, M(&vavg_table[n - 1]));
MOV(PTRBITS, R(TEMPREG), ImmPtr(&vavg_table[n - 1]));
MULSS(reg, MatR(TEMPREG));
break;
}
View
@@ -329,8 +329,7 @@ MIPSOpcode Jit::GetOffsetInstruction(int offset) {
return Memory::Read_Instruction(GetCompilerPC() + 4 * offset);
}
const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
{
const u8 *Jit::DoJit(u32 em_address, JitBlock *b) {
js.cancel = false;
js.blockStart = js.compilerPC = mips_->pc;
js.lastContinuedPC = 0;
@@ -394,8 +393,7 @@ const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
js.numInstructions++;
// Safety check, in case we get a bunch of really large jit ops without a lot of branching.
if (GetSpaceLeft() < 0x800 || js.numInstructions >= JitBlockCache::MAX_BLOCK_INSTRUCTIONS)
{
if (GetSpaceLeft() < 0x800 || js.numInstructions >= JitBlockCache::MAX_BLOCK_INSTRUCTIONS) {
FlushAll();
WriteExit(GetCompilerPC(), js.nextExit++);
js.compiling = false;
@@ -405,19 +403,17 @@ const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
b->codeSize = (u32)(GetCodePtr() - b->normalEntry);
NOP();
AlignCode4();
if (js.lastContinuedPC == 0)
if (js.lastContinuedPC == 0) {
b->originalSize = js.numInstructions;
else
{
} else {
// We continued at least once. Add the last proxy and set the originalSize correctly.
blocks.ProxyBlock(js.blockStart, js.lastContinuedPC, (GetCompilerPC() - js.lastContinuedPC) / sizeof(u32), GetCodePtr());
b->originalSize = js.initialBlockSize;
}
return b->normalEntry;
}
void Jit::AddContinuedBlock(u32 dest)
{
void Jit::AddContinuedBlock(u32 dest) {
// The first block is the root block. When we continue, we create proxy blocks after that.
if (js.lastContinuedPC == 0)
js.initialBlockSize = js.numInstructions;
@@ -703,8 +699,7 @@ void Jit::WriteExit(u32 destination, int exit_num) {
void Jit::WriteExitDestInReg(X64Reg reg) {
// If we need to verify coreState and rewind, we may not jump yet.
if (js.afterOp & (JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE))
{
if (js.afterOp & (JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE)) {
// CORE_RUNNING is <= CORE_NEXTFRAME.
CMP(32, M(&coreState), Imm32(CORE_NEXTFRAME));
FixupBranch skipCheck = J_CC(CC_LE);
View
@@ -72,8 +72,6 @@ void PSP_BeginHostFrame();
void PSP_EndHostFrame();
void PSP_RunLoopUntil(u64 globalticks);
void PSP_RunLoopFor(int cycles);
void PSP_BeginFrame();
void PSP_EndFrame();
void Audio_Init();
@@ -88,8 +86,7 @@ void InitSysDirectories();
#endif
// RUNNING must be at 0, NEXTFRAME must be at 1.
enum CoreState
{
enum CoreState {
CORE_RUNNING = 0,
CORE_NEXTFRAME = 1,
CORE_STEPPING,

0 comments on commit d82f90f

Please sign in to comment.