From d8a37e287cb70eb47aec9622f58a34285de6a119 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 31 Dec 2016 10:46:13 +0000 Subject: [PATCH] IR: Add IR type CoprocInfo --- src/frontend/ir/opcodes.cpp | 6 +++--- src/frontend/ir/opcodes.h | 1 + src/frontend/ir/value.cpp | 11 +++++++++++ src/frontend/ir/value.h | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/frontend/ir/opcodes.cpp b/src/frontend/ir/opcodes.cpp index d63ff9f2..19f9b391 100644 --- a/src/frontend/ir/opcodes.cpp +++ b/src/frontend/ir/opcodes.cpp @@ -29,7 +29,7 @@ static const std::map opcode_info {{ #define OPCODE(name, type, ...) { Opcode::name, { #name, type, { __VA_ARGS__ } } }, #include "opcodes.inc" #undef OPCODE - }}; +}}; } // namespace OpcodeInfo @@ -50,8 +50,8 @@ const char* GetNameOf(Opcode op) { } const char* GetNameOf(Type type) { - const static std::array names = { - "Void", "RegRef", "ExtRegRef", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64" + const static std::array names = { + "Void", "RegRef", "ExtRegRef", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64", "CoprocInfo" }; return names.at(static_cast(type)); } diff --git a/src/frontend/ir/opcodes.h b/src/frontend/ir/opcodes.h index 44bcbbe7..88306898 100644 --- a/src/frontend/ir/opcodes.h +++ b/src/frontend/ir/opcodes.h @@ -39,6 +39,7 @@ enum class Type { U64, F32, F64, + CoprocInfo, }; /// Get return type of an opcode diff --git a/src/frontend/ir/value.cpp b/src/frontend/ir/value.cpp index 1e2b6444..409ed804 100644 --- a/src/frontend/ir/value.cpp +++ b/src/frontend/ir/value.cpp @@ -39,6 +39,10 @@ Value::Value(u64 value) : type(Type::U64) { inner.imm_u64 = value; } +Value::Value(std::array value) : type(Type::CoprocInfo) { + inner.imm_coproc = value; +} + bool Value::IsImmediate() const { if (type == Type::Opaque) return inner.inst->GetOpcode() == Opcode::Identity ? inner.inst->GetArg(0).IsImmediate() : false; @@ -103,5 +107,12 @@ u64 Value::GetU64() const { return inner.imm_u64; } +std::array Value::GetCoprocInfo() const { + if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity) + return inner.inst->GetArg(0).GetCoprocInfo(); + DEBUG_ASSERT(type == Type::CoprocInfo); + return inner.imm_coproc; +} + } // namespace IR } // namespace Dynarmic diff --git a/src/frontend/ir/value.h b/src/frontend/ir/value.h index 62e61e39..ec1bcc0e 100644 --- a/src/frontend/ir/value.h +++ b/src/frontend/ir/value.h @@ -28,6 +28,7 @@ public: explicit Value(u8 value); explicit Value(u32 value); explicit Value(u64 value); + explicit Value(std::array value); bool IsEmpty() const; bool IsImmediate() const; @@ -40,6 +41,7 @@ public: u8 GetU8() const; u32 GetU32() const; u64 GetU64() const; + std::array GetCoprocInfo() const; private: Type type; @@ -52,8 +54,10 @@ private: u8 imm_u8; u32 imm_u32; u64 imm_u64; + std::array imm_coproc; } inner; }; +static_assert(sizeof(Value) <= 2 * sizeof(u64), "IR::Value should be kept small in size"); } // namespace IR } // namespace Dynarmic