summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/x64/cpu_detect.cpp220
-rw-r--r--src/common/x64/cpu_detect.h99
-rw-r--r--src/common/x64/emitter.cpp18
-rw-r--r--src/common/x64/emitter.h2
4 files changed, 141 insertions, 198 deletions
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp
index 72c8297a3..d9c430c67 100644
--- a/src/common/x64/cpu_detect.cpp
+++ b/src/common/x64/cpu_detect.cpp
@@ -1,23 +1,25 @@
1// Copyright 2008 Dolphin Emulator Project 1// Copyright 2013 Dolphin Emulator Project / 2015 Citra Emulator Project
2// Licensed under GPLv2+ 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring> 5#include <cstring>
6#include <string> 6#include <string>
7#include <thread>
7 8
8#include "common/common_types.h" 9#include "common/common_types.h"
9 10
10#include "cpu_detect.h" 11#include "cpu_detect.h"
11 12
12#ifndef _WIN32 13namespace Common {
14
15#ifndef _MSC_VER
13 16
14#ifdef __FreeBSD__ 17#ifdef __FreeBSD__
15#include <sys/types.h> 18#include <sys/types.h>
16#include <machine/cpufunc.h> 19#include <machine/cpufunc.h>
17#endif 20#endif
18 21
19static inline void __cpuidex(int info[4], int function_id, int subfunction_id) 22static inline void __cpuidex(int info[4], int function_id, int subfunction_id) {
20{
21#ifdef __FreeBSD__ 23#ifdef __FreeBSD__
22 // Despite the name, this is just do_cpuid() with ECX as second input. 24 // Despite the name, this is just do_cpuid() with ECX as second input.
23 cpuid_count((u_int)function_id, (u_int)subfunction_id, (u_int*)info); 25 cpuid_count((u_int)function_id, (u_int)subfunction_id, (u_int*)info);
@@ -36,96 +38,67 @@ static inline void __cpuidex(int info[4], int function_id, int subfunction_id)
36#endif 38#endif
37} 39}
38 40
39static inline void __cpuid(int info[4], int function_id) 41static inline void __cpuid(int info[4], int function_id) {
40{
41 return __cpuidex(info, function_id, 0); 42 return __cpuidex(info, function_id, 0);
42} 43}
43 44
44#define _XCR_XFEATURE_ENABLED_MASK 0 45#define _XCR_XFEATURE_ENABLED_MASK 0
45static u64 _xgetbv(u32 index) 46static u64 _xgetbv(u32 index) {
46{
47 u32 eax, edx; 47 u32 eax, edx;
48 __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); 48 __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
49 return ((u64)edx << 32) | eax; 49 return ((u64)edx << 32) | eax;
50} 50}
51 51
52#endif // ifndef _WIN32 52#endif // ifndef _MSC_VER
53
54namespace Common {
55
56CPUInfo cpu_info;
57
58CPUInfo::CPUInfo() {
59 Detect();
60}
61 53
62// Detects the various CPU features 54// Detects the various CPU features
63void CPUInfo::Detect() { 55static CPUCaps Detect() {
64 memset(this, 0, sizeof(*this)); 56 CPUCaps caps = {};
65#ifdef ARCHITECTURE_X64
66 Mode64bit = true;
67 OS64bit = true;
68#endif
69 num_cores = 1;
70 57
71 // Set obvious defaults, for extra safety 58 caps.num_cores = std::thread::hardware_concurrency();
72 if (Mode64bit) { 59
73 bSSE = true; 60 // Assumes the CPU supports the CPUID instruction. Those that don't would likely not support
74 bSSE2 = true; 61 // Citra at all anyway
75 bLongMode = true;
76 }
77 62
78 // Assume CPU supports the CPUID instruction. Those that don't can barely
79 // boot modern OS:es anyway.
80 int cpu_id[4]; 63 int cpu_id[4];
81 memset(brand_string, 0, sizeof(brand_string)); 64 memset(caps.brand_string, 0, sizeof(caps.brand_string));
82 65
83 // Detect CPU's CPUID capabilities, and grab CPU string 66 // Detect CPU's CPUID capabilities and grab CPU string
84 __cpuid(cpu_id, 0x00000000); 67 __cpuid(cpu_id, 0x00000000);
85 u32 max_std_fn = cpu_id[0]; // EAX 68 u32 max_std_fn = cpu_id[0]; // EAX
86 *((int *)brand_string) = cpu_id[1]; 69
87 *((int *)(brand_string + 4)) = cpu_id[3]; 70 std::memcpy(&caps.brand_string[0], &cpu_id[1], sizeof(int));
88 *((int *)(brand_string + 8)) = cpu_id[2]; 71 std::memcpy(&caps.brand_string[4], &cpu_id[3], sizeof(int));
72 std::memcpy(&caps.brand_string[8], &cpu_id[2], sizeof(int));
73
89 __cpuid(cpu_id, 0x80000000); 74 __cpuid(cpu_id, 0x80000000);
75
90 u32 max_ex_fn = cpu_id[0]; 76 u32 max_ex_fn = cpu_id[0];
91 if (!strcmp(brand_string, "GenuineIntel")) 77 if (!strcmp(caps.brand_string, "GenuineIntel"))
92 vendor = VENDOR_INTEL; 78 caps.vendor = CPUVendor::INTEL;
93 else if (!strcmp(brand_string, "AuthenticAMD")) 79 else if (!strcmp(caps.brand_string, "AuthenticAMD"))
94 vendor = VENDOR_AMD; 80 caps.vendor = CPUVendor::AMD;
95 else 81 else
96 vendor = VENDOR_OTHER; 82 caps.vendor = CPUVendor::OTHER;
97 83
98 // Set reasonable default brand string even if brand string not available. 84 // Set reasonable default brand string even if brand string not available
99 strcpy(cpu_string, brand_string); 85 strcpy(caps.cpu_string, caps.brand_string);
100 86
101 // Detect family and other misc stuff. 87 // Detect family and other miscellaneous features
102 bool ht = false;
103 HTT = ht;
104 logical_cpu_count = 1;
105 if (max_std_fn >= 1) { 88 if (max_std_fn >= 1) {
106 __cpuid(cpu_id, 0x00000001); 89 __cpuid(cpu_id, 0x00000001);
107 int family = ((cpu_id[0] >> 8) & 0xf) + ((cpu_id[0] >> 20) & 0xff); 90
108 int model = ((cpu_id[0] >> 4) & 0xf) + ((cpu_id[0] >> 12) & 0xf0); 91 if ((cpu_id[3] >> 25) & 1) caps.sse = true;
109 // Detect people unfortunate enough to be running Dolphin on an Atom 92 if ((cpu_id[3] >> 26) & 1) caps.sse2 = true;
110 if (family == 6 && (model == 0x1C || model == 0x26 || model == 0x27 || model == 0x35 || model == 0x36 || 93 if ((cpu_id[2]) & 1) caps.sse3 = true;
111 model == 0x37 || model == 0x4A || model == 0x4D || model == 0x5A || model == 0x5D)) 94 if ((cpu_id[2] >> 9) & 1) caps.ssse3 = true;
112 bAtom = true; 95 if ((cpu_id[2] >> 19) & 1) caps.sse4_1 = true;
113 logical_cpu_count = (cpu_id[1] >> 16) & 0xFF; 96 if ((cpu_id[2] >> 20) & 1) caps.sse4_2 = true;
114 ht = (cpu_id[3] >> 28) & 1; 97 if ((cpu_id[2] >> 22) & 1) caps.movbe = true;
115 98 if ((cpu_id[2] >> 25) & 1) caps.aes = true;
116 if ((cpu_id[3] >> 25) & 1) bSSE = true; 99
117 if ((cpu_id[3] >> 26) & 1) bSSE2 = true; 100 if ((cpu_id[3] >> 24) & 1) {
118 if ((cpu_id[2]) & 1) bSSE3 = true; 101 caps.fxsave_fxrstor = true;
119 if ((cpu_id[2] >> 9) & 1) bSSSE3 = true;
120 if ((cpu_id[2] >> 19) & 1) bSSE4_1 = true;
121 if ((cpu_id[2] >> 20) & 1) bSSE4_2 = true;
122 if ((cpu_id[2] >> 22) & 1) bMOVBE = true;
123 if ((cpu_id[2] >> 25) & 1) bAES = true;
124
125 if ((cpu_id[3] >> 24) & 1)
126 {
127 // We can use FXSAVE.
128 bFXSR = true;
129 } 102 }
130 103
131 // AVX support requires 3 separate checks: 104 // AVX support requires 3 separate checks:
@@ -134,95 +107,80 @@ void CPUInfo::Detect() {
134 // - XGETBV result has the XCR bit set. 107 // - XGETBV result has the XCR bit set.
135 if (((cpu_id[2] >> 28) & 1) && ((cpu_id[2] >> 27) & 1)) { 108 if (((cpu_id[2] >> 28) & 1) && ((cpu_id[2] >> 27) & 1)) {
136 if ((_xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6) == 0x6) { 109 if ((_xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6) == 0x6) {
137 bAVX = true; 110 caps.avx = true;
138 if ((cpu_id[2] >> 12) & 1) 111 if ((cpu_id[2] >> 12) & 1)
139 bFMA = true; 112 caps.fma = true;
140 } 113 }
141 } 114 }
142 115
143 if (max_std_fn >= 7) { 116 if (max_std_fn >= 7) {
144 __cpuidex(cpu_id, 0x00000007, 0x00000000); 117 __cpuidex(cpu_id, 0x00000007, 0x00000000);
145 // careful; we can't enable AVX2 unless the XSAVE/XGETBV checks above passed 118 // Can't enable AVX2 unless the XSAVE/XGETBV checks above passed
146 if ((cpu_id[1] >> 5) & 1) 119 if ((cpu_id[1] >> 5) & 1)
147 bAVX2 = bAVX; 120 caps.avx2 = caps.avx;
148 if ((cpu_id[1] >> 3) & 1) 121 if ((cpu_id[1] >> 3) & 1)
149 bBMI1 = true; 122 caps.bmi1 = true;
150 if ((cpu_id[1] >> 8) & 1) 123 if ((cpu_id[1] >> 8) & 1)
151 bBMI2 = true; 124 caps.bmi2 = true;
152 } 125 }
153 } 126 }
154 127
155 bFlushToZero = bSSE; 128 caps.flush_to_zero = caps.sse;
156 129
157 if (max_ex_fn >= 0x80000004) { 130 if (max_ex_fn >= 0x80000004) {
158 // Extract CPU model string 131 // Extract CPU model string
159 __cpuid(cpu_id, 0x80000002); 132 __cpuid(cpu_id, 0x80000002);
160 memcpy(cpu_string, cpu_id, sizeof(cpu_id)); 133 std::memcpy(caps.cpu_string, cpu_id, sizeof(cpu_id));
161 __cpuid(cpu_id, 0x80000003); 134 __cpuid(cpu_id, 0x80000003);
162 memcpy(cpu_string + 16, cpu_id, sizeof(cpu_id)); 135 std::memcpy(caps.cpu_string + 16, cpu_id, sizeof(cpu_id));
163 __cpuid(cpu_id, 0x80000004); 136 __cpuid(cpu_id, 0x80000004);
164 memcpy(cpu_string + 32, cpu_id, sizeof(cpu_id)); 137 std::memcpy(caps.cpu_string + 32, cpu_id, sizeof(cpu_id));
165 } 138 }
139
166 if (max_ex_fn >= 0x80000001) { 140 if (max_ex_fn >= 0x80000001) {
167 // Check for more features. 141 // Check for more features
168 __cpuid(cpu_id, 0x80000001); 142 __cpuid(cpu_id, 0x80000001);
169 if (cpu_id[2] & 1) bLAHFSAHF64 = true; 143 if (cpu_id[2] & 1) caps.lahf_sahf_64 = true;
170 if ((cpu_id[2] >> 5) & 1) bLZCNT = true; 144 if ((cpu_id[2] >> 5) & 1) caps.lzcnt = true;
171 if ((cpu_id[2] >> 16) & 1) bFMA4 = true; 145 if ((cpu_id[2] >> 16) & 1) caps.fma4 = true;
172 if ((cpu_id[3] >> 29) & 1) bLongMode = true; 146 if ((cpu_id[3] >> 29) & 1) caps.long_mode = true;
173 } 147 }
174 148
175 num_cores = (logical_cpu_count == 0) ? 1 : logical_cpu_count; 149 return caps;
176
177 if (max_ex_fn >= 0x80000008) {
178 // Get number of cores. This is a bit complicated. Following AMD manual here.
179 __cpuid(cpu_id, 0x80000008);
180 int apic_id_core_id_size = (cpu_id[2] >> 12) & 0xF;
181 if (apic_id_core_id_size == 0) {
182 if (ht) {
183 // New mechanism for modern Intel CPUs.
184 if (vendor == VENDOR_INTEL) {
185 __cpuidex(cpu_id, 0x00000004, 0x00000000);
186 int cores_x_package = ((cpu_id[0] >> 26) & 0x3F) + 1;
187 HTT = (cores_x_package < logical_cpu_count);
188 cores_x_package = ((logical_cpu_count % cores_x_package) == 0) ? cores_x_package : 1;
189 num_cores = (cores_x_package > 1) ? cores_x_package : num_cores;
190 logical_cpu_count /= cores_x_package;
191 }
192 }
193 } else {
194 // Use AMD's new method.
195 num_cores = (cpu_id[2] & 0xFF) + 1;
196 }
197 }
198} 150}
199 151
200// Turn the CPU info into a string we can show 152const CPUCaps& GetCPUCaps() {
201std::string CPUInfo::Summarize() { 153 static CPUCaps caps = Detect();
202 std::string sum(cpu_string); 154 return caps;
155}
156
157std::string GetCPUCapsString() {
158 auto caps = GetCPUCaps();
159
160 std::string sum(caps.cpu_string);
203 sum += " ("; 161 sum += " (";
204 sum += brand_string; 162 sum += caps.brand_string;
205 sum += ")"; 163 sum += ")";
206 164
207 if (bSSE) sum += ", SSE"; 165 if (caps.sse) sum += ", SSE";
208 if (bSSE2) { 166 if (caps.sse2) {
209 sum += ", SSE2"; 167 sum += ", SSE2";
210 if (!bFlushToZero) 168 if (!caps.flush_to_zero) sum += " (without DAZ)";
211 sum += " (but not DAZ!)";
212 } 169 }
213 if (bSSE3) sum += ", SSE3"; 170
214 if (bSSSE3) sum += ", SSSE3"; 171 if (caps.sse3) sum += ", SSE3";
215 if (bSSE4_1) sum += ", SSE4.1"; 172 if (caps.ssse3) sum += ", SSSE3";
216 if (bSSE4_2) sum += ", SSE4.2"; 173 if (caps.sse4_1) sum += ", SSE4.1";
217 if (HTT) sum += ", HTT"; 174 if (caps.sse4_2) sum += ", SSE4.2";
218 if (bAVX) sum += ", AVX"; 175 if (caps.avx) sum += ", AVX";
219 if (bAVX2) sum += ", AVX2"; 176 if (caps.avx2) sum += ", AVX2";
220 if (bBMI1) sum += ", BMI1"; 177 if (caps.bmi1) sum += ", BMI1";
221 if (bBMI2) sum += ", BMI2"; 178 if (caps.bmi2) sum += ", BMI2";
222 if (bFMA) sum += ", FMA"; 179 if (caps.fma) sum += ", FMA";
223 if (bAES) sum += ", AES"; 180 if (caps.aes) sum += ", AES";
224 if (bMOVBE) sum += ", MOVBE"; 181 if (caps.movbe) sum += ", MOVBE";
225 if (bLongMode) sum += ", 64-bit support"; 182 if (caps.long_mode) sum += ", 64-bit support";
183
226 return sum; 184 return sum;
227} 185}
228 186
diff --git a/src/common/x64/cpu_detect.h b/src/common/x64/cpu_detect.h
index 19a2c25d6..0af3a8adb 100644
--- a/src/common/x64/cpu_detect.h
+++ b/src/common/x64/cpu_detect.h
@@ -1,81 +1,66 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project 1// Copyright 2013 Dolphin Emulator Project / 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5
6// Detect the CPU, so we'll know which optimizations to use
7#pragma once 5#pragma once
8 6
9#include <string> 7#include <string>
10 8
11namespace Common { 9namespace Common {
12 10
13enum CPUVendor 11/// x86/x64 CPU vendors that may be detected by this module
14{ 12enum class CPUVendor {
15 VENDOR_INTEL = 0, 13 INTEL,
16 VENDOR_AMD = 1, 14 AMD,
17 VENDOR_ARM = 2, 15 OTHER,
18 VENDOR_OTHER = 3,
19}; 16};
20 17
21struct CPUInfo 18/// x86/x64 CPU capabilities that may be detected by this module
22{ 19struct CPUCaps {
23 CPUVendor vendor; 20 CPUVendor vendor;
24
25 char cpu_string[0x21]; 21 char cpu_string[0x21];
26 char brand_string[0x41]; 22 char brand_string[0x41];
27 bool OS64bit;
28 bool CPU64bit;
29 bool Mode64bit;
30
31 bool HTT;
32 int num_cores; 23 int num_cores;
33 int logical_cpu_count; 24 bool sse;
25 bool sse2;
26 bool sse3;
27 bool ssse3;
28 bool sse4_1;
29 bool sse4_2;
30 bool lzcnt;
31 bool avx;
32 bool avx2;
33 bool bmi1;
34 bool bmi2;
35 bool fma;
36 bool fma4;
37 bool aes;
34 38
35 bool bSSE; 39 // Support for the FXSAVE and FXRSTOR instructions
36 bool bSSE2; 40 bool fxsave_fxrstor;
37 bool bSSE3;
38 bool bSSSE3;
39 bool bPOPCNT;
40 bool bSSE4_1;
41 bool bSSE4_2;
42 bool bLZCNT;
43 bool bSSE4A;
44 bool bAVX;
45 bool bAVX2;
46 bool bBMI1;
47 bool bBMI2;
48 bool bFMA;
49 bool bFMA4;
50 bool bAES;
51 // FXSAVE/FXRSTOR
52 bool bFXSR;
53 bool bMOVBE;
54 // This flag indicates that the hardware supports some mode
55 // in which denormal inputs _and_ outputs are automatically set to (signed) zero.
56 bool bFlushToZero;
57 bool bLAHFSAHF64;
58 bool bLongMode;
59 bool bAtom;
60 41
61 // ARMv8 specific 42 bool movbe;
62 bool bFP;
63 bool bASIMD;
64 bool bCRC32;
65 bool bSHA1;
66 bool bSHA2;
67 43
68 // Call Detect() 44 // This flag indicates that the hardware supports some mode in which denormal inputs and outputs
69 explicit CPUInfo(); 45 // are automatically set to (signed) zero.
46 bool flush_to_zero;
70 47
71 // Turn the cpu info into a string we can show 48 // Support for LAHF and SAHF instructions in 64-bit mode
72 std::string Summarize(); 49 bool lahf_sahf_64;
73 50
74private: 51 bool long_mode;
75 // Detects the various cpu features
76 void Detect();
77}; 52};
78 53
79extern CPUInfo cpu_info; 54/**
55 * Gets the supported capabilities of the host CPU
56 * @return Reference to a CPUCaps struct with the detected host CPU capabilities
57 */
58const CPUCaps& GetCPUCaps();
59
60/**
61 * Gets a string summary of the name and supported capabilities of the host CPU
62 * @return String summary
63 */
64std::string GetCPUCapsString();
80 65
81} // namespace Common 66} // namespace Common
diff --git a/src/common/x64/emitter.cpp b/src/common/x64/emitter.cpp
index 5463841d7..030c73918 100644
--- a/src/common/x64/emitter.cpp
+++ b/src/common/x64/emitter.cpp
@@ -826,14 +826,14 @@ void XEmitter::BSR(int bits, X64Reg dest, OpArg src) {WriteBitSearchType(bits,de
826void XEmitter::TZCNT(int bits, X64Reg dest, OpArg src) 826void XEmitter::TZCNT(int bits, X64Reg dest, OpArg src)
827{ 827{
828 CheckFlags(); 828 CheckFlags();
829 if (!Common::cpu_info.bBMI1) 829 if (!Common::GetCPUCaps().bmi1)
830 ASSERT_MSG(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer."); 830 ASSERT_MSG(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
831 WriteBitSearchType(bits, dest, src, 0xBC, true); 831 WriteBitSearchType(bits, dest, src, 0xBC, true);
832} 832}
833void XEmitter::LZCNT(int bits, X64Reg dest, OpArg src) 833void XEmitter::LZCNT(int bits, X64Reg dest, OpArg src)
834{ 834{
835 CheckFlags(); 835 CheckFlags();
836 if (!Common::cpu_info.bLZCNT) 836 if (!Common::GetCPUCaps().lzcnt)
837 ASSERT_MSG(0, "Trying to use LZCNT on a system that doesn't support it. Bad programmer."); 837 ASSERT_MSG(0, "Trying to use LZCNT on a system that doesn't support it. Bad programmer.");
838 WriteBitSearchType(bits, dest, src, 0xBD, true); 838 WriteBitSearchType(bits, dest, src, 0xBD, true);
839} 839}
@@ -907,7 +907,7 @@ void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
907 907
908void XEmitter::MOVBE(int bits, const OpArg& dest, const OpArg& src) 908void XEmitter::MOVBE(int bits, const OpArg& dest, const OpArg& src)
909{ 909{
910 ASSERT_MSG(Common::cpu_info.bMOVBE, "Generating MOVBE on a system that does not support it."); 910 ASSERT_MSG(Common::GetCPUCaps().movbe, "Generating MOVBE on a system that does not support it.");
911 if (bits == 8) 911 if (bits == 8)
912 { 912 {
913 MOV(bits, dest, src); 913 MOV(bits, dest, src);
@@ -1420,7 +1420,7 @@ static int GetVEXpp(u8 opPrefix)
1420 1420
1421void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) 1421void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
1422{ 1422{
1423 if (!Common::cpu_info.bAVX) 1423 if (!Common::GetCPUCaps().avx)
1424 ASSERT_MSG(0, "Trying to use AVX on a system that doesn't support it. Bad programmer."); 1424 ASSERT_MSG(0, "Trying to use AVX on a system that doesn't support it. Bad programmer.");
1425 int mmmmm = GetVEXmmmmm(op); 1425 int mmmmm = GetVEXmmmmm(op);
1426 int pp = GetVEXpp(opPrefix); 1426 int pp = GetVEXpp(opPrefix);
@@ -1445,7 +1445,7 @@ void XEmitter::WriteVEXOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg r
1445void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) 1445void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
1446{ 1446{
1447 CheckFlags(); 1447 CheckFlags();
1448 if (!Common::cpu_info.bBMI1) 1448 if (!Common::GetCPUCaps().bmi1)
1449 ASSERT_MSG(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer."); 1449 ASSERT_MSG(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
1450 WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes); 1450 WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
1451} 1451}
@@ -1453,7 +1453,7 @@ void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg
1453void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) 1453void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes)
1454{ 1454{
1455 CheckFlags(); 1455 CheckFlags();
1456 if (!Common::cpu_info.bBMI2) 1456 if (!Common::GetCPUCaps().bmi2)
1457 ASSERT_MSG(0, "Trying to use BMI2 on a system that doesn't support it. Bad programmer."); 1457 ASSERT_MSG(0, "Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
1458 WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes); 1458 WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
1459} 1459}
@@ -1647,7 +1647,7 @@ void XEmitter::UNPCKHPD(X64Reg dest, OpArg arg) {WriteSSEOp(0x66, 0x15, dest, ar
1647 1647
1648void XEmitter::MOVDDUP(X64Reg regOp, OpArg arg) 1648void XEmitter::MOVDDUP(X64Reg regOp, OpArg arg)
1649{ 1649{
1650 if (Common::cpu_info.bSSE3) 1650 if (Common::GetCPUCaps().sse3)
1651 { 1651 {
1652 WriteSSEOp(0xF2, 0x12, regOp, arg); //SSE3 movddup 1652 WriteSSEOp(0xF2, 0x12, regOp, arg); //SSE3 movddup
1653 } 1653 }
@@ -1737,14 +1737,14 @@ void XEmitter::PSRAD(X64Reg reg, int shift)
1737 1737
1738void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes) 1738void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes)
1739{ 1739{
1740 if (!Common::cpu_info.bSSSE3) 1740 if (!Common::GetCPUCaps().ssse3)
1741 ASSERT_MSG(0, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer."); 1741 ASSERT_MSG(0, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
1742 WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); 1742 WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
1743} 1743}
1744 1744
1745void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes) 1745void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes)
1746{ 1746{
1747 if (!Common::cpu_info.bSSE4_1) 1747 if (!Common::GetCPUCaps().sse4_1)
1748 ASSERT_MSG(0, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer."); 1748 ASSERT_MSG(0, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
1749 WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); 1749 WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
1750} 1750}
diff --git a/src/common/x64/emitter.h b/src/common/x64/emitter.h
index 312e9dc19..aaebb56f6 100644
--- a/src/common/x64/emitter.h
+++ b/src/common/x64/emitter.h
@@ -532,7 +532,7 @@ public:
532 void MOVSX(int dbits, int sbits, X64Reg dest, OpArg src); //automatically uses MOVSXD if necessary 532 void MOVSX(int dbits, int sbits, X64Reg dest, OpArg src); //automatically uses MOVSXD if necessary
533 void MOVZX(int dbits, int sbits, X64Reg dest, OpArg src); 533 void MOVZX(int dbits, int sbits, X64Reg dest, OpArg src);
534 534
535 // Available only on Atom or >= Haswell so far. Test with cpu_info.bMOVBE. 535 // Available only on Atom or >= Haswell so far. Test with GetCPUCaps().movbe.
536 void MOVBE(int dbits, const OpArg& dest, const OpArg& src); 536 void MOVBE(int dbits, const OpArg& dest, const OpArg& src);
537 537
538 // Available only on AMD >= Phenom or Intel >= Haswell 538 // Available only on AMD >= Phenom or Intel >= Haswell