Integrate new MIPS emitter.

This commit is contained in:
xSacha authored and Unknown W. Brackets committed 2014-11-18 08:40:57 -08:00
1 parent 8b6a5f2ecc
commit 3172fa22e2
9 files changed
+466 -18

No files matched your search

+11
View File
@@ -298,6 +298,11 @@ elseif(X86)
Common/x64Analyzer.h
Common/x64Emitter.cpp
Common/x64Emitter.h)
elseif(MIPS)
set(CommonExtra ${CommonExtra}
Common/FakeCPUDetect.cpp
Common/MipsEmitter.cpp
Common/MipsEmitter.h)
else()
set(CommonExtra ${CommonExtra}
Common/FakeCPUDetect.cpp
@@ -1069,6 +1074,12 @@ elseif(X86)
Core/MIPS/x86/RegCacheFPU.h
GPU/Common/VertexDecoderX86.cpp
ext/disarm.cpp)
elseif(MIPS)
set(CoreExtra ${CoreExtra}
Core/MIPS/MIPS/MipsJit.cpp
Core/MIPS/MIPS/MipsJit.h
GPU/Common/VertexDecoderFake.cpp
ext/disarm.cpp)
else()
set(CoreExtra ${CoreExtra}
Core/MIPS/fake/FakeJit.cpp
+5
View File
@@ -49,6 +49,11 @@ typedef Gen::XCodeBlock CodeBlock;
namespace PpcGen { class PPCXEmitter; }
using namespace PpcGen;
typedef PpcGen::PPCXCodeBlock CodeBlock;
#elif defined(MIPS)
#include "Common/MipsEmitter.h"
namespace MIPSGen { class MIPSXEmitter; }
using namespace MIPSGen;
typedef MIPSGen::MIPSXCodeBlock CodeBlock;
#else
#warning "Unsupported arch!"
#include "Common/FakeEmitter.h"
+2
View File
@@ -34,6 +34,8 @@ struct JitBlock;
#include "../ARM/ArmJit.h"
#elif defined(_M_IX86) || defined(_M_X64)
#include "../x86/Jit.h"
#elif defined(MIPS)
#include "../MIPS/MipsJit.h"
#else
#include "../fake/FakeJit.h"
#endif
+2
View File
@@ -38,6 +38,8 @@
#include "ARM/ArmJit.h"
#elif defined(_M_IX86) || defined(_M_X64)
#include "x86/Jit.h"
#elif defined(MIPS)
#include "MIPS/MipsJit.h"
#else
#include "fake/FakeJit.h"
#endif
+239
View File
@@ -0,0 +1,239 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "base/logging.h"
#include "Common/ChunkFile.h"
#include "Core/Reporting.h"
#include "Core/Config.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/SymbolMap.h"
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/MIPS/MIPSCodeUtils.h"
#include "Core/MIPS/MIPSInt.h"
#include "Core/MIPS/MIPSTables.h"
#include "Core/HLE/ReplaceTables.h"
#include "MipsJit.h"
#include "CPUDetect.h"
void DisassembleMIPS(const u8 *data, int size) {
}
namespace MIPSComp
{
MIPSJitOptions::MIPSJitOptions() {
enableBlocklink = true;
downcountInRegister = true;
useBackJump = false;
useForwardJump = false;
cachePointers = true;
immBranches = false;
continueBranches = false;
continueJumps = false;
continueMaxInstructions = 300;
}
Jit::Jit(MIPSState *mips) : blocks(mips, this), mips_(mips)
{
logBlocks = 0;
dontLogBlocks = 0;
blocks.Init();
}
void Jit::DoState(PointerWrap &p)
{
auto s = p.Section("Jit", 1, 2);
if (!s)
return;
p.Do(js.startDefaultPrefix);
if (s >= 2) {
p.Do(js.hasSetRounding);
js.lastSetRounding = 0;
} else {
js.hasSetRounding = 1;
}
}
// This is here so the savestate matches between jit and non-jit.
void Jit::DoDummyState(PointerWrap &p)
{
auto s = p.Section("Jit", 1, 2);
if (!s)
return;
bool dummy = false;
p.Do(dummy);
if (s >= 2) {
dummy = true;
p.Do(dummy);
}
}
void Jit::FlushAll()
{
FlushPrefixV();
}
void Jit::FlushPrefixV()
{
}
void Jit::ClearCache()
{
blocks.Clear();
ClearCodeSpace();
}
void Jit::InvalidateCache()
{
blocks.Clear();
}
void Jit::InvalidateCacheAt(u32 em_address, int length)
{
blocks.InvalidateICache(em_address, length);
}
void Jit::EatInstruction(MIPSOpcode op) {
}
void Jit::CompileDelaySlot(int flags)
{
}
void Jit::Compile(u32 em_address) {
}
void Jit::RunLoopUntil(u64 globalticks)
{
((void (*)())enterCode)();
}
const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
{
return b->normalEntry;
}
void Jit::AddContinuedBlock(u32 dest)
{
}
bool Jit::DescribeCodePtr(const u8 *ptr, std::string &name)
{
// TODO: Not used by anything yet.
return false;
}
void Jit::Comp_RunBlock(MIPSOpcode op)
{
// This shouldn't be necessary, the dispatcher should catch us before we get here.
ERROR_LOG(JIT, "Comp_RunBlock should never be reached!");
}
bool Jit::ReplaceJalTo(u32 dest) {
return true;
}
void Jit::Comp_ReplacementFunc(MIPSOpcode op)
{
}
void Jit::Comp_Generic(MIPSOpcode op)
{
FlushAll();
MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
if (func)
{
SaveDowncount();
RestoreDowncount();
}
const MIPSInfo info = MIPSGetInfo(op);
if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)
{
// If it does eat them, it'll happen in MIPSCompileOp().
if ((info & OUT_EAT_PREFIX) == 0)
js.PrefixUnknown();
}
}
void Jit::MovFromPC(MIPSReg r) {
}
void Jit::MovToPC(MIPSReg r) {
}
void Jit::SaveDowncount() {
}
void Jit::RestoreDowncount() {
}
void Jit::WriteDownCount(int offset) {
}
// Abuses R2
void Jit::WriteDownCountR(MIPSReg reg) {
}
void Jit::RestoreRoundingMode(bool force) {
}
void Jit::ApplyRoundingMode(bool force) {
}
void Jit::UpdateRoundingMode() {
}
void Jit::WriteExit(u32 destination, int exit_num)
{
}
void Jit::WriteExitDestInR(MIPSReg Reg)
{
}
void Jit::WriteSyscallExit()
{
}
#define _RS ((op>>21) & 0x1F)
#define _RT ((op>>16) & 0x1F)
#define _RD ((op>>11) & 0x1F)
#define _FS ((op>>11) & 0x1F)
#define _FT ((op>>16) & 0x1F)
#define _FD ((op>>6) & 0x1F)
#define _POS ((op>>6) & 0x1F)
#define _SIZE ((op>>11) & 0x1F)
//memory regions:
//
// 08-0A
// 48-4A
// 04-05
// 44-45
// mov eax, addrreg
// shr eax, 28
// mov eax, [table+eax]
// mov dreg, [eax+offreg]
}
+199
View File
@@ -0,0 +1,199 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/MIPS/JitCommon/JitBlockCache.h"
#include "../MIPSVFPUUtils.h"
#ifndef offsetof
#include "stddef.h"
#endif
namespace MIPSComp
{
struct MIPSJitOptions
{
MIPSJitOptions();
bool useNEONVFPU;
bool enableBlocklink;
bool downcountInRegister;
bool useBackJump;
bool useForwardJump;
bool cachePointers;
bool immBranches;
bool continueBranches;
bool continueJumps;
int continueMaxInstructions;
};
class Jit : public MIPSGen::MIPSXCodeBlock
{
public:
Jit(MIPSState *mips);
void DoState(PointerWrap &p);
static void DoDummyState(PointerWrap &p);
// Compiled ops should ignore delay slots
// the compiler will take care of them by itself
// OR NOT
void Comp_Generic(MIPSOpcode op);
void RunLoopUntil(u64 globalticks);
void Compile(u32 em_address); // Compiles a block at current MIPS PC
const u8 *DoJit(u32 em_address, JitBlock *b);
bool DescribeCodePtr(const u8 *ptr, std::string &name);
void CompileDelaySlot(int flags);
void EatInstruction(MIPSOpcode op);
void AddContinuedBlock(u32 dest);
void Comp_RunBlock(MIPSOpcode op);
void Comp_ReplacementFunc(MIPSOpcode op);
// Ops
void Comp_ITypeMem(MIPSOpcode op) {}
void Comp_Cache(MIPSOpcode op) {}
void Comp_RelBranch(MIPSOpcode op) {}
void Comp_RelBranchRI(MIPSOpcode op) {}
void Comp_FPUBranch(MIPSOpcode op) {}
void Comp_FPULS(MIPSOpcode op) {}
void Comp_FPUComp(MIPSOpcode op) {}
void Comp_Jump(MIPSOpcode op) {}
void Comp_JumpReg(MIPSOpcode op) {}
void Comp_Syscall(MIPSOpcode op) {}
void Comp_Break(MIPSOpcode op) {}
void Comp_IType(MIPSOpcode op) {}
void Comp_RType2(MIPSOpcode op) {}
void Comp_RType3(MIPSOpcode op) {}
void Comp_ShiftType(MIPSOpcode op) {}
void Comp_Allegrex(MIPSOpcode op) {}
void Comp_Allegrex2(MIPSOpcode op) {}
void Comp_VBranch(MIPSOpcode op) {}
void Comp_MulDivType(MIPSOpcode op) {}
void Comp_Special3(MIPSOpcode op) {}
void Comp_FPU3op(MIPSOpcode op) {}
void Comp_FPU2op(MIPSOpcode op) {}
void Comp_mxc1(MIPSOpcode op) {}
void Comp_DoNothing(MIPSOpcode op) {}
void Comp_SV(MIPSOpcode op) {}
void Comp_SVQ(MIPSOpcode op) {}
void Comp_VPFX(MIPSOpcode op) {}
void Comp_VVectorInit(MIPSOpcode op) {}
void Comp_VMatrixInit(MIPSOpcode op) {}
void Comp_VDot(MIPSOpcode op) {}
void Comp_VecDo3(MIPSOpcode op) {}
void Comp_VV2Op(MIPSOpcode op) {}
void Comp_Mftv(MIPSOpcode op) {}
void Comp_Vmfvc(MIPSOpcode op) {}
void Comp_Vmtvc(MIPSOpcode op) {}
void Comp_Vmmov(MIPSOpcode op) {}
void Comp_VScl(MIPSOpcode op) {}
void Comp_Vmmul(MIPSOpcode op) {}
void Comp_Vmscl(MIPSOpcode op) {}
void Comp_Vtfm(MIPSOpcode op) {}
void Comp_VHdp(MIPSOpcode op) {}
void Comp_VCrs(MIPSOpcode op) {}
void Comp_VDet(MIPSOpcode op) {}
void Comp_Vi2x(MIPSOpcode op) {}
void Comp_Vx2i(MIPSOpcode op) {}
void Comp_Vf2i(MIPSOpcode op) {}
void Comp_Vi2f(MIPSOpcode op) {}
void Comp_Vh2f(MIPSOpcode op) {}
void Comp_Vcst(MIPSOpcode op) {}
void Comp_Vhoriz(MIPSOpcode op) {}
void Comp_VRot(MIPSOpcode op) {}
void Comp_VIdt(MIPSOpcode op) {}
void Comp_Vcmp(MIPSOpcode op) {}
void Comp_Vcmov(MIPSOpcode op) {}
void Comp_Viim(MIPSOpcode op) {}
void Comp_Vfim(MIPSOpcode op) {}
void Comp_VCrossQuat(MIPSOpcode op) {}
void Comp_Vsgn(MIPSOpcode op) {}
void Comp_Vocp(MIPSOpcode op) {}
int Replace_fabsf() { return 0; }
JitBlockCache *GetBlockCache() { return &blocks; }
void ClearCache();
void InvalidateCache();
void InvalidateCacheAt(u32 em_address, int length = 4);
void EatPrefix() { js.EatPrefix(); }
private:
void GenerateFixedCode();
void FlushAll();
void FlushPrefixV();
void WriteDownCount(int offset = 0);
void WriteDownCountR(MIPSReg reg);
void RestoreRoundingMode(bool force = false);
void ApplyRoundingMode(bool force = false);
void UpdateRoundingMode();
void MovFromPC(MIPSReg r);
void MovToPC(MIPSReg r);
bool ReplaceJalTo(u32 dest);
void SaveDowncount();
void RestoreDowncount();
void WriteExit(u32 destination, int exit_num);
void WriteExitDestInR(MIPSReg Reg);
void WriteSyscallExit();
JitBlockCache blocks;
MIPSJitOptions jo;
JitState js;
MIPSState *mips_;
int dontLogBlocks;
int logBlocks;
public:
// Code pointers
const u8 *enterCode;
const u8 *outerLoop;
const u8 *outerLoopPCInR0;
const u8 *dispatcherCheckCoreState;
const u8 *dispatcherPCInR0;
const u8 *dispatcher;
const u8 *dispatcherNoCheck;
const u8 *breakpointBailout;
};
typedef void (Jit::*MIPSCompileFunc)(MIPSOpcode opcode);
typedef int (Jit::*MIPSReplaceFunc)();
} // namespace MIPSComp
-18
View File
@@ -169,24 +169,6 @@ private:
void WriteExitDestInR(FakeReg Reg);
void WriteSyscallExit();
// Utility compilation functions
void BranchFPFlag(MIPSOpcode op, FakeGen::CCFlags cc, bool likely);
void BranchVFPUFlag(MIPSOpcode op, FakeGen::CCFlags cc, bool likely);
void BranchRSZeroComp(MIPSOpcode op, FakeGen::CCFlags cc, bool andLink, bool likely);
void BranchRSRTComp(MIPSOpcode op, FakeGen::CCFlags cc, bool likely);
// Utilities to reduce duplicated code
void CompImmLogic(MIPSGPReg rs, MIPSGPReg rt, u32 uimm, void (FakeXEmitter::*arith)(FakeReg dst, FakeReg src, Operand2 op2), bool (FakeXEmitter::*tryArithI2R)(FakeReg dst, FakeReg src, u32 val), u32 (*eval)(u32 a, u32 b));
void CompType3(MIPSGPReg rd, MIPSGPReg rs, MIPSGPReg rt, void (FakeXEmitter::*arithOp2)(FakeReg dst, FakeReg rm, Operand2 rn), bool (FakeXEmitter::*tryArithI2R)(FakeReg dst, FakeReg rm, u32 val), u32 (*eval)(u32 a, u32 b), bool symmetric = false);
void CompShiftImm(MIPSOpcode op, FakeGen::ShiftType shiftType, int sa);
void CompShiftVar(MIPSOpcode op, FakeGen::ShiftType shiftType);
// Utils
void SetR0ToEffectiveAddress(MIPSGPReg rs, s16 offset);
void SetCCAndR0ForSafeAddress(MIPSGPReg rs, s16 offset, FakeReg tempReg, bool reverse = false);
void Comp_ITypeMemLR(MIPSOpcode op, bool load);
JitBlockCache blocks;
FakeJitOptions jo;
JitState js;
+4
View File
@@ -27,6 +27,8 @@
#include "Common/ArmEmitter.h"
#elif defined(_M_IX86) || defined(_M_X64)
#include "Common/x64Emitter.h"
#elif defined(MIPS)
#include "Common/MipsEmitter.h"
#else
#include "Common/FakeEmitter.h"
#endif
@@ -579,6 +581,8 @@ public:
class VertexDecoderJitCache : public ArmGen::ARMXCodeBlock {
#elif defined(_M_IX86) || defined(_M_X64)
class VertexDecoderJitCache : public Gen::XCodeBlock {
#elif defined(MIPS)
class VertexDecoderJitCache : public MIPSGen::MIPSXCodeBlock {
#else
class VertexDecoderJitCache : public FakeGen::FakeXCodeBlock {
#endif
+4
View File
@@ -26,7 +26,11 @@ static const float by128 = 1.0f / 128.0f;
static const float by16384 = 1.0f / 16384.0f;
static const float by32768 = 1.0f / 32768.0f;
#ifdef MIPS
using namespace MIPSGen;
#else
using namespace FakeGen;
#endif
static const JitLookup jitLookup[] = {
{&VertexDecoder::Step_WeightsU8, &VertexDecoderJitCache::Jit_WeightsU8},