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/Common/CPUDetect.h
Views: 1401
1
// Copyright (C) 2003 Dolphin 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.
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 SVN repository and contact information can be found at
16
// http://code.google.com/p/dolphin-emu/
17
18
// Detect the cpu, so we'll know which optimizations to use
19
#pragma once
20
21
#include "ppsspp_config.h"
22
#include <string>
23
#include <vector>
24
25
enum CPUVendor {
26
VENDOR_INTEL = 0,
27
VENDOR_AMD = 1,
28
VENDOR_ARM = 2,
29
VENDOR_OTHER = 3,
30
};
31
32
struct CPUInfo {
33
CPUVendor vendor;
34
35
// Misc
36
char cpu_string[0x21];
37
char brand_string[0x41];
38
bool OS64bit;
39
bool CPU64bit;
40
bool Mode64bit;
41
42
bool HTT;
43
44
// Number of real CPU cores.
45
int num_cores;
46
// Number of logical CPUs per core.
47
int logical_cpu_count;
48
49
bool bAtom;
50
bool bPOPCNT;
51
bool bLAHFSAHF64;
52
bool bLongMode;
53
bool bMOVBE;
54
bool bFXSR;
55
bool bLZCNT;
56
bool bBMI1;
57
bool bBMI2;
58
bool bBMI2_fast;
59
bool bXOP;
60
bool bRTM;
61
62
// x86 : SIMD 128 bit
63
bool bSSE;
64
bool bSSE2;
65
bool bSSE3;
66
bool bSSSE3;
67
bool bSSE4_1;
68
bool bSSE4_2;
69
bool bSSE4A;
70
bool bAES;
71
bool bSHA;
72
bool bF16C;
73
// x86 : SIMD 256 bit
74
bool bAVX;
75
bool bAVX2;
76
bool bFMA3;
77
bool bFMA4;
78
79
// ARM specific CPUInfo
80
bool bSwp;
81
bool bHalf;
82
bool bThumb;
83
bool bFastMult;
84
bool bVFP;
85
bool bEDSP;
86
bool bThumbEE;
87
bool bNEON;
88
bool bVFPv3;
89
bool bTLS;
90
bool bVFPv4;
91
bool bIDIVa;
92
bool bIDIVt;
93
94
// ARMv8 specific
95
bool bFP;
96
bool bASIMD;
97
bool bSVE;
98
bool bSVE2;
99
bool bFRINT;
100
101
// MIPS specific
102
bool bXBurst1;
103
bool bXBurst2;
104
105
// RiscV specific extension flags.
106
bool RiscV_M;
107
bool RiscV_A;
108
bool RiscV_F;
109
bool RiscV_D;
110
bool RiscV_C;
111
bool RiscV_V;
112
bool RiscV_Zicsr;
113
bool RiscV_Zba;
114
bool RiscV_Zbb;
115
bool RiscV_Zbc;
116
bool RiscV_Zbs;
117
bool RiscV_Zcb;
118
bool RiscV_Zfa;
119
bool RiscV_Zfh;
120
bool RiscV_Zfhmin;
121
bool RiscV_Zicond;
122
bool RiscV_Zvbb;
123
bool RiscV_Zvkb;
124
125
// LoongArch specific extension flags.
126
bool LOONGARCH_CPUCFG;
127
bool LOONGARCH_LAM;
128
bool LOONGARCH_UAL;
129
bool LOONGARCH_FPU;
130
bool LOONGARCH_LSX;
131
bool LOONGARCH_LASX;
132
bool LOONGARCH_CRC32;
133
bool LOONGARCH_COMPLEX;
134
bool LOONGARCH_CRYPTO;
135
bool LOONGARCH_LVZ;
136
bool LOONGARCH_LBT_X86;
137
bool LOONGARCH_LBT_ARM;
138
bool LOONGARCH_LBT_MIPS;
139
bool LOONGARCH_PTW;
140
141
// Quirks
142
struct {
143
// Samsung Galaxy S7 devices (Exynos 8890) have a big.LITTLE configuration where the cacheline size differs between big and LITTLE.
144
// GCC's cache clearing function would detect the cacheline size on one and keep it for later. When clearing
145
// with the wrong cacheline size on the other, that's an issue. In case we want to do something different in this
146
// situation in the future, let's keep this as a quirk, but our current code won't detect it reliably
147
// if it happens on new archs. We now use better clearing code on ARM64 that doesn't have this issue.
148
bool bExynos8890DifferingCachelineSizes;
149
} sQuirks;
150
151
// Call Detect()
152
explicit CPUInfo();
153
154
// Turn the cpu info into a string we can show
155
std::vector<std::string> Features();
156
std::string Summarize();
157
158
private:
159
// Detects the various cpu features
160
void Detect();
161
};
162
163
extern CPUInfo cpu_info;
164
165
const char *GetCompilerABI();
166
167