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/IR/IRCompLoadStore.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 "Core/Config.h"
19
#include "Core/MemMap.h"
20
#include "Core/MIPS/MIPS.h"
21
#include "Core/MIPS/MIPSAnalyst.h"
22
#include "Core/MIPS/MIPSCodeUtils.h"
23
#include "Core/MIPS/IR/IRFrontend.h"
24
#include "Core/MIPS/IR/IRRegCache.h"
25
26
#define _RS MIPS_GET_RS(op)
27
#define _RT MIPS_GET_RT(op)
28
#define _RD MIPS_GET_RD(op)
29
#define _FS MIPS_GET_FS(op)
30
#define _FT MIPS_GET_FT(op)
31
#define _FD MIPS_GET_FD(op)
32
#define _SA MIPS_GET_SA(op)
33
#define _POS ((op>> 6) & 0x1F)
34
#define _SIZE ((op>>11) & 0x1F)
35
#define _IMM16 (signed short)(op & 0xFFFF)
36
#define _IMM26 (op & 0x03FFFFFF)
37
38
// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.
39
// Currently known non working ones should have DISABLE.
40
41
// #define CONDITIONAL_DISABLE(flag) { Comp_Generic(op); return; }
42
#define CONDITIONAL_DISABLE(flag) if (opts.disableFlags & (uint32_t)JitDisable::flag) { Comp_Generic(op); return; }
43
#define DISABLE { Comp_Generic(op); return; }
44
#define INVALIDOP { Comp_Generic(op); return; }
45
46
namespace MIPSComp {
47
void IRFrontend::Comp_ITypeMem(MIPSOpcode op) {
48
CONDITIONAL_DISABLE(LSU);
49
50
int offset = _IMM16;
51
MIPSGPReg rt = _RT;
52
MIPSGPReg rs = _RS;
53
int o = op >> 26;
54
if (((op >> 29) & 1) == 0 && rt == MIPS_REG_ZERO) {
55
// Don't load anything into $zr
56
return;
57
}
58
59
CheckMemoryBreakpoint(rs, offset);
60
61
switch (o) {
62
// Load
63
case 35:
64
ir.Write(IROp::Load32, rt, rs, ir.AddConstant(offset));
65
break;
66
case 37:
67
ir.Write(IROp::Load16, rt, rs, ir.AddConstant(offset));
68
break;
69
case 33:
70
ir.Write(IROp::Load16Ext, rt, rs, ir.AddConstant(offset));
71
break;
72
case 36:
73
ir.Write(IROp::Load8, rt, rs, ir.AddConstant(offset));
74
break;
75
case 32:
76
ir.Write(IROp::Load8Ext, rt, rs, ir.AddConstant(offset));
77
break;
78
// Store
79
case 43:
80
ir.Write(IROp::Store32, rt, rs, ir.AddConstant(offset));
81
break;
82
case 41:
83
ir.Write(IROp::Store16, rt, rs, ir.AddConstant(offset));
84
break;
85
case 40:
86
ir.Write(IROp::Store8, rt, rs, ir.AddConstant(offset));
87
break;
88
89
case 34: //lwl
90
ir.Write(IROp::Load32Left, rt, rs, ir.AddConstant(offset));
91
break;
92
case 38: //lwr
93
ir.Write(IROp::Load32Right, rt, rs, ir.AddConstant(offset));
94
break;
95
case 42: //swl
96
ir.Write(IROp::Store32Left, rt, rs, ir.AddConstant(offset));
97
break;
98
case 46: //swr
99
ir.Write(IROp::Store32Right, rt, rs, ir.AddConstant(offset));
100
break;
101
102
default:
103
INVALIDOP;
104
return;
105
}
106
}
107
108
void IRFrontend::Comp_StoreSync(MIPSOpcode op) {
109
CONDITIONAL_DISABLE(LSU);
110
111
int offset = _IMM16;
112
MIPSGPReg rt = _RT;
113
MIPSGPReg rs = _RS;
114
// Note: still does something even if loading to zero.
115
116
CheckMemoryBreakpoint(rs, offset);
117
118
switch (op >> 26) {
119
case 48: // ll
120
ir.Write(IROp::Load32Linked, rt, rs, ir.AddConstant(offset));
121
break;
122
123
case 56: // sc
124
ir.Write(IROp::Store32Conditional, rt, rs, ir.AddConstant(offset));
125
break;
126
127
default:
128
INVALIDOP;
129
}
130
}
131
132
void IRFrontend::Comp_Cache(MIPSOpcode op) {
133
CONDITIONAL_DISABLE(LSU);
134
135
int func = (op >> 16) & 0x1F;
136
137
// See Int_Cache for the definitions.
138
switch (func) {
139
case 24: break;
140
case 25: break;
141
case 27: break;
142
case 30: break;
143
default:
144
// Fall back to the interpreter.
145
DISABLE;
146
}
147
}
148
}
149
150