ir/value: Use type alias CoprocessorInfo for std::array<u8, 8>

Provides a more descriptive label for the interface, and avoids the need
to hardcode the array size in multiple places.
This commit is contained in:
Lioncash
2018-08-13 15:35:36 -04:00
committed by MerryMage
parent 71e137715d
commit 2188765e28
3 changed files with 46 additions and 44 deletions

View File

@@ -52,7 +52,7 @@ Value::Value(u64 value) : type(Type::U64) {
inner.imm_u64 = value;
}
Value::Value(std::array<u8, 8> value) : type(Type::CoprocInfo) {
Value::Value(CoprocessorInfo value) : type(Type::CoprocInfo) {
inner.imm_coproc = value;
}
@@ -141,7 +141,7 @@ u64 Value::GetU64() const {
return inner.imm_u64;
}
std::array<u8, 8> Value::GetCoprocInfo() const {
Value::CoprocessorInfo Value::GetCoprocInfo() const {
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
return inner.inst->GetArg(0).GetCoprocInfo();
ASSERT(type == Type::CoprocInfo);

View File

@@ -25,6 +25,8 @@ class Inst;
*/
class Value {
public:
using CoprocessorInfo = std::array<u8, 8>;
Value() : type(Type::Void) {}
explicit Value(Inst* value);
explicit Value(A32::Reg value);
@@ -36,7 +38,7 @@ public:
explicit Value(u16 value);
explicit Value(u32 value);
explicit Value(u64 value);
explicit Value(std::array<u8, 8> value);
explicit Value(CoprocessorInfo value);
explicit Value(Cond value);
bool IsEmpty() const;
@@ -53,7 +55,7 @@ public:
u16 GetU16() const;
u32 GetU32() const;
u64 GetU64() const;
std::array<u8, 8> GetCoprocInfo() const;
CoprocessorInfo GetCoprocInfo() const;
Cond GetCond() const;
private:
@@ -70,7 +72,7 @@ private:
u16 imm_u16;
u32 imm_u32;
u64 imm_u64;
std::array<u8, 8> imm_coproc;
CoprocessorInfo imm_coproc;
Cond imm_cond;
} inner;
};