Skip to content

Commit

Permalink
GS: Remove MSVC macro hack
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastRar authored and refractionpcsx2 committed May 30, 2024
1 parent c44659d commit f2e4a5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
1 change: 1 addition & 0 deletions cmake/BuildParameters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ if(MSVC AND NOT USE_CLANG_CL)
"$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>"
"$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>"
"$<$<COMPILE_LANGUAGE:CXX>:/permissive->"
"$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>"
"/Zo"
"/utf-8"
)
Expand Down
1 change: 1 addition & 0 deletions common/vsprops/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<ConformanceMode>true</ConformanceMode>
<UseStandardPreprocessor>true</UseStandardPreprocessor>

<!-- SH 2/3 flashlight, explicitly set here don't change -->
<!-- https://github.com/PCSX2/pcsx2/commit/16431653e4d92fda4069031897e24fbe4688d36a -->
Expand Down
37 changes: 9 additions & 28 deletions pcsx2/GS/Renderers/SW/GSNewCodeGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ class GSNewCodeGenerator
// ACTUAL_FORWARD_*: Actually forward the function of the given type
// FORWARD#: First validates the arguments (e.g. make sure you're not passing registers over 7 on x86), then forwards to an ACTUAL_FORWARD_*

// Big thanks to https://stackoverflow.com/a/24028231 for helping me figure out how to work around MSVC's terrible macro expander
// Of course GCC/Clang don't like the workaround so enjoy the ifdefs
#define EXPAND_ARGS(macro, args) macro args

#define ACTUAL_FORWARD_BASE(name, ...) \
actual.name(__VA_ARGS__);

Expand Down Expand Up @@ -152,15 +148,9 @@ class GSNewCodeGenerator
ACTUAL_FORWARD_##category(name, a, b, c, d) \
}

#if defined(__GNUC__) || (defined(_MSC_VER) && defined(__clang__))
#define FORWARD_(argcount, ...) FORWARD##argcount(__VA_ARGS__)
// Gets the macro evaluator to evaluate in the right order
#define FORWARD(...) FORWARD_(__VA_ARGS__)
#else
#define FORWARD_(argcount, ...) EXPAND_ARGS(FORWARD##argcount, (__VA_ARGS__))
// Gets the macro evaluator to evaluate in the right order
#define FORWARD(...) EXPAND_ARGS(FORWARD_, (__VA_ARGS__))
#endif
#define FORWARD_(argcount, ...) FORWARD##argcount(__VA_ARGS__)
// Gets the macro evaluator to evaluate in the right order
#define FORWARD(...) FORWARD_(__VA_ARGS__)

#define FORWARD_SSE_XMM0(name) \
void name(const Xmm& a, const Operand& b) \
Expand All @@ -180,21 +170,12 @@ class GSNewCodeGenerator
#define ADD_ONE_2 3
#define ADD_ONE_3 4

#if defined(__GNUC__) || defined(_MSC_VER) && defined(__clang__)
#define SFORWARD(argcount, name, ...) FORWARD(argcount, SSE, name, __VA_ARGS__)
#define AFORWARD_(argcount, name, arg1, ...) \
SFORWARD(argcount, name, arg1, __VA_ARGS__) \
FORWARD(ADD_ONE_##argcount, AVX, v##name, arg1, arg1, __VA_ARGS__)
// Gets the macro evaluator to evaluate in the right order
#define AFORWARD(...) EXPAND_ARGS(AFORWARD_, (__VA_ARGS__))
#else
#define SFORWARD(argcount, name, ...) EXPAND_ARGS(FORWARD, (argcount, SSE, name, __VA_ARGS__))
#define AFORWARD_(argcount, name, arg1, ...) \
EXPAND_ARGS(SFORWARD, (argcount, name, arg1, __VA_ARGS__)) \
EXPAND_ARGS(FORWARD, (ADD_ONE_##argcount, AVX, v##name, arg1, arg1, __VA_ARGS__))
// Gets the macro evaluator to evaluate in the right order
#define AFORWARD(...) EXPAND_ARGS(AFORWARD_, (__VA_ARGS__))
#endif
#define SFORWARD(argcount, name, ...) FORWARD(argcount, SSE, name, __VA_ARGS__)
#define AFORWARD_(argcount, name, arg1, ...) \
SFORWARD(argcount, name, arg1, __VA_ARGS__) \
FORWARD(ADD_ONE_##argcount, AVX, v##name, arg1, arg1, __VA_ARGS__)
// Gets the macro evaluator to evaluate in the right order
#define AFORWARD(...) AFORWARD_(__VA_ARGS__)

#define FORWARD_OO_OI(name) \
FORWARD(2, BASE, name, ARGS_OO) \
Expand Down

0 comments on commit f2e4a5e

Please sign in to comment.