IR: Add IR type CoprocInfo
This commit is contained in:
parent
890b2f75ad
commit
d8a37e287c
4 changed files with 19 additions and 3 deletions
|
@ -29,7 +29,7 @@ static const std::map<Opcode, Meta> opcode_info {{
|
||||||
#define OPCODE(name, type, ...) { Opcode::name, { #name, type, { __VA_ARGS__ } } },
|
#define OPCODE(name, type, ...) { Opcode::name, { #name, type, { __VA_ARGS__ } } },
|
||||||
#include "opcodes.inc"
|
#include "opcodes.inc"
|
||||||
#undef OPCODE
|
#undef OPCODE
|
||||||
}};
|
}};
|
||||||
|
|
||||||
} // namespace OpcodeInfo
|
} // namespace OpcodeInfo
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ const char* GetNameOf(Opcode op) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetNameOf(Type type) {
|
const char* GetNameOf(Type type) {
|
||||||
const static std::array<const char*, 11> names = {
|
const static std::array<const char*, 12> names = {
|
||||||
"Void", "RegRef", "ExtRegRef", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64"
|
"Void", "RegRef", "ExtRegRef", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64", "CoprocInfo"
|
||||||
};
|
};
|
||||||
return names.at(static_cast<size_t>(type));
|
return names.at(static_cast<size_t>(type));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ enum class Type {
|
||||||
U64,
|
U64,
|
||||||
F32,
|
F32,
|
||||||
F64,
|
F64,
|
||||||
|
CoprocInfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Get return type of an opcode
|
/// Get return type of an opcode
|
||||||
|
|
|
@ -39,6 +39,10 @@ Value::Value(u64 value) : type(Type::U64) {
|
||||||
inner.imm_u64 = value;
|
inner.imm_u64 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value::Value(std::array<u8, 8> value) : type(Type::CoprocInfo) {
|
||||||
|
inner.imm_coproc = value;
|
||||||
|
}
|
||||||
|
|
||||||
bool Value::IsImmediate() const {
|
bool Value::IsImmediate() const {
|
||||||
if (type == Type::Opaque)
|
if (type == Type::Opaque)
|
||||||
return inner.inst->GetOpcode() == Opcode::Identity ? inner.inst->GetArg(0).IsImmediate() : false;
|
return inner.inst->GetOpcode() == Opcode::Identity ? inner.inst->GetArg(0).IsImmediate() : false;
|
||||||
|
@ -103,5 +107,12 @@ u64 Value::GetU64() const {
|
||||||
return inner.imm_u64;
|
return inner.imm_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::array<u8, 8> 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 IR
|
||||||
} // namespace Dynarmic
|
} // namespace Dynarmic
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
explicit Value(u8 value);
|
explicit Value(u8 value);
|
||||||
explicit Value(u32 value);
|
explicit Value(u32 value);
|
||||||
explicit Value(u64 value);
|
explicit Value(u64 value);
|
||||||
|
explicit Value(std::array<u8, 8> value);
|
||||||
|
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
bool IsImmediate() const;
|
bool IsImmediate() const;
|
||||||
|
@ -40,6 +41,7 @@ public:
|
||||||
u8 GetU8() const;
|
u8 GetU8() const;
|
||||||
u32 GetU32() const;
|
u32 GetU32() const;
|
||||||
u64 GetU64() const;
|
u64 GetU64() const;
|
||||||
|
std::array<u8, 8> GetCoprocInfo() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
|
@ -52,8 +54,10 @@ private:
|
||||||
u8 imm_u8;
|
u8 imm_u8;
|
||||||
u32 imm_u32;
|
u32 imm_u32;
|
||||||
u64 imm_u64;
|
u64 imm_u64;
|
||||||
|
std::array<u8, 8> imm_coproc;
|
||||||
} inner;
|
} inner;
|
||||||
};
|
};
|
||||||
|
static_assert(sizeof(Value) <= 2 * sizeof(u64), "IR::Value should be kept small in size");
|
||||||
|
|
||||||
} // namespace IR
|
} // namespace IR
|
||||||
} // namespace Dynarmic
|
} // namespace Dynarmic
|
||||||
|
|
Loading…
Reference in a new issue