ir/value: Support U16 immediates

This commit is contained in:
MerryMage 2017-01-29 22:58:11 +00:00
parent 5f7ffe0d0b
commit 642ccb0f66
2 changed files with 14 additions and 0 deletions

View file

@ -31,6 +31,10 @@ Value::Value(u8 value) : type(Type::U8) {
inner.imm_u8 = value;
}
Value::Value(u16 value) : type(Type::U16) {
inner.imm_u16 = value;
}
Value::Value(u32 value) : type(Type::U32) {
inner.imm_u32 = value;
}
@ -93,6 +97,13 @@ u8 Value::GetU8() const {
return inner.imm_u8;
}
u16 Value::GetU16() const {
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
return inner.inst->GetArg(0).GetU16();
DEBUG_ASSERT(type == Type::U16);
return inner.imm_u16;
}
u32 Value::GetU32() const {
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
return inner.inst->GetArg(0).GetU32();

View file

@ -26,6 +26,7 @@ public:
explicit Value(Arm::ExtReg value);
explicit Value(bool value);
explicit Value(u8 value);
explicit Value(u16 value);
explicit Value(u32 value);
explicit Value(u64 value);
explicit Value(std::array<u8, 8> value);
@ -39,6 +40,7 @@ public:
Arm::ExtReg GetExtRegRef() const;
bool GetU1() const;
u8 GetU8() const;
u16 GetU16() const;
u32 GetU32() const;
u64 GetU64() const;
std::array<u8, 8> GetCoprocInfo() const;
@ -52,6 +54,7 @@ private:
Arm::ExtReg imm_extregref;
bool imm_u1;
u8 imm_u8;
u16 imm_u16;
u32 imm_u32;
u64 imm_u64;
std::array<u8, 8> imm_coproc;