Skip to content

Commit

Permalink
clang-format: left-align escaped newlines
Browse files Browse the repository at this point in the history
alternative to FEX-Emu#3638. this is theoretically better for side-by-side diffs. in
practice it may make other diffs worse since all the \'s change when part of the
macro change.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
  • Loading branch information
alyssarosenzweig committed May 20, 2024
1 parent 048c8de commit a10f984
Show file tree
Hide file tree
Showing 31 changed files with 262 additions and 262 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: DontAlign
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
Expand Down
14 changes: 7 additions & 7 deletions FEXCore/Source/Interface/Core/CPUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,14 @@ void CPUIDEmu::SetupFeatures() {
return;
}

#define ENABLE_DISABLE_OPTION(FeatureName, name, enum_name) \
do { \
const bool Disable##name = (CPUIDFeatures() & FEXCore::Config::CPUID::DISABLE##enum_name) != 0; \
const bool Enable##name = (CPUIDFeatures() & FEXCore::Config::CPUID::ENABLE##enum_name) != 0; \
#define ENABLE_DISABLE_OPTION(FeatureName, name, enum_name) \
do { \
const bool Disable##name = (CPUIDFeatures() & FEXCore::Config::CPUID::DISABLE##enum_name) != 0; \
const bool Enable##name = (CPUIDFeatures() & FEXCore::Config::CPUID::ENABLE##enum_name) != 0; \
LogMan::Throw::AFmt(!(Disable##name && Enable##name), "Disabling and Enabling CPU feature (" #name ") is mutually exclusive"); \
const bool AlreadyEnabled = Features.FeatureName; \
const bool Result = (AlreadyEnabled | Enable##name) & !Disable##name; \
Features.FeatureName = Result; \
const bool AlreadyEnabled = Features.FeatureName; \
const bool Result = (AlreadyEnabled | Enable##name) & !Disable##name; \
Features.FeatureName = Result; \
} while (0)

ENABLE_DISABLE_OPTION(SHA, SHA, SHA);
Expand Down
18 changes: 9 additions & 9 deletions FEXCore/Source/Interface/Core/HostFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ static void OverrideFeatures(HostFeatures* Features) {
return;
}

#define ENABLE_DISABLE_OPTION(FeatureName, name, enum_name) \
do { \
const bool Disable##name = (HostFeatures() & FEXCore::Config::HostFeatures::DISABLE##enum_name) != 0; \
const bool Enable##name = (HostFeatures() & FEXCore::Config::HostFeatures::ENABLE##enum_name) != 0; \
#define ENABLE_DISABLE_OPTION(FeatureName, name, enum_name) \
do { \
const bool Disable##name = (HostFeatures() & FEXCore::Config::HostFeatures::DISABLE##enum_name) != 0; \
const bool Enable##name = (HostFeatures() & FEXCore::Config::HostFeatures::ENABLE##enum_name) != 0; \
LogMan::Throw::AFmt(!(Disable##name && Enable##name), "Disabling and Enabling CPU feature (" #name ") is mutually exclusive"); \
const bool AlreadyEnabled = Features->FeatureName; \
const bool Result = (AlreadyEnabled | Enable##name) & !Disable##name; \
Features->FeatureName = Result; \
const bool AlreadyEnabled = Features->FeatureName; \
const bool Result = (AlreadyEnabled | Enable##name) & !Disable##name; \
Features->FeatureName = Result; \
} while (0)

#define GET_SINGLE_OPTION(name, enum_name) \
#define GET_SINGLE_OPTION(name, enum_name) \
const bool Disable##name = (HostFeatures() & FEXCore::Config::HostFeatures::DISABLE##enum_name) != 0; \
const bool Enable##name = (HostFeatures() & FEXCore::Config::HostFeatures::ENABLE##enum_name) != 0; \
const bool Enable##name = (HostFeatures() & FEXCore::Config::HostFeatures::ENABLE##enum_name) != 0; \
LogMan::Throw::AFmt(!(Disable##name && Enable##name), "Disabling and Enabling CPU feature (" #name ") is mutually exclusive");

ENABLE_DISABLE_OPTION(SupportsAVX, AVX, AVX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,22 @@ bool InterpreterOps::GetFallbackHandler(bool SupportsPreserveAllABI, const IR::I
break;
}

#define COMMON_UNARY_X87_OP(OP) \
case IR::OP_F80##OP: { \
#define COMMON_UNARY_X87_OP(OP) \
case IR::OP_F80##OP: { \
*Info = {FABI_F80_I16_F80, (void*)&FEXCore::CPU::OpHandlers<IR::OP_F80##OP>::handle, Core::OPINDEX_F80##OP, SupportsPreserveAllABI}; \
return true; \
return true; \
}

#define COMMON_BINARY_X87_OP(OP) \
case IR::OP_F80##OP: { \
#define COMMON_BINARY_X87_OP(OP) \
case IR::OP_F80##OP: { \
*Info = {FABI_F80_I16_F80_F80, (void*)&FEXCore::CPU::OpHandlers<IR::OP_F80##OP>::handle, Core::OPINDEX_F80##OP, SupportsPreserveAllABI}; \
return true; \
return true; \
}

#define COMMON_F64_OP(OP) \
case IR::OP_F64##OP: { \
#define COMMON_F64_OP(OP) \
case IR::OP_F64##OP: { \
*Info = GetFallbackInfo(&FEXCore::CPU::OpHandlers<IR::OP_F64##OP>::handle, Core::OPINDEX_F64##OP); \
return true; \
return true; \
}

// Unary
Expand Down
14 changes: 7 additions & 7 deletions FEXCore/Source/Interface/Core/JIT/Arm64/ConversionOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ DEF_OP(Vector_FToI) {
// frinti having AdvSIMD, AdvSIMD scalar, and an SVE version),
// we can't just use a lambda without some seriously ugly casting.
// This is fairly self-contained otherwise.
#define ROUNDING_FN(name) \
if (ElementSize == 2) { \
name(Dst.H(), Vector.H()); \
#define ROUNDING_FN(name) \
if (ElementSize == 2) { \
name(Dst.H(), Vector.H()); \
} else if (ElementSize == 4) { \
name(Dst.S(), Vector.S()); \
name(Dst.S(), Vector.S()); \
} else if (ElementSize == 8) { \
name(Dst.D(), Vector.D()); \
} else { \
FEX_UNREACHABLE; \
name(Dst.D(), Vector.D()); \
} else { \
FEX_UNREACHABLE; \
}

switch (Op->Round) {
Expand Down
4 changes: 2 additions & 2 deletions FEXCore/Source/Interface/Core/OpcodeDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,9 @@ class OpDispatchBuilder final : public IREmitter {
// replaced with NewOp. Useful for generic building code. Not safe in general.
// but does the right handling of ImplicitFlagClobber at least and must be
// used instead of raw Op mutation.
#define DeriveOp(Dest, NewOp, Expr) \
#define DeriveOp(Dest, NewOp, Expr) \
if (ImplicitFlagClobber(NewOp)) SaveNZCV(NewOp); \
auto Dest = (Expr); \
auto Dest = (Expr); \
Dest.first->Header.Op = (NewOp)

// Named constant cache for the current block.
Expand Down
6 changes: 3 additions & 3 deletions FEXCore/Source/Utils/SpinWaitLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ namespace FEXCore::Utils::SpinWaitLock {
*/
#ifdef _M_ARM_64

#define LOADEXCLUSIVE(LoadExclusiveOp, RegSize) \
#define LOADEXCLUSIVE(LoadExclusiveOp, RegSize) \
/* Prime the exclusive monitor with the passed in address. */ \
#LoadExclusiveOp " %" #RegSize "[Result], [%[Futex]];"

#define SPINLOOP_BODY(LoadAtomicOp, RegSize) \
#define SPINLOOP_BODY(LoadAtomicOp, RegSize) \
/* WFE will wait for either the memory to change or spurious wake-up. */ \
"wfe;" /* Load with acquire to get the result of memory. */ \
"wfe;" /* Load with acquire to get the result of memory. */ \
#LoadAtomicOp " %" #RegSize "[Result], [%[Futex]]; "

#define SPINLOOP_WFE_LDX_8BIT LOADEXCLUSIVE(ldaxrb, w)
Expand Down
6 changes: 3 additions & 3 deletions FEXCore/include/FEXCore/Config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ namespace DefaultValues {
#define OPT_STRARRAY(group, enum, json, default) OPT_STR(group, enum, json, default)
#include <FEXCore/Config/ConfigValues.inl>
} // namespace Type
#define FEX_CONFIG_OPT(name, enum) \
#define FEX_CONFIG_OPT(name, enum) \
FEXCore::Config::Value<FEXCore::Config::DefaultValues::Type::enum> name { \
FEXCore::Config::CONFIG_##enum, \
FEXCore::Config::DefaultValues::enum \
FEXCore::Config::CONFIG_##enum, \
FEXCore::Config::DefaultValues::enum \
}

#undef P
Expand Down
30 changes: 15 additions & 15 deletions FEXCore/include/FEXCore/Utils/EnumOperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
#pragma once
#include <type_traits>

#define FEX_DEF_ENUM_CLASS_BIN_OP(Enum, Op) \
[[maybe_unused]] static constexpr Enum operator Op(Enum lhs, Enum rhs) { \
using Type = std::underlying_type_t<Enum>; \
Type _lhs = static_cast<Type>(lhs); \
Type _rhs = static_cast<Type>(rhs); \
return static_cast<Enum>(_lhs Op _rhs); \
} \
#define FEX_DEF_ENUM_CLASS_BIN_OP(Enum, Op) \
[[maybe_unused]] static constexpr Enum operator Op(Enum lhs, Enum rhs) { \
using Type = std::underlying_type_t<Enum>; \
Type _lhs = static_cast<Type>(lhs); \
Type _rhs = static_cast<Type>(rhs); \
return static_cast<Enum>(_lhs Op _rhs); \
} \
[[maybe_unused]] static constexpr uint64_t operator Op(uint64_t lhs, Enum rhs) { \
using Type = std::underlying_type_t<Enum>; \
Type _rhs = static_cast<Type>(rhs); \
return lhs Op _rhs; \
using Type = std::underlying_type_t<Enum>; \
Type _rhs = static_cast<Type>(rhs); \
return lhs Op _rhs; \
}

#define FEX_DEF_ENUM_CLASS_UNARY_OP(Enum, Op) \
#define FEX_DEF_ENUM_CLASS_UNARY_OP(Enum, Op) \
[[maybe_unused]] static constexpr Enum operator Op(Enum rhs) { \
using Type = std::underlying_type_t<Enum>; \
Type _rhs = static_cast<Type>(rhs); \
return static_cast<Enum>(Op _rhs); \
using Type = std::underlying_type_t<Enum>; \
Type _rhs = static_cast<Type>(rhs); \
return static_cast<Enum>(Op _rhs); \
}

#define FEX_DEF_NUM_OPS(Enum) \
#define FEX_DEF_NUM_OPS(Enum) \
FEX_DEF_ENUM_CLASS_BIN_OP(Enum, |) \
FEX_DEF_ENUM_CLASS_BIN_OP(Enum, &) \
FEX_DEF_ENUM_CLASS_BIN_OP(Enum, ^) \
Expand Down
86 changes: 43 additions & 43 deletions FEXCore/include/FEXCore/Utils/EnumUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,52 @@ namespace FEXCore {
// Macro that defines all of the built in operators for conveniently using
// enum classes as flag types without needing to define all of the basic
// boilerplate.
#define FEX_DECLARE_ENUM_FLAG_OPERATORS(type) \
[[nodiscard]] \
constexpr type \
operator|(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
#define FEX_DECLARE_ENUM_FLAG_OPERATORS(type) \
[[nodiscard]] \
constexpr type \
operator|(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<type>(static_cast<T>(a) | static_cast<T>(b)); \
} \
[[nodiscard]] \
constexpr type \
operator&(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
} \
[[nodiscard]] \
constexpr type \
operator&(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<type>(static_cast<T>(a) & static_cast<T>(b)); \
} \
[[nodiscard]] \
constexpr type \
operator^(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
} \
[[nodiscard]] \
constexpr type \
operator^(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<type>(static_cast<T>(a) ^ static_cast<T>(b)); \
} \
constexpr type& operator|=(type& a, type b) noexcept { \
a = a | b; \
return a; \
} \
constexpr type& operator&=(type& a, type b) noexcept { \
a = a & b; \
return a; \
} \
constexpr type& operator^=(type& a, type b) noexcept { \
a = a ^ b; \
return a; \
} \
[[nodiscard]] \
constexpr type \
operator~(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<type>(~static_cast<T>(key)); \
} \
[[nodiscard]] \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
[[nodiscard]] \
constexpr bool False(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) == 0; \
} \
constexpr type& operator|=(type& a, type b) noexcept { \
a = a | b; \
return a; \
} \
constexpr type& operator&=(type& a, type b) noexcept { \
a = a & b; \
return a; \
} \
constexpr type& operator^=(type& a, type b) noexcept { \
a = a ^ b; \
return a; \
} \
[[nodiscard]] \
constexpr type \
operator~(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<type>(~static_cast<T>(key)); \
} \
[[nodiscard]] \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
[[nodiscard]] \
constexpr bool False(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) == 0; \
}

// Equivalent to C++23's std::to_underlying.
Expand Down
38 changes: 19 additions & 19 deletions FEXCore/include/FEXCore/Utils/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ namespace Throw {
MFmt(fmt, fmt::make_format_args(args...));
}

#define LOGMAN_THROW_A_FMT(pred, ...) \
do { \
#define LOGMAN_THROW_A_FMT(pred, ...) \
do { \
LogMan::Throw::AFmt(pred, __VA_ARGS__); \
} while (0)
#define LOGMAN_THROW_AA_FMT(pred, ...) \
do { \
#define LOGMAN_THROW_AA_FMT(pred, ...) \
do { \
LogMan::Throw::AFmt(pred, __VA_ARGS__); \
} while (0)
#else
static inline void AFmt(bool, const char*, ...) {}
#define LOGMAN_THROW_A_FMT(pred, ...) \
do { \
do { \
} while (0)
static inline void AAFmt(bool pred, const char*, ...) {
__builtin_assume(pred);
}
#define LOGMAN_THROW_AA_FMT(pred, ...) \
do { \
__builtin_assume(pred); \
do { \
__builtin_assume(pred); \
} while (0)
#endif

Expand Down Expand Up @@ -144,31 +144,31 @@ namespace Msg {
MFmtImpl(ASSERT, fmt, fmt::make_format_args(args...));
FEX_TRAP_EXECUTION;
}
#define LOGMAN_MSG_A_FMT(...) \
do { \
#define LOGMAN_MSG_A_FMT(...) \
do { \
LogMan::Msg::AFmt(__VA_ARGS__); \
} while (0)
#else
template<typename... Args>
static inline void AFmt(const char*, const Args&...) {}
#define LOGMAN_MSG_A_FMT(...) \
do { \
do { \
} while (0)
#endif

#define WARN_ONCE_FMT(...) \
do { \
static bool Warned {}; \
if (!Warned) { \
#define WARN_ONCE_FMT(...) \
do { \
static bool Warned {}; \
if (!Warned) { \
LogMan::Msg::DFmt(__VA_ARGS__); \
Warned = true; \
} \
Warned = true; \
} \
} while (0);

#define ERROR_AND_DIE_FMT(...) \
do { \
#define ERROR_AND_DIE_FMT(...) \
do { \
LogMan::Msg::EFmt(__VA_ARGS__); \
FEX_TRAP_EXECUTION; \
FEX_TRAP_EXECUTION; \
} while (0)

} // namespace Msg
Expand Down
4 changes: 2 additions & 2 deletions FEXCore/include/FEXCore/Utils/Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ static void TraceObject(std::string_view const Format) {}
static void TraceObject(std::string_view const, uint64_t) {}

#define FEXCORE_PROFILE_INSTANT(...) \
do { \
do { \
} while (0)
#define FEXCORE_PROFILE_SCOPED(...) \
do { \
do { \
} while (0)
#endif
} // namespace FEXCore::Profiler
Loading

0 comments on commit a10f984

Please sign in to comment.