diff --git a/FEXCore/Source/Interface/Core/X86Tables/X86Tables.h b/FEXCore/Source/Interface/Core/X86Tables/X86Tables.h index f04e6d244..96fe7ea52 100644 --- a/FEXCore/Source/Interface/Core/X86Tables/X86Tables.h +++ b/FEXCore/Source/Interface/Core/X86Tables/X86Tables.h @@ -590,6 +590,6 @@ constexpr static inline void GenerateX87Table(X86InstInfo *FinalTable, X86Tables } }; -} - FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::X86Tables::DecodedOperand::OpType); + +} // namespace FEXCore::X86Tables diff --git a/FEXCore/Source/Interface/IR/IR.h b/FEXCore/Source/Interface/IR/IR.h index 779548d07..c916cc1cf 100644 --- a/FEXCore/Source/Interface/IR/IR.h +++ b/FEXCore/Source/Interface/IR/IR.h @@ -693,6 +693,15 @@ inline NodeID NodeWrapperBase::ID() const { bool IsBlockExit(FEXCore::IR::IROps Op); void Dump(fextl::stringstream* out, const IRListView* IR); + +constexpr auto format_as(FEXCore::IR::NodeID ID) { + return ID.Value; +} + +FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::FenceType) +FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::MemOffsetType) +FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::OpSize) +FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::RegClass) } // namespace FEXCore::IR template<> @@ -701,20 +710,3 @@ struct std::hash { return std::hash {}(ID.Value); } }; - -template<> -struct fmt::formatter : fmt::formatter { - using Base = fmt::formatter; - - // Pass-through the underlying value, so IDs can - // be formatted like any integral value. - template - auto format(const FEXCore::IR::NodeID& ID, FormatContext& ctx) const { - return Base::format(ID.Value, ctx); - } -}; - -FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::FenceType); -FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::MemOffsetType); -FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::OpSize); -FEX_DEFINE_ENUM_FMT_PASSTHROUGH(FEXCore::IR::RegClass); diff --git a/FEXCore/include/FEXCore/Utils/EnumUtils.h b/FEXCore/include/FEXCore/Utils/EnumUtils.h index aedb16212..f74957227 100644 --- a/FEXCore/include/FEXCore/Utils/EnumUtils.h +++ b/FEXCore/include/FEXCore/Utils/EnumUtils.h @@ -57,15 +57,9 @@ namespace FEXCore { // Macro that defines a fmt formatter for a reasonable case where an enum // is formatted as a purely integral type based on its underlying type. -#define FEX_DEFINE_ENUM_FMT_PASSTHROUGH(type) \ - template<> \ - struct fmt::formatter : fmt::formatter> { \ - using Base = fmt::formatter>; \ - \ - template \ - auto format(const type& Value, FormatContext& ctx) const { \ - return Base::format(FEXCore::ToUnderlying(Value), ctx); \ - } \ +#define FEX_DEFINE_ENUM_FMT_PASSTHROUGH(type) \ + constexpr auto format_as(type t) { \ + return FEXCore::ToUnderlying(t); \ } // Equivalent to C++23's std::to_underlying.