CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/MIPS/fake/FakeJit.cpp
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include "Common/Serialize/Serializer.h"
19
#include "Common/Serialize/SerializeFuncs.h"
20
#include "Core/Reporting.h"
21
#include "Core/Config.h"
22
#include "Core/Core.h"
23
#include "Core/CoreTiming.h"
24
#include "Core/Debugger/Breakpoints.h"
25
#include "Core/Debugger/SymbolMap.h"
26
#include "Core/MemMap.h"
27
#include "Core/MIPS/MIPS.h"
28
#include "Core/MIPS/MIPSCodeUtils.h"
29
#include "Core/MIPS/MIPSInt.h"
30
#include "Core/MIPS/MIPSTables.h"
31
#include "Core/HLE/ReplaceTables.h"
32
33
#include "FakeEmitter.h"
34
#include "FakeJit.h"
35
#include "CPUDetect.h"
36
37
void DisassembleFake(const u8 *data, int size) {
38
}
39
40
namespace MIPSComp
41
{
42
43
FakeJit::FakeJit(MIPSState *mipsState) : blocks(mipsState, this), mips_(mipsState), js()
44
{
45
logBlocks = 0;
46
dontLogBlocks = 0;
47
blocks.Init();
48
}
49
50
void FakeJit::DoState(PointerWrap &p) {
51
auto s = p.Section("Jit", 1, 2);
52
if (!s)
53
return;
54
55
Do(p, js.startDefaultPrefix);
56
if (s >= 2) {
57
Do(p, js.hasSetRounding);
58
if (p.mode == PointerWrap::MODE_READ) {
59
js.lastSetRounding = 0;
60
}
61
} else {
62
js.hasSetRounding = 1;
63
}
64
65
// The debugger sets this so that "go" on a breakpoint will actually... go.
66
// But if they load a state, we can end up hitting it by mistake, since it's based on PC and ticks.
67
CBreakPoints::SetSkipFirst(0);
68
}
69
70
// This is here so the savestate matches between jit and non-jit.
71
void FakeJit::DoDummyState(PointerWrap &p)
72
{
73
auto s = p.Section("FakeJit", 1, 2);
74
if (!s)
75
return;
76
77
bool dummy = false;
78
Do(p, dummy);
79
if (s >= 2) {
80
dummy = true;
81
Do(p, dummy);
82
}
83
}
84
85
void FakeJit::FlushAll()
86
{
87
//gpr.FlushAll();
88
//fpr.FlushAll();
89
FlushPrefixV();
90
}
91
92
void FakeJit::FlushPrefixV()
93
{
94
}
95
96
void FakeJit::ClearCache()
97
{
98
blocks.Clear();
99
ClearCodeSpace(0);
100
//GenerateFixedCode();
101
}
102
103
void FakeJit::InvalidateCacheAt(u32 em_address, int length) {
104
if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {
105
blocks.InvalidateICache(em_address, length);
106
}
107
}
108
109
void FakeJit::EatInstruction(MIPSOpcode op) {
110
MIPSInfo info = MIPSGetInfo(op);
111
if (info & DELAYSLOT) {
112
ERROR_LOG_REPORT_ONCE(ateDelaySlot, Log::JIT, "Ate a branch op.");
113
}
114
if (js.inDelaySlot) {
115
ERROR_LOG_REPORT_ONCE(ateInDelaySlot, Log::JIT, "Ate an instruction inside a delay slot.");
116
}
117
118
js.numInstructions++;
119
js.compilerPC += 4;
120
js.downcountAmount += MIPSGetInstructionCycleEstimate(op);
121
}
122
123
void FakeJit::CompileDelaySlot(int flags)
124
{
125
}
126
127
128
void FakeJit::Compile(u32 em_address) {
129
}
130
131
void FakeJit::RunLoopUntil(u64 globalticks) {
132
MIPSInterpret_RunUntil(globalticks);
133
}
134
135
const u8 *FakeJit::DoJit(u32 em_address, JitBlock *b) {
136
_assert_(false);
137
return nullptr;
138
}
139
140
void FakeJit::AddContinuedBlock(u32 dest)
141
{
142
}
143
144
bool FakeJit::DescribeCodePtr(const u8 *ptr, std::string &name)
145
{
146
// TODO: Not used by anything yet.
147
return false;
148
}
149
150
void FakeJit::Comp_RunBlock(MIPSOpcode op)
151
{
152
// This shouldn't be necessary, the dispatcher should catch us before we get here.
153
ERROR_LOG(Log::JIT, "Comp_RunBlock should never be reached!");
154
}
155
156
void FakeJit::Comp_ReplacementFunc(MIPSOpcode op)
157
{
158
}
159
160
void FakeJit::Comp_Generic(MIPSOpcode op)
161
{
162
FlushAll();
163
MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
164
if (func)
165
{
166
SaveDowncount();
167
RestoreDowncount();
168
}
169
170
const MIPSInfo info = MIPSGetInfo(op);
171
if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)
172
{
173
// If it does eat them, it'll happen in MIPSCompileOp().
174
if ((info & OUT_EAT_PREFIX) == 0)
175
js.PrefixUnknown();
176
}
177
}
178
179
void FakeJit::MovFromPC(FakeReg r) {
180
}
181
182
void FakeJit::MovToPC(FakeReg r) {
183
}
184
185
void FakeJit::SaveDowncount() {
186
}
187
188
void FakeJit::RestoreDowncount() {
189
}
190
191
void FakeJit::WriteDownCount(int offset) {
192
}
193
194
// Abuses R2
195
void FakeJit::WriteDownCountR(FakeReg reg) {
196
}
197
198
void FakeJit::RestoreRoundingMode(bool force) {
199
}
200
201
void FakeJit::ApplyRoundingMode(bool force) {
202
}
203
204
void FakeJit::UpdateRoundingMode() {
205
}
206
207
void FakeJit::WriteExit(u32 destination, int exit_num)
208
{
209
}
210
211
void FakeJit::WriteExitDestInR(FakeReg Reg)
212
{
213
}
214
215
void FakeJit::WriteSyscallExit()
216
{
217
}
218
219
#define _RS ((op>>21) & 0x1F)
220
#define _RT ((op>>16) & 0x1F)
221
#define _RD ((op>>11) & 0x1F)
222
#define _FS ((op>>11) & 0x1F)
223
#define _FT ((op>>16) & 0x1F)
224
#define _FD ((op>>6) & 0x1F)
225
#define _POS ((op>>6) & 0x1F)
226
#define _SIZE ((op>>11) & 0x1F)
227
228
//memory regions:
229
//
230
// 08-0A
231
// 48-4A
232
// 04-05
233
// 44-45
234
// mov eax, addrreg
235
// shr eax, 28
236
// mov eax, [table+eax]
237
// mov dreg, [eax+offreg]
238
239
}
240
241