diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2020-06-15 20:02:06 +0200 |
---|---|---|
committer | MerryMage <MerryMage@users.noreply.github.com> | 2020-06-15 20:07:11 +0200 |
commit | 36362e9695a988e4727adcfb52f265394d55e8d5 (patch) | |
tree | 3933b724ab7353344c548ca5e48911aa226fbed4 /src/common/x64 | |
parent | xbyak_abi: Remove *GPS variants of stack manipulation functions (diff) | |
download | yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar.gz yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar.bz2 yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar.lz yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar.xz yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.tar.zst yuzu-36362e9695a988e4727adcfb52f265394d55e8d5.zip |
Diffstat (limited to 'src/common/x64')
-rw-r--r-- | src/common/x64/xbyak_abi.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index 1dcd147b6..33a96d6cb 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h @@ -11,7 +11,7 @@ namespace Common::X64 { -inline int RegToIndex(const Xbyak::Reg& reg) { +inline std::size_t RegToIndex(const Xbyak::Reg& reg) { using Kind = Xbyak::Reg::Kind; ASSERT_MSG((reg.getKind() & (Kind::REG | Kind::XMM)) != 0, "RegSet only support GPRs and XMM registers."); @@ -19,17 +19,17 @@ inline int RegToIndex(const Xbyak::Reg& reg) { return reg.getIdx() + (reg.getKind() == Kind::REG ? 0 : 16); } -inline Xbyak::Reg64 IndexToReg64(int reg_index) { +inline Xbyak::Reg64 IndexToReg64(std::size_t reg_index) { ASSERT(reg_index < 16); - return Xbyak::Reg64(reg_index); + return Xbyak::Reg64(static_cast<int>(reg_index)); } -inline Xbyak::Xmm IndexToXmm(int reg_index) { +inline Xbyak::Xmm IndexToXmm(std::size_t reg_index) { ASSERT(reg_index >= 16 && reg_index < 32); - return Xbyak::Xmm(reg_index - 16); + return Xbyak::Xmm(static_cast<int>(reg_index - 16)); } -inline Xbyak::Reg IndexToReg(int reg_index) { +inline Xbyak::Reg IndexToReg(std::size_t reg_index) { if (reg_index < 16) { return IndexToReg64(reg_index); } else { @@ -181,7 +181,7 @@ inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::b for (std::size_t i = 0; i < regs.size(); ++i) { if (regs[i] && ABI_ALL_GPRS[i]) { - code.push(IndexToReg64(static_cast<int>(i))); + code.push(IndexToReg64(i)); } } @@ -191,7 +191,7 @@ inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::b for (std::size_t i = 0; i < regs.size(); ++i) { if (regs[i] && ABI_ALL_XMMS[i]) { - code.movaps(code.xword[code.rsp + xmm_offset], IndexToXmm(static_cast<int>(i))); + code.movaps(code.xword[code.rsp + xmm_offset], IndexToXmm(i)); xmm_offset += 0x10; } } @@ -206,7 +206,7 @@ inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::bits for (std::size_t i = 0; i < regs.size(); ++i) { if (regs[i] && ABI_ALL_XMMS[i]) { - code.movaps(IndexToXmm(static_cast<int>(i)), code.xword[code.rsp + xmm_offset]); + code.movaps(IndexToXmm(i), code.xword[code.rsp + xmm_offset]); xmm_offset += 0x10; } } @@ -216,8 +216,9 @@ inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, std::bits } // GPRs need to be popped in reverse order - for (int i = 15; i >= 0; i--) { - if (regs[i]) { + for (std::size_t j = 0; j < regs.size(); ++j) { + const std::size_t i = regs.size() - j - 1; + if (regs[i] && ABI_ALL_GPRS[i]) { code.pop(IndexToReg64(i)); } } |