2016-08-12 18:17:31 +01:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
|
|
* General Public License version 2 or any later version.
|
|
|
|
*/
|
|
|
|
|
2016-08-17 13:29:05 +01:00
|
|
|
#include <array>
|
2016-08-12 18:17:31 +01:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "frontend/ir/opcodes.h"
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
namespace Dynarmic::IR {
|
2016-08-12 18:17:31 +01:00
|
|
|
|
|
|
|
// Opcode information
|
|
|
|
|
|
|
|
namespace OpcodeInfo {
|
|
|
|
|
|
|
|
using T = Dynarmic::IR::Type;
|
|
|
|
|
|
|
|
struct Meta {
|
|
|
|
const char* name;
|
|
|
|
Type type;
|
|
|
|
std::vector<Type> arg_types;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const std::map<Opcode, Meta> opcode_info {{
|
|
|
|
#define OPCODE(name, type, ...) { Opcode::name, { #name, type, { __VA_ARGS__ } } },
|
2018-01-01 16:19:43 +00:00
|
|
|
#define A32OPC(name, type, ...) { Opcode::A32##name, { #name, type, { __VA_ARGS__ } } },
|
2018-01-07 00:11:57 +00:00
|
|
|
#define A64OPC(name, type, ...) { Opcode::A64##name, { #name, type, { __VA_ARGS__ } } },
|
2016-08-12 18:17:31 +01:00
|
|
|
#include "opcodes.inc"
|
|
|
|
#undef OPCODE
|
2018-01-01 16:19:43 +00:00
|
|
|
#undef A32OPC
|
2018-01-07 00:11:57 +00:00
|
|
|
#undef A64OPC
|
2016-12-31 10:46:13 +00:00
|
|
|
}};
|
2016-08-12 18:17:31 +01:00
|
|
|
|
|
|
|
} // namespace OpcodeInfo
|
|
|
|
|
|
|
|
Type GetTypeOf(Opcode op) {
|
|
|
|
return OpcodeInfo::opcode_info.at(op).type;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t GetNumArgsOf(Opcode op) {
|
|
|
|
return OpcodeInfo::opcode_info.at(op).arg_types.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
Type GetArgTypeOf(Opcode op, size_t arg_index) {
|
|
|
|
return OpcodeInfo::opcode_info.at(op).arg_types.at(arg_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetNameOf(Opcode op) {
|
|
|
|
return OpcodeInfo::opcode_info.at(op).name;
|
|
|
|
}
|
|
|
|
|
2016-08-17 13:29:05 +01:00
|
|
|
const char* GetNameOf(Type type) {
|
2018-01-05 20:30:41 +00:00
|
|
|
static const std::array<const char*, 14> names = {
|
|
|
|
"Void", "A32Reg", "A32ExtReg", "A64Reg", "A64Vec", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64", "CoprocInfo"
|
2016-08-17 13:29:05 +01:00
|
|
|
};
|
|
|
|
return names.at(static_cast<size_t>(type));
|
|
|
|
}
|
|
|
|
|
2016-08-19 01:34:14 +01:00
|
|
|
bool AreTypesCompatible(Type t1, Type t2) {
|
|
|
|
return t1 == t2 || t1 == Type::Opaque || t2 == Type::Opaque;
|
|
|
|
}
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
} // namespace Dynarmic::IR
|