Best-effort update of the MipsJit prototype

This commit is contained in:
Henrik Rydgård 2015-04-12 11:53:16 -07:00 committed by Unknown W. Brackets
parent 0818c77f11
commit 071b6b986a
3 changed files with 37 additions and 60 deletions

View File

@ -34,10 +34,7 @@ typedef MIPSComp::Arm64Jit NativeJit;
typedef MIPSComp::Jit NativeJit; typedef MIPSComp::Jit NativeJit;
#elif defined(MIPS) #elif defined(MIPS)
#include "../MIPS/MipsJit.h" #include "../MIPS/MipsJit.h"
typedef MIPSComp::Jit NativeJit; typedef MIPSComp::MipsJit NativeJit;
//#elif defined(ARM64)
//#include "../ARM64/Arm64Jit.h"
//typedef MIPSComp::Arm64Jit NativeJit;
#else #else
#include "../fake/FakeJit.h" #include "../fake/FakeJit.h"
typedef MIPSComp::FakeJit NativeJit; typedef MIPSComp::FakeJit NativeJit;
@ -48,5 +45,4 @@ namespace MIPSComp {
typedef void (NativeJit::*MIPSCompileFunc)(MIPSOpcode opcode); typedef void (NativeJit::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (NativeJit::*MIPSReplaceFunc)(); typedef int (NativeJit::*MIPSReplaceFunc)();
} }

View File

@ -38,15 +38,7 @@ void DisassembleMIPS(const u8 *data, int size) {
namespace MIPSComp namespace MIPSComp
{ {
MIPSJitOptions::MIPSJitOptions() { MipsJit::MipsJit(MIPSState *mips) : blocks(mips, this), mips_(mips)
enableBlocklink = true;
immBranches = false;
continueBranches = false;
continueJumps = false;
continueMaxInstructions = 300;
}
Jit::Jit(MIPSState *mips) : blocks(mips, this), mips_(mips)
{ {
logBlocks = 0; logBlocks = 0;
dontLogBlocks = 0; dontLogBlocks = 0;
@ -55,7 +47,7 @@ Jit::Jit(MIPSState *mips) : blocks(mips, this), mips_(mips)
js.startDefaultPrefix = mips_->HasDefaultPrefix(); js.startDefaultPrefix = mips_->HasDefaultPrefix();
} }
void Jit::DoState(PointerWrap &p) void MipsJit::DoState(PointerWrap &p)
{ {
auto s = p.Section("Jit", 1, 2); auto s = p.Section("Jit", 1, 2);
if (!s) if (!s)
@ -71,7 +63,7 @@ void Jit::DoState(PointerWrap &p)
} }
// This is here so the savestate matches between jit and non-jit. // This is here so the savestate matches between jit and non-jit.
void Jit::DoDummyState(PointerWrap &p) void MipsJit::DoDummyState(PointerWrap &p)
{ {
auto s = p.Section("Jit", 1, 2); auto s = p.Section("Jit", 1, 2);
if (!s) if (!s)
@ -85,35 +77,35 @@ void Jit::DoDummyState(PointerWrap &p)
} }
} }
void Jit::FlushAll() void MipsJit::FlushAll()
{ {
//gpr.FlushAll(); //gpr.FlushAll();
//fpr.FlushAll(); //fpr.FlushAll();
FlushPrefixV(); FlushPrefixV();
} }
void Jit::FlushPrefixV() void MipsJit::FlushPrefixV()
{ {
} }
void Jit::ClearCache() void MipsJit::ClearCache()
{ {
blocks.Clear(); blocks.Clear();
ClearCodeSpace(); ClearCodeSpace();
//GenerateFixedCode(); //GenerateFixedCode();
} }
void Jit::InvalidateCache() void MipsJit::InvalidateCache()
{ {
blocks.Clear(); blocks.Clear();
} }
void Jit::InvalidateCacheAt(u32 em_address, int length) void MipsJit::InvalidateCacheAt(u32 em_address, int length)
{ {
blocks.InvalidateICache(em_address, length); blocks.InvalidateICache(em_address, length);
} }
void Jit::EatInstruction(MIPSOpcode op) { void MipsJit::EatInstruction(MIPSOpcode op) {
MIPSInfo info = MIPSGetInfo(op); MIPSInfo info = MIPSGetInfo(op);
if (info & DELAYSLOT) { if (info & DELAYSLOT) {
ERROR_LOG_REPORT_ONCE(ateDelaySlot, JIT, "Ate a branch op."); ERROR_LOG_REPORT_ONCE(ateDelaySlot, JIT, "Ate a branch op.");
@ -127,7 +119,7 @@ void Jit::EatInstruction(MIPSOpcode op) {
js.downcountAmount += MIPSGetInstructionCycleEstimate(op); js.downcountAmount += MIPSGetInstructionCycleEstimate(op);
} }
void Jit::CompileDelaySlot(int flags) void MipsJit::CompileDelaySlot(int flags)
{ {
//if (flags & DELAYSLOT_SAFE) //if (flags & DELAYSLOT_SAFE)
// Save flags here // Save flags here
@ -144,7 +136,7 @@ void Jit::CompileDelaySlot(int flags)
} }
void Jit::Compile(u32 em_address) { void MipsJit::Compile(u32 em_address) {
if (GetSpaceLeft() < 0x10000 || blocks.IsFull()) { if (GetSpaceLeft() < 0x10000 || blocks.IsFull()) {
ClearCache(); ClearCache();
} }
@ -169,12 +161,12 @@ void Jit::Compile(u32 em_address) {
} }
} }
void Jit::RunLoopUntil(u64 globalticks) void MipsJit::RunLoopUntil(u64 globalticks)
{ {
((void (*)())enterCode)(); ((void (*)())enterCode)();
} }
const u8 *Jit::DoJit(u32 em_address, JitBlock *b) const u8 *MipsJit::DoJit(u32 em_address, JitBlock *b)
{ {
js.cancel = false; js.cancel = false;
js.blockStart = js.compilerPC = mips_->pc; js.blockStart = js.compilerPC = mips_->pc;
@ -224,7 +216,7 @@ const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
return b->normalEntry; return b->normalEntry;
} }
void Jit::AddContinuedBlock(u32 dest) void MipsJit::AddContinuedBlock(u32 dest)
{ {
// The first block is the root block. When we continue, we create proxy blocks after that. // The first block is the root block. When we continue, we create proxy blocks after that.
if (js.lastContinuedPC == 0) if (js.lastContinuedPC == 0)
@ -234,27 +226,27 @@ void Jit::AddContinuedBlock(u32 dest)
js.lastContinuedPC = dest; js.lastContinuedPC = dest;
} }
bool Jit::DescribeCodePtr(const u8 *ptr, std::string &name) bool MipsJit::DescribeCodePtr(const u8 *ptr, std::string &name)
{ {
// TODO: Not used by anything yet. // TODO: Not used by anything yet.
return false; return false;
} }
void Jit::Comp_RunBlock(MIPSOpcode op) void MipsJit::Comp_RunBlock(MIPSOpcode op)
{ {
// This shouldn't be necessary, the dispatcher should catch us before we get here. // This shouldn't be necessary, the dispatcher should catch us before we get here.
ERROR_LOG(JIT, "Comp_RunBlock should never be reached!"); ERROR_LOG(JIT, "Comp_RunBlock should never be reached!");
} }
bool Jit::ReplaceJalTo(u32 dest) { bool MipsJit::ReplaceJalTo(u32 dest) {
return true; return true;
} }
void Jit::Comp_ReplacementFunc(MIPSOpcode op) void MipsJit::Comp_ReplacementFunc(MIPSOpcode op)
{ {
} }
void Jit::Comp_Generic(MIPSOpcode op) void MipsJit::Comp_Generic(MIPSOpcode op)
{ {
FlushAll(); FlushAll();
MIPSInterpretFunc func = MIPSGetInterpretFunc(op); MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
@ -277,34 +269,34 @@ void Jit::Comp_Generic(MIPSOpcode op)
} }
} }
void Jit::MovFromPC(MIPSReg r) { void MipsJit::MovFromPC(MIPSReg r) {
} }
void Jit::MovToPC(MIPSReg r) { void MipsJit::MovToPC(MIPSReg r) {
} }
void Jit::SaveDowncount() { void MipsJit::SaveDowncount() {
} }
void Jit::RestoreDowncount() { void MipsJit::RestoreDowncount() {
} }
void Jit::WriteDownCount(int offset) { void MipsJit::WriteDownCount(int offset) {
} }
void Jit::WriteDownCountR(MIPSReg reg) { void MipsJit::WriteDownCountR(MIPSReg reg) {
} }
void Jit::RestoreRoundingMode(bool force) { void MipsJit::RestoreRoundingMode(bool force) {
} }
void Jit::ApplyRoundingMode(bool force) { void MipsJit::ApplyRoundingMode(bool force) {
} }
void Jit::UpdateRoundingMode() { void MipsJit::UpdateRoundingMode() {
} }
void Jit::WriteExit(u32 destination, int exit_num) void MipsJit::WriteExit(u32 destination, int exit_num)
{ {
//WriteDownCount(); //WriteDownCount();
JitBlock *b = js.curBlock; JitBlock *b = js.curBlock;
@ -323,7 +315,7 @@ void Jit::WriteExit(u32 destination, int exit_num)
} }
} }
void Jit::WriteExitDestInR(MIPSReg Reg) void MipsJit::WriteExitDestInR(MIPSReg Reg)
{ {
MovToPC(Reg); MovToPC(Reg);
//WriteDownCount(); //WriteDownCount();
@ -331,7 +323,7 @@ void Jit::WriteExitDestInR(MIPSReg Reg)
B((const void *)dispatcher); B((const void *)dispatcher);
} }
void Jit::WriteSyscallExit() void MipsJit::WriteSyscallExit()
{ {
//WriteDownCount(); //WriteDownCount();
B((const void *)dispatcherCheckCoreState); B((const void *)dispatcherCheckCoreState);

View File

@ -28,21 +28,10 @@
namespace MIPSComp namespace MIPSComp
{ {
struct MIPSJitOptions class MipsJit : public MIPSGen::MIPSCodeBlock
{
MIPSJitOptions();
bool enableBlocklink;
bool immBranches;
bool continueBranches;
bool continueJumps;
int continueMaxInstructions;
};
class Jit : public MIPSGen::MIPSCodeBlock
{ {
public: public:
Jit(MIPSState *mips); MipsJit(MIPSState *mips);
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
static void DoDummyState(PointerWrap &p); static void DoDummyState(PointerWrap &p);
@ -165,7 +154,7 @@ private:
void WriteSyscallExit(); void WriteSyscallExit();
JitBlockCache blocks; JitBlockCache blocks;
MIPSJitOptions jo; JitOptions jo;
JitState js; JitState js;
MIPSState *mips_; MIPSState *mips_;
@ -187,8 +176,8 @@ public:
const u8 *breakpointBailout; const u8 *breakpointBailout;
}; };
typedef void (Jit::*MIPSCompileFunc)(MIPSOpcode opcode); typedef void (MipsJit::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (Jit::*MIPSReplaceFunc)(); typedef int (MipsJit::*MIPSReplaceFunc)();
} // namespace MIPSComp } // namespace MIPSComp