shader: Add utility to resolve identities on a value

This commit is contained in:
ReinUsesLisp 2021-02-16 19:49:24 -03:00 committed by ameerj
parent 3a59fffaa1
commit 3633e43377
2 changed files with 8 additions and 0 deletions

View file

@ -79,6 +79,13 @@ IR::Inst* Value::InstRecursive() const {
return inst; return inst;
} }
IR::Value Value::Resolve() const {
if (IsIdentity()) {
return inst->Arg(0).Resolve();
}
return *this;
}
IR::Reg Value::Reg() const { IR::Reg Value::Reg() const {
ValidateAccess(Type::Reg); ValidateAccess(Type::Reg);
return reg; return reg;

View file

@ -41,6 +41,7 @@ public:
[[nodiscard]] IR::Inst* Inst() const; [[nodiscard]] IR::Inst* Inst() const;
[[nodiscard]] IR::Block* Label() const; [[nodiscard]] IR::Block* Label() const;
[[nodiscard]] IR::Inst* InstRecursive() const; [[nodiscard]] IR::Inst* InstRecursive() const;
[[nodiscard]] IR::Value Resolve() const;
[[nodiscard]] IR::Reg Reg() const; [[nodiscard]] IR::Reg Reg() const;
[[nodiscard]] IR::Pred Pred() const; [[nodiscard]] IR::Pred Pred() const;
[[nodiscard]] IR::Attribute Attribute() const; [[nodiscard]] IR::Attribute Attribute() const;