Refactor prep: Split JitInterface into MIPSFrontendInterface and JitInterface

This commit is contained in:
Henrik Rydgard committed 2016-05-09 19:41:39 +02:00
1 parent f50617d679
commit 6e44e97ffa
11 files changed
+44 -32

No files matched your search

+1 -1
View File
@@ -1109,7 +1109,7 @@ static int Hook_omertachinmokunookitethelegacy_download_frame() {
return 0;
}
#define JITFUNC(f) (&MIPSComp::JitInterface::f)
#define JITFUNC(f) (&MIPSComp::MIPSFrontendInterface::f)
// Can either replace with C functions or functions emitted in Asm/ArmAsm.
static const ReplacementTableEntry entries[] = {
+1 -1
View File
@@ -33,7 +33,7 @@
namespace MIPSComp {
class ArmJit : public ArmGen::ARMXCodeBlock, public JitInterface {
class ArmJit : public ArmGen::ARMXCodeBlock, public JitInterface, public MIPSFrontendInterface {
public:
ArmJit(MIPSState *mips);
virtual ~ArmJit();
+1 -1
View File
@@ -33,7 +33,7 @@
namespace MIPSComp {
class Arm64Jit : public Arm64Gen::ARM64CodeBlock, public JitInterface {
class Arm64Jit : public Arm64Gen::ARM64CodeBlock, public JitInterface, public MIPSFrontendInterface {
public:
Arm64Jit(MIPSState *mips);
virtual ~Arm64Jit();
+3 -1
View File
@@ -254,6 +254,8 @@ void IRJit::DoJit(u32 em_address, IRBlock *b) {
if (IRApplyPasses(passes, ARRAY_SIZE(passes), ir, simplified))
logBlocks = 1;
code = &simplified;
if (ir.GetInstructions().size() >= 24)
logBlocks = 1;
}
b->SetInstructions(code->GetInstructions(), code->GetConstants());
@@ -408,4 +410,4 @@ MIPSOpcode IRJit::GetOriginalOp(MIPSOpcode op) {
return b->GetOriginalFirstOp();
}
} // namespace MIPSComp
} // namespace MIPSComp
+1 -1
View File
@@ -101,7 +101,7 @@ private:
std::vector<IRBlock> blocks_;
};
class IRJit : public JitInterface {
class IRJit : public JitInterface, public MIPSFrontendInterface{
public:
IRJit(MIPSState *mips);
virtual ~IRJit();
+4
View File
@@ -121,6 +121,10 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) {
case IROp::And:
case IROp::Or:
case IROp::Xor:
// Regularize, for the add/or check below.
if (symmetric && inst.src2 == inst.dest && inst.src1 != inst.src2) {
std::swap(inst.src1, inst.src2);
}
if (gpr.IsImm(inst.src1) && gpr.IsImm(inst.src2)) {
gpr.SetImm(inst.dest, Evaluate(gpr.GetImm(inst.src1), gpr.GetImm(inst.src2), inst.op));
} else if (gpr.IsImm(inst.src2)) {
+26 -20
View File
@@ -42,27 +42,11 @@ class MIPSState;
namespace MIPSComp {
void JitAt();
class JitInterface {
class MIPSFrontendInterface {
public:
virtual ~JitInterface() {}
virtual ~MIPSFrontendInterface() {}
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;
virtual const u8 *GetDispatcher() const = 0;
virtual JitBlockCache *GetBlockCache() = 0;
virtual void InvalidateCache() = 0;
virtual void InvalidateCacheAt(u32 em_address, int length = 4) = 0;
virtual void DoState(PointerWrap &p) = 0;
virtual void DoDummyState(PointerWrap &p) = 0;
virtual void RunLoopUntil(u64 globalticks) = 0;
virtual void Compile(u32 em_address) = 0;
virtual void ClearCache() = 0;
virtual void EatPrefix() = 0;
virtual MIPSOpcode GetOriginalOp(MIPSOpcode op) = 0;
// Block linking. This may need to work differently for whole-function JITs and stuff
// like that.
virtual void LinkBlock(u8 *exitPoint, const u8 *entryPoint) = 0;
virtual void UnlinkBlock(u8 *checkedEntry, u32 originalAddress) = 0;
virtual void Comp_Generic(MIPSOpcode op) = 0;
virtual void Comp_RunBlock(MIPSOpcode op) = 0;
@@ -132,8 +116,30 @@ namespace MIPSComp {
virtual int Replace_fabsf() = 0;
};
typedef void (JitInterface::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (JitInterface::*MIPSReplaceFunc)();
class JitInterface {
public:
virtual ~JitInterface() {}
virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;
virtual const u8 *GetDispatcher() const = 0;
virtual JitBlockCache *GetBlockCache() = 0;
virtual void InvalidateCache() = 0;
virtual void InvalidateCacheAt(u32 em_address, int length = 4) = 0;
virtual void DoState(PointerWrap &p) = 0;
virtual void DoDummyState(PointerWrap &p) = 0;
virtual void RunLoopUntil(u64 globalticks) = 0;
virtual void Compile(u32 em_address) = 0;
virtual void ClearCache() = 0;
virtual MIPSOpcode GetOriginalOp(MIPSOpcode op) = 0;
// Block linking. This may need to work differently for whole-function JITs and stuff
// like that.
virtual void LinkBlock(u8 *exitPoint, const u8 *entryPoint) = 0;
virtual void UnlinkBlock(u8 *checkedEntry, u32 originalAddress) = 0;
};
typedef void (MIPSFrontendInterface::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (MIPSFrontendInterface::*MIPSReplaceFunc)();
extern JitInterface *jit;
+2 -1
View File
@@ -20,6 +20,7 @@
#include "Common/MipsEmitter.h"
using namespace MIPSGen;
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/MIPS/JitCommon/JitBlockCache.h"
#include "../MIPSVFPUUtils.h"
@@ -31,7 +32,7 @@ using namespace MIPSGen;
namespace MIPSComp
{
class MipsJit : public MIPSGen::MIPSCodeBlock, public JitInterface
class MipsJit : public MIPSGen::MIPSCodeBlock, public JitInterface, public MIPSFrontendInterface
{
public:
MipsJit(MIPSState *mips);
+2 -3
View File
@@ -82,7 +82,7 @@ struct MIPSInstruction {
#define ENCODING(a) {a}
#define INSTR(name, comp, dis, inter, flags) {Instruc, name, comp, dis, inter, MIPSInfo(flags)}
#define JITFUNC(f) (&JitInterface::f)
#define JITFUNC(f) (&MIPSFrontendInterface::f)
using namespace MIPSDis;
using namespace MIPSInt;
@@ -912,7 +912,7 @@ const MIPSInstruction *MIPSGetInstruction(MIPSOpcode op) {
return instr;
}
void MIPSCompileOp(MIPSOpcode op, MIPSComp::JitInterface *jit) {
void MIPSCompileOp(MIPSOpcode op, MIPSComp::MIPSFrontendInterface *jit) {
if (op == 0)
return;
const MIPSInstruction *instr = MIPSGetInstruction(op);
@@ -923,7 +923,6 @@ void MIPSCompileOp(MIPSOpcode op, MIPSComp::JitInterface *jit) {
} else {
ERROR_LOG_REPORT(CPU,"MIPSCompileOp %08x failed",op.encoding);
}
if (info & OUT_EAT_PREFIX)
jit->EatPrefix();
} else {
+2 -2
View File
@@ -112,10 +112,10 @@ typedef void (CDECL *MIPSDisFunc)(MIPSOpcode opcode, char *out);
typedef void (CDECL *MIPSInterpretFunc)(MIPSOpcode opcode);
namespace MIPSComp {
class JitInterface;
class MIPSFrontendInterface;
}
void MIPSCompileOp(MIPSOpcode op, MIPSComp::JitInterface *jit);
void MIPSCompileOp(MIPSOpcode op, MIPSComp::MIPSFrontendInterface *jit);
void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, bool tabsToSpaces = false);
MIPSInfo MIPSGetInfo(MIPSOpcode op);
void MIPSInterpret(MIPSOpcode op); //only for those rare ones
+1 -1
View File
@@ -46,7 +46,7 @@ struct RegCacheState {
FPURegCacheState fpr;
};
class Jit : public Gen::XCodeBlock, public JitInterface {
class Jit : public Gen::XCodeBlock, public JitInterface, public MIPSFrontendInterface {
public:
Jit(MIPSState *mips);
virtual ~Jit();