13#ifndef MLIR_IR_REGION_H
14#define MLIR_IR_REGION_H
20template <
typename ValueRangeT>
60 bool empty() {
return blocks.empty(); }
72 return &Region::blocks;
146 :
public llvm::iterator_facade_base<OpIterator, std::forward_iterator_tag,
153 using llvm::iterator_facade_base<
OpIterator, std::forward_iterator_tag,
161 return operation ==
rhs.operation;
166 void skipOverBlocksWithNoOps();
178 template <
typename OpT>
189 template <
typename OpT>
193 template <
typename OpT>
197 template <
typename OpT>
217 template <
typename ParentT>
221 if (
auto parent = dyn_cast_or_null<ParentT>(region->container))
223 }
while ((region = region->getParentRegion()));
226 template <
typename... ParentT>
230 if (!region->container)
232 if (isa<ParentT...>(region->container))
233 return region->container;
234 }
while ((region = region->getParentRegion()));
268 blocks.splice(blocks.end(), other.
getBlocks());
310 if constexpr (std::is_same<ArgT, Region *>::value &&
313 if constexpr (std::is_same<RetT, void>::value) {
316 RetT
result = callback(
this);
319 if (
result.wasInterrupted())
325 for (
auto &block : *
this) {
326 if constexpr (std::is_same<RetT, void>::value) {
327 block.walk<Order, Iterator>(callback);
329 if (block.walk<Order, Iterator>(callback).wasInterrupted())
334 if constexpr (std::is_same<ArgT, Region *>::value &&
337 return callback(
this);
339 if constexpr (!std::is_same<RetT, void>::value)
361 unsigned nextBlockID = 0;
363 friend struct llvm::ilist_traits<
Block>;
374 PointerUnion<Region *, const std::unique_ptr<Region> *, Region **>,
375 Region *, Region *, Region *> {
383 using RangeBaseT::RangeBaseT;
387 template <
typename Arg,
typename = std::enable_if_t<std::is_constructible<
392 template <
typename Arg>
394 Arg &&arg LLVM_LIFETIME_BOUND,
403 static OwnerT offset_base(
const OwnerT &owner, ptrdiff_t
index);
405 static Region *dereference_iterator(
const OwnerT &owner, ptrdiff_t
index);
411llvm::raw_ostream &
operator<<(llvm::raw_ostream &os, Region ®ion);
This class represents an argument of a Block.
Block represents an ordered list of Operations.
OpListType::iterator iterator
BlockArgument insertArgument(args_iterator it, Type type, Location loc)
Insert one value to the position in the argument list indicated by the given iterator.
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
BlockArgListType getArguments()
void eraseArgument(unsigned index)
Erase the argument at 'index' and remove it from the argument list.
This is a utility class for mapping one set of IR entities to another.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
Operation is the basic unit of execution within MLIR.
RegionRange(Arg &&arg LLVM_LIFETIME_BOUND)
RegionRange(Arg &&arg LLVM_LIFETIME_BOUND, std::enable_if_t< std::is_constructible< ArrayRef< Region * >, Arg >::value > *=nullptr)
RegionRange(MutableArrayRef< Region > regions={})
This class provides iteration over the held operations of blocks directly within a region.
OpIterator(Region *region, bool end=false)
Initialize OpIterator for a region, specify end to return the iterator to last operation.
bool operator==(const OpIterator &rhs) const
Compare this iterator with another.
Operation & operator*() const
OpIterator & operator++()
Operation * operator->() const
bool operator!=(const OpIterator &rhs) const
This class contains a list of basic blocks and a link to the parent operation it is attached to.
unsigned getMaxBlockID() const
One past the largest block ID handed out in this region; block IDs lie in [0, getMaxBlockID()).
llvm::iplist< Block > BlockListType
Region * getParentRegion()
Return the region containing this region or nullptr if the region is attached to a top-level operatio...
reverse_args_iterator args_rend()
BlockArgument insertArgument(args_iterator it, Type type, Location loc)
Insert one value to the position in the argument list indicated by the given iterator.
void eraseArgument(unsigned index)
Erase the argument at 'index' and remove it from the argument list.
BlockArgListType getArguments()
args_iterator args_begin()
iterator_range< op_iterator< OpT > > getOps()
iterator_range< args_iterator > addArguments(TypeRange types, ArrayRef< Location > locs)
Add one argument to the argument list for each type specified in the list.
detail::op_iterator< OpT, OpIterator > op_iterator
This class provides iteration over the held operations of a region for a specific operation type.
Operation * findAncestorOpInRegion(Operation &op)
Returns 'op' if 'op' lies in this region, or otherwise finds the ancestor of 'op' that lies in this r...
unsigned getRegionNumber()
Return the number of this region in the parent operation.
OpIterator op_begin()
Return iterators that walk the operations nested directly within this region.
void dropAllReferences()
Drop all operand uses from operations within this region, which is an essential step in breaking cycl...
bool isAncestor(Region *other)
Return true if this region is ancestor of the other region.
void push_back(Block *block)
BlockArgListType::iterator args_iterator
iterator_range< OpIterator > getOps()
BlockArgument insertArgument(unsigned index, Type type, Location loc)
Add one value to the argument list at the specified position.
static BlockListType Region::* getSublistAccess(Block *)
getSublistAccess() - Returns pointer to member of region.
op_iterator< OpT > op_begin()
Return iterators that walk operations of type 'T' nested directly within this region.
BlockListType::reverse_iterator reverse_iterator
void cloneInto(Region *dest, IRMapping &mapper)
Clone the internal blocks from this region into dest.
bool isProperAncestor(Region *other)
Return true if this region is a proper ancestor of the other region.
unsigned getNumArguments()
Location getLoc()
Return a location for this region.
ValueTypeRange< BlockArgListType > getArgumentTypes()
Returns the argument types of the first block within the region.
BlockArgument getArgument(unsigned i)
Operation * getParentOp()
Return the parent operation this region is attached to.
MutableArrayRef< BlockArgument > BlockArgListType
MLIRContext * getContext()
Return the context this region is inserted in.
BlockListType & getBlocks()
reverse_args_iterator args_rbegin()
BlockListType::iterator iterator
void push_front(Block *block)
void takeBody(Region &other)
Takes body of another region (that region will have no body after this operation completes).
reverse_iterator rbegin()
op_iterator< OpT > op_end()
ParentT getParentOfType()
Find the first parent operation of the given type, or nullptr if there is no ancestor operation.
Block * findAncestorBlockInRegion(Block &block)
Returns 'block' if 'block' lies in this region, or otherwise finds the ancestor of 'block' that lies ...
std::enable_if_t<(sizeof...(ParentT) > 1), Operation * > getParentOfType()
BlockArgListType::reverse_iterator reverse_args_iterator
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
bool hasOneBlock()
Return true if this region has exactly one block.
RetT walk(FnT &&callback)
Walk all nested operations, blocks or regions (including this region), depending on the type of callb...
unsigned getBlockIDEpoch() const
The block-ID epoch, part of the generic number-indexed graph contract (LoopInfo, DominatorTree) for d...
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class implements iteration on the types of a given range of values.
static WalkResult advance()
static WalkResult interrupt()
A utility iterator that filters out operations that are not 'OpT'.
This class provides iteration over the held operations of a block for a specific operation type.
decltype(first_argument_type(std::declval< T >())) first_argument
Type definition of the first argument to the given callable 'T'.
decltype(walk(nullptr, std::declval< FnT >())) walkResultType
Utility to provide the return type of a templated walk method.
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
WalkOrder
Traversal order for region, block and operation walk utilities.
This iterator enumerates the elements in "forward" order.