Forward declare IR::Opcode and IR::Type where possible

This commit is contained in:
MerryMage 2018-02-11 11:46:18 +00:00
parent 6c9b4f0114
commit f378d2ef1b
13 changed files with 112 additions and 57 deletions

View file

@ -14,6 +14,7 @@
#include <fmt/ostream.h>
#include "frontend/ir/opcodes.h"
#include "frontend/ir/type.h"
namespace Dynarmic::IR {
@ -59,26 +60,8 @@ std::string GetNameOf(Opcode op) {
return OpcodeInfo::opcode_info.at(op).name;
}
std::string GetNameOf(Type type) {
static const std::array<const char*, 16> names = {
"Void", "A32Reg", "A32ExtReg", "A64Reg", "A64Vec", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64", "CoprocInfo", "NZCVFlags", "Cond"
};
const size_t index = static_cast<size_t>(type);
if (index > names.size())
return fmt::format("Unknown Type {}", index);
return names.at(index);
}
bool AreTypesCompatible(Type t1, Type t2) {
return t1 == t2 || t1 == Type::Opaque || t2 == Type::Opaque;
}
std::ostream& operator<<(std::ostream& o, Opcode opcode) {
return o << GetNameOf(opcode);
}
std::ostream& operator<<(std::ostream& o, Type type) {
return o << GetNameOf(type);
}
} // namespace Dynarmic::IR