My Project
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::Block Class Reference

Block represents an ordered list of Operations. More...

#include <Block.h>

Inheritance diagram for mlir::Block:
Inheritance graph
[legend]
Collaboration diagram for mlir::Block:
Collaboration graph
[legend]

Classes

class  op_iterator
 

Public Types

using BlockArgListType = MutableArrayRef< BlockArgument >
 
using args_iterator = BlockArgListType::iterator
 
using reverse_args_iterator = BlockArgListType::reverse_iterator
 
using OpListType = llvm::iplist< Operation >
 This is the list of operations in the block. More...
 
using iterator = OpListType::iterator
 
using reverse_iterator = OpListType::reverse_iterator
 
using pred_iterator = PredecessorIterator
 
using succ_iterator = SuccessorRange::iterator
 
- Public Types inherited from mlir::IRObjectWithUseList< BlockOperand >
using use_iterator = ValueUseIterator< BlockOperand >
 
using use_range = iterator_range< use_iterator >
 
using user_iterator = ValueUserIterator< use_iterator, BlockOperand >
 
using user_range = iterator_range< user_iterator >
 

Public Member Functions

 Block ()
 
 ~Block ()
 
void clear ()
 
RegiongetParent () const
 
OperationgetParentOp ()
 Returns the closest surrounding operation that contains this block. More...
 
bool isEntryBlock ()
 Return if this block is the entry block in the parent region. More...
 
void insertBefore (Block *block)
 
void moveBefore (Block *block)
 
void erase ()
 Unlink this Block from its parent region and delete it. More...
 
BlockArgListType getArguments ()
 
args_iterator args_begin ()
 
args_iterator args_end ()
 
reverse_args_iterator args_rbegin ()
 
reverse_args_iterator args_rend ()
 
bool args_empty ()
 
BlockArgument addArgument (Type type)
 Add one value to the argument list. More...
 
BlockArgument insertArgument (args_iterator it, Type type)
 
iterator_range< args_iteratoraddArguments (ArrayRef< Type > types)
 Add one argument to the argument list for each type specified in the list. More...
 
void eraseArgument (unsigned index, bool updatePredTerms=true)
 
unsigned getNumArguments ()
 
BlockArgument getArgument (unsigned i)
 
OpListTypegetOperations ()
 
iterator begin ()
 
iterator end ()
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
bool empty ()
 
void push_back (Operation *op)
 
void push_front (Operation *op)
 
Operationback ()
 
Operationfront ()
 
OperationfindAncestorOpInBlock (Operation &op)
 
void dropAllReferences ()
 
void dropAllDefinedValueUses ()
 
bool isOpOrderValid ()
 
void invalidateOpOrder ()
 Invalidates the current ordering of operations. More...
 
bool verifyOpOrder ()
 
void recomputeOpOrder ()
 Recomputes the ordering of child operations within the block. More...
 
template<typename OpT >
iterator_range< op_iterator< OpT > > getOps ()
 
template<typename OpT >
op_iterator< OpT > op_begin ()
 
template<typename OpT >
op_iterator< OpT > op_end ()
 
iterator_range< iteratorwithout_terminator ()
 
OperationgetTerminator ()
 
pred_iterator pred_begin ()
 
pred_iterator pred_end ()
 
iterator_range< pred_iteratorgetPredecessors ()
 
bool hasNoPredecessors ()
 Return true if this block has no predecessors. More...
 
BlockgetSinglePredecessor ()
 
unsigned getNumSuccessors ()
 
BlockgetSuccessor (unsigned i)
 
succ_iterator succ_begin ()
 
succ_iterator succ_end ()
 
SuccessorRange getSuccessors ()
 
template<typename FnT , typename RetT = detail::walkResultType<FnT>>
RetT walk (FnT &&callback)
 
template<typename FnT , typename RetT = detail::walkResultType<FnT>>
std::enable_if< std::is_same< RetT, void >::value, RetT >::type walk (Block::iterator begin, Block::iterator end, FnT &&callback)
 
template<typename FnT , typename RetT = detail::walkResultType<FnT>>
std::enable_if< std::is_same< RetT, WalkResult >::value, RetT >::type walk (Block::iterator begin, Block::iterator end, FnT &&callback)
 
BlocksplitBlock (iterator splitBefore)
 
BlocksplitBlock (Operation *splitBeforeOp)
 
void print (raw_ostream &os)
 
void dump ()
 
void printAsOperand (raw_ostream &os, bool printType=true)
 Print out the name of the block without printing its body. More...
 
- Public Member Functions inherited from mlir::IRObjectWithUseList< BlockOperand >
 ~IRObjectWithUseList ()
 
void dropAllUses ()
 Drop all uses of this object from their respective owners. More...
 
void replaceAllUsesWith (typename BlockOperand ::ValueType newValue)
 
use_iterator use_begin () const
 
use_iterator use_end () const
 
use_range getUses () const
 Returns a range of all uses, which is useful for iterating over all uses. More...
 
bool hasOneUse () const
 Returns true if this value has exactly one use. More...
 
bool use_empty () const
 Returns true if this value has no uses. More...
 
user_iterator user_begin () const
 
user_iterator user_end () const
 
user_range getUsers () const
 Returns a range of all users. More...
 

Static Public Member Functions

static OpListType Block::* getSublistAccess (Operation *)
 Returns pointer to member of operation list. More...
 

Friends

struct llvm::ilist_traits< Block >
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::IRObjectWithUseList< BlockOperand >
 IRObjectWithUseList ()
 
BlockOperandgetFirstUse () const
 

Detailed Description

Block represents an ordered list of Operations.

Member Typedef Documentation

◆ args_iterator

using mlir::Block::args_iterator = BlockArgListType::iterator

◆ BlockArgListType

◆ iterator

using mlir::Block::iterator = OpListType::iterator

◆ OpListType

using mlir::Block::OpListType = llvm::iplist<Operation>

This is the list of operations in the block.

◆ pred_iterator

◆ reverse_args_iterator

using mlir::Block::reverse_args_iterator = BlockArgListType::reverse_iterator

◆ reverse_iterator

using mlir::Block::reverse_iterator = OpListType::reverse_iterator

◆ succ_iterator

using mlir::Block::succ_iterator = SuccessorRange::iterator

Constructor & Destructor Documentation

◆ Block()

mlir::Block::Block ( )
inlineexplicit

◆ ~Block()

Block::~Block ( )

Member Function Documentation

◆ addArgument()

BlockArgument Block::addArgument ( Type  type)

Add one value to the argument list.

◆ addArguments()

auto Block::addArguments ( ArrayRef< Type types)

Add one argument to the argument list for each type specified in the list.

◆ args_begin()

args_iterator mlir::Block::args_begin ( )
inline

◆ args_empty()

bool mlir::Block::args_empty ( )
inline

◆ args_end()

args_iterator mlir::Block::args_end ( )
inline

◆ args_rbegin()

reverse_args_iterator mlir::Block::args_rbegin ( )
inline

◆ args_rend()

reverse_args_iterator mlir::Block::args_rend ( )
inline

◆ back()

Operation& mlir::Block::back ( )
inline

◆ begin()

iterator mlir::Block::begin ( )
inline

◆ clear()

void mlir::Block::clear ( )
inline

◆ dropAllDefinedValueUses()

void Block::dropAllDefinedValueUses ( )

This drops all uses of values defined in this block or in the blocks of nested regions wherever the uses are located.

◆ dropAllReferences()

void Block::dropAllReferences ( )

This drops all operand uses from operations within this block, which is an essential step in breaking cyclic dependences between references when they are to be deleted.

◆ dump()

void Block::dump ( )

◆ empty()

bool mlir::Block::empty ( )
inline

◆ end()

iterator mlir::Block::end ( )
inline

◆ erase()

void Block::erase ( )

Unlink this Block from its parent region and delete it.

Unlink this Block from its parent Region and delete it.

◆ eraseArgument()

void Block::eraseArgument ( unsigned  index,
bool  updatePredTerms = true 
)

Erase the argument at 'index' and remove it from the argument list. If 'updatePredTerms' is set to true, this argument is also removed from the terminators of each predecessor to this block.

◆ findAncestorOpInBlock()

Operation * Block::findAncestorOpInBlock ( Operation op)

Returns 'op' if 'op' lies in this block, or otherwise finds the ancestor operation of 'op' that lies in this block. Returns nullptr if the latter fails. TODO: This is very specific functionality that should live somewhere else, probably in Dominance.cpp.

Returns 'op' if 'op' lies in this block, or otherwise finds the ancestor operation of 'op' that lies in this block. Returns nullptr if the latter fails.

◆ front()

Operation& mlir::Block::front ( )
inline

◆ getArgument()

BlockArgument mlir::Block::getArgument ( unsigned  i)
inline

◆ getArguments()

BlockArgListType mlir::Block::getArguments ( )
inline

◆ getNumArguments()

unsigned mlir::Block::getNumArguments ( )
inline

◆ getNumSuccessors()

unsigned Block::getNumSuccessors ( )

◆ getOperations()

OpListType& mlir::Block::getOperations ( )
inline

◆ getOps()

template<typename OpT >
iterator_range<op_iterator<OpT> > mlir::Block::getOps ( )
inline

Return an iterator range over the operations within this block that are of 'OpT'.

◆ getParent()

Region * Block::getParent ( ) const

Provide a 'getParent' method for ilist_node_with_parent methods. We mark it as a const function because ilist_node_with_parent specifically requires a 'getParent() const' method. Once ilist_node removes this constraint, we should drop the const to fit the rest of the MLIR const model.

◆ getParentOp()

Operation * Block::getParentOp ( )

Returns the closest surrounding operation that contains this block.

Returns the closest surrounding operation that contains this block or nullptr if this block is unlinked.

◆ getPredecessors()

iterator_range<pred_iterator> mlir::Block::getPredecessors ( )
inline

◆ getSinglePredecessor()

Block * Block::getSinglePredecessor ( )

If this block has exactly one predecessor, return it. Otherwise, return null.

Note that if a block has duplicate predecessors from a single block (e.g. if you have a conditional branch with the same block as the true/false destinations) is not considered to be a single predecessor.

If this block has exactly one predecessor, return it. Otherwise, return null.

Note that multiple edges from a single block (e.g. if you have a cond branch with the same block as the true/false destinations) is not considered to be a single predecessor.

◆ getSublistAccess()

static OpListType Block::* mlir::Block::getSublistAccess ( Operation )
inlinestatic

Returns pointer to member of operation list.

◆ getSuccessor()

Block * Block::getSuccessor ( unsigned  i)

◆ getSuccessors()

SuccessorRange mlir::Block::getSuccessors ( )
inline

◆ getTerminator()

Operation * Block::getTerminator ( )

Get the terminator operation of this block. This function asserts that the block has a valid terminator operation.

◆ hasNoPredecessors()

bool Block::hasNoPredecessors ( )

Return true if this block has no predecessors.

◆ insertArgument()

BlockArgument Block::insertArgument ( args_iterator  it,
Type  type 
)

Insert one value to the position in the argument list indicated by the given iterator. The existing arguments are shifted. The block is expected not to have predecessors.

Insert one value to the given position of the argument list. The existing arguments are shifted. The block is expected not to have predecessors.

◆ insertBefore()

void Block::insertBefore ( Block block)

Insert this block (which must not already be in a region) right before the specified block.

◆ invalidateOpOrder()

void Block::invalidateOpOrder ( )

Invalidates the current ordering of operations.

◆ isEntryBlock()

bool Block::isEntryBlock ( )

Return if this block is the entry block in the parent region.

◆ isOpOrderValid()

bool Block::isOpOrderValid ( )

Returns true if the ordering of the child operations is valid, false otherwise.

◆ moveBefore()

void Block::moveBefore ( Block block)

Unlink this block from its current region and insert it right before the specific block.

◆ op_begin()

template<typename OpT >
op_iterator<OpT> mlir::Block::op_begin ( )
inline

◆ op_end()

template<typename OpT >
op_iterator<OpT> mlir::Block::op_end ( )
inline

◆ pred_begin()

pred_iterator mlir::Block::pred_begin ( )
inline

◆ pred_end()

pred_iterator mlir::Block::pred_end ( )
inline

◆ print()

void Block::print ( raw_ostream &  os)

◆ printAsOperand()

void Block::printAsOperand ( raw_ostream &  os,
bool  printType = true 
)

Print out the name of the block without printing its body.

Print out the name of the block without printing its body. NOTE: The printType argument is ignored. We keep it for compatibility with LLVM dominator machinery that expects it to exist.

◆ push_back()

void mlir::Block::push_back ( Operation op)
inline

◆ push_front()

void mlir::Block::push_front ( Operation op)
inline

◆ rbegin()

reverse_iterator mlir::Block::rbegin ( )
inline

◆ recomputeOpOrder()

void Block::recomputeOpOrder ( )

Recomputes the ordering of child operations within the block.

◆ rend()

reverse_iterator mlir::Block::rend ( )
inline

◆ splitBlock() [1/2]

Block * Block::splitBlock ( iterator  splitBefore)

Split the block into two blocks before the specified operation or iterator.

Note that all operations BEFORE the specified iterator stay as part of the original basic block, and the rest of the operations in the original block are moved to the new block, including the old terminator. The original block is left without a terminator.

The newly formed Block is returned, and the specified iterator is invalidated.

◆ splitBlock() [2/2]

Block* mlir::Block::splitBlock ( Operation splitBeforeOp)
inline

◆ succ_begin()

succ_iterator mlir::Block::succ_begin ( )
inline

◆ succ_end()

succ_iterator mlir::Block::succ_end ( )
inline

◆ verifyOpOrder()

bool Block::verifyOpOrder ( )

Verifies the current ordering of child operations matches the validOpOrder flag. Returns false if the order is valid, true otherwise.

Verifies the current ordering of child operations. Returns false if the order is valid, true otherwise.

◆ walk() [1/3]

template<typename FnT , typename RetT = detail::walkResultType<FnT>>
RetT mlir::Block::walk ( FnT &&  callback)
inline

Walk the operations in this block in postorder, calling the callback for each operation. See Operation::walk for more details.

◆ walk() [2/3]

template<typename FnT , typename RetT = detail::walkResultType<FnT>>
std::enable_if<std::is_same<RetT, void>::value, RetT>::type mlir::Block::walk ( Block::iterator  begin,
Block::iterator  end,
FnT &&  callback 
)
inline

Walk the operations in the specified [begin, end) range of this block in postorder, calling the callback for each operation. This method is invoked for void return callbacks. See Operation::walk for more details.

◆ walk() [3/3]

template<typename FnT , typename RetT = detail::walkResultType<FnT>>
std::enable_if<std::is_same<RetT, WalkResult>::value, RetT>::type mlir::Block::walk ( Block::iterator  begin,
Block::iterator  end,
FnT &&  callback 
)
inline

Walk the operations in the specified [begin, end) range of this block in postorder, calling the callback for each operation. This method is invoked for interruptible callbacks. See Operation::walk for more details.

◆ without_terminator()

iterator_range<iterator> mlir::Block::without_terminator ( )
inline

Return an iterator range over the operation within this block excluding the terminator operation at the end.

Friends And Related Function Documentation

◆ llvm::ilist_traits< Block >

friend struct llvm::ilist_traits< Block >
friend

The documentation for this class was generated from the following files: