[Mlir-commits] [mlir] 979ffe9 - [mlir] Allow RegionRange to accept ArrayRef<Region *>
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 28 12:39:47 PDT 2022
Author: Mogball
Date: 2022-03-28T19:39:42Z
New Revision: 979ffe97b9bf925a9d1448d13aa4737cfda8fc35
URL: https://github.com/llvm/llvm-project/commit/979ffe97b9bf925a9d1448d13aa4737cfda8fc35
DIFF: https://github.com/llvm/llvm-project/commit/979ffe97b9bf925a9d1448d13aa4737cfda8fc35.diff
LOG: [mlir] Allow RegionRange to accept ArrayRef<Region *>
Adds another pointer to the union in RegionRange to allow RegionRange to work on ArrayRef<Region *> (i.e. vectors of Region *).
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D122514
Added:
Modified:
mlir/include/mlir/IR/Region.h
mlir/lib/IR/Region.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h
index c2694ad33ddac..3a1e57b84fe0a 100644
--- a/mlir/include/mlir/IR/Region.h
+++ b/mlir/include/mlir/IR/Region.h
@@ -321,11 +321,14 @@ class Region {
/// parameter.
class RegionRange
: public llvm::detail::indexed_accessor_range_base<
- RegionRange, PointerUnion<Region *, const std::unique_ptr<Region> *>,
+ RegionRange,
+ PointerUnion<Region *, const std::unique_ptr<Region> *, Region **>,
Region *, Region *, Region *> {
- /// The type representing the owner of this range. This is either a list of
- /// values, operands, or results.
- using OwnerT = PointerUnion<Region *, const std::unique_ptr<Region> *>;
+ /// The type representing the owner of this range. This is either an owning
+ /// list of regions, a list of region unique pointers, or a list of region
+ /// pointers.
+ using OwnerT =
+ PointerUnion<Region *, const std::unique_ptr<Region> *, Region **>;
public:
using RangeBaseT::RangeBaseT;
@@ -339,6 +342,7 @@ class RegionRange
: RegionRange(ArrayRef<std::unique_ptr<Region>>(std::forward<Arg>(arg))) {
}
RegionRange(ArrayRef<std::unique_ptr<Region>> regions);
+ RegionRange(ArrayRef<Region *> regions);
private:
/// See `llvm::detail::indexed_accessor_range_base` for details.
diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp
index 8739b98d67018..a5bca205fae1d 100644
--- a/mlir/lib/IR/Region.cpp
+++ b/mlir/lib/IR/Region.cpp
@@ -228,18 +228,24 @@ RegionRange::RegionRange(MutableArrayRef<Region> regions)
: RegionRange(regions.data(), regions.size()) {}
RegionRange::RegionRange(ArrayRef<std::unique_ptr<Region>> regions)
: RegionRange(regions.data(), regions.size()) {}
+RegionRange::RegionRange(ArrayRef<Region *> regions)
+ : RegionRange(const_cast<Region **>(regions.data()), regions.size()) {}
/// See `llvm::detail::indexed_accessor_range_base` for details.
RegionRange::OwnerT RegionRange::offset_base(const OwnerT &owner,
ptr
diff _t index) {
- if (auto *operand = owner.dyn_cast<const std::unique_ptr<Region> *>())
- return operand + index;
+ if (auto *region = owner.dyn_cast<const std::unique_ptr<Region> *>())
+ return region + index;
+ if (auto **region = owner.dyn_cast<Region **>())
+ return region + index;
return &owner.get<Region *>()[index];
}
/// See `llvm::detail::indexed_accessor_range_base` for details.
Region *RegionRange::dereference_iterator(const OwnerT &owner,
ptr
diff _t index) {
- if (auto *operand = owner.dyn_cast<const std::unique_ptr<Region> *>())
- return operand[index].get();
+ if (auto *region = owner.dyn_cast<const std::unique_ptr<Region> *>())
+ return region[index].get();
+ if (auto **region = owner.dyn_cast<Region **>())
+ return region[index];
return &owner.get<Region *>()[index];
}
More information about the Mlir-commits
mailing list