CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/MIPS/JitCommon/JitCommon.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <mutex>20#include <string>21#include <vector>2223#include "Common/CommonTypes.h"24#include "Core/MIPS/MIPS.h"2526// TODO: Find a better place for these.27std::vector<std::string> DisassembleArm2(const u8 *data, int size);28std::vector<std::string> DisassembleArm64(const u8 *data, int size);29std::vector<std::string> DisassembleX86(const u8 *data, int size);30std::vector<std::string> DisassembleRV64(const u8 *data, int size);3132struct JitBlock;33class JitBlockCache;34class JitBlockCacheDebugInterface;35class PointerWrap;3637#ifdef USING_QT_UI38#undef emit39#endif4041class MIPSState;4243namespace MIPSComp {44void JitAt();4546class MIPSFrontendInterface {47public:48virtual ~MIPSFrontendInterface() {}4950virtual void EatPrefix() = 0;5152virtual void Comp_Generic(MIPSOpcode op) = 0;53virtual void Comp_RunBlock(MIPSOpcode op) = 0;54virtual void Comp_ReplacementFunc(MIPSOpcode op) = 0;55virtual void Comp_ITypeMem(MIPSOpcode op) = 0;56virtual void Comp_StoreSync(MIPSOpcode op) = 0;57virtual void Comp_Cache(MIPSOpcode op) = 0;58virtual void Comp_RelBranch(MIPSOpcode op) = 0;59virtual void Comp_RelBranchRI(MIPSOpcode op) = 0;60virtual void Comp_FPUBranch(MIPSOpcode op) = 0;61virtual void Comp_FPULS(MIPSOpcode op) = 0;62virtual void Comp_FPUComp(MIPSOpcode op) = 0;63virtual void Comp_Jump(MIPSOpcode op) = 0;64virtual void Comp_JumpReg(MIPSOpcode op) = 0;65virtual void Comp_Syscall(MIPSOpcode op) = 0;66virtual void Comp_Break(MIPSOpcode op) = 0;67virtual void Comp_IType(MIPSOpcode op) = 0;68virtual void Comp_RType2(MIPSOpcode op) = 0;69virtual void Comp_RType3(MIPSOpcode op) = 0;70virtual void Comp_ShiftType(MIPSOpcode op) = 0;71virtual void Comp_Allegrex(MIPSOpcode op) = 0;72virtual void Comp_Allegrex2(MIPSOpcode op) = 0;73virtual void Comp_VBranch(MIPSOpcode op) = 0;74virtual void Comp_MulDivType(MIPSOpcode op) = 0;75virtual void Comp_Special3(MIPSOpcode op) = 0;76virtual void Comp_FPU3op(MIPSOpcode op) = 0;77virtual void Comp_FPU2op(MIPSOpcode op) = 0;78virtual void Comp_mxc1(MIPSOpcode op) = 0;79virtual void Comp_SV(MIPSOpcode op) = 0;80virtual void Comp_SVQ(MIPSOpcode op) = 0;81virtual void Comp_VPFX(MIPSOpcode op) = 0;82virtual void Comp_VVectorInit(MIPSOpcode op) = 0;83virtual void Comp_VMatrixInit(MIPSOpcode op) = 0;84virtual void Comp_VDot(MIPSOpcode op) = 0;85virtual void Comp_VecDo3(MIPSOpcode op) = 0;86virtual void Comp_VV2Op(MIPSOpcode op) = 0;87virtual void Comp_Mftv(MIPSOpcode op) = 0;88virtual void Comp_Vmfvc(MIPSOpcode op) = 0;89virtual void Comp_Vmtvc(MIPSOpcode op) = 0;90virtual void Comp_Vmmov(MIPSOpcode op) = 0;91virtual void Comp_VScl(MIPSOpcode op) = 0;92virtual void Comp_Vmmul(MIPSOpcode op) = 0;93virtual void Comp_Vmscl(MIPSOpcode op) = 0;94virtual void Comp_Vtfm(MIPSOpcode op) = 0;95virtual void Comp_VHdp(MIPSOpcode op) = 0;96virtual void Comp_VCrs(MIPSOpcode op) = 0;97virtual void Comp_VDet(MIPSOpcode op) = 0;98virtual void Comp_Vi2x(MIPSOpcode op) = 0;99virtual void Comp_Vx2i(MIPSOpcode op) = 0;100virtual void Comp_Vf2i(MIPSOpcode op) = 0;101virtual void Comp_Vi2f(MIPSOpcode op) = 0;102virtual void Comp_Vh2f(MIPSOpcode op) = 0;103virtual void Comp_Vcst(MIPSOpcode op) = 0;104virtual void Comp_Vhoriz(MIPSOpcode op) = 0;105virtual void Comp_VRot(MIPSOpcode op) = 0;106virtual void Comp_VIdt(MIPSOpcode op) = 0;107virtual void Comp_Vcmp(MIPSOpcode op) = 0;108virtual void Comp_Vcmov(MIPSOpcode op) = 0;109virtual void Comp_Viim(MIPSOpcode op) = 0;110virtual void Comp_Vfim(MIPSOpcode op) = 0;111virtual void Comp_VCrossQuat(MIPSOpcode op) = 0;112virtual void Comp_Vsgn(MIPSOpcode op) = 0;113virtual void Comp_Vocp(MIPSOpcode op) = 0;114virtual void Comp_ColorConv(MIPSOpcode op) = 0;115virtual void Comp_Vbfy(MIPSOpcode op) = 0;116virtual void Comp_DoNothing(MIPSOpcode op) = 0;117118virtual int Replace_fabsf() = 0;119};120121class JitInterface {122public:123virtual ~JitInterface() {}124125virtual bool CodeInRange(const u8 *ptr) const = 0;126virtual bool DescribeCodePtr(const u8 *ptr, std::string &name) = 0;127virtual bool IsAtDispatchFetch(const u8 *ptr) const {128return false;129}130virtual const u8 *GetDispatcher() const = 0;131virtual const u8 *GetCrashHandler() const = 0;132virtual JitBlockCache *GetBlockCache() = 0;133virtual JitBlockCacheDebugInterface *GetBlockCacheDebugInterface() = 0;134virtual void InvalidateCacheAt(u32 em_address, int length = 4) = 0;135virtual void DoState(PointerWrap &p) = 0;136virtual void RunLoopUntil(u64 globalticks) = 0;137virtual void Compile(u32 em_address) = 0;138virtual void CompileFunction(u32 start_address, u32 length) { }139virtual void ClearCache() = 0;140virtual void UpdateFCR31() = 0;141virtual MIPSOpcode GetOriginalOp(MIPSOpcode op) = 0;142143// No jit operations may be run between these calls.144// Meant to be used to make memory safe for savestates, memcpy, etc.145virtual std::vector<u32> SaveAndClearEmuHackOps() = 0;146virtual void RestoreSavedEmuHackOps(std::vector<u32> saved) = 0;147148// Block linking. This may need to work differently for whole-function JITs and stuff149// like that.150virtual void LinkBlock(u8 *exitPoint, const u8 *entryPoint) = 0;151virtual void UnlinkBlock(u8 *checkedEntry, u32 originalAddress) = 0;152};153154typedef void (MIPSFrontendInterface::*MIPSCompileFunc)(MIPSOpcode opcode);155typedef int (MIPSFrontendInterface::*MIPSReplaceFunc)();156157struct BranchInfo {158BranchInfo(u32 pc, MIPSOpcode op, MIPSOpcode delaySlotOp, bool andLink, bool likely);159160u32 compilerPC;161MIPSOpcode op;162MIPSOpcode delaySlotOp;163u64 delaySlotInfo;164bool likely;165bool andLink;166// Update manually if it's not always nice (rs/rt, rs/zero, etc.)167bool delaySlotIsNice = true;168bool delaySlotIsBranch;169};170171// This seems to be the same for all branch types.172u32 ResolveNotTakenTarget(const BranchInfo &branchInfo);173174extern JitInterface *jit;175extern std::recursive_mutex jitLock;176177void DoDummyJitState(PointerWrap &p);178179JitInterface *CreateNativeJit(MIPSState *mipsState, bool useIR);180}181182183