From: David Neto Date: Fri, 29 Jul 2016 15:24:57 +0000 (-0400) Subject: Add BasicBlock methods: dominates postdominates X-Git-Tag: upstream/2018.6~1168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3bf4dc102f4ffa2262b9a8d678d732ce66b08f81;p=platform%2Fupstream%2FSPIRV-Tools.git Add BasicBlock methods: dominates postdominates --- diff --git a/source/val/BasicBlock.h b/source/val/BasicBlock.h index ffba779..dd1014c 100644 --- a/source/val/BasicBlock.h +++ b/source/val/BasicBlock.h @@ -31,6 +31,7 @@ #include +#include #include #include #include @@ -127,6 +128,22 @@ class BasicBlock { /// Returns true if the id of the BasicBlock matches bool operator==(const uint32_t& other_id) const { return other_id == id_; } + /// Returns true if this block dominates the other block. + /// Assumes dominators have been computed. + bool dominates(const BasicBlock& other) const { + return (this == &other) || + !(other.dom_end() == + std::find(other.dom_begin(), other.dom_end(), this)); + } + + /// Returns true if this block postdominates the other block. + /// Assumes dominators have been computed. + bool postdominates(const BasicBlock& other) const { + return (this == &other) || + !(other.pdom_end() == + std::find(other.pdom_begin(), other.pdom_end(), this)); + } + /// @brief A BasicBlock dominator iterator class /// /// This iterator will iterate over the (post)dominators of the block