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/IRAnalysis.h
Views: 1401
1
// Copyright (c) 2016- 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 "Core/MIPS/IR/IRInst.h"
21
22
struct IRInstMeta {
23
union {
24
IRInst i;
25
struct {
26
IROp op;
27
union {
28
IRReg dest;
29
IRReg src3;
30
};
31
IRReg src1;
32
IRReg src2;
33
u32 constant;
34
};
35
};
36
IRMeta m;
37
};
38
39
static_assert(offsetof(IRInst, src2) == offsetof(IRInstMeta, src2));
40
41
inline IRInstMeta GetIRMeta(const IRInst &inst) {
42
return { { inst }, *GetIRMeta(inst.op) };
43
}
44
45
bool IRReadsFromFPR(const IRInstMeta &inst, int reg, bool *directly = nullptr);
46
bool IRReadsFromGPR(const IRInstMeta &inst, int reg, bool *directly = nullptr);
47
bool IRWritesToGPR(const IRInstMeta &inst, int reg);
48
bool IRWritesToFPR(const IRInstMeta &inst, int reg);
49
int IRDestGPR(const IRInstMeta &inst);
50
int IRDestFPRs(const IRInstMeta &inst, IRReg regs[4]);
51
int IRReadsFromGPRs(const IRInstMeta &inst, IRReg regs[4]);
52
int IRReadsFromFPRs(const IRInstMeta &inst, IRReg regs[16]);
53
54
struct IRSituation {
55
int lookaheadCount;
56
int currentIndex;
57
const IRInst *instructions;
58
int numInstructions;
59
};
60
61
enum class IRUsage {
62
UNKNOWN,
63
UNUSED,
64
READ,
65
WRITE,
66
CLOBBERED,
67
};
68
69
IRUsage IRNextGPRUsage(int gpr, const IRSituation &info);
70
IRUsage IRNextFPRUsage(int fpr, const IRSituation &info);
71
72