Remove const support from mlir::Region
PiperOrigin-RevId: 239642194
This commit is contained in:
parent
88e9f418f5
commit
6ab2984b23
|
@ -147,7 +147,7 @@ public:
|
|||
|
||||
/// Get the body region of the AffineForOp.
|
||||
Region &getRegion() { return getInstruction()->getRegion(0); }
|
||||
const Region &getRegion() const { return getInstruction()->getRegion(0); }
|
||||
Region &getRegion() const { return getInstruction()->getRegion(0); }
|
||||
|
||||
/// Returns the induction variable for this loop.
|
||||
Value *getInductionVar();
|
||||
|
@ -331,13 +331,13 @@ public:
|
|||
|
||||
/// Returns the 'then' region.
|
||||
Region &getThenBlocks();
|
||||
const Region &getThenBlocks() const {
|
||||
Region &getThenBlocks() const {
|
||||
return const_cast<AffineIfOp *>(this)->getThenBlocks();
|
||||
}
|
||||
|
||||
/// Returns the 'else' blocks.
|
||||
Region &getElseBlocks();
|
||||
const Region &getElseBlocks() const {
|
||||
Region &getElseBlocks() const {
|
||||
return const_cast<AffineIfOp *>(this)->getElseBlocks();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
void recalculate(Function *function);
|
||||
|
||||
/// Get the root dominance node of the given region.
|
||||
DominanceInfoNode *getRootNode(const Region *region) {
|
||||
DominanceInfoNode *getRootNode(Region *region) {
|
||||
assert(dominanceInfos.count(region) != 0);
|
||||
return dominanceInfos[region]->getRootNode();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ protected:
|
|||
bool properlyDominates(const Block *a, const Block *b);
|
||||
|
||||
/// A mapping of regions to their base dominator tree.
|
||||
llvm::DenseMap<const Region *, std::unique_ptr<base>> dominanceInfos;
|
||||
llvm::DenseMap<Region *, std::unique_ptr<base>> dominanceInfos;
|
||||
};
|
||||
} // end namespace detail
|
||||
|
||||
|
|
|
@ -384,32 +384,22 @@ public:
|
|||
|
||||
using RegionType = llvm::iplist<Block>;
|
||||
RegionType &getBlocks() { return blocks; }
|
||||
const RegionType &getBlocks() const { return blocks; }
|
||||
|
||||
// Iteration over the block in the function.
|
||||
using iterator = RegionType::iterator;
|
||||
using const_iterator = RegionType::const_iterator;
|
||||
using reverse_iterator = RegionType::reverse_iterator;
|
||||
using const_reverse_iterator = RegionType::const_reverse_iterator;
|
||||
|
||||
iterator begin() { return blocks.begin(); }
|
||||
iterator end() { return blocks.end(); }
|
||||
const_iterator begin() const { return blocks.begin(); }
|
||||
const_iterator end() const { return blocks.end(); }
|
||||
reverse_iterator rbegin() { return blocks.rbegin(); }
|
||||
reverse_iterator rend() { return blocks.rend(); }
|
||||
const_reverse_iterator rbegin() const { return blocks.rbegin(); }
|
||||
const_reverse_iterator rend() const { return blocks.rend(); }
|
||||
|
||||
bool empty() const { return blocks.empty(); }
|
||||
bool empty() { return blocks.empty(); }
|
||||
void push_back(Block *block) { blocks.push_back(block); }
|
||||
void push_front(Block *block) { blocks.push_front(block); }
|
||||
|
||||
Block &back() { return blocks.back(); }
|
||||
const Block &back() const { return const_cast<Region *>(this)->back(); }
|
||||
|
||||
Block &front() { return blocks.front(); }
|
||||
const Block &front() const { return const_cast<Region *>(this)->front(); }
|
||||
|
||||
/// getSublistAccess() - Returns pointer to member of region.
|
||||
static RegionType Region::*getSublistAccess(Block *) {
|
||||
|
@ -419,20 +409,17 @@ public:
|
|||
/// A Region is either a function body or a part of an operation. If it is
|
||||
/// part of an operation, then return the operation, otherwise return null.
|
||||
Instruction *getContainingInst();
|
||||
const Instruction *getContainingInst() const {
|
||||
return const_cast<Region *>(this)->getContainingInst();
|
||||
}
|
||||
|
||||
/// A Region is either a function body or a part of an operation. If it is
|
||||
/// a Function body, then return this function, otherwise return null.
|
||||
Function *getContainingFunction() const;
|
||||
Function *getContainingFunction();
|
||||
|
||||
/// Clone the internal blocks from this region into dest. Any
|
||||
/// cloned blocks are appended to the back of dest. If the mapper
|
||||
/// contains entries for block arguments, these arguments are not included
|
||||
/// in the respective cloned block.
|
||||
void cloneInto(Region *dest, BlockAndValueMapping &mapper,
|
||||
MLIRContext *context) const;
|
||||
MLIRContext *context);
|
||||
|
||||
private:
|
||||
RegionType blocks;
|
||||
|
|
|
@ -291,21 +291,16 @@ public:
|
|||
unsigned getNumRegions() const { return numRegions; }
|
||||
|
||||
/// Returns the regions held by this operation.
|
||||
MutableArrayRef<Region> getRegions() {
|
||||
return {getTrailingObjects<Region>(), numRegions};
|
||||
}
|
||||
ArrayRef<Region> getRegions() const {
|
||||
return const_cast<Instruction *>(this)->getRegions();
|
||||
MutableArrayRef<Region> getRegions() const {
|
||||
auto *regions = getTrailingObjects<Region>();
|
||||
return {const_cast<Region *>(regions), numRegions};
|
||||
}
|
||||
|
||||
/// Returns the region held by this operation at position 'index'.
|
||||
Region &getRegion(unsigned index) {
|
||||
Region &getRegion(unsigned index) const {
|
||||
assert(index < numRegions && "invalid region index");
|
||||
return getRegions()[index];
|
||||
}
|
||||
const Region &getRegion(unsigned index) const {
|
||||
return const_cast<Instruction *>(this)->getRegion(index);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Terminators
|
||||
|
|
|
@ -90,8 +90,7 @@ public:
|
|||
virtual void printGenericOp(const Instruction *op) = 0;
|
||||
|
||||
/// Prints a region.
|
||||
virtual void printRegion(const Region &blocks,
|
||||
bool printEntryBlockArgs = true) = 0;
|
||||
virtual void printRegion(Region &blocks, bool printEntryBlockArgs = true) = 0;
|
||||
|
||||
private:
|
||||
OpAsmPrinter(const OpAsmPrinter &) = delete;
|
||||
|
|
|
@ -568,7 +568,7 @@ void AffineForOp::build(Builder *builder, OperationState *result, int64_t lb,
|
|||
}
|
||||
|
||||
bool AffineForOp::verify() const {
|
||||
const auto &bodyRegion = getInstruction()->getRegion(0);
|
||||
auto &bodyRegion = getInstruction()->getRegion(0);
|
||||
|
||||
// The body region must contain a single basic block.
|
||||
if (bodyRegion.empty() || std::next(bodyRegion.begin()) != bodyRegion.end())
|
||||
|
@ -1057,7 +1057,7 @@ bool AffineIfOp::verify() const {
|
|||
return true;
|
||||
|
||||
// Verify that the entry of each child region does not have arguments.
|
||||
for (const auto ®ion : getInstruction()->getRegions()) {
|
||||
for (auto ®ion : getInstruction()->getRegions()) {
|
||||
if (region.empty())
|
||||
continue;
|
||||
|
||||
|
@ -1123,7 +1123,7 @@ void AffineIfOp::print(OpAsmPrinter *p) const {
|
|||
p->printRegion(getInstruction()->getRegion(0));
|
||||
|
||||
// Print the 'else' regions if it has any blocks.
|
||||
const auto &elseRegion = getInstruction()->getRegion(1);
|
||||
auto &elseRegion = getInstruction()->getRegion(1);
|
||||
if (!elseRegion.empty()) {
|
||||
*p << " else";
|
||||
p->printRegion(elseRegion);
|
||||
|
|
|
@ -1111,7 +1111,7 @@ public:
|
|||
unsigned index) override;
|
||||
|
||||
/// Print a region.
|
||||
void printRegion(const Region &blocks, bool printEntryBlockArgs) override {
|
||||
void printRegion(Region &blocks, bool printEntryBlockArgs) override {
|
||||
os << " {\n";
|
||||
if (!blocks.empty()) {
|
||||
auto *entryBlock = &blocks.front();
|
||||
|
|
|
@ -273,14 +273,14 @@ Instruction *Region::getContainingInst() {
|
|||
return container.dyn_cast<Instruction *>();
|
||||
}
|
||||
|
||||
Function *Region::getContainingFunction() const {
|
||||
Function *Region::getContainingFunction() {
|
||||
return container.dyn_cast<Function *>();
|
||||
}
|
||||
|
||||
/// Clone the internal blocks from this region into `dest`. Any
|
||||
/// cloned blocks are appended to the back of dest.
|
||||
void Region::cloneInto(Region *dest, BlockAndValueMapping &mapper,
|
||||
MLIRContext *context) const {
|
||||
MLIRContext *context) {
|
||||
assert(dest && "expected valid region to clone into");
|
||||
|
||||
// If the list is empty there is nothing to clone.
|
||||
|
|
Loading…
Reference in New Issue