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> {
32 explicit Block() =
default;
42 operations.pop_back();
60 void insertBefore(
Block *block);
64 void moveBefore(
Block *block);
107 void eraseArgument(
unsigned index);
114 void eraseArguments(
const BitVector &eraseIndices);
139 bool empty() {
return operations.empty(); }
156 void dropAllReferences();
160 void dropAllDefinedValueUses();
164 bool isOpOrderValid();
167 void invalidateOpOrder();
171 bool verifyOpOrder();
174 void recomputeOpOrder();
178 template <
typename OpT>
183 template <
typename OpT>
189 template <
typename OpT>
193 template <
typename OpT>
201 if (begin() == end())
202 return {begin(), end()};
203 auto endIt = --end();
204 return {begin(), endIt};
226 return {pred_begin(), pred_end()};
241 Block *getSinglePredecessor();
245 Block *getUniquePredecessor();
248 unsigned getNumSuccessors();
249 Block *getSuccessor(
unsigned i);
271 template <
WalkOrder Order = WalkOrder::PostOrder,
typename FnT,
274 return walk<Order>(begin(), end(), std::forward<FnT>(callback));
287 template <
WalkOrder Order = WalkOrder::PostOrder,
typename FnT,
291 for (
auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
292 detail::walk<Order>(&op, callback);
306 template <
WalkOrder Order = WalkOrder::PostOrder,
typename FnT,
310 for (
auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
311 if (detail::walk<Order>(&op, callback).wasInterrupted())
312 return WalkResult::interrupt();
313 return WalkResult::advance();
332 return splitBlock(
iterator(splitBeforeOp));
337 return &Block::operations;
340 void print(raw_ostream &os);
347 void printAsOperand(raw_ostream &os,
bool printType =
true);
348 void printAsOperand(raw_ostream &os,
AsmState &state);
353 llvm::PointerIntPair<
Region *, 1,
bool> parentValidOpOrderPair;
359 std::vector<BlockArgument> arguments;
362 void operator=(
Block &) =
delete;
364 friend struct llvm::ilist_traits<
Block>;
368 #endif // MLIR_IR_BLOCK_H std::enable_if< std::is_same< RetT, WalkResult >::value, RetT >::type walk(Block::iterator begin, Block::iterator end, FnT &&callback)
Walk the operations in the specified [begin, end) range of this block.
Include the generated interface declarations.
This class contains a list of basic blocks and a link to the parent operation it is attached to...
Explicitly register a set of "builtin" types.
Operation is a basic unit of execution within MLIR.
Block represents an ordered list of Operations.
OpListType::reverse_iterator reverse_iterator
OpListType & getOperations()
A block operand represents an operand that holds a reference to a Block, e.g.
void printType(Type type, AsmPrinter &printer)
Prints an LLVM Dialect type.
iterator_range< pred_iterator > getPredecessors()
args_iterator args_begin()
void push_front(Operation *op)
iterator_range< iterator > without_terminator()
Return an iterator range over the operation within this block excluding the terminator operation at t...
reverse_args_iterator args_rend()
BlockArgument getArgument(unsigned i)
static constexpr const bool value
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
decltype(walk(nullptr, std::declval< FnT >())) walkResultType
Utility to provide the return type of a templated walk method.
BlockArgListType::iterator args_iterator
This class represents a single IR object that contains a use list.
Block * splitBlock(Operation *splitBeforeOp)
OpListType::iterator iterator
SuccessorRange::iterator succ_iterator
reverse_iterator rbegin()
unsigned getNumArguments()
This class provides an abstraction over the various different ranges of value types.
RetT walk(FnT &&callback)
Walk the operations in this block.
BlockArgListType getArguments()
This class represents an argument of a Block.
reverse_args_iterator args_rbegin()
BlockArgListType::reverse_iterator reverse_args_iterator
static void print(ArrayType type, DialectAsmPrinter &os)
This class implements the successor iterators for Block.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides iteration over the held operations of a block for a specific operation type...
static OpListType Block::* getSublistAccess(Operation *)
Returns pointer to member of operation list.
This class implements iteration on the types of a given range of values.
void push_back(Operation *op)
op_iterator< OpT > op_begin()
std::enable_if< std::is_same< RetT, void >::value, RetT >::type walk(Block::iterator begin, Block::iterator end, FnT &&callback)
Walk the operations in the specified [begin, end) range of this block.
llvm::iplist< Operation > OpListType
This is the list of operations in the block.
bool hasNoSuccessors()
Returns true if this blocks has no successors.
iterator_range< op_iterator< OpT > > getOps()
Return an iterator range over the operations within this block that are of 'OpT'. ...
bool hasNoPredecessors()
Return true if this block has no predecessors.
Implement a predecessor iterator for blocks.
A utility iterator that filters out operations that are not 'OpT'.
op_iterator< OpT > op_end()
SuccessorRange getSuccessors()
WalkOrder
Traversal order for region, block and operation walk utilities.
succ_iterator succ_begin()
This class provides management for the lifetime of the state used when printing the IR...
pred_iterator pred_begin()