Skip to content

Commit

Permalink
mipsjit: Fix basic compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Feb 9, 2021
1 parent c7635a5 commit 4e24b27
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Core/MIPS/JitCommon/JitState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ namespace MIPSComp {

// We can get block linking to work with W^X by doing even more unprotect/re-protect, but let's try without first.
// enableBlocklink = !PlatformIsWXExclusive(); // Revert to this line if block linking is slow in W^X mode
#if PPSSPP_ARCH(MIPS)
enableBlocklink = false;
#else
enableBlocklink = !Disabled(JitDisable::BLOCKLINK);
#endif
immBranches = false;
continueBranches = false;
continueJumps = false;
Expand Down
18 changes: 18 additions & 0 deletions Core/MIPS/MIPS/MipsJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ void MipsJit::FlushPrefixV()
{
}

MIPSOpcode MipsJit::GetOriginalOp(MIPSOpcode op) {
JitBlockCache *bc = GetBlockCache();
int block_num = bc->GetBlockNumberFromEmuHackOp(op, true);
if (block_num >= 0) {
return bc->GetOriginalFirstOp(block_num);
} else {
return op;
}
}

void MipsJit::ClearCache()
{
blocks.Clear();
Expand Down Expand Up @@ -226,6 +236,14 @@ void MipsJit::Comp_RunBlock(MIPSOpcode op)
ERROR_LOG(JIT, "Comp_RunBlock should never be reached!");
}

void MipsJit::LinkBlock(u8 *exitPoint, const u8 *checkedEntry) {
// TODO
}

void MipsJit::UnlinkBlock(u8 *checkedEntry, u32 originalAddress) {
// TODO
}

bool MipsJit::ReplaceJalTo(u32 dest) {
const ReplacementTableEntry *entry = nullptr;
u32 funcSize = 0;
Expand Down
14 changes: 11 additions & 3 deletions Core/MIPS/MIPS/MipsJit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class MipsJit : public MIPSGen::MIPSCodeBlock, public JitInterface, public MIPSF
void Compile(u32 em_address) override; // Compiles a block at current MIPS PC
const u8 *DoJit(u32 em_address, JitBlock *b);

const u8 *GetCrashHandler() const override { return nullptr; }
bool CodeInRange(const u8 *ptr) const override { return IsInSpace(ptr); }
bool DescribeCodePtr(const u8 *ptr, std::string &name);

void CompileDelaySlot(int flags);
Expand Down Expand Up @@ -131,13 +133,22 @@ class MipsJit : public MIPSGen::MIPSCodeBlock, public JitInterface, public MIPSF
JitBlockCache *GetBlockCache() override { return &blocks; }
JitBlockCacheDebugInterface *GetBlockCacheDebugInterface() override { return &blocks; }

MIPSOpcode GetOriginalOp(MIPSOpcode op) override;

std::vector<u32> SaveAndClearEmuHackOps() override { return blocks.SaveAndClearEmuHackOps(); }
void RestoreSavedEmuHackOps(std::vector<u32> saved) override { blocks.RestoreSavedEmuHackOps(saved); }

void ClearCache() override;
void InvalidateCacheAt(u32 em_address, int length = 4) override;
void UpdateFCR31() override;

const u8 *GetDispatcher() const override {
return dispatcher;
}

void LinkBlock(u8 *exitPoint, const u8 *checkedEntry) override;
void UnlinkBlock(u8 *checkedEntry, u32 originalAddress) override;

void EatPrefix() override { js.EatPrefix(); }

private:
Expand Down Expand Up @@ -183,8 +194,5 @@ class MipsJit : public MIPSGen::MIPSCodeBlock, public JitInterface, public MIPSF
const u8 *dispatcherNoCheck;
};

typedef void (MipsJit::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (MipsJit::*MIPSReplaceFunc)();

} // namespace MIPSComp

0 comments on commit 4e24b27

Please sign in to comment.