Update for fmt 9.0.0

This commit is contained in:
Merry 2022-08-28 19:15:45 +03:00 committed by emufan4568
parent 9f88f234a1
commit 153e10cad3
15 changed files with 113 additions and 86 deletions

View File

@ -3,20 +3,17 @@
* SPDX-License-Identifier: 0BSD
*/
#include <ostream>
#include <fmt/format.h>
#include "frontend/A32/location_descriptor.h"
namespace Dynarmic::A32 {
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor) {
o << fmt::format("{{{:08x},{},{},{:08x}{}}}",
descriptor.PC(),
descriptor.TFlag() ? "T" : "!T",
descriptor.EFlag() ? "E" : "!E",
descriptor.FPSCR().Value(),
descriptor.SingleStepping() ? ",step" : "");
return o;
std::string ToString(const LocationDescriptor& descriptor) {
return fmt::format("{{{:08x},{},{},{:08x}{}}}",
descriptor.PC(),
descriptor.TFlag() ? "T" : "!T",
descriptor.EFlag() ? "E" : "!E",
descriptor.FPSCR().Value(),
descriptor.SingleStepping() ? ",step" : "");
}
} // namespace Dynarmic::A32

View File

@ -6,8 +6,10 @@
#pragma once
#include <functional>
#include <iosfwd>
#include <string>
#include <tuple>
#include <fmt/format.h>
#include "common/common_types.h"
#include "frontend/A32/FPSCR.h"
#include "frontend/A32/PSR.h"
@ -126,10 +128,9 @@ private:
/**
* Provides a string representation of a LocationDescriptor.
*
* @param o Output stream
* @param descriptor The descriptor to get a string representation of
*/
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor);
std::string ToString(const LocationDescriptor& descriptor);
} // namespace Dynarmic::A32
@ -147,3 +148,11 @@ struct hash<Dynarmic::A32::LocationDescriptor> {
}
};
} // namespace std
template<>
struct fmt::formatter<Dynarmic::A32::LocationDescriptor> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::A32::LocationDescriptor descriptor, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::A32::ToString(descriptor), ctx);
}
};

View File

@ -68,24 +68,4 @@ std::string RegListToString(RegList reg_list) {
return ret;
}
std::ostream& operator<<(std::ostream& o, Reg reg) {
o << RegToString(reg);
return o;
}
std::ostream& operator<<(std::ostream& o, ExtReg reg) {
o << ExtRegToString(reg);
return o;
}
std::ostream& operator<<(std::ostream& o, CoprocReg reg) {
o << CoprocRegToString(reg);
return o;
}
std::ostream& operator<<(std::ostream& o, RegList reg_list) {
o << RegListToString(reg_list);
return o;
}
} // namespace Dynarmic::A32

View File

@ -5,10 +5,10 @@
#pragma once
#include <iosfwd>
#include <string>
#include <utility>
#include <fmt/format.h>
#include <dynarmic/A32/coprocessor_util.h>
#include "common/assert.h"
@ -62,11 +62,6 @@ const char* ExtRegToString(ExtReg reg);
const char* CoprocRegToString(CoprocReg reg);
std::string RegListToString(RegList reg_list);
std::ostream& operator<<(std::ostream& o, Reg reg);
std::ostream& operator<<(std::ostream& o, ExtReg reg);
std::ostream& operator<<(std::ostream& o, CoprocReg reg);
std::ostream& operator<<(std::ostream& o, RegList reg_list);
constexpr bool IsSingleExtReg(ExtReg reg) {
return reg >= ExtReg::S0 && reg <= ExtReg::S31;
}
@ -138,3 +133,35 @@ inline ExtReg ToVector(bool Q, size_t base, bool bit) {
}
} // namespace Dynarmic::A32
template<>
struct fmt::formatter<Dynarmic::A32::Reg> : fmt::formatter<const char*> {
template<typename FormatContext>
auto format(Dynarmic::A32::Reg reg, FormatContext& ctx) const {
return formatter<const char*>::format(Dynarmic::A32::RegToString(reg), ctx);
}
};
template<>
struct fmt::formatter<Dynarmic::A32::ExtReg> : fmt::formatter<const char*> {
template<typename FormatContext>
auto format(Dynarmic::A32::ExtReg reg, FormatContext& ctx) const {
return formatter<const char*>::format(Dynarmic::A32::ExtRegToString(reg), ctx);
}
};
template<>
struct fmt::formatter<Dynarmic::A32::CoprocReg> : fmt::formatter<const char*> {
template<typename FormatContext>
auto format(Dynarmic::A32::CoprocReg reg, FormatContext& ctx) const {
return formatter<const char*>::format(Dynarmic::A32::CoprocRegToString(reg), ctx);
}
};
template<>
struct fmt::formatter<Dynarmic::A32::RegList> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::A32::RegList reg_list, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::A32::RegListToString(reg_list), ctx);
}
};

View File

@ -3,16 +3,12 @@
* SPDX-License-Identifier: 0BSD
*/
#include <ostream>
#include <fmt/format.h>
#include "frontend/A64/location_descriptor.h"
namespace Dynarmic::A64 {
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor) {
o << fmt::format("{{{}, {}{}}}", descriptor.PC(), descriptor.FPCR().Value(), descriptor.SingleStepping() ? ", step" : "");
return o;
std::string ToString(const LocationDescriptor& descriptor) {
return fmt::format("{{{}, {}{}}}", descriptor.PC(), descriptor.FPCR().Value(), descriptor.SingleStepping() ? ", step" : "");
}
} // namespace Dynarmic::A64

View File

@ -6,9 +6,10 @@
#pragma once
#include <functional>
#include <iosfwd>
#include <string>
#include <tuple>
#include <fmt/format.h>
#include "common/bit_util.h"
#include "common/common_types.h"
#include "common/fp/fpcr.h"
@ -85,10 +86,9 @@ private:
/**
* Provides a string representation of a LocationDescriptor.
*
* @param o Output stream
* @param descriptor The descriptor to get a string representation of
*/
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor);
std::string ToString(const LocationDescriptor& descriptor);
} // namespace Dynarmic::A64
@ -106,3 +106,11 @@ struct hash<Dynarmic::A64::LocationDescriptor> {
}
};
} // namespace std
template<>
struct fmt::formatter<Dynarmic::A64::LocationDescriptor> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::A64::LocationDescriptor descriptor, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::A64::ToString(descriptor), ctx);
}
};

View File

@ -31,14 +31,4 @@ std::string VecToString(Vec vec) {
return fmt::format("v{}", static_cast<size_t>(vec));
}
std::ostream& operator<<(std::ostream& o, Reg reg) {
o << RegToString(reg);
return o;
}
std::ostream& operator<<(std::ostream& o, Vec vec) {
o << VecToString(vec);
return o;
}
} // namespace Dynarmic::A64

View File

@ -5,9 +5,9 @@
#pragma once
#include <iosfwd>
#include <string>
#include <fmt/format.h>
#include "common/assert.h"
#include "common/common_types.h"
#include "frontend/ir/cond.h"
@ -43,9 +43,6 @@ const char* CondToString(Cond cond);
std::string RegToString(Reg reg);
std::string VecToString(Vec vec);
std::ostream& operator<<(std::ostream& o, Reg reg);
std::ostream& operator<<(std::ostream& o, Vec vec);
constexpr size_t RegNumber(Reg reg) {
return static_cast<size_t>(reg);
}
@ -69,3 +66,19 @@ inline Vec operator+(Vec vec, size_t number) {
}
} // namespace Dynarmic::A64
template<>
struct fmt::formatter<Dynarmic::A64::Reg> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::A64::Reg reg, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::A64::RegToString(reg), ctx);
}
};
template<>
struct fmt::formatter<Dynarmic::A64::Vec> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::A64::Vec vec, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::A64::VecToString(vec), ctx);
}
};

View File

@ -3,16 +3,12 @@
* SPDX-License-Identifier: 0BSD
*/
#include <ostream>
#include <fmt/format.h>
#include "frontend/ir/location_descriptor.h"
namespace Dynarmic::IR {
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor) {
o << fmt::format("{{{:016x}}}", descriptor.Value());
return o;
std::string ToString(const LocationDescriptor& descriptor) {
return fmt::format("{{{:016x}}}", descriptor.Value());
}
} // namespace Dynarmic::IR

View File

@ -6,8 +6,9 @@
#pragma once
#include <functional>
#include <iosfwd>
#include <string>
#include <fmt/format.h>
#include "common/common_types.h"
namespace Dynarmic::IR {
@ -30,7 +31,7 @@ private:
u64 value;
};
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor);
std::string ToString(const LocationDescriptor& descriptor);
inline bool operator<(const LocationDescriptor& x, const LocationDescriptor& y) noexcept {
return x.Value() < y.Value();
@ -52,3 +53,11 @@ struct hash<Dynarmic::IR::LocationDescriptor> {
}
};
} // namespace std
template<>
struct fmt::formatter<Dynarmic::IR::LocationDescriptor> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::IR::LocationDescriptor descriptor, FormatContext& ctx) const {
return formatter<std::string>::format(ToString(descriptor), ctx);
}
};

View File

@ -5,8 +5,6 @@
#include <algorithm>
#include <fmt/ostream.h>
#include "common/assert.h"
#include "frontend/ir/microinstruction.h"
#include "frontend/ir/opcodes.h"

View File

@ -71,8 +71,4 @@ std::string GetNameOf(Opcode op) {
return OpcodeInfo::opcode_info.at(static_cast<size_t>(op)).name;
}
std::ostream& operator<<(std::ostream& o, Opcode opcode) {
return o << GetNameOf(opcode);
}
} // namespace Dynarmic::IR

View File

@ -5,9 +5,9 @@
#pragma once
#include <iosfwd>
#include <string>
#include <fmt/format.h>
#include "common/common_types.h"
namespace Dynarmic::IR {
@ -43,6 +43,12 @@ Type GetArgTypeOf(Opcode op, size_t arg_index);
/// Get the name of an opcode.
std::string GetNameOf(Opcode op);
std::ostream& operator<<(std::ostream& o, Opcode opcode);
} // namespace Dynarmic::IR
template<>
struct fmt::formatter<Dynarmic::IR::Opcode> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::IR::Opcode op, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::IR::GetNameOf(op), ctx);
}
};

View File

@ -44,8 +44,4 @@ bool AreTypesCompatible(Type t1, Type t2) {
return t1 == t2 || t1 == Type::Opaque || t2 == Type::Opaque;
}
std::ostream& operator<<(std::ostream& o, Type type) {
return o << GetNameOf(type);
}
} // namespace Dynarmic::IR

View File

@ -5,9 +5,9 @@
#pragma once
#include <iosfwd>
#include <string>
#include <fmt/format.h>
#include "common/common_types.h"
namespace Dynarmic::IR {
@ -48,6 +48,12 @@ std::string GetNameOf(Type type);
/// @returns true if t1 and t2 are compatible types
bool AreTypesCompatible(Type t1, Type t2);
std::ostream& operator<<(std::ostream& o, Type type);
} // namespace Dynarmic::IR
template<>
struct fmt::formatter<Dynarmic::IR::Type> : fmt::formatter<std::string> {
template<typename FormatContext>
auto format(Dynarmic::IR::Type type, FormatContext& ctx) const {
return formatter<std::string>::format(Dynarmic::IR::GetNameOf(type), ctx);
}
};