diff options
Diffstat (limited to 'mlir/lib/IR/Region.cpp')
| -rw-r--r-- | mlir/lib/IR/Region.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index a91d36b1e48..a5a19cbcbf2 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -213,3 +213,21 @@ void llvm::ilist_traits<::mlir::Block>::transferNodesFromList( for (; first != last; ++first) first->parentValidOpOrderPair.setPointer(curParent); } + +//===----------------------------------------------------------------------===// +// RegionRange +//===----------------------------------------------------------------------===// +RegionRange::RegionRange(MutableArrayRef<Region> regions) + : owner(regions.data()), count(regions.size()) {} +RegionRange::RegionRange(ArrayRef<std::unique_ptr<Region>> regions) + : owner(regions.data()), count(regions.size()) {} +RegionRange::Iterator::Iterator(OwnerT owner, unsigned curIndex) + : indexed_accessor_iterator<Iterator, OwnerT, Region *, Region *, Region *>( + owner, curIndex) {} + +Region *RegionRange::Iterator::operator*() const { + if (const std::unique_ptr<Region> *operand = + object.dyn_cast<const std::unique_ptr<Region> *>()) + return operand[index].get(); + return &object.get<Region *>()[index]; +} |

