Lines Matching full:region

1 //===- Region.cpp - MLIR Region Class -------------------------------------===//
9 #include "mlir/IR/Region.h"
14 Region::Region(Operation *container) : container(container) {}
16 Region::~Region() {
22 /// Return the context this region is inserted in. The region must have a valid
24 MLIRContext *Region::getContext() {
25 assert(container && "region is not attached to a container");
29 /// Return a location for this region. This is the location attached to the
30 /// parent container. The region must have a valid parent container.
31 Location Region::getLoc() {
32 assert(container && "region is not attached to a container");
36 auto Region::getArgumentTypes() -> ValueTypeRange<BlockArgListType> {
40 iterator_range<Region::args_iterator>
41 Region::addArguments(TypeRange types, ArrayRef<Location> locs) {
45 Region *Region::getParentRegion() {
46 assert(container && "region is not attached to a container");
50 bool Region::isProperAncestor(Region *other) {
61 /// Return the number of this region in the parent operation.
62 unsigned Region::getRegionNumber() {
68 /// Clone the internal blocks from this region into `dest`. Any
70 void Region::cloneInto(Region *dest, IRMapping &mapper) {
71 assert(dest && "expected valid region to clone into");
75 /// Clone this region into 'dest' before the given position in 'dest'.
76 void Region::cloneInto(Region *dest, Region::iterator destPos,
78 assert(dest && "expected valid region to clone into");
79 assert(this != dest && "cannot clone region into itself");
87 // of the blocks or operation results contained within this region as that
89 // 'Value's from outside the region however, in which case it is not read
112 llvm::make_range(Region::iterator(mapper.lookup(&front())), destPos);
118 // Cloning the operands and region as well would lead to uses of operations
151 /// Returns 'block' if 'block' lies in this region, or otherwise finds the
152 /// ancestor of 'block' that lies in this region. Returns nullptr if the latter
154 Block *Region::findAncestorBlockInRegion(Block &block) {
165 /// Returns 'op' if 'op' lies in this region, or otherwise finds the
166 /// ancestor of 'op' that lies in this region. Returns nullptr if the
168 Operation *Region::findAncestorOpInRegion(Operation &op) {
170 while (Region *opRegion = curOp->getParentRegion()) {
181 void Region::dropAllReferences() {
186 Region *llvm::ilist_traits<::mlir::Block>::getParentRegion() {
188 size_t(&((Region *)nullptr->*Region::getSublistAccess(nullptr))));
190 return reinterpret_cast<Region *>(reinterpret_cast<char *>(anchor) - offset);
193 /// This is a trait method invoked when a basic block is added to a region.
194 /// We keep the region pointer up to date.
196 assert(!block->getParent() && "already in a region!");
201 /// region. We keep the region pointer up to date.
203 assert(block->getParent() && "not already in a region!");
223 // Region::OpIterator
226 Region::OpIterator::OpIterator(Region *region, bool end)
227 : region(region), block(end ? region->end() : region->begin()) {
228 if (!region->empty())
232 Region::OpIterator &Region::OpIterator::operator++() {
244 void Region::OpIterator::skipOverBlocksWithNoOps() {
245 while (block != region->end() && block->empty())
250 if (block == region->end())
260 RegionRange::RegionRange(MutableArrayRef<Region> regions)
262 RegionRange::RegionRange(ArrayRef<std::unique_ptr<Region>> regions)
264 RegionRange::RegionRange(ArrayRef<Region *> regions)
265 : RegionRange(const_cast<Region **>(regions.data()), regions.size()) {}
270 if (auto *region = llvm::dyn_cast_if_present<const std::unique_ptr<Region> *>(owner))
271 return region + index;
272 if (auto **region = llvm::dyn_cast_if_present<Region **>(owner))
273 return region + index;
274 return &cast<Region *>(owner)[index];
277 Region *RegionRange::dereference_iterator(const OwnerT &owner,
279 if (auto *region = llvm::dyn_cast_if_present<const std::unique_ptr<Region> *>(owner))
280 return region[index].get();
281 if (auto **region = llvm::dyn_cast_if_present<Region **>(owner))
282 return region[index];
283 return &cast<Region *>(owner)[index];