From d6bf1b31c82a5b3eb4dc1ae2d59aeeb10de3f85d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 14 Aug 2018 18:27:27 -0400 Subject: [PATCH 1/2] common/xbyak: Use nested namespace specifiers where applicable --- src/common/x64/xbyak_abi.h | 6 ++---- src/common/x64/xbyak_util.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index fd3fbdd4b7..a27f5c72db 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h @@ -9,8 +9,7 @@ #include "common/assert.h" #include "common/bit_set.h" -namespace Common { -namespace X64 { +namespace Common::X64 { int RegToIndex(const Xbyak::Reg& reg) { using Kind = Xbyak::Reg::Kind; @@ -217,5 +216,4 @@ void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, s } } -} // namespace X64 -} // namespace Common +} // namespace Common::X64 diff --git a/src/common/x64/xbyak_util.h b/src/common/x64/xbyak_util.h index 0f52f704b7..b705d1ff28 100644 --- a/src/common/x64/xbyak_util.h +++ b/src/common/x64/xbyak_util.h @@ -8,8 +8,7 @@ #include #include "common/x64/xbyak_abi.h" -namespace Common { -namespace X64 { +namespace Common::X64 { // Constants for use with cmpps/cmpss enum { @@ -45,5 +44,4 @@ inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) { } } -} // namespace X64 -} // namespace Common +} // namespace Common::X64 From 0fbae792cfd26f2bd31432fa56eb9777828fe7e4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 14 Aug 2018 18:29:53 -0400 Subject: [PATCH 2/2] common/xbyak_abi: Mark defined functions in header as inline Avoids potential One Definition Rule violations when these are used in the future. --- src/common/x64/xbyak_abi.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index a27f5c72db..927da91875 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h @@ -11,7 +11,7 @@ namespace Common::X64 { -int RegToIndex(const Xbyak::Reg& reg) { +inline int 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."); @@ -151,8 +151,8 @@ constexpr size_t ABI_SHADOW_SPACE = 0; #endif -void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_frame_size, - s32* out_subtraction, s32* out_xmm_offset) { +inline void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_frame_size, + s32* out_subtraction, s32* out_xmm_offset) { int count = (regs & ABI_ALL_GPRS).Count(); rsp_alignment -= count * 8; size_t subtraction = 0; @@ -173,8 +173,8 @@ void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_f *out_xmm_offset = (s32)(subtraction - xmm_base_subtraction); } -size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, - size_t rsp_alignment, size_t needed_frame_size = 0) { +inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, + size_t rsp_alignment, size_t needed_frame_size = 0) { s32 subtraction, xmm_offset; ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset); @@ -194,8 +194,8 @@ size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs return ABI_SHADOW_SPACE; } -void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, size_t rsp_alignment, - size_t needed_frame_size = 0) { +inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, + size_t rsp_alignment, size_t needed_frame_size = 0) { s32 subtraction, xmm_offset; ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset);