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/fake/FakeJit.cpp
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#include "Common/Serialize/Serializer.h"18#include "Common/Serialize/SerializeFuncs.h"19#include "Core/Reporting.h"20#include "Core/Config.h"21#include "Core/Core.h"22#include "Core/CoreTiming.h"23#include "Core/Debugger/Breakpoints.h"24#include "Core/Debugger/SymbolMap.h"25#include "Core/MemMap.h"26#include "Core/MIPS/MIPS.h"27#include "Core/MIPS/MIPSCodeUtils.h"28#include "Core/MIPS/MIPSInt.h"29#include "Core/MIPS/MIPSTables.h"30#include "Core/HLE/ReplaceTables.h"3132#include "FakeEmitter.h"33#include "FakeJit.h"34#include "CPUDetect.h"3536void DisassembleFake(const u8 *data, int size) {37}3839namespace MIPSComp40{4142FakeJit::FakeJit(MIPSState *mipsState) : blocks(mipsState, this), mips_(mipsState), js()43{44logBlocks = 0;45dontLogBlocks = 0;46blocks.Init();47}4849void FakeJit::DoState(PointerWrap &p) {50auto s = p.Section("Jit", 1, 2);51if (!s)52return;5354Do(p, js.startDefaultPrefix);55if (s >= 2) {56Do(p, js.hasSetRounding);57if (p.mode == PointerWrap::MODE_READ) {58js.lastSetRounding = 0;59}60} else {61js.hasSetRounding = 1;62}6364// The debugger sets this so that "go" on a breakpoint will actually... go.65// But if they load a state, we can end up hitting it by mistake, since it's based on PC and ticks.66CBreakPoints::SetSkipFirst(0);67}6869// This is here so the savestate matches between jit and non-jit.70void FakeJit::DoDummyState(PointerWrap &p)71{72auto s = p.Section("FakeJit", 1, 2);73if (!s)74return;7576bool dummy = false;77Do(p, dummy);78if (s >= 2) {79dummy = true;80Do(p, dummy);81}82}8384void FakeJit::FlushAll()85{86//gpr.FlushAll();87//fpr.FlushAll();88FlushPrefixV();89}9091void FakeJit::FlushPrefixV()92{93}9495void FakeJit::ClearCache()96{97blocks.Clear();98ClearCodeSpace(0);99//GenerateFixedCode();100}101102void FakeJit::InvalidateCacheAt(u32 em_address, int length) {103if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {104blocks.InvalidateICache(em_address, length);105}106}107108void FakeJit::EatInstruction(MIPSOpcode op) {109MIPSInfo info = MIPSGetInfo(op);110if (info & DELAYSLOT) {111ERROR_LOG_REPORT_ONCE(ateDelaySlot, Log::JIT, "Ate a branch op.");112}113if (js.inDelaySlot) {114ERROR_LOG_REPORT_ONCE(ateInDelaySlot, Log::JIT, "Ate an instruction inside a delay slot.");115}116117js.numInstructions++;118js.compilerPC += 4;119js.downcountAmount += MIPSGetInstructionCycleEstimate(op);120}121122void FakeJit::CompileDelaySlot(int flags)123{124}125126127void FakeJit::Compile(u32 em_address) {128}129130void FakeJit::RunLoopUntil(u64 globalticks) {131MIPSInterpret_RunUntil(globalticks);132}133134const u8 *FakeJit::DoJit(u32 em_address, JitBlock *b) {135_assert_(false);136return nullptr;137}138139void FakeJit::AddContinuedBlock(u32 dest)140{141}142143bool FakeJit::DescribeCodePtr(const u8 *ptr, std::string &name)144{145// TODO: Not used by anything yet.146return false;147}148149void FakeJit::Comp_RunBlock(MIPSOpcode op)150{151// This shouldn't be necessary, the dispatcher should catch us before we get here.152ERROR_LOG(Log::JIT, "Comp_RunBlock should never be reached!");153}154155void FakeJit::Comp_ReplacementFunc(MIPSOpcode op)156{157}158159void FakeJit::Comp_Generic(MIPSOpcode op)160{161FlushAll();162MIPSInterpretFunc func = MIPSGetInterpretFunc(op);163if (func)164{165SaveDowncount();166RestoreDowncount();167}168169const MIPSInfo info = MIPSGetInfo(op);170if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)171{172// If it does eat them, it'll happen in MIPSCompileOp().173if ((info & OUT_EAT_PREFIX) == 0)174js.PrefixUnknown();175}176}177178void FakeJit::MovFromPC(FakeReg r) {179}180181void FakeJit::MovToPC(FakeReg r) {182}183184void FakeJit::SaveDowncount() {185}186187void FakeJit::RestoreDowncount() {188}189190void FakeJit::WriteDownCount(int offset) {191}192193// Abuses R2194void FakeJit::WriteDownCountR(FakeReg reg) {195}196197void FakeJit::RestoreRoundingMode(bool force) {198}199200void FakeJit::ApplyRoundingMode(bool force) {201}202203void FakeJit::UpdateRoundingMode() {204}205206void FakeJit::WriteExit(u32 destination, int exit_num)207{208}209210void FakeJit::WriteExitDestInR(FakeReg Reg)211{212}213214void FakeJit::WriteSyscallExit()215{216}217218#define _RS ((op>>21) & 0x1F)219#define _RT ((op>>16) & 0x1F)220#define _RD ((op>>11) & 0x1F)221#define _FS ((op>>11) & 0x1F)222#define _FT ((op>>16) & 0x1F)223#define _FD ((op>>6) & 0x1F)224#define _POS ((op>>6) & 0x1F)225#define _SIZE ((op>>11) & 0x1F)226227//memory regions:228//229// 08-0A230// 48-4A231// 04-05232// 44-45233// mov eax, addrreg234// shr eax, 28235// mov eax, [table+eax]236// mov dreg, [eax+offreg]237238}239240241