2016-07-01 15:01:06 +02: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace Dynarmic {
|
|
|
|
namespace IR {
|
|
|
|
|
2016-08-12 19:17:31 +02:00
|
|
|
/**
|
|
|
|
* The Opcodes of our intermediate representation.
|
|
|
|
* Type signatures for each opcode can be found in opcodes.inc
|
|
|
|
*/
|
2016-07-01 15:01:06 +02:00
|
|
|
enum class Opcode {
|
|
|
|
#define OPCODE(name, type, ...) name,
|
2018-01-01 17:19:43 +01:00
|
|
|
#define A32OPC(name, type, ...) A32##name,
|
2016-07-01 15:01:06 +02:00
|
|
|
#include "opcodes.inc"
|
|
|
|
#undef OPCODE
|
2018-01-01 17:19:43 +01:00
|
|
|
#undef A32OPC
|
2016-07-01 15:01:06 +02:00
|
|
|
NUM_OPCODE
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr size_t OpcodeCount = static_cast<size_t>(Opcode::NUM_OPCODE);
|
|
|
|
|
2016-08-12 19:17:31 +02:00
|
|
|
/**
|
|
|
|
* The intermediate representation is typed. These are the used by our IR.
|
|
|
|
*/
|
|
|
|
enum class Type {
|
2018-01-05 22:47:23 +01:00
|
|
|
Void = 0,
|
|
|
|
A32Reg = 1 << 0,
|
|
|
|
A32ExtReg = 1 << 1,
|
|
|
|
A64Reg = 1 << 2,
|
|
|
|
A64Vec = 1 << 3,
|
|
|
|
Opaque = 1 << 4,
|
|
|
|
U1 = 1 << 5,
|
|
|
|
U8 = 1 << 6,
|
|
|
|
U16 = 1 << 7,
|
|
|
|
U32 = 1 << 8,
|
|
|
|
U64 = 1 << 9,
|
|
|
|
F32 = 1 << 10,
|
|
|
|
F64 = 1 << 11,
|
2018-01-05 00:05:27 +01:00
|
|
|
F128 = 1 << 12,
|
|
|
|
CoprocInfo = 1 << 13,
|
2016-08-12 19:17:31 +02:00
|
|
|
};
|
|
|
|
|
2018-01-05 22:47:23 +01:00
|
|
|
constexpr Type operator|(Type a, Type b) {
|
|
|
|
return static_cast<Type>(static_cast<size_t>(a) | static_cast<size_t>(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr Type operator&(Type a, Type b) {
|
|
|
|
return static_cast<Type>(static_cast<size_t>(a) & static_cast<size_t>(b));
|
|
|
|
}
|
|
|
|
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Get return type of an opcode
|
|
|
|
Type GetTypeOf(Opcode op);
|
|
|
|
|
|
|
|
/// Get the number of arguments an opcode accepts
|
|
|
|
size_t GetNumArgsOf(Opcode op);
|
|
|
|
|
|
|
|
/// Get the required type of an argument of an opcode
|
|
|
|
Type GetArgTypeOf(Opcode op, size_t arg_index);
|
|
|
|
|
|
|
|
/// Get the name of an opcode.
|
|
|
|
const char* GetNameOf(Opcode op);
|
|
|
|
|
2016-08-17 14:29:05 +02:00
|
|
|
/// Get the name of a type.
|
|
|
|
const char* GetNameOf(Type type);
|
|
|
|
|
2016-08-19 02:34:14 +02:00
|
|
|
/// @returns true if t1 and t2 are compatible types
|
|
|
|
bool AreTypesCompatible(Type t1, Type t2);
|
|
|
|
|
2016-07-01 15:01:06 +02:00
|
|
|
} // namespace Arm
|
|
|
|
} // namespace Dynarmic
|