// Insert a `dealloc` operation right before the `return` operations, unless
// it is returned itself in which case the caller is responsible for it.
- alloc.getContainingRegion()->walk([&](Operation *op) {
+ alloc.getParentRegion()->walk([&](Operation *op) {
auto returnOp = dyn_cast<ReturnOp>(op);
if (!returnOp)
return;
/// Blocks are maintained in a Region.
Region *getParent();
- /// Returns the closest surrounding operation that contains this block or
- /// nullptr if this is a top-level block.
- Operation *getContainingOp();
+ /// Returns the closest surrounding operation that contains this block.
+ Operation *getParentOp();
/// Return if this block is the entry block in the parent region.
bool isEntryBlock();
block_iterator first, block_iterator last);
private:
- mlir::Region *getContainingRegion();
+ mlir::Region *getParentRegion();
};
} // end namespace llvm
/// Return the dialect that this refers to.
Dialect *getDialect() { return getOperation()->getDialect(); }
- /// Return the Region enclosing this Op.
- Region *getContainingRegion() {
- return getOperation()->getContainingRegion();
- }
+ /// Return the parent Region of this operation.
+ Region *getParentRegion() { return getOperation()->getParentRegion(); }
/// Return true if this "op class" can match against the specified operation.
/// This hook can be overridden with a more specific implementation in
/// Set the source location the operation was defined or derived from.
void setLoc(Location loc) { location = loc; }
- /// Returns the region to which the instruction belongs, which can be a
- /// function body region or a region that belongs to another operation.
- /// Returns nullptr if the instruction is unlinked.
- Region *getContainingRegion() const;
+ /// Returns the region to which the instruction belongs. Returns nullptr if
+ /// the instruction is unlinked.
+ Region *getParentRegion();
/// Returns the closest surrounding operation that contains this operation
/// or nullptr if this is a top-level operation.
return &Region::blocks;
}
- /// Return the region containing this region or nullptr if it is a top-level
- /// region.
- Region *getContainingRegion();
+ /// Return the region containing this region or nullptr if the region is
+ /// attached to a top-level operation.
+ Region *getParentRegion();
/// Return the parent operation this region is attached to.
- Operation *getContainingOp();
+ Operation *getParentOp();
/// Find the first parent operation of the given type, or nullptr if there is
/// no ancestor operation.
do {
if (auto parent = dyn_cast_or_null<ParentT>(region->container))
return parent;
- } while ((region = region->getContainingRegion()));
+ } while ((region = region->getParentRegion()));
return ParentT();
}
Location getLoc();
/// Return the Region in which this Value is defined.
- Region *getContainingRegion();
+ Region *getParentRegion();
using use_iterator = ValueUseIterator<OpOperand>;
using use_range = llvm::iterator_range<use_iterator>;
template <typename Range>
bool areValuesDefinedAbove(Range values, Region &limit) {
for (Value *v : values)
- if (!v->getContainingRegion()->isProperAncestor(&limit))
+ if (!v->getParentRegion()->isProperAncestor(&limit))
return false;
return true;
}
/// A utility function to check if a given region is attached to a function.
static bool isFunctionRegion(Region *region) {
- return llvm::isa<FuncOp>(region->getContainingOp());
+ return llvm::isa<FuncOp>(region->getParentOp());
}
/// A utility function to check if a value is defined at the top level of a
bool mlir::isTopLevelSymbol(Value *value) {
if (auto *arg = dyn_cast<BlockArgument>(value))
return isFunctionRegion(arg->getOwner()->getParent());
- return isFunctionRegion(value->getDefiningOp()->getContainingRegion());
+ return isFunctionRegion(value->getDefiningOp()->getParentRegion());
}
// Value can be used as a dimension id if it is valid as a symbol, or
if (auto *op = value->getDefiningOp()) {
// Top level operation or constant operation is ok.
- if (isFunctionRegion(op->getContainingRegion()) || isa<ConstantOp>(op))
+ if (isFunctionRegion(op->getParentRegion()) || isa<ConstantOp>(op))
return true;
// Affine apply operation is ok if all of its operands are ok.
if (auto applyOp = dyn_cast<AffineApplyOp>(op))
if (auto *op = value->getDefiningOp()) {
// Top level operation or constant operation is ok.
- if (isFunctionRegion(op->getContainingRegion()) || isa<ConstantOp>(op))
+ if (isFunctionRegion(op->getParentRegion()) || isa<ConstantOp>(op))
return true;
// Affine apply operation is ok if all of its operands are ok.
if (auto applyOp = dyn_cast<AffineApplyOp>(op))
auto *ivArg = dyn_cast<BlockArgument>(val);
if (!ivArg || !ivArg->getOwner())
return AffineForOp();
- auto *containingInst = ivArg->getOwner()->getParent()->getContainingOp();
+ auto *containingInst = ivArg->getOwner()->getParent()->getParentOp();
return dyn_cast<AffineForOp>(containingInst);
}
unsigned numCommonLoops) {
if (numCommonLoops == 0) {
auto *block = srcAccess.opInst->getBlock();
- while (!llvm::isa<FuncOp>(block->getContainingOp())) {
- block = block->getContainingOp()->getBlock();
+ while (!llvm::isa<FuncOp>(block->getParentOp())) {
+ block = block->getParentOp()->getBlock();
}
return block;
}
if (regionA != regionB) {
Operation *bAncestor;
do {
- bAncestor = regionB->getContainingOp();
+ bAncestor = regionB->getParentOp();
// If 'bAncestor' is the top level region, then 'a' is a block that post
// dominates 'b'.
if (!bAncestor || !bAncestor->getBlock())
// rely on linear scans.
int instPosInBlock = std::distance(block->begin(), op->getIterator());
positions->push_back(instPosInBlock);
- op = block->getContainingOp();
+ op = block->getParentOp();
block = op->getBlock();
}
std::reverse(positions->begin(), positions->end());
if (!ivArg)
return ForOp();
assert(ivArg->getOwner() && "unlinked block argument");
- auto *containingInst = ivArg->getOwner()->getContainingOp();
+ auto *containingInst = ivArg->getOwner()->getParentOp();
return dyn_cast_or_null<ForOp>(containingInst);
}
return;
}
- auto region = getContainingRegion();
+ auto region = getParentRegion();
if (!region) {
os << "<<UNLINKED INSTRUCTION>>\n";
return;
}
// Get the top-level region.
- while (auto *nextRegion = region->getContainingRegion())
+ while (auto *nextRegion = region->getParentRegion())
region = nextRegion;
ModuleState state(getContext());
}
// Get the top-level region.
- while (auto *nextRegion = region->getContainingRegion())
+ while (auto *nextRegion = region->getParentRegion())
region = nextRegion;
ModuleState state(region->getContext());
}
// Get the top-level region.
- while (auto *nextRegion = region->getContainingRegion())
+ while (auto *nextRegion = region->getParentRegion())
region = nextRegion;
ModuleState state(region->getContext());
Region *Block::getParent() { return parentValidInstOrderPair.getPointer(); }
/// Returns the closest surrounding operation that contains this block or
-/// nullptr if this is a top-level operation block.
-Operation *Block::getContainingOp() {
- return getParent() ? getParent()->getContainingOp() : nullptr;
+/// nullptr if this block is unlinked.
+Operation *Block::getParentOp() {
+ return getParent() ? getParent()->getParentOp() : nullptr;
}
/// Return if this block is the entry block in the parent region.
return getContext()->getRegisteredDialect(getName().getDialect());
}
-Region *Operation::getContainingRegion() const {
+Region *Operation::getParentRegion() {
return block ? block->getParent() : nullptr;
}
Operation *Operation::getParentOp() {
- return block ? block->getContainingOp() : nullptr;
+ return block ? block->getParentOp() : nullptr;
}
/// Replace any uses of 'from' with 'to' within this operation.
}
static LogicalResult verifyTerminatorSuccessors(Operation *op) {
- auto *parent = op->getContainingRegion();
+ auto *parent = op->getParentRegion();
// Verify that the operands lines up with the BB arguments in the successor.
for (unsigned i = 0, e = op->getNumSuccessors(); i != e; ++i) {
return container->getLoc();
}
-Region *Region::getContainingRegion() {
+Region *Region::getParentRegion() {
assert(container && "region is not attached to a container");
- return container->getContainingRegion();
+ return container->getParentRegion();
}
-Operation *Region::getContainingOp() { return container; }
+Operation *Region::getParentOp() { return container; }
bool Region::isProperAncestor(Region *other) {
if (this == other)
return false;
- while ((other = other->getContainingRegion())) {
+ while ((other = other->getParentRegion())) {
if (this == other)
return true;
}
unsigned Region::getRegionNumber() {
// Regions are always stored consecutively, so use pointer subtraction to
// figure out what number this is.
- return this - &getContainingOp()->getRegions()[0];
+ return this - &getParentOp()->getRegions()[0];
}
/// Clone the internal blocks from this region into `dest`. Any
for (Value *operand : op.getOperands()) {
// Check that any value that is used by an operation is defined in the
// same region as either an operation result or a block argument.
- if (operand->getContainingRegion()->isProperAncestor(&limit)) {
+ if (operand->getParentRegion()->isProperAncestor(&limit)) {
if (noteLoc) {
op.emitOpError("using value defined outside the region")
.attachNote(noteLoc)
block.walk(callback);
}
-Region *llvm::ilist_traits<::mlir::Block>::getContainingRegion() {
+Region *llvm::ilist_traits<::mlir::Block>::getParentRegion() {
size_t Offset(
size_t(&((Region *)nullptr->*Region::getSublistAccess(nullptr))));
iplist<Block> *Anchor(static_cast<iplist<Block> *>(this));
/// We keep the region pointer up to date.
void llvm::ilist_traits<::mlir::Block>::addNodeToList(Block *block) {
assert(!block->getParent() && "already in a region!");
- block->parentValidInstOrderPair.setPointer(getContainingRegion());
+ block->parentValidInstOrderPair.setPointer(getParentRegion());
}
/// This is a trait method invoked when an operation is removed from a
ilist_traits<Block> &otherList, block_iterator first, block_iterator last) {
// If we are transferring operations within the same function, the parent
// pointer doesn't need to be updated.
- auto *curParent = getContainingRegion();
- if (curParent == otherList.getContainingRegion())
+ auto *curParent = getParentRegion();
+ if (curParent == otherList.getParentRegion())
return;
// Update the 'parent' member of each Block.
}
/// Return the Region in which this Value is defined.
-Region *Value::getContainingRegion() {
+Region *Value::getParentRegion() {
switch (getKind()) {
case Value::Kind::BlockArgument:
return cast<BlockArgument>(this)->getOwner()->getParent();
case Value::Kind::OpResult:
- return getDefiningOp()->getContainingRegion();
+ return getDefiningOp()->getParentRegion();
}
llvm_unreachable("Unknown Value Kind");
}
static InFlightDiagnostic LLVM_ATTRIBUTE_UNUSED
emitRemarkForBlock(Block &block) {
- return block.getContainingOp()->emitRemark();
+ return block.getParentOp()->emitRemark();
}
/// Generates a point-wise copy from/to `memref' to/from `fastMemRef' and
if (totalCopyBuffersSizeInBytes > fastMemCapacityBytes) {
StringRef str = "Total size of all copy buffers' for this block "
"exceeds fast memory capacity\n";
- block->getContainingOp()->emitError(str);
+ block->getParentOp()->emitError(str);
}
return totalCopyBuffersSizeInBytes;
/// Given an operation, find the parent region that folded constants should be
/// inserted into.
static Region *getInsertionRegion(Operation *op) {
- while (Region *region = op->getContainingRegion()) {
+ while (Region *region = op->getParentRegion()) {
// Insert in this region for any of the following scenarios:
// * The parent is unregistered, or is known to be isolated from above.
// * The parent is a top-level operation.
- auto *parentOp = region->getContainingOp();
+ auto *parentOp = region->getParentOp();
if (!parentOp->isRegistered() || parentOp->isKnownIsolatedFromAbove() ||
!parentOp->getBlock())
return region;
void mlir::replaceAllUsesInRegionWith(Value *orig, Value *replacement,
Region ®ion) {
for (IROperand &use : llvm::make_early_inc_range(orig->getUses())) {
- if (region.isAncestor(use.getOwner()->getContainingRegion()))
+ if (region.isAncestor(use.getOwner()->getParentRegion()))
use.set(replacement);
}
}
// Collect proper ancestors of `limit` upfront to avoid traversing the region
// tree for every value.
llvm::SmallPtrSet<Region *, 4> properAncestors;
- for (auto *reg = limit.getContainingRegion(); reg != nullptr;
- reg = reg->getContainingRegion()) {
+ for (auto *reg = limit.getParentRegion(); reg != nullptr;
+ reg = reg->getParentRegion()) {
properAncestors.insert(reg);
}
for (Value *operand : op->getOperands())
// Collect values that are used by an operation and defined in a proper
// ancestor of region.
- if (properAncestors.count(operand->getContainingRegion()))
+ if (properAncestors.count(operand->getParentRegion()))
values.insert(operand);
});
}
matchAndRewrite(Operation *op, ArrayRef<Value *> operands,
ConversionPatternRewriter &rewriter) const final {
// Inline this region into the parent region.
- auto &parentRegion = *op->getContainingRegion();
+ auto &parentRegion = *op->getParentRegion();
rewriter.inlineRegionBefore(op->getRegion(0), parentRegion,
parentRegion.end());
func.walk<loop::ForOp>([&processorIds, &numProcessors](loop::ForOp op) {
// Ignore nested loops.
- if (op.getContainingRegion()->getParentOfType<loop::ForOp>())
+ if (op.getParentRegion()->getParentOfType<loop::ForOp>())
return;
mapLoopToProcessorIds(op, processorIds, numProcessors);
});
FuncOp func = getFunction();
func.walk<loop::ForOp>([this](loop::ForOp op) {
// Ignore nested loops.
- if (op.getContainingRegion()->getParentOfType<loop::ForOp>())
+ if (op.getParentRegion()->getParentOfType<loop::ForOp>())
return;
extractFixedOuterLoops(op, sizes);
});