13 #ifndef MLIR_IR_BLOCK_H
14 #define MLIR_IR_BLOCK_H
25 template <
typename ValueRangeT>
30 public llvm::ilist_node_with_parent<Block, Region> {
42 operations.pop_back();
141 bool empty() {
return operations.empty(); }
180 template <
typename OpT>
185 template <
typename OpT>
191 template <
typename OpT>
195 template <
typename OpT>
205 auto endIt = --
end();
206 return {
begin(), endIt};
281 return walk<Order, Iterator>(
begin(),
end(), std::forward<FnT>(callback));
298 std::enable_if_t<std::is_same<RetT, void>::value, RetT>
300 for (
auto &op : llvm::make_early_inc_range(llvm::make_range(
begin,
end)))
301 detail::walk<Order, Iterator>(&op, callback);
319 std::enable_if_t<std::is_same<RetT, WalkResult>::value, RetT>
321 for (
auto &op : llvm::make_early_inc_range(llvm::make_range(
begin,
end)))
322 if (detail::walk<Order, Iterator>(&op, callback).wasInterrupted())
348 return &Block::operations;
351 void print(raw_ostream &os);
364 llvm::PointerIntPair<
Region *, 1,
bool> parentValidOpOrderPair;
370 std::vector<BlockArgument> arguments;
375 friend struct llvm::ilist_traits<
Block>;
This class provides management for the lifetime of the state used when printing the IR.
This class represents an argument of a Block.
A block operand represents an operand that holds a reference to a Block, e.g.
Block represents an ordered list of Operations.
void recomputeOpOrder()
Recomputes the ordering of child operations within the block.
std::enable_if_t< std::is_same< RetT, void >::value, RetT > walk(Block::iterator begin, Block::iterator end, FnT &&callback)
Walk the operations in the specified [begin, end) range of this block.
OpListType::iterator iterator
Block * splitBlock(Operation *splitBeforeOp)
Operation * findAncestorOpInBlock(Operation &op)
Returns 'op' if 'op' lies in this block, or otherwise finds the ancestor operation of 'op' that lies ...
ValueTypeRange< BlockArgListType > getArgumentTypes()
Return a range containing the types of the arguments for this block.
unsigned getNumSuccessors()
void push_front(Operation *op)
SuccessorRange::iterator succ_iterator
BlockArgument getArgument(unsigned i)
bool hasNoSuccessors()
Returns true if this blocks has no successors.
unsigned getNumArguments()
void erase()
Unlink this Block from its parent region and delete it.
BlockArgument insertArgument(args_iterator it, Type type, Location loc)
Insert one value to the position in the argument list indicated by the given iterator.
iterator_range< args_iterator > addArguments(TypeRange types, ArrayRef< Location > locs)
Add one argument to the argument list for each type specified in the list.
Block * splitBlock(iterator splitBefore)
Split the block into two blocks before the specified operation or iterator.
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
bool isOpOrderValid()
Returns true if the ordering of the child operations is valid, false otherwise.
op_iterator< OpT > op_begin()
BlockArgListType::reverse_iterator reverse_args_iterator
pred_iterator pred_begin()
void dropAllDefinedValueUses()
This drops all uses of values defined in this block or in the blocks of nested regions wherever the u...
bool verifyOpOrder()
Verifies the current ordering of child operations matches the validOpOrder flag.
SuccessorRange getSuccessors()
void invalidateOpOrder()
Invalidates the current ordering of operations.
Block * getSinglePredecessor()
If this block has exactly one predecessor, return it.
void printAsOperand(raw_ostream &os, bool printType=true)
Print out the name of the block without printing its body.
reverse_args_iterator args_rend()
void insertAfter(Block *block)
Insert this block (which must not already be in a region) right after the specified block.
Operation * getTerminator()
Get the terminator operation of this block.
succ_iterator succ_begin()
iterator_range< pred_iterator > getPredecessors()
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
RetT walk(FnT &&callback)
Walk the operations in this block.
std::enable_if_t< std::is_same< RetT, WalkResult >::value, RetT > walk(Block::iterator begin, Block::iterator end, FnT &&callback)
Walk the operations in the specified [begin, end) range of this block.
void eraseArguments(unsigned start, unsigned num)
Erases 'num' arguments from the index 'start'.
OpListType & getOperations()
void print(raw_ostream &os)
bool mightHaveTerminator()
Check whether this block might have a terminator.
BlockArgListType getArguments()
PredecessorIterator pred_iterator
Block * getUniquePredecessor()
If this block has a unique predecessor, i.e., all incoming edges originate from one block,...
op_iterator< OpT > op_end()
void eraseArgument(unsigned index)
Erase the argument at 'index' and remove it from the argument list.
iterator_range< op_iterator< OpT > > getOps()
Return an iterator range over the operations within this block that are of 'OpT'.
Block * getSuccessor(unsigned i)
args_iterator args_begin()
bool isEntryBlock()
Return if this block is the entry block in the parent region.
void dropAllReferences()
This drops all operand uses from operations within this block, which is an essential step in breaking...
void insertBefore(Block *block)
Insert this block (which must not already be in a region) right before the specified block.
void moveBefore(Block *block)
Unlink this block from its current region and insert it right before the specific block.
void push_back(Operation *op)
reverse_args_iterator args_rbegin()
bool hasNoPredecessors()
Return true if this block has no predecessors.
static OpListType Block::* getSublistAccess(Operation *)
Returns pointer to member of operation list.
iterator_range< iterator > without_terminator()
Return an iterator range over the operation within this block excluding the terminator operation at t...
Operation * getParentOp()
Returns the closest surrounding operation that contains this block.
BlockArgListType::iterator args_iterator
reverse_iterator rbegin()
OpListType::reverse_iterator reverse_iterator
llvm::iplist< Operation > OpListType
This is the list of operations in the block.
This class represents a single IR object that contains a use list.
BlockOperand * getFirstUse() const
Return the first operand that is using this value, for use by custom use/def iterators.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation is the basic unit of execution within MLIR.
Implement a predecessor iterator for blocks.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class implements the successor iterators for Block.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class implements iteration on the types of a given range of values.
static WalkResult advance()
static WalkResult interrupt()
A utility iterator that filters out operations that are not 'OpT'.
This class provides iteration over the held operations of a block for a specific operation type.
Include the generated interface declarations.
void printType(Type type, AsmPrinter &printer)
Prints an LLVM Dialect type.
decltype(walk(nullptr, std::declval< FnT >())) walkResultType
Utility to provide the return type of a templated walk method.
This header declares functions that assist transformations in the MemRef dialect.
WalkOrder
Traversal order for region, block and operation walk utilities.
This iterator enumerates the elements in "forward" order.