Lines Matching full:block

1 //===- Block.cpp - MLIR Block Class ---------------------------------------===//
9 #include "mlir/IR/Block.h"
19 // Block
22 Block::~Block() {
29 Region *Block::getParent() const { return parentValidOpOrderPair.getPointer(); }
31 /// Returns the closest surrounding operation that contains this block or
32 /// nullptr if this block is unlinked.
33 Operation *Block::getParentOp() {
37 /// Return if this block is the entry block in the parent region.
38 bool Block::isEntryBlock() { return this == &getParent()->front(); }
40 /// Insert this block (which must not already be in a region) right before the
41 /// specified block.
42 void Block::insertBefore(Block *block) {
43 assert(!getParent() && "already inserted into a block!");
44 assert(block->getParent() && "cannot insert before a block without a parent");
45 block->getParent()->getBlocks().insert(block->getIterator(), this);
48 void Block::insertAfter(Block *block) {
49 assert(!getParent() && "already inserted into a block!");
50 assert(block->getParent() && "cannot insert before a block without a parent");
51 block->getParent()->getBlocks().insertAfter(block->getIterator(), this);
54 /// Unlink this block from its current region and insert it right before the
55 /// specific block.
56 void Block::moveBefore(Block *block) {
57 assert(block->getParent() && "cannot insert before a block without a parent");
58 moveBefore(block->getParent(), block->getIterator());
61 /// Unlink this block from its current region and insert it right before the
62 /// block that the given iterator points to in the region region.
63 void Block::moveBefore(Region *region, llvm::iplist<Block>::iterator iterator) {
67 /// Unlink this Block from its parent Region and delete it.
68 void Block::erase() {
69 assert(getParent() && "Block has no parent");
73 /// Returns 'op' if 'op' lies in this block, or otherwise finds the
74 /// ancestor operation of 'op' that lies in this block. Returns nullptr if
76 Operation *Block::findAncestorOpInBlock(Operation &op) {
78 // find the ancestor operation that resides in the block of 'forOp'.
88 /// This drops all operand uses from operations within this block, which is
91 void Block::dropAllReferences() {
96 void Block::dropAllDefinedValueUses() {
106 bool Block::isOpOrderValid() { return parentValidOpOrderPair.getInt(); }
109 void Block::invalidateOpOrder() {
117 bool Block::verifyOpOrder() {
137 /// Recomputes the ordering of child operations within the block.
138 void Block::recomputeOpOrder() {
150 /// Return a range containing the types of the arguments for this block.
151 auto Block::getArgumentTypes() -> ValueTypeRange<BlockArgListType> {
155 BlockArgument Block::addArgument(Type type, Location loc) {
162 auto Block::addArguments(TypeRange types, ArrayRef<Location> locs)
165 "incorrect number of block argument locations");
174 BlockArgument Block::insertArgument(unsigned index, Type type, Location loc) {
188 /// arguments are shifted. The block is expected not to have predecessors.
189 BlockArgument Block::insertArgument(args_iterator it, Type type, Location loc) {
195 void Block::eraseArgument(unsigned index) {
203 void Block::eraseArguments(unsigned start, unsigned num) {
212 void Block::eraseArguments(const BitVector &eraseIndices) {
217 void Block::eraseArguments(function_ref<bool(BlockArgument)> shouldEraseFn) {
244 /// Get the terminator operation of this block. This function asserts that
245 /// the block might have a valid terminator operation.
246 Operation *Block::getTerminator() {
251 /// Check whether this block might have a terminator.
252 bool Block::mightHaveTerminator() {
257 unsigned Block::getNumSuccessors() {
261 Block *Block::getSuccessor(unsigned i) {
266 /// If this block has exactly one predecessor, return it. Otherwise, return
269 /// Note that multiple edges from a single block (e.g. if you have a cond
270 /// branch with the same block as the true/false destinations) is not
272 Block *Block::getSinglePredecessor() {
281 /// If this block has a unique predecessor, i.e., all incoming edges originate
282 /// from one block, return it. Otherwise, return null.
283 Block *Block::getUniquePredecessor() {
300 /// Split the block into two blocks before the specified operation or
304 /// the original basic block, and the rest of the operations in the original
305 /// block are moved to the new block, including the old terminator. The
306 /// original block is left without a terminator.
308 /// The newly formed Block is returned, and the specified iterator is
310 Block *Block::splitBlock(iterator splitBefore) {
311 // Start by creating a new basic block, and insert it immediate after this
313 auto *newBB = new Block();
317 // into the new block.
327 Block *PredecessorIterator::unwrap(BlockOperand &value) {
342 SuccessorRange::SuccessorRange(Block *block) : SuccessorRange() {
343 if (block->empty() || llvm::hasSingleElement(*block->getParent()))
345 Operation *term = &block->back();
355 bool Block::isReachable(Block *other, SmallPtrSet<Block *, 16> &&except) {
359 // "this" to `other` (that does not pass through an excluded block).
362 SmallVector<Block *> worklist(succ_begin(), succ_end());
364 Block *next = worklist.pop_back_val();
379 BlockRange::BlockRange(ArrayRef<Block *> blocks) : BlockRange(nullptr, 0) {
391 return {llvm::dyn_cast_if_present<Block *const *>(object) + index};
395 Block *BlockRange::dereference_iterator(OwnerT object, ptrdiff_t index) {
398 return llvm::dyn_cast_if_present<Block *const *>(object)[index];