summaryrefslogtreecommitdiffstats
path: root/mlir
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2019-03-21 11:57:14 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 17:30:14 -0700
commit6ab2984b23c86de626f2c99473e1733cc2ebfad0 (patch)
tree0d65a4eebe8e8d85b139c49fed959e938d3042ad /mlir
parent88e9f418f5ec04efbe7d470712991b34c2a9869c (diff)
downloadbcm5719-llvm-6ab2984b23c86de626f2c99473e1733cc2ebfad0.tar.gz
bcm5719-llvm-6ab2984b23c86de626f2c99473e1733cc2ebfad0.zip
Remove const support from mlir::Region
PiperOrigin-RevId: 239642194
Diffstat (limited to 'mlir')
-rw-r--r--mlir/include/mlir/AffineOps/AffineOps.h6
-rw-r--r--mlir/include/mlir/Analysis/Dominance.h4
-rw-r--r--mlir/include/mlir/IR/Block.h19
-rw-r--r--mlir/include/mlir/IR/Instruction.h13
-rw-r--r--mlir/include/mlir/IR/OpImplementation.h3
-rw-r--r--mlir/lib/AffineOps/AffineOps.cpp6
-rw-r--r--mlir/lib/IR/AsmPrinter.cpp2
-rw-r--r--mlir/lib/IR/Block.cpp4
8 files changed, 19 insertions, 38 deletions
diff --git a/mlir/include/mlir/AffineOps/AffineOps.h b/mlir/include/mlir/AffineOps/AffineOps.h
index 0cb270ac3c4..a9b93ba2918 100644
--- a/mlir/include/mlir/AffineOps/AffineOps.h
+++ b/mlir/include/mlir/AffineOps/AffineOps.h
@@ -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();
}
diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h
index ab4022c41da..39c95b8fbe9 100644
--- a/mlir/include/mlir/Analysis/Dominance.h
+++ b/mlir/include/mlir/Analysis/Dominance.h
@@ -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
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 9269c25049e..6f1196ba882 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -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;
diff --git a/mlir/include/mlir/IR/Instruction.h b/mlir/include/mlir/IR/Instruction.h
index ccc5472d5e7..7a12d4f543a 100644
--- a/mlir/include/mlir/IR/Instruction.h
+++ b/mlir/include/mlir/IR/Instruction.h
@@ -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
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 5ad22e6dca3..f8465afe0ea 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -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;
diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp
index ab75909877f..cd73916a21b 100644
--- a/mlir/lib/AffineOps/AffineOps.cpp
+++ b/mlir/lib/AffineOps/AffineOps.cpp
@@ -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 &region : getInstruction()->getRegions()) {
+ for (auto &region : 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);
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index b93fe0d00bd..78f40a55670 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -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();
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index 4d407fdf3f5..1e3c79f491e 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -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.
OpenPOWER on IntegriCloud