summaryrefslogtreecommitdiff
path: root/src/common/x64
diff options
context:
space:
mode:
authorGravatar Levi2021-01-10 22:09:56 -0700
committerGravatar Levi2021-01-10 22:09:56 -0700
commit7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch)
tree5056f9406dec188439cb0deb87603498243a9412 /src/common/x64
parentMore forgetting... duh (diff)
parentMerge pull request #5229 from Morph1984/fullscreen-opt (diff)
downloadyuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz
yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/common/x64')
-rw-r--r--src/common/x64/native_clock.cpp8
-rw-r--r--src/common/x64/native_clock.h7
-rw-r--r--src/common/x64/xbyak_abi.h20
3 files changed, 18 insertions, 17 deletions
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp
index 424b39b1f..eb8a7782f 100644
--- a/src/common/x64/native_clock.cpp
+++ b/src/common/x64/native_clock.cpp
@@ -43,10 +43,10 @@ u64 EstimateRDTSCFrequency() {
43} 43}
44 44
45namespace X64 { 45namespace X64 {
46NativeClock::NativeClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, 46NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequency_,
47 u64 rtsc_frequency) 47 u64 rtsc_frequency_)
48 : WallClock(emulated_cpu_frequency, emulated_clock_frequency, true), rtsc_frequency{ 48 : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, true), rtsc_frequency{
49 rtsc_frequency} { 49 rtsc_frequency_} {
50 _mm_mfence(); 50 _mm_mfence();
51 last_measure = __rdtsc(); 51 last_measure = __rdtsc();
52 accumulated_ticks = 0U; 52 accumulated_ticks = 0U;
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h
index 891a3bbfd..6d1e32ac8 100644
--- a/src/common/x64/native_clock.h
+++ b/src/common/x64/native_clock.h
@@ -12,9 +12,10 @@
12namespace Common { 12namespace Common {
13 13
14namespace X64 { 14namespace X64 {
15class NativeClock : public WallClock { 15class NativeClock final : public WallClock {
16public: 16public:
17 NativeClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, u64 rtsc_frequency); 17 explicit NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequency_,
18 u64 rtsc_frequency_);
18 19
19 std::chrono::nanoseconds GetTimeNS() override; 20 std::chrono::nanoseconds GetTimeNS() override;
20 21
@@ -34,7 +35,7 @@ private:
34 /// value used to reduce the native clocks accuracy as some apss rely on 35 /// value used to reduce the native clocks accuracy as some apss rely on
35 /// undefined behavior where the level of accuracy in the clock shouldn't 36 /// undefined behavior where the level of accuracy in the clock shouldn't
36 /// be higher. 37 /// be higher.
37 static constexpr u64 inaccuracy_mask = ~(0x400 - 1); 38 static constexpr u64 inaccuracy_mask = ~(UINT64_C(0x400) - 1);
38 39
39 SpinLock rtsc_serialize{}; 40 SpinLock rtsc_serialize{};
40 u64 last_measure{}; 41 u64 last_measure{};
diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h
index 26e4bfda5..c2c9b6134 100644
--- a/src/common/x64/xbyak_abi.h
+++ b/src/common/x64/xbyak_abi.h
@@ -11,25 +11,25 @@
11 11
12namespace Common::X64 { 12namespace Common::X64 {
13 13
14constexpr std::size_t RegToIndex(const Xbyak::Reg& reg) { 14constexpr size_t RegToIndex(const Xbyak::Reg& reg) {
15 using Kind = Xbyak::Reg::Kind; 15 using Kind = Xbyak::Reg::Kind;
16 ASSERT_MSG((reg.getKind() & (Kind::REG | Kind::XMM)) != 0, 16 ASSERT_MSG((reg.getKind() & (Kind::REG | Kind::XMM)) != 0,
17 "RegSet only support GPRs and XMM registers."); 17 "RegSet only support GPRs and XMM registers.");
18 ASSERT_MSG(reg.getIdx() < 16, "RegSet only supports XXM0-15."); 18 ASSERT_MSG(reg.getIdx() < 16, "RegSet only supports XXM0-15.");
19 return reg.getIdx() + (reg.getKind() == Kind::REG ? 0 : 16); 19 return static_cast<size_t>(reg.getIdx()) + (reg.getKind() == Kind::REG ? 0 : 16);
20} 20}
21 21
22constexpr Xbyak::Reg64 IndexToReg64(std::size_t reg_index) { 22constexpr Xbyak::Reg64 IndexToReg64(size_t reg_index) {
23 ASSERT(reg_index < 16); 23 ASSERT(reg_index < 16);
24 return Xbyak::Reg64(static_cast<int>(reg_index)); 24 return Xbyak::Reg64(static_cast<int>(reg_index));
25} 25}
26 26
27constexpr Xbyak::Xmm IndexToXmm(std::size_t reg_index) { 27constexpr Xbyak::Xmm IndexToXmm(size_t reg_index) {
28 ASSERT(reg_index >= 16 && reg_index < 32); 28 ASSERT(reg_index >= 16 && reg_index < 32);
29 return Xbyak::Xmm(static_cast<int>(reg_index - 16)); 29 return Xbyak::Xmm(static_cast<int>(reg_index - 16));
30} 30}
31 31
32constexpr Xbyak::Reg IndexToReg(std::size_t reg_index) { 32constexpr Xbyak::Reg IndexToReg(size_t reg_index) {
33 if (reg_index < 16) { 33 if (reg_index < 16) {
34 return IndexToReg64(reg_index); 34 return IndexToReg64(reg_index);
35 } else { 35 } else {
@@ -182,7 +182,7 @@ inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::b
182 size_t rsp_alignment, size_t needed_frame_size = 0) { 182 size_t rsp_alignment, size_t needed_frame_size = 0) {
183 auto frame_info = ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size); 183 auto frame_info = ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size);
184 184
185 for (std::size_t i = 0; i < regs.size(); ++i) { 185 for (size_t i = 0; i < regs.size(); ++i) {
186 if (regs[i] && ABI_ALL_GPRS[i]) { 186 if (regs[i] && ABI_ALL_GPRS[i]) {
187 code.push(IndexToReg64(i)); 187 code.push(IndexToReg64(i));
188 } 188 }
@@ -192,7 +192,7 @@ inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::b
192 code.sub(code.rsp, frame_info.subtraction); 192 code.sub(code.rsp, frame_info.subtraction);
193 } 193 }
194 194
195 for (std::size_t i = 0; i < regs.size(); ++i) { 195 for (size_t i = 0; i < regs.size(); ++i) {
196 if (regs[i] && ABI_ALL_XMMS[i]) { 196 if (regs[i] && ABI_ALL_XMMS[i]) {
197 code.movaps(code.xword[code.rsp + frame_info.xmm_offset], IndexToXmm(i)); 197 code.movaps(code.xword[code.rsp + frame_info.xmm_offset], IndexToXmm(i));
198 frame_info.xmm_offset += 0x10; 198 frame_info.xmm_offset += 0x10;
@@ -206,7 +206,7 @@ inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::bits
206 size_t rsp_alignment, size_t needed_frame_size = 0) { 206 size_t rsp_alignment, size_t needed_frame_size = 0) {
207 auto frame_info = ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size); 207 auto frame_info = ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size);
208 208
209 for (std::size_t i = 0; i < regs.size(); ++i) { 209 for (size_t i = 0; i < regs.size(); ++i) {
210 if (regs[i] && ABI_ALL_XMMS[i]) { 210 if (regs[i] && ABI_ALL_XMMS[i]) {
211 code.movaps(IndexToXmm(i), code.xword[code.rsp + frame_info.xmm_offset]); 211 code.movaps(IndexToXmm(i), code.xword[code.rsp + frame_info.xmm_offset]);
212 frame_info.xmm_offset += 0x10; 212 frame_info.xmm_offset += 0x10;
@@ -218,8 +218,8 @@ inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::bits
218 } 218 }
219 219
220 // GPRs need to be popped in reverse order 220 // GPRs need to be popped in reverse order
221 for (std::size_t j = 0; j < regs.size(); ++j) { 221 for (size_t j = 0; j < regs.size(); ++j) {
222 const std::size_t i = regs.size() - j - 1; 222 const size_t i = regs.size() - j - 1;
223 if (regs[i] && ABI_ALL_GPRS[i]) { 223 if (regs[i] && ABI_ALL_GPRS[i]) {
224 code.pop(IndexToReg64(i)); 224 code.pop(IndexToReg64(i));
225 } 225 }