19 #ifndef MLIR_IR_DOMINANCE_H
20 #define MLIR_IR_DOMINANCE_H
23 #include "llvm/Support/GenericDomTree.h"
25 extern template class llvm::DominatorTreeBase<mlir::Block, false>;
26 extern template class llvm::DominatorTreeBase<mlir::Block, true>;
27 extern template class llvm::DomTreeNodeBase<mlir::Block>;
34 template <
bool IsPostDom>
36 using DomTree = llvm::DominatorTreeBase<Block, IsPostDom>;
50 void invalidate(
Region *region);
59 template <
typename BlockRangeT>
61 if (blocks.begin() == blocks.end())
64 for (
auto it = ++blocks.begin(); it != blocks.end(); ++it) {
65 dom = findNearestCommonDominator(dom, *it);
75 auto domInfo = getDominanceInfo(region,
true).getPointer();
76 assert(domInfo &&
"Region isn't multiblock");
77 return domInfo->getRootNode();
83 return getDomTree(a->
getParent()).getNode(a);
88 bool isReachableFromEntry(
Block *a)
const;
93 return hasSSADominance(block->
getParent());
98 return getDominanceInfo(region,
false).getInt();
103 "Can't get DomTree for single block regions");
104 return *getDominanceInfo(region,
true).getPointer();
113 llvm::PointerIntPair<DomTree *, 1, bool>
114 getDominanceInfo(
Region *region,
bool needsDomTree)
const;
117 bool properlyDominatesImpl(
Block *a,
Block *b)
const;
121 bool enclosingOpOk =
true)
const;
154 bool enclosingOpOk =
true)
const {
155 return super::properlyDominatesImpl(a, b, enclosingOpOk);
161 return a == b || properlyDominates(a, b);
177 return a == b || properlyDominates(a, b);
192 return super::properlyDominatesImpl(a, b);
203 bool enclosingOpOk =
true)
const {
204 return super::properlyDominatesImpl(a, b, enclosingOpOk);
209 return a == b || properlyPostDominates(a, b);
214 return super::properlyDominatesImpl(a, b);
219 return a == b || properlyPostDominates(a, b);
Block represents an ordered list of Operations.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
A class for computing basic dominance information.
bool dominates(Block *a, Block *b) const
Return true if the specified block A dominates block B, i.e.
bool dominates(Value a, Operation *b) const
Return true if the a value dominates operation b.
bool properlyDominates(Operation *a, Operation *b, bool enclosingOpOk=true) const
Return true if operation A properly dominates operation B, i.e.
bool properlyDominates(Block *a, Block *b) const
Return true if the specified block A properly dominates block B, i.e.
bool dominates(Operation *a, Operation *b) const
Return true if operation A dominates operation B, i.e.
Operation is the basic unit of execution within MLIR.
A class for computing basic postdominance information.
bool properlyPostDominates(Block *a, Block *b) const
Return true if the specified block A properly postdominates block B.
bool postDominates(Operation *a, Operation *b) const
Return true if operation A postdominates operation B.
bool properlyPostDominates(Operation *a, Operation *b, bool enclosingOpOk=true) const
Return true if operation A properly postdominates operation B.
bool postDominates(Block *a, Block *b) const
Return true if the specified block A postdominates block B.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
bool hasOneBlock()
Return true if this region has exactly one block.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Block * findNearestCommonDominator(BlockRangeT &&blocks) const
Finds the nearest common dominator block for the given range of blocks.
DenseMap< Region *, llvm::PointerIntPair< DomTree *, 1, bool > > dominanceInfos
A mapping of regions to their base dominator tree and a cached "hasSSADominance" bit.
bool hasSSADominance(Region *region) const
Return true if operations in the specified block are known to obey SSA dominance requirements.
DominanceInfoNode * getNode(Block *a)
Return the dominance node from the Region containing block A.
DominanceInfoBase(const DominanceInfoBase &)=delete
DominanceInfoBase & operator=(DominanceInfoBase &&)=default
DominanceInfoBase(DominanceInfoBase &&)=default
DominanceInfoBase & operator=(const DominanceInfoBase &)=delete
DominanceInfoBase(Operation *op=nullptr)
DominanceInfoNode * getRootNode(Region *region)
Get the root dominance node of the given region.
bool hasSSADominance(Block *block) const
Return true if operations in the specified block are known to obey SSA dominance requirements.
DomTree & getDomTree(Region *region) const
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
llvm::DomTreeNodeBase< Block > DominanceInfoNode
const mlir::DominanceInfoNode * NodeRef
static NodeRef getEntryNode(NodeRef N)
mlir::DominanceInfoNode::const_iterator ChildIteratorType
static ChildIteratorType child_end(NodeRef N)
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static ChildIteratorType child_begin(NodeRef N)
mlir::DominanceInfoNode::const_iterator ChildIteratorType
static NodeRef getEntryNode(NodeRef N)
mlir::DominanceInfoNode * NodeRef