summaryrefslogtreecommitdiff
path: root/src/common/x64
diff options
context:
space:
mode:
authorGravatar Morph2023-06-28 01:35:16 -0400
committerGravatar Morph2023-06-28 01:39:15 -0400
commit295fc7d0f8f0b6158307c5c9b11a60516f9eb221 (patch)
treeb80f91f05df4d70861d8b216e59a9f1ea5c707cd /src/common/x64
parentx64: cpu_wait: Remove magic values (diff)
downloadyuzu-295fc7d0f8f0b6158307c5c9b11a60516f9eb221.tar.gz
yuzu-295fc7d0f8f0b6158307c5c9b11a60516f9eb221.tar.xz
yuzu-295fc7d0f8f0b6158307c5c9b11a60516f9eb221.zip
x64: cpu_wait: Implement MWAITX for non-MSVC compilers
Diffstat (limited to 'src/common/x64')
-rw-r--r--src/common/x64/cpu_wait.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/x64/cpu_wait.cpp b/src/common/x64/cpu_wait.cpp
index ea16c8490..41d385f59 100644
--- a/src/common/x64/cpu_wait.cpp
+++ b/src/common/x64/cpu_wait.cpp
@@ -47,6 +47,16 @@ static void TPAUSE() {
47 const auto edx = static_cast<u32>(tsc >> 32); 47 const auto edx = static_cast<u32>(tsc >> 32);
48 asm volatile("tpause %0" : : "r"(RequestC02State), "d"(edx), "a"(eax)); 48 asm volatile("tpause %0" : : "r"(RequestC02State), "d"(edx), "a"(eax));
49} 49}
50
51static void MWAITX() {
52 static constexpr auto EnableWaitTimeFlag = 1U << 1;
53 static constexpr auto RequestC1State = 0U;
54
55 // monitor_var should be aligned to a cache line.
56 alignas(64) u64 monitor_var{};
57 asm volatile("monitorx" : : "a"(&monitor_var), "c"(0), "d"(0));
58 asm volatile("mwaitx" : : "a"(RequestC1State), "b"(PauseCycles), "c"(EnableWaitTimeFlag));
59}
50#endif 60#endif
51 61
52void MicroSleep() { 62void MicroSleep() {