diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64PowerPCState.h b/Source/Core/Core/PowerPC/Jit64Common/Jit64PowerPCState.h index f534c853c8..692129e0ab 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64PowerPCState.h +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64PowerPCState.h @@ -11,11 +11,26 @@ // We offset by 0x80 because the range of one byte memory offsets is // -0x80..0x7f. +#ifdef __GNUC__ +#define PPCSTATE_OFF(i) \ + ([]() consteval { \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"") return static_cast( \ + offsetof(PowerPC::PowerPCState, i)) - \ + 0x80; \ + _Pragma("GCC diagnostic pop") \ + }()) + +#define PPCSTATE_OFF_ARRAY(elem, i) \ + (PPCSTATE_OFF(elem[0]) + static_cast(sizeof(PowerPC::PowerPCState::elem[0]) * (i))) +#else #define PPCSTATE_OFF(i) (static_cast(offsetof(PowerPC::PowerPCState, i)) - 0x80) + #define PPCSTATE_OFF_ARRAY(elem, i) \ (static_cast(offsetof(PowerPC::PowerPCState, elem[0]) + \ sizeof(PowerPC::PowerPCState::elem[0]) * (i)) - \ 0x80) +#endif #define PPCSTATE_OFF_GPR(i) PPCSTATE_OFF_ARRAY(gpr, i) #define PPCSTATE_OFF_CR(i) PPCSTATE_OFF_ARRAY(cr.fields, i) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.h b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.h index a8e63eb006..01339184ea 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.h +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.h @@ -25,10 +25,23 @@ constexpr Arm64Gen::ARM64Reg PPC_REG = Arm64Gen::ARM64Reg::X29; // PC register when calling the dispatcher constexpr Arm64Gen::ARM64Reg DISPATCHER_PC = Arm64Gen::ARM64Reg::W26; +#ifdef __GNUC__ +#define PPCSTATE_OFF(elem) \ + ([]() consteval { \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"") return offsetof( \ + PowerPC::PowerPCState, elem); \ + _Pragma("GCC diagnostic pop") \ + }()) + +#define PPCSTATE_OFF_ARRAY(elem, i) \ + (PPCSTATE_OFF(elem[0]) + sizeof(PowerPC::PowerPCState::elem[0]) * (i)) +#else #define PPCSTATE_OFF(elem) (offsetof(PowerPC::PowerPCState, elem)) #define PPCSTATE_OFF_ARRAY(elem, i) \ (offsetof(PowerPC::PowerPCState, elem[0]) + sizeof(PowerPC::PowerPCState::elem[0]) * (i)) +#endif #define PPCSTATE_OFF_GPR(i) PPCSTATE_OFF_ARRAY(gpr, i) #define PPCSTATE_OFF_CR(i) PPCSTATE_OFF_ARRAY(cr.fields, i)