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/MIPSTables.h
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
#pragma once
19
20
#include <string>
21
#include <stdint.h>
22
#include "Common/CommonTypes.h"
23
#include "Core/MIPS/MIPS.h"
24
25
#define CONDTYPE_MASK 0x00000007
26
#define CONDTYPE_EQ 0x00000001
27
#define CONDTYPE_NE 0x00000002
28
#define CONDTYPE_LEZ 0x00000003
29
#define CONDTYPE_GTZ 0x00000004
30
#define CONDTYPE_LTZ 0x00000005
31
#define CONDTYPE_GEZ 0x00000006
32
33
#define CONDTYPE_FPUFALSE CONDTYPE_EQ
34
#define CONDTYPE_FPUTRUE CONDTYPE_NE
35
36
// as long as the other flags are checked,
37
// there is no way to misinterpret these
38
// as CONDTYPE_X
39
#define MEMTYPE_MASK 0x00000007ULL
40
#define MEMTYPE_BYTE 0x00000001ULL
41
#define MEMTYPE_HWORD 0x00000002ULL
42
#define MEMTYPE_WORD 0x00000003ULL
43
#define MEMTYPE_FLOAT 0x00000004ULL
44
#define MEMTYPE_VQUAD 0x00000005ULL
45
46
#define IS_CONDMOVE 0x00000008ULL
47
#define DELAYSLOT 0x00000010ULL
48
#define BAD_INSTRUCTION 0x00000020ULL
49
#define LIKELY 0x00000040ULL
50
#define IS_CONDBRANCH 0x00000080ULL
51
#define IS_JUMP 0x00000100ULL
52
53
#define IN_RS 0x00000200ULL
54
#define IN_RS_ADDR (0x00000400ULL | IN_RS)
55
#define IN_RS_SHIFT (0x00000800ULL | IN_RS)
56
#define IN_RT 0x00001000ULL
57
#define IN_SA 0x00002000ULL
58
#define IN_IMM16 0x00004000ULL
59
#define IN_IMM26 0x00008000ULL
60
#define IN_MEM 0x00010000ULL
61
#define IN_OTHER 0x00020000ULL
62
#define IN_FPUFLAG 0x00040000ULL
63
#define IN_VFPU_CC 0x00080000ULL
64
65
#define OUT_RT 0x00100000ULL
66
#define OUT_RD 0x00200000ULL
67
#define OUT_RA 0x00400000ULL
68
#define OUT_MEM 0x00800000ULL
69
#define OUT_OTHER 0x01000000ULL
70
#define OUT_FPUFLAG 0x02000000ULL
71
#define OUT_VFPU_CC 0x04000000ULL
72
#define OUT_EAT_PREFIX 0x08000000ULL
73
74
#define VFPU_NO_PREFIX 0x10000000ULL
75
#define OUT_VFPU_PREFIX 0x20000000ULL
76
#define IS_VFPU 0x40000000ULL
77
#define IS_FPU 0x80000000ULL
78
79
#define IN_FS 0x000100000000ULL
80
#define IN_FT 0x000200000000ULL
81
#define IN_LO 0x000400000000ULL
82
#define IN_HI 0x000800000000ULL
83
84
#define OUT_FD 0x001000000000ULL
85
#define OUT_FS 0x002000000000ULL
86
#define OUT_LO 0x004000000000ULL
87
#define OUT_HI 0x008000000000ULL
88
89
#define IN_VS 0x010000000000ULL
90
#define IN_VT 0x020000000000ULL
91
#define OUT_FT 0x040000000000ULL
92
93
#define OUT_VD 0x100000000000ULL
94
95
#define IS_SYSCALL 0x200000000000ULL
96
97
#ifndef CDECL
98
#define CDECL
99
#endif
100
101
struct MIPSInfo {
102
MIPSInfo() {
103
value = 0;
104
cycles = 0;
105
}
106
107
explicit MIPSInfo(u64 v, u16 c = 0) : value(v), cycles(c) {
108
if (c == 0) {
109
cycles = 1;
110
if (v & IS_VFPU)
111
cycles++;
112
}
113
}
114
115
u64 operator & (const u64 &arg) const {
116
return value & arg;
117
}
118
119
u64 value : 48;
120
u64 cycles : 16;
121
};
122
123
typedef void (CDECL *MIPSDisFunc)(MIPSOpcode opcode, uint32_t pc, char *out, size_t outSize);
124
typedef void (CDECL *MIPSInterpretFunc)(MIPSOpcode opcode);
125
126
namespace MIPSComp {
127
class MIPSFrontendInterface;
128
}
129
130
void MIPSCompileOp(MIPSOpcode op, MIPSComp::MIPSFrontendInterface *jit);
131
void MIPSDisAsm(MIPSOpcode op, u32 pc, char *out, size_t outSize, bool tabsToSpaces = false);
132
MIPSInfo MIPSGetInfo(MIPSOpcode op);
133
void MIPSInterpret(MIPSOpcode op); //only for those rare ones
134
int MIPSInterpret_RunUntil(u64 globalTicks);
135
MIPSInterpretFunc MIPSGetInterpretFunc(MIPSOpcode op);
136
137
int MIPSGetInstructionCycleEstimate(MIPSOpcode op);
138
int MIPSGetMemoryAccessSize(MIPSOpcode op);
139
const char *MIPSGetName(MIPSOpcode op);
140
std::string MIPSDisasmAt(u32 compilerPC);
141
142