IR: Properly support Identity in IR::Value
This commit is contained in:
parent
ca40015145
commit
01cfaf0286
2 changed files with 56 additions and 33 deletions
|
@ -52,8 +52,56 @@ const char* GetNameOf(Opcode op) {
|
|||
|
||||
// Value class member definitions
|
||||
|
||||
bool Value::IsImmediate() const {
|
||||
if (type == Type::Opaque)
|
||||
return inner.inst->GetOpcode() == Opcode::Identity ? inner.inst->GetArg(0).IsImmediate() : false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Value::IsEmpty() const {
|
||||
return type == Type::Void;
|
||||
}
|
||||
|
||||
Type Value::GetType() const {
|
||||
return IsImmediate() ? type : inner.inst->GetType();
|
||||
if (type == Type::Opaque) {
|
||||
if (inner.inst->GetOpcode() == Opcode::Identity) {
|
||||
return inner.inst->GetArg(0).GetType();
|
||||
} else {
|
||||
return inner.inst->GetType();
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
Arm::Reg Value::GetRegRef() const {
|
||||
DEBUG_ASSERT(type == Type::RegRef);
|
||||
return inner.imm_regref;
|
||||
}
|
||||
|
||||
Inst* Value::GetInst() const {
|
||||
DEBUG_ASSERT(type == Type::Opaque);
|
||||
return inner.inst;
|
||||
}
|
||||
|
||||
bool Value::GetU1() const {
|
||||
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
|
||||
return inner.inst->GetArg(0).GetU1();
|
||||
DEBUG_ASSERT(type == Type::U1);
|
||||
return inner.imm_u1;
|
||||
}
|
||||
|
||||
u8 Value::GetU8() const {
|
||||
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
|
||||
return inner.inst->GetArg(0).GetU8();
|
||||
DEBUG_ASSERT(type == Type::U8);
|
||||
return inner.imm_u8;
|
||||
}
|
||||
|
||||
u32 Value::GetU32() const {
|
||||
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
|
||||
return inner.inst->GetArg(0).GetU32();
|
||||
DEBUG_ASSERT(type == Type::U32);
|
||||
return inner.imm_u32;
|
||||
}
|
||||
|
||||
// Inst class member definitions
|
||||
|
|
|
@ -84,40 +84,15 @@ public:
|
|||
inner.imm_u32 = value;
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
return type == Type::Void;
|
||||
}
|
||||
|
||||
bool IsImmediate() const {
|
||||
return type != Type::Opaque;
|
||||
}
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool IsImmediate() const;
|
||||
Type GetType() const;
|
||||
|
||||
Inst* GetInst() const {
|
||||
DEBUG_ASSERT(type == Type::Opaque);
|
||||
return inner.inst;
|
||||
}
|
||||
|
||||
Arm::Reg GetRegRef() const {
|
||||
DEBUG_ASSERT(type == Type::RegRef);
|
||||
return inner.imm_regref;
|
||||
}
|
||||
|
||||
bool GetU1() const {
|
||||
DEBUG_ASSERT(type == Type::U1);
|
||||
return inner.imm_u1;
|
||||
}
|
||||
|
||||
u8 GetU8() const {
|
||||
DEBUG_ASSERT(type == Type::U8);
|
||||
return inner.imm_u8;
|
||||
}
|
||||
|
||||
u32 GetU32() const {
|
||||
DEBUG_ASSERT(type == Type::U32);
|
||||
return inner.imm_u32;
|
||||
}
|
||||
Inst* GetInst() const;
|
||||
Arm::Reg GetRegRef() const;
|
||||
bool GetU1() const;
|
||||
u8 GetU8() const;
|
||||
u32 GetU32() const;
|
||||
|
||||
private:
|
||||
Type type;
|
||||
|
|
Loading…
Reference in a new issue