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();