MLIR  14.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::Operation Class Referencefinal

Operation is a basic unit of execution within MLIR. More...

#include "mlir/IR/Operation.h"

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

Classes

class  dialect_attr_iterator
 A utility iterator that filters out non-dialect attributes. More...
 

Public Types

using operand_range = OperandRange
 
using operand_iterator = operand_range::iterator
 
using operand_type_iterator = operand_range::type_iterator
 
using operand_type_range = operand_range::type_range
 
using result_range = ResultRange
 Support result iteration. More...
 
using result_iterator = result_range::iterator
 
using result_type_iterator = result_range::type_iterator
 Support result type iteration. More...
 
using result_type_range = result_range::type_range
 
using dialect_attr_range = iterator_range< dialect_attr_iterator >
 
using succ_iterator = SuccessorRange::iterator
 
using use_iterator = result_range::use_iterator
 
using use_range = result_range::use_range
 
using user_iterator = ValueUserIterator< use_iterator, OpOperand >
 
using user_range = iterator_range< user_iterator >
 

Public Member Functions

OperationName getName ()
 The name of an operation is the key identifier for it. More...
 
Optional< RegisteredOperationNamegetRegisteredInfo ()
 If this operation has a registered operation description, return it. More...
 
bool isRegistered ()
 Returns true if this operation has a registered operation description, otherwise false. More...
 
void erase ()
 Remove this operation from its parent block and delete it. More...
 
void remove ()
 Remove the operation from its parent block, but don't delete it. More...
 
Operationclone (BlockAndValueMapping &mapper)
 Create a deep copy of this operation, remapping any operands that use values outside of the operation using the map that is provided (leaving them alone if no entry is present). More...
 
Operationclone ()
 
OperationcloneWithoutRegions (BlockAndValueMapping &mapper)
 Create a partial copy of this operation without traversing into attached regions. More...
 
OperationcloneWithoutRegions ()
 Create a partial copy of this operation without traversing into attached regions. More...
 
BlockgetBlock ()
 Returns the operation block that contains this operation. More...
 
MLIRContextgetContext ()
 Return the context this operation is associated with. More...
 
DialectgetDialect ()
 Return the dialect this operation is associated with, or nullptr if the associated dialect is not loaded. More...
 
Location getLoc ()
 The source location the operation was defined or derived from. More...
 
void setLoc (Location loc)
 Set the source location the operation was defined or derived from. More...
 
RegiongetParentRegion ()
 Returns the region to which the instruction belongs. More...
 
OperationgetParentOp ()
 Returns the closest surrounding operation that contains this operation or nullptr if this is a top-level operation. More...
 
template<typename OpTy >
OpTy getParentOfType ()
 Return the closest surrounding parent operation that is of type 'OpTy'. More...
 
template<template< typename T > class Trait>
OperationgetParentWithTrait ()
 Returns the closest surrounding parent operation with trait Trait. More...
 
bool isProperAncestor (Operation *other)
 Return true if this operation is a proper ancestor of the other operation. More...
 
bool isAncestor (Operation *other)
 Return true if this operation is an ancestor of the other operation. More...
 
void replaceUsesOfWith (Value from, Value to)
 Replace any uses of 'from' with 'to' within this operation. More...
 
template<typename ValuesT >
void replaceAllUsesWith (ValuesT &&values)
 Replace all uses of results of this operation with the provided 'values'. More...
 
void destroy ()
 Destroys this operation and its subclass data. More...
 
void dropAllReferences ()
 This drops all operand uses from this operation, which is an essential step in breaking cyclic dependences between references when they are to be deleted. More...
 
void dropAllDefinedValueUses ()
 Drop uses of all values defined by this operation or its nested regions. More...
 
void moveBefore (Operation *existingOp)
 Unlink this operation from its current block and insert it right before existingOp which may be in the same or another block in the same function. More...
 
void moveBefore (Block *block, llvm::iplist< Operation >::iterator iterator)
 Unlink this operation from its current block and insert it right before iterator in the specified block. More...
 
void moveAfter (Operation *existingOp)
 Unlink this operation from its current block and insert it right after existingOp which may be in the same or another block in the same function. More...
 
void moveAfter (Block *block, llvm::iplist< Operation >::iterator iterator)
 Unlink this operation from its current block and insert it right after iterator in the specified block. More...
 
bool isBeforeInBlock (Operation *other)
 Given an operation 'other' that is within the same parent block, return whether the current operation is before 'other' in the operation list of the parent block. More...
 
void print (raw_ostream &os, const OpPrintingFlags &flags=llvm::None)
 
void print (raw_ostream &os, AsmState &state, const OpPrintingFlags &flags=llvm::None)
 
void dump ()
 
void setOperands (ValueRange operands)
 Replace the current operands of this operation with the ones provided in 'operands'. More...
 
void setOperands (unsigned start, unsigned length, ValueRange operands)
 Replace the operands beginning at 'start' and ending at 'start' + 'length' with the ones provided in 'operands'. More...
 
void insertOperands (unsigned index, ValueRange operands)
 Insert the given operands into the operand list at the given 'index'. More...
 
unsigned getNumOperands ()
 
Value getOperand (unsigned idx)
 
void setOperand (unsigned idx, Value value)
 
void eraseOperand (unsigned idx)
 Erase the operand at position idx. More...
 
void eraseOperands (unsigned idx, unsigned length=1)
 Erase the operands starting at position idx and ending at position 'idx'+'length'. More...
 
void eraseOperands (const llvm::BitVector &eraseIndices)
 Erases the operands that have their corresponding bit set in eraseIndices and removes them from the operand list. More...
 
operand_iterator operand_begin ()
 
operand_iterator operand_end ()
 
operand_range getOperands ()
 Returns an iterator on the underlying Value's. More...
 
MutableArrayRef< OpOperandgetOpOperands ()
 
OpOperandgetOpOperand (unsigned idx)
 
operand_type_iterator operand_type_begin ()
 
operand_type_iterator operand_type_end ()
 
operand_type_range getOperandTypes ()
 
unsigned getNumResults ()
 Return the number of results held by this operation. More...
 
OpResult getResult (unsigned idx)
 Get the 'idx'th result of this operation. More...
 
result_iterator result_begin ()
 
result_iterator result_end ()
 
result_range getResults ()
 
result_range getOpResults ()
 
OpResult getOpResult (unsigned idx)
 
result_type_iterator result_type_begin ()
 
result_type_iterator result_type_end ()
 
result_type_range getResultTypes ()
 
ArrayRef< NamedAttributegetAttrs ()
 Return all of the attributes on this operation. More...
 
DictionaryAttr getAttrDictionary ()
 Return all of the attributes on this operation as a DictionaryAttr. More...
 
void setAttrs (DictionaryAttr newAttrs)
 Set the attribute dictionary on this operation. More...
 
void setAttrs (ArrayRef< NamedAttribute > newAttrs)
 
Attribute getAttr (StringAttr name)
 Return the specified attribute if present, null otherwise. More...
 
Attribute getAttr (StringRef name)
 
template<typename AttrClass >
AttrClass getAttrOfType (StringAttr name)
 
template<typename AttrClass >
AttrClass getAttrOfType (StringRef name)
 
bool hasAttr (StringAttr name)
 Return true if the operation has an attribute with the provided name, false otherwise. More...
 
bool hasAttr (StringRef name)
 
template<typename AttrClass , typename NameT >
bool hasAttrOfType (NameT &&name)
 
void setAttr (StringAttr name, Attribute value)
 If the an attribute exists with the specified name, change it to the new value. More...
 
void setAttr (StringRef name, Attribute value)
 
Attribute removeAttr (StringAttr name)
 Remove the attribute with the specified name if it exists. More...
 
Attribute removeAttr (StringRef name)
 
dialect_attr_range getDialectAttrs ()
 Return a range corresponding to the dialect attributes for this operation. More...
 
dialect_attr_iterator dialect_attr_begin ()
 
dialect_attr_iterator dialect_attr_end ()
 
template<typename DialectAttrT >
void setDialectAttrs (DialectAttrT &&dialectAttrs)
 Set the dialect attributes for this operation, and preserve all dependent. More...
 
unsigned getNumRegions ()
 Returns the number of regions held by this operation. More...
 
MutableArrayRef< RegiongetRegions ()
 Returns the regions held by this operation. More...
 
RegiongetRegion (unsigned index)
 Returns the region held by this operation at position 'index'. More...
 
MutableArrayRef< BlockOperandgetBlockOperands ()
 
succ_iterator successor_begin ()
 
succ_iterator successor_end ()
 
SuccessorRange getSuccessors ()
 
bool hasSuccessors ()
 
unsigned getNumSuccessors ()
 
BlockgetSuccessor (unsigned index)
 
void setSuccessor (Block *block, unsigned index)
 
LogicalResult fold (ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results)
 Attempt to fold this operation with the specified constant operand values. More...
 
template<template< typename T > class Trait>
bool hasTrait ()
 Returns true if the operation was registered with a particular trait, e.g. More...
 
template<template< typename T > class Trait>
bool mightHaveTrait ()
 Returns true if the operation might have the provided trait. More...
 
template<WalkOrder Order = WalkOrder::PostOrder, typename FnT , typename RetT = detail::walkResultType<FnT>>
RetT walk (FnT &&callback)
 Walk the operation by calling the callback for each nested operation (including this one), block or region, depending on the callback provided. More...
 
void dropAllUses ()
 Drop all uses of results of this operation. More...
 
use_iterator use_begin ()
 
use_iterator use_end ()
 
use_range getUses ()
 Returns a range of all uses, which is useful for iterating over all uses. More...
 
bool hasOneUse ()
 Returns true if this operation has exactly one use. More...
 
bool use_empty ()
 Returns true if this operation has no uses. More...
 
bool isUsedOutsideOfBlock (Block *block)
 Returns true if the results of this operation are used outside of the given block. More...
 
user_iterator user_begin ()
 
user_iterator user_end ()
 
user_range getUsers ()
 Returns a range of all users. More...
 
InFlightDiagnostic emitOpError (const Twine &message={})
 Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers. More...
 
InFlightDiagnostic emitError (const Twine &message={})
 Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers that may be listening. More...
 
InFlightDiagnostic emitWarning (const Twine &message={})
 Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening. More...
 
InFlightDiagnostic emitRemark (const Twine &message={})
 Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening. More...
 

Static Public Member Functions

static Operationcreate (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, ArrayRef< NamedAttribute > attributes, BlockRange successors, unsigned numRegions)
 Create a new Operation with the specific fields. More...
 
static Operationcreate (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, DictionaryAttr attributes, BlockRange successors, unsigned numRegions)
 Overload of create that takes an existing DictionaryAttr to avoid unnecessarily uniquing a list of attributes. More...
 
static Operationcreate (const OperationState &state)
 Create a new Operation from the fields stored in state. More...
 
static Operationcreate (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, DictionaryAttr attributes, BlockRange successors={}, RegionRange regions={})
 Create a new Operation with the specific fields. More...
 

Friends

struct llvm::ilist_traits< Operation >
 
class Block
 
class Value
 
class llvm::ilist_node_with_parent< Operation, Block >
 

Detailed Description

Operation is a basic unit of execution within MLIR.

Operations can be nested within Regions held by other operations effectively forming a tree. Child operations are organized into operation blocks represented by a 'Block' class.

Definition at line 28 of file Operation.h.

Member Typedef Documentation

◆ dialect_attr_range

Definition at line 387 of file Operation.h.

◆ operand_iterator

using mlir::Operation::operand_iterator = operand_range::iterator

Definition at line 241 of file Operation.h.

◆ operand_range

Definition at line 240 of file Operation.h.

◆ operand_type_iterator

Definition at line 262 of file Operation.h.

◆ operand_type_range

Definition at line 263 of file Operation.h.

◆ result_iterator

using mlir::Operation::result_iterator = result_range::iterator

Definition at line 280 of file Operation.h.

◆ result_range

Support result iteration.

Definition at line 279 of file Operation.h.

◆ result_type_iterator

Support result type iteration.

Definition at line 293 of file Operation.h.

◆ result_type_range

Definition at line 294 of file Operation.h.

◆ succ_iterator

using mlir::Operation::succ_iterator = SuccessorRange::iterator

Definition at line 443 of file Operation.h.

◆ use_iterator

Definition at line 527 of file Operation.h.

◆ use_range

Definition at line 528 of file Operation.h.

◆ user_iterator

Definition at line 554 of file Operation.h.

◆ user_range

Definition at line 555 of file Operation.h.

Member Function Documentation

◆ clone() [1/2]

Operation * Operation::clone ( BlockAndValueMapping mapper)

Create a deep copy of this operation, remapping any operands that use values outside of the operation using the map that is provided (leaving them alone if no entry is present).

Replaces references to cloned sub-operations to the corresponding operation that is copied, and adds those mappings to the map.

Definition at line 564 of file Operation.cpp.

References mlir::Region::cloneInto(), cloneWithoutRegions(), and getRegion().

Referenced by mlir::OpBuilder::clone(), mlir::spirv::Deserializer::collect(), convertToLaunchFuncOp(), fuse(), and verifyNamedStructuredOp().

◆ clone() [2/2]

Operation * Operation::clone ( )

Definition at line 574 of file Operation.cpp.

Referenced by isRegistered().

◆ cloneWithoutRegions() [1/2]

Operation * Operation::cloneWithoutRegions ( BlockAndValueMapping mapper)

Create a partial copy of this operation without traversing into attached regions.

Create a deep copy of this operation but keep the operation regions empty.

The new operation will have the same number of regions as the original one, but they will be left empty. Operands are remapped using mapper (if present), and mapper is updated to contain the results.

Operands are remapped using mapper (if present), and mapper is updated to contain the results.

Definition at line 529 of file Operation.cpp.

References create(), getLoc(), getName(), getNumOperands(), getNumRegions(), getNumResults(), getNumSuccessors(), getOperands(), getResult(), getResultTypes(), getSuccessors(), mlir::BlockAndValueMapping::lookupOrDefault(), and mlir::BlockAndValueMapping::map().

Referenced by mlir::OpBuilder::cloneWithoutRegions().

◆ cloneWithoutRegions() [2/2]

Operation * Operation::cloneWithoutRegions ( )

Create a partial copy of this operation without traversing into attached regions.

The new operation will have the same number of regions as the original one, but they will be left empty.

Definition at line 554 of file Operation.cpp.

Referenced by clone(), and isRegistered().

◆ create() [1/4]

Operation * Operation::create ( Location  location,
OperationName  name,
TypeRange  resultTypes,
ValueRange  operands,
ArrayRef< NamedAttribute attributes,
BlockRange  successors,
unsigned  numRegions 
)
static

◆ create() [2/4]

Operation * Operation::create ( Location  location,
OperationName  name,
TypeRange  resultTypes,
ValueRange  operands,
DictionaryAttr  attributes,
BlockRange  successors,
unsigned  numRegions 
)
static

◆ create() [3/4]

Operation * Operation::create ( const OperationState state)
static

◆ create() [4/4]

Operation * Operation::create ( Location  location,
OperationName  name,
TypeRange  resultTypes,
ValueRange  operands,
DictionaryAttr  attributes,
BlockRange  successors = {},
RegionRange  regions = {} 
)
static

Create a new Operation with the specific fields.

Definition at line 44 of file Operation.cpp.

References create(), getRegion(), and mlir::Region::takeBody().

◆ destroy()

void Operation::destroy ( )

Destroys this operation and its subclass data.

Destroy this operation or one of its subclasses.

Definition at line 171 of file Operation.cpp.

Referenced by mlir::OperationFolder::create(), mlir::OpBuilder::createOrFold(), llvm::ilist_traits<::mlir::Operation >::deleteNode(), erase(), and replaceAllUsesWith().

◆ dialect_attr_begin()

dialect_attr_iterator mlir::Operation::dialect_attr_begin ( )
inline

Definition at line 395 of file Operation.h.

References getAttrs().

◆ dialect_attr_end()

dialect_attr_iterator mlir::Operation::dialect_attr_end ( )
inline

Definition at line 399 of file Operation.h.

References getAttrs().

◆ dropAllDefinedValueUses()

void Operation::dropAllDefinedValueUses ( )

Drop uses of all values defined by this operation or its nested regions.

This drops all uses of any values defined by this operation or its nested regions, wherever they are located.

Definition at line 482 of file Operation.cpp.

References mlir::Block::dropAllDefinedValueUses(), dropAllUses(), and getRegions().

Referenced by replaceAllUsesWith().

◆ dropAllReferences()

void Operation::dropAllReferences ( )

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

Definition at line 469 of file Operation.cpp.

References getBlockOperands(), getOpOperands(), and getRegions().

Referenced by mlir::Block::dropAllReferences(), and replaceAllUsesWith().

◆ dropAllUses()

void mlir::Operation::dropAllUses ( )
inline

Drop all uses of results of this operation.

Definition at line 522 of file Operation.h.

References getOpResults().

Referenced by detachNestedAndErase(), and dropAllDefinedValueUses().

◆ dump()

void Operation::dump ( )

◆ emitError()

InFlightDiagnostic Operation::emitError ( const Twine &  message = {})

Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers that may be listening.

Definition at line 231 of file Operation.cpp.

References mlir::Diagnostic::append(), mlir::Diagnostic::appendOp(), mlir::InFlightDiagnostic::attachNote(), diag(), mlir::emitError(), getContext(), and getLoc().

Referenced by mlir::affineDataCopyGenerate(), mlir::linalg::comprehensive_bufferize::scf_ext::ExecuteRegionOpInterface::bufferize(), mlir::linalg::comprehensive_bufferize::bufferize(), mlir::linalg::comprehensive_bufferize::AllocationHoistingBarrierOnly< OpTy >::bufferize(), checkAffineLoopNestMappableImpl(), checkAndUpdateCapabilityRequirements(), checkAndUpdateExtensionRequirements(), mlir::MemRefRegion::compute(), convertOmpReductionOp(), convertStandaloneDataOp(), mlir::LLVM::detail::createIntrinsicCall(), diagnoseInvalidOperandDominance(), eachHasOnlyOneOfTypes(), emitOpError(), findLiveUserOfReplaced(), generateLocationsFromIR(), getEnclosingforOps(), getInsertExtractValueElementType(), getMemoryFootprintBytes(), getOrInsertBuiltinVariable(), mlir::spirv::getPushConstantValue(), mlir::linalg::comprehensive_bufferize::getResultBuffer(), getUsers(), mlir::insertBackwardComputationSlice(), legalizeUnresolvedMaterialization(), mlir::linalg::LinalgBasePromotionPattern::matchAndRewrite(), mayBeValidWithoutTerminator(), parseROCDLMubufStoreOp(), mlir::DataLayoutSpecAttr::print(), print(), printOperation(), validateSupportedControlFlow(), verify(), mlir::detail::verifyBranchSuccessorOperands(), mlir::impl::verifyCastOp(), mlir::OpTrait::impl::verifyCompatibleOperandBroadcast(), mlir::detail::verifyDataLayoutOp(), mlir::verifyListOfOperandsOrIntegers(), verifyMemorySemantics(), verifyPointerAndCoopMatrixType(), verifyRegionAttribute(), verifyShiftOp(), mlir::detail::verifySymbolTable(), verifyTerminatorSuccessors(), and walkReferenceCountedValues().

◆ emitOpError()

InFlightDiagnostic Operation::emitOpError ( const Twine &  message = {})

Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.

Definition at line 518 of file Operation.cpp.

References emitError(), and getName().

Referenced by create(), foldTransferInBoundsAttribute(), getInsertExtractValueElementType(), mlir::OpPassManager::getNesting(), getUsers(), inlineCallsInSCC(), GpuAsyncRegionPass::ThreadTokenCallback::operator()(), printOperation(), processOperands(), verify(), mlir::OpTrait::impl::verifyAtLeastNOperands(), mlir::OpTrait::impl::verifyAtLeastNRegions(), mlir::OpTrait::impl::verifyAtLeastNResults(), mlir::OpTrait::impl::verifyAtLeastNSuccessors(), verifyAtomicUpdateOp(), verifyAttributions(), mlir::impl::verifyCastInterfaceOp(), verifyCastOp(), mlir::OpTrait::impl::verifyCompatibleOperandBroadcast(), mlir::OpTrait::impl::verifyElementwise(), verifyGroupNonUniformArithmeticOp(), verifyHasBindingUse(), mlir::detail::verifyInferredResultTypes(), mlir::OpTrait::impl::verifyIsTerminator(), verifyMemoryOpIndexing(), verifyMultShape(), mlir::OpTrait::impl::verifyNOperands(), mlir::OpTrait::impl::verifyNoRegionArguments(), mlir::OpTrait::impl::verifyNRegions(), mlir::OpTrait::impl::verifyNResults(), mlir::OpTrait::impl::verifyNSuccessors(), mlir::OpTrait::impl::verifyOneOperand(), mlir::OpTrait::impl::verifyOneRegion(), mlir::OpTrait::impl::verifyOneResult(), mlir::OpTrait::impl::verifyOneSuccessor(), mlir::OpTrait::impl::verifyOperandsAreFloatLike(), mlir::OpTrait::impl::verifyOperandsAreSignlessIntegerLike(), verifyOpMetadata(), verifyReductionDeclareOp(), verifyReductionVarList(), mlir::OpTrait::impl::verifyResultsAreBoolLike(), mlir::OpTrait::impl::verifyResultsAreFloatLike(), mlir::OpTrait::impl::verifyResultsAreSignlessIntegerLike(), mlir::OpTrait::impl::verifySameOperandsAndResultElementType(), mlir::OpTrait::impl::verifySameOperandsAndResultShape(), mlir::OpTrait::impl::verifySameOperandsAndResultType(), mlir::OpTrait::impl::verifySameOperandsElementType(), mlir::OpTrait::impl::verifySameOperandsShape(), mlir::OpTrait::impl::verifySameTypeOperands(), verifyShapeOrExtentTensorOp(), verifySizeOrIndexOp(), mlir::linalg::detail::verifyStructuredOpInterface(), mlir::detail::verifySymbol(), verifySymbolAttribute(), verifySymbolAttrUse(), mlir::detail::verifySymbolTable(), verifySynchronizationHint(), verifyTileSize(), mlir::OpTrait::SingleBlock< ConcreteType >::verifyTrait(), mlir::OpTrait::SingleBlockImplicitTerminator< TerminatorOpType >::Impl< ConcreteType >::verifyTrait(), mlir::OpTrait::HasParent< ParentOpTypes >::Impl< ConcreteType >::verifyTrait(), verifyTypesAlongAllEdges(), mlir::detail::verifyTypesAlongControlFlowEdges(), mlir::OpTrait::impl::verifyValueSizeAttr(), verifyVectorMemoryOp(), mlir::OpTrait::impl::verifyZeroOperands(), mlir::OpTrait::impl::verifyZeroRegion(), mlir::OpTrait::impl::verifyZeroResult(), mlir::OpTrait::impl::verifyZeroSuccessor(), and walkReferenceCountedValues().

◆ emitRemark()

InFlightDiagnostic Operation::emitRemark ( const Twine &  message = {})

Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening.

Definition at line 252 of file Operation.cpp.

References mlir::InFlightDiagnostic::attachNote(), diag(), mlir::emitRemark(), getContext(), and getLoc().

Referenced by emitRemarkForBlock(), and getUsers().

◆ emitWarning()

InFlightDiagnostic Operation::emitWarning ( const Twine &  message = {})

Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening.

Definition at line 243 of file Operation.cpp.

References mlir::InFlightDiagnostic::attachNote(), diag(), mlir::emitWarning(), getContext(), and getLoc().

Referenced by getLibraryCallSymbolRef(), getMemoryFootprintBytes(), and getUsers().

◆ erase()

void Operation::erase ( )

◆ eraseOperand()

void mlir::Operation::eraseOperand ( unsigned  idx)
inline

Erase the operand at position idx.

Definition at line 225 of file Operation.h.

References eraseOperands().

◆ eraseOperands() [1/2]

void mlir::Operation::eraseOperands ( unsigned  idx,
unsigned  length = 1 
)
inline

Erase the operands starting at position idx and ending at position 'idx'+'length'.

Definition at line 229 of file Operation.h.

References mlir::detail::OperandStorage::eraseOperands().

Referenced by mlir::MutableOperandRange::clear(), mlir::MutableOperandRange::erase(), and eraseOperand().

◆ eraseOperands() [2/2]

void mlir::Operation::eraseOperands ( const llvm::BitVector &  eraseIndices)
inline

Erases the operands that have their corresponding bit set in eraseIndices and removes them from the operand list.

Definition at line 235 of file Operation.h.

References mlir::detail::OperandStorage::eraseOperands().

◆ fold()

LogicalResult Operation::fold ( ArrayRef< Attribute operands,
SmallVectorImpl< OpFoldResult > &  results 
)

Attempt to fold this operation with the specified constant operand values.

Attempt to fold this operation using the Op's registered foldHook.

  • the elements in "operands" will correspond directly to the operands of the operation, but may be null if non-constant. If folding is successful, this fills in the results vector. If not, results is unspecified.

Definition at line 496 of file Operation.cpp.

References mlir::failure(), getDialect(), getRegisteredInfo(), mlir::succeeded(), and mlir::success().

Referenced by mlir::OperationFolder::getOrCreateConstant(), getSuccessor(), mlir::detail::constant_op_binder< AttrT >::match(), and mlir::OpBuilder::tryFold().

◆ getAttr() [1/2]

Attribute mlir::Operation::getAttr ( StringAttr  name)
inline

◆ getAttr() [2/2]

Attribute mlir::Operation::getAttr ( StringRef  name)
inline

Definition at line 324 of file Operation.h.

◆ getAttrDictionary()

DictionaryAttr mlir::Operation::getAttrDictionary ( )
inline

◆ getAttrOfType() [1/2]

template<typename AttrClass >
AttrClass mlir::Operation::getAttrOfType ( StringAttr  name)
inline

◆ getAttrOfType() [2/2]

template<typename AttrClass >
AttrClass mlir::Operation::getAttrOfType ( StringRef  name)
inline

Definition at line 331 of file Operation.h.

References mlir::Attribute::dyn_cast_or_null(), and getAttr().

◆ getAttrs()

ArrayRef<NamedAttribute> mlir::Operation::getAttrs ( )
inline

◆ getBlock()

Block* mlir::Operation::getBlock ( )
inline

Returns the operation block that contains this operation.

Definition at line 96 of file Operation.h.

Referenced by llvm::ilist_traits<::mlir::Operation >::addNodeToList(), mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), constructTiledLoopNest(), mlir::createLoopFusionPass(), diagnoseInvalidOperandDominance(), erase(), mlir::Region::findAncestorBlockInRegion(), findAncestorOpInRegion(), findInstPosition(), funcsToCoroutines(), mlir::generateCopyForMemRegion(), getCommonBlock(), getEnclosingforOps(), mlir::NumberOfExecutions::getNumberOfExecutions(), getPhiIncomingBlock(), mlir::BufferPlacementAllocs::getStartOperation(), hasAllocationScope(), hasNoInterveningEffect(), hoistAffineIfOp(), mlir::inlineRegion(), mlir::Liveness::isDeadAfter(), mlir::isLegalForBranchOpInterfaceTypeConversionPattern(), mlir::isNotBranchOpInterfaceOrReturnLikeOp(), mlir::detail::DominanceInfoBase< true >::isReachableFromEntry(), mlir::Value::isUsedOutsideOfBlock(), mlir::linalg::LinalgBaseTileAndFusePattern::matchAndRewrite(), mlir::linalg::PadTensorOpTransformationPattern::matchAndRewrite(), mayExistInterleavedUses(), mlir::RewriterBase::mergeBlockBefore(), moveAfter(), moveBefore(), mlir::OperationFolder::notifyRemoval(), printIR(), mlir::DominanceInfo::properlyDominates(), mlir::PostDominanceInfo::properlyPostDominates(), remove(), mlir::OpBuilder::setInsertionPoint(), mlir::OpBuilder::setInsertionPointAfter(), mlir::Block::splitBlock(), validateSupportedControlFlow(), mlir::OpTrait::impl::verifyIsTerminator(), and verifyResultTypesAreInferrable().

◆ getBlockOperands()

MutableArrayRef<BlockOperand> mlir::Operation::getBlockOperands ( )
inline

◆ getContext()

MLIRContext* mlir::Operation::getContext ( )
inline

Return the context this operation is associated with.

Definition at line 99 of file Operation.h.

References mlir::Attribute::getContext().

Referenced by mlir::gpu::addAsyncDependency(), mlir::applyOpPatternsAndFold(), mlir::linalg::comprehensive_bufferize::bufferize(), collectValidReferencesFor(), create(), diagnoseInvalidOperandDominance(), emitError(), emitRemark(), emitWarning(), generateLocationsFromIR(), mlir::getComputationSliceState(), mlir::Region::getContext(), getLibraryCallSymbolRef(), mlir::LLVM::detail::getLLVMConstant(), getLocalInvocationDimSize(), mlir::detail::PassCrashReproducerGenerator::initialize(), mlir::SymbolTable::insert(), mlir::SymbolTable::lookup(), mlir::SymbolTable::lookupSymbolIn(), mlir::spirv::lookupTargetEnvOrDefault(), mlir::OpToFuncCallLowering< SourceOp >::matchAndRewrite(), mlirLinalgFillBuiltinNamedOpRegion(), prepareLLVMModule(), removeAttr(), mlir::detail::OpToOpPassAdaptor::runOnOperation(), mlir::function_like_impl::setAllArgAttrDicts(), setAllArgResAttrDicts(), mlir::function_like_impl::setAllResultAttrDicts(), mlir::OpTrait::FunctionLike< ConcreteType >::setArgAttrs(), mlir::function_like_impl::detail::setArgResAttrDict(), setAttr(), setAttrs(), setDialectAttrs(), mlir::OpTrait::FunctionLike< ConcreteType >::setResultAttrs(), mlir::SymbolTable::setSymbolName(), mlir::SymbolTable::setSymbolVisibility(), mlir::linalg::skipUnitDimReshape(), mlir::SymbolTable::SymbolTable(), mlir::detail::verifyInferredResultTypes(), and GpuAsyncRegionPass::DeferWaitCallback::~DeferWaitCallback().

◆ getDialect()

Dialect* mlir::Operation::getDialect ( )
inline

◆ getDialectAttrs()

dialect_attr_range mlir::Operation::getDialectAttrs ( )
inline

Return a range corresponding to the dialect attributes for this operation.

Definition at line 390 of file Operation.h.

References getAttrs().

Referenced by forwardPassthroughAttributes().

◆ getLoc()

Location mlir::Operation::getLoc ( )
inline

The source location the operation was defined or derived from.

Definition at line 106 of file Operation.h.

Referenced by addRuntimePreemptionSpecifier(), mlir::affineDataCopyGenerate(), buildMultiDimReduce(), buildUnresolvedTargetMaterialization(), buildVectorComparison(), cloneWithoutRegions(), computeMemoryOpIndices(), containsReturn(), mlir::LLVM::ModuleTranslation::convertBlock(), convertElementwiseOp(), convertOmpWsLoop(), mlir::createAffineComputationSlice(), mlir::AllocLikeOpLLVMLowering::createAligned(), createConstFromIntAttribute(), createLinalgBodyCalculationForElementwiseOp(), createLinalgBodyCalculationForReduceOp(), createPrivateMemRef(), createSourceLocationInfo(), createVectorizedOp(), diagnoseInvalidOperandDominance(), mlir::vector::distributPointwiseVectorOp(), elementwiseMatchAndRewriteHelper(), emitError(), emitRemark(), emitWarning(), mlir::detail::PassCrashReproducerGenerator::finalize(), findLiveUserOfReplaced(), fuse(), fuseWithReshapeByExpansion(), getLibraryCallSymbolRef(), mlir::Region::getLoc(), getMemoryFootprintBytes(), mlir::getMemRefSizeInBytes(), getOrCreateOperandsMatchingResultTypes(), getOrInsertBuiltinVariable(), mlir::spirv::getPushConstantValue(), mlir::linalg::comprehensive_bufferize::getResultBuffer(), mlir::LLVM::detail::handleMultidimensionalVectors(), interruptIfValidLocation(), mlir::OperationEquivalence::isEquivalentTo(), isFusionProfitable(), isMemRefNormalizable(), logFailure(), mlir::OpToFuncCallLowering< SourceOp >::matchAndRewrite(), mlir::ConversionPattern::matchAndRewrite(), mlir::linalg::LinalgBaseTileAndFusePattern::matchAndRewrite(), mlirLinalgFillBuiltinNamedOpRegion(), mlir::ConversionPatternRewriter::notifyMatchFailure(), mlir::LLVM::detail::oneToOneRewrite(), GpuAsyncRegionPass::ThreadTokenCallback::operator()(), parseSpecConstantOperationOp(), printConstantOp(), mlir::AsmPrinter::Impl::printIntegerSet(), printOperation(), reduceMatchAndRewriteHelper(), mlir::replaceAllMemRefUsesWith(), mlir::RewriterBase::replaceOpWithNewOp(), shouldPrintElementsAttrWithHex(), splatZero(), mlir::OpBuilder::tryFold(), mlir::LLVM::detail::vectorOneToOneRewrite(), verify(), mlir::detail::verifyDataLayoutOp(), mlir::detail::verifyInferredResultTypes(), mlir::OpTrait::impl::verifyIsIsolatedFromAbove(), verifyNamedStructuredOp(), verifyRegionAttribute(), mlir::detail::verifySymbolTable(), widenOp(), and GpuAsyncRegionPass::DeferWaitCallback::~DeferWaitCallback().

◆ getName()

OperationName mlir::Operation::getName ( )
inline

The name of an operation is the key identifier for it.

Definition at line 57 of file Operation.h.

Referenced by checkAndUpdateCapabilityRequirements(), checkAndUpdateExtensionRequirements(), mlir::Op< AffineDmaStartOp, OpTrait::MemRefsNormalizable, OpTrait::VariadicOperands, OpTrait::ZeroResult, AffineMapAccessInterface::Trait >::classof(), cloneWithoutRegions(), mlir::OperationEquivalence::computeHash(), convertOmpReductionOp(), convertStandaloneDataOp(), mlir::LLVM::detail::createIntrinsicCall(), mlir::createSimplifyAffineStructuresPass(), createVectorizedOp(), emitOpError(), mlir::ConversionPatternRewriter::eraseOp(), findLiveUserOfReplaced(), mlir::OpTrait::impl::foldIdempotent(), mlir::OpTrait::impl::foldInvolution(), mlir::linalg::generateLibraryCallName(), mlir::SPIRVConversionTarget::get(), getDialect(), getElementPtrType(), mlir::OpInterface< AffineMapAccessInterface, detail::AffineMapAccessInterfaceInterfaceTraits >::getInterfaceFor(), getLspDiagnoticFromDiag(), mlir::OpPassManager::getNesting(), getRegisteredInfo(), mlir::AsmParserState::initialize(), inlineCallsInSCC(), mlir::OperationEquivalence::isEquivalentTo(), mlir::ConversionTarget::isIllegal(), mlir::ConversionTarget::isLegal(), isMemRefNormalizable(), isRegistered(), legalizeUnresolvedMaterialization(), mlir::PatternApplicator::matchAndRewrite(), mlir::ConversionPattern::matchAndRewrite(), mayBeValidWithoutTerminator(), mlirLinalgFillBuiltinNamedOpRegion(), mlir::ConversionPatternRewriter::notifyOperationInserted(), GpuAsyncRegionPass::ThreadTokenCallback::operator()(), mlir::detail::PassCrashReproducerGenerator::prepareReproducerFor(), mlir::CallGraph::print(), mlir::AsmPrinter::Impl::printIntegerSet(), printIR(), mlir::NumberOfExecutions::printOperationExecutions(), printOperationInfo(), mlir::OpState::printOpName(), mlir::spirv::Serializer::printValueIDMap(), mlir::replaceAllMemRefUsesWith(), mlir::ConversionPatternRewriter::replaceOp(), mlir::ConversionPatternRewriter::replaceUsesOfBlockArgument(), mlir::PassManager::run(), mlir::detail::OpToOpPassAdaptor::runOnOperation(), splatZero(), mlir::OpTrait::SingleBlockImplicitTerminator< TerminatorOpType >::Impl< ConcreteType >::verifyTrait(), visitInPrettyBlockOrder(), and widenOp().

◆ getNumOperands()

unsigned mlir::Operation::getNumOperands ( )
inline

◆ getNumRegions()

unsigned mlir::Operation::getNumRegions ( )
inline

◆ getNumResults()

unsigned mlir::Operation::getNumResults ( )
inline

Return the number of results held by this operation.

Definition at line 273 of file Operation.h.

Referenced by analyzeProfitability(), cloneWithoutRegions(), convertOperationImpl(), mlir::vector::distributPointwiseVectorOp(), elementwiseMatchAndRewriteHelper(), mlir::ConversionPatternRewriter::eraseOp(), executeGetOperandsResults(), getEnclosingforOps(), getLibraryCallSymbolRef(), mlir::OperationFolder::getOrCreateConstant(), getUsers(), mlir::detail::isConstantLike(), mlir::OperationEquivalence::isEquivalentTo(), isMemRefNormalizable(), VectorizeConvolution::matchAndRewrite(), PointwiseExtractPattern::matchAndRewrite(), mlir::matchReduction(), materializeConversion(), mlir::detail::ConversionPatternRewriterImpl::notifyOpReplaced(), mlir::LLVM::detail::oneToOneRewrite(), GpuAsyncRegionPass::ThreadTokenCallback::operator()(), mlir::detail::Parser::parseFloatFromIntegerLiteral(), mlir::Liveness::print(), mlir::OpAsmPrinter::printFunctionalType(), mlir::AsmPrinter::Impl::printIntegerSet(), printNVVMIntrinsicOp(), mlir::impl::printOneResultOp(), printOperation(), mlir::replaceAllMemRefUsesWith(), mlir::RewriterBase::replaceOp(), mlir::RewriterBase::replaceOpWithIf(), setInPlaceOpResult(), splatZero(), mlir::RewriterBase::splitBlock(), mlir::OpTrait::impl::verifyAtLeastNResults(), mlir::OpTrait::impl::verifyElementwise(), verifyNamedStructuredOp(), mlir::OpTrait::impl::verifyNResults(), mlir::OpTrait::impl::verifyOneResult(), mlir::OpTrait::impl::verifyResultSizeAttr(), verifyShapeOrExtentTensorOp(), verifySizeOrIndexOp(), mlir::linalg::detail::verifyStructuredOpInterface(), mlir::OpTrait::impl::verifyZeroResult(), and walkReferenceCountedValues().

◆ getNumSuccessors()

unsigned mlir::Operation::getNumSuccessors ( )
inline

◆ getOperand()

Value mlir::Operation::getOperand ( unsigned  idx)
inline

◆ getOperands()

operand_range mlir::Operation::getOperands ( )
inline

Returns an iterator on the underlying Value's.

Definition at line 247 of file Operation.h.

References getOpOperands().

Referenced by canBeHoisted(), cloneWithoutRegions(), mlir::OperationEquivalence::computeHash(), computeRegionBlockNumberOfExecutions(), convertElementwiseOp(), convertOperationImpl(), convertStructType(), mlir::createAffineComputationSlice(), defaultIsSmallAlloc(), dependsOnCarriedVals(), diagnoseInvalidOperandDominance(), elementwiseMatchAndRewriteHelper(), extractBeneficiaryOps(), mlir::impl::foldCastInterfaceOp(), getBackwardSliceImpl(), getOperandTypes(), getOrCreateOperandsMatchingResultTypes(), getOutermostInvariantForOp(), mlir::linalg::getUpperBoundForIndex(), mlir::LLVM::detail::handleMultidimensionalVectors(), hasAllocationScope(), hasNonAffineUsersOnThePath(), inlineConvertOmpRegions(), isMemRefNormalizable(), mlir::ConversionPattern::matchAndRewrite(), matchSimpleReduction(), mayBeValidWithoutTerminator(), operand_begin(), operand_end(), mlir::MutableOperandRange::operator OperandRange(), GpuAsyncRegionPass::ThreadTokenCallback::operator()(), mlir::outlineIfOp(), print(), printAtomicUpdateOp(), mlir::OpAsmPrinter::printFunctionalType(), mlir::AsmPrinter::Impl::printIntegerSet(), printLogicalOp(), printNVVMIntrinsicOp(), mlir::impl::printOneResultOp(), printOperation(), mlir::replaceAllMemRefUsesWith(), mlir::replaceForOpWithNewYields(), replaceOpWithRegion(), sourceMaterializationCallback(), splatZero(), validateSupportedControlFlow(), vectorizeOneOp(), verify(), mlir::detail::verifyInferredResultTypes(), mlir::OpTrait::impl::verifySameOperandsAndResultElementType(), mlir::OpTrait::impl::verifySameOperandsElementType(), visitInPrettyBlockOrder(), and widenOp().

◆ getOperandTypes()

operand_type_range mlir::Operation::getOperandTypes ( )
inline

◆ getOpOperand()

OpOperand& mlir::Operation::getOpOperand ( unsigned  idx)
inline

◆ getOpOperands()

MutableArrayRef<OpOperand> mlir::Operation::getOpOperands ( )
inline

◆ getOpResult()

OpResult mlir::Operation::getOpResult ( unsigned  idx)
inline

◆ getOpResults()

result_range mlir::Operation::getOpResults ( )
inline

◆ getParentOfType()

template<typename OpTy >
OpTy mlir::Operation::getParentOfType ( )
inline

◆ getParentOp()

Operation* mlir::Operation::getParentOp ( )
inline

Returns the closest surrounding operation that contains this operation or nullptr if this is a top-level operation.

Definition at line 117 of file Operation.h.

References mlir::Block::getParentOp().

Referenced by mlir::DataLayout::closest(), collectParentLayouts(), collectSymbolScopes(), collectValidReferencesFor(), mlir::DataLayoutAnalysis::DataLayoutAnalysis(), declareReduction(), mlir::SymbolTable::erase(), mlir::Block::findAncestorOpInBlock(), findAncestorOpInRegion(), mlir::Region::findAncestorOpInRegion(), findOptimal(), mlir::DataLayoutAnalysis::getAbove(), mlir::LLVM::ModuleTranslation::getAccessGroup(), mlir::LLVM::ModuleTranslation::getAliasScope(), getAllocEffectFor(), getAtMostNEnclosingLoops(), mlir::AnalysisManager::getCachedChildAnalysis(), mlir::detail::DominanceInfoBase< true >::getDominanceInfo(), mlir::getEnclosingAffineForAndIfOps(), mlir::getLoopIVs(), mlir::SymbolTable::getNearestSymbolTable(), mlir::getNestingDepth(), mlir::NumberOfExecutions::getNumberOfExecutions(), getOrInsertBuiltinVariable(), getParentWithTrait(), mlir::spirv::getPushConstantValue(), getTiledProducer(), happensBefore(), hasNoInterveningEffect(), mlir::SymbolTable::insert(), isNestedInFunctionLikeOp(), mlir::isNotBranchOpInterfaceOrReturnLikeOp(), mlir::detail::ConversionPatternRewriterImpl::isOpIgnored(), isProperAncestor(), mlir::isTopLevelValue(), mlir::spirv::lookupEntryPointABI(), lookupSymbolInModule(), mlir::spirv::lookupTargetEnv(), mlir::matchReduction(), moveInsertionPointToAllocationHoistingBarrier(), mlir::AnalysisManager::nest(), mlir::detail::PassCrashReproducerGenerator::prepareReproducerFor(), print(), mlir::CallGraph::print(), mlir::Block::print(), printOperation(), mlir::SymbolUserMap::replaceAllUsesWith(), vectorizeConstant(), verify(), verifyHasBindingUse(), verifySymbolAttribute(), mlir::OpTrait::HasParent< ParentOpTypes >::Impl< ConcreteType >::verifyTrait(), visit(), and walkReferencedSymbolNodes().

◆ getParentRegion()

Region* mlir::Operation::getParentRegion ( )
inline

Returns the region to which the instruction belongs.

Returns nullptr if the instruction is unlinked.

Definition at line 113 of file Operation.h.

References mlir::Block::getParent().

Referenced by findAncestorOpInRegion(), mlir::Region::findAncestorOpInRegion(), getAffineScope(), mlir::Region::getParentRegion(), hasNoInterveningEffect(), isTopLevelValue(), mlir::isValidSymbol(), and verifyTerminatorSuccessors().

◆ getParentWithTrait()

template<template< typename T > class Trait>
Operation* mlir::Operation::getParentWithTrait ( )
inline

Returns the closest surrounding parent operation with trait Trait.

Definition at line 130 of file Operation.h.

References getParentOp(), hasTrait(), and isProperAncestor().

Referenced by getAllocEffectFor(), and getDumpRootOp().

◆ getRegion()

Region& mlir::Operation::getRegion ( unsigned  index)
inline

◆ getRegions()

MutableArrayRef<Region> mlir::Operation::getRegions ( )
inline

◆ getRegisteredInfo()

Optional<RegisteredOperationName> mlir::Operation::getRegisteredInfo ( )
inline

◆ getResult()

OpResult mlir::Operation::getResult ( unsigned  idx)
inline

Get the 'idx'th result of this operation.

Definition at line 276 of file Operation.h.

Referenced by addRuntimePreemptionSpecifier(), mlir::affineParallelize(), mlir::AllocLikeOpLLVMLowering::AllocLikeOpLLVMLowering(), analyzeProfitability(), mlir::Op< AffineDmaStartOp, OpTrait::MemRefsNormalizable, OpTrait::VariadicOperands, OpTrait::ZeroResult, AffineMapAccessInterface::Trait >::attachInterface(), mlir::linalg::comprehensive_bufferize::vector_ext::TransferWriteOpInterface::bufferize(), buildVectorWrite(), cloneWithoutRegions(), mlir::spirv::Deserializer::collect(), convertElementwiseOp(), convertOperationImpl(), mlir::vector::distributPointwiseVectorOp(), elementwiseMatchAndRewriteHelper(), executeGetOperandsResults(), extractOpcode(), mlir::impl::foldCastOp(), mlir::op_definition_impl::foldTrait(), genForInduction(), mlir::linalg::comprehensive_bufferize::tensor_ext::CastOpInterface::getAliasingOpResult(), mlir::linalg::comprehensive_bufferize::tensor_ext::ExtractSliceOpInterface::getAliasingOpResult(), mlir::linalg::comprehensive_bufferize::tensor_ext::InsertSliceOpInterface::getAliasingOpResult(), getEnclosingforOps(), getLLVMAtomicOrdering(), getLspDiagnoticFromDiag(), getOpResult(), mlir::OperationFolder::getOrCreateConstant(), mlir::LLVM::detail::handleMultidimensionalVectors(), isMemRefNormalizable(), mlir::detail::constant_int_op_binder::match(), VectorizeConvolution::matchAndRewrite(), PointwiseExtractPattern::matchAndRewrite(), ContractExtractPattern::matchAndRewrite(), TransferReadToVectorLoadLowering::matchAndRewrite(), materializeConversion(), mlir::OperationFolder::notifyRemoval(), mlir::LLVM::detail::oneToOneRewrite(), mlir::detail::Parser::parseFloatFromIntegerLiteral(), parseSpecConstantOperationOp(), mlir::impl::printCastOp(), printConstantOp(), mlir::OpAsmPrinter::printFunctionalType(), printGroupNonUniformArithmeticOp(), mlir::AsmPrinter::Impl::printIntegerSet(), mlir::impl::printOneResultOp(), printOperation(), reduceMatchAndRewriteHelper(), splatZero(), mlir::RewriterBase::splitBlock(), mlir::OperationFolder::tryToFold(), vectorizeOperand(), mlir::LLVM::detail::vectorOneToOneRewrite(), verify(), verifyCastOp(), mlir::impl::verifyCastOp(), verifyNamedStructuredOp(), mlir::OpTrait::impl::verifySameOperandsAndResultElementType(), mlir::OpTrait::impl::verifySameOperandsAndResultType(), verifyShiftOp(), and walkReferenceCountedValues().

◆ getResults()

result_range mlir::Operation::getResults ( )
inline

Definition at line 284 of file Operation.h.

Referenced by analyzeProfitability(), annotateOpsWithBufferizationMarkers(), mlir::applyPatternsAndFoldGreedily(), mlir::linalg::comprehensive_bufferize::BufferizationAliasInfo::BufferizationAliasInfo(), buildVectorWrite(), mlir::async::cloneConstantsIntoTheRegion(), mlir::OperationEquivalence::computeHash(), DFSPostorder(), elementwiseMatchAndRewriteHelper(), extractBeneficiaryOps(), mlir::impl::foldCastInterfaceOp(), getForwardSliceImpl(), getLastDependentOpInRange(), getLspDiagnoticFromDiag(), getOpResults(), getResultTypes(), mlir::linalg::getUpperBoundForIndex(), getUses(), mlir::linalg::LinalgGeneralizationPattern::matchAndRewrite(), mlir::linalg::ExtractSliceOfPadTensorSwapPattern::matchAndRewrite(), matchSimpleAtomicOp(), mlir::detail::ConversionPatternRewriterImpl::notifyOpReplaced(), mlir::outlineIfOp(), peelLoop(), mlir::Liveness::print(), mlir::OpAsmPrinter::printFunctionalType(), printOperation(), processParallelLoop(), propagateLiveness(), reduceMatchAndRewriteHelper(), mlir::replaceAllMemRefUsesWith(), replaceAllUsesWith(), mlir::ResultRange::replaceAllUsesWith(), mlir::RewriterBase::replaceOpWithIf(), result_begin(), result_end(), mlir::sinkOperationsIntoLaunchOp(), mlir::RewriterBase::splitBlock(), mlir::OpBuilder::tryFold(), use_begin(), use_empty(), use_end(), validateSupportedControlFlow(), vectorizeAsLinalgGeneric(), mlir::linalg::vectorizeLinalgOp(), verifyNamedStructuredOp(), mlir::OpTrait::impl::verifySameOperandsAndResultElementType(), and widenOp().

◆ getResultTypes()

result_type_range mlir::Operation::getResultTypes ( )
inline

◆ getSuccessor()

Block* mlir::Operation::getSuccessor ( unsigned  index)
inline

◆ getSuccessors()

SuccessorRange mlir::Operation::getSuccessors ( )
inline

◆ getUsers()

user_range mlir::Operation::getUsers ( )
inline

◆ getUses()

use_range mlir::Operation::getUses ( )
inline

Returns a range of all uses, which is useful for iterating over all uses.

Definition at line 534 of file Operation.h.

References getResults(), and mlir::ResultRange::getUses().

Referenced by hasOneUse().

◆ hasAttr() [1/2]

bool mlir::Operation::hasAttr ( StringAttr  name)
inline

Return true if the operation has an attribute with the provided name, false otherwise.

Definition at line 337 of file Operation.h.

◆ hasAttr() [2/2]

bool mlir::Operation::hasAttr ( StringRef  name)
inline

Definition at line 338 of file Operation.h.

◆ hasAttrOfType()

template<typename AttrClass , typename NameT >
bool mlir::Operation::hasAttrOfType ( NameT &&  name)
inline

Definition at line 340 of file Operation.h.

◆ hasOneUse()

bool mlir::Operation::hasOneUse ( )
inline

Returns true if this operation has exactly one use.

Definition at line 537 of file Operation.h.

References getUses().

Referenced by mlir::matchReduction().

◆ hasSuccessors()

bool mlir::Operation::hasSuccessors ( )
inline

Definition at line 448 of file Operation.h.

◆ hasTrait()

template<template< typename T > class Trait>
bool mlir::Operation::hasTrait ( )
inline

Returns true if the operation was registered with a particular trait, e.g.

hasTrait<OperandsAreSignlessIntegerLike>().

Definition at line 470 of file Operation.h.

References mlir::OperationName::hasTrait().

Referenced by canBeHoisted(), mlir::async::cloneConstantsIntoTheRegion(), collectSymbolScopes(), collectValidReferencesFor(), diagnoseInvalidOperandDominance(), eachHasOnlyOneOfTypes(), mlir::impl::ensureRegionTerminator(), executeGetOperandsResults(), extractOpcode(), mlir::op_definition_impl::foldTrait(), getBackwardSliceImpl(), getCommonBlock(), mlir::function_like_impl::getFunctionBody(), mlir::function_like_impl::getFunctionType(), getLspDiagnoticFromDiag(), mlir::LocalAliasAnalysis::getModRef(), mlir::getMutableRegionBranchSuccessorOperands(), mlir::SymbolTable::getNearestSymbolTable(), mlir::OpPassManager::getNesting(), mlir::OperationFolder::getOrCreateConstant(), getParentWithTrait(), mlir::OpTrait::hasElementwiseMappableTraits(), inlineCallsInSCC(), mlir::detail::isConstantLike(), isDirectInModuleLikeOp(), mlir::isLegalForReturnOpTypeConversionPattern(), isMemRefNormalizable(), isNestedInFunctionLikeOp(), mlir::isRegionReturnLike(), mlir::isTopLevelValue(), isUseSpeciallyKnownDead(), mlir::isValidSymbol(), mlir::spirv::lookupEntryPointABI(), mlir::SymbolTable::lookupSymbolIn(), lookupSymbolInImpl(), mayBeValidWithoutTerminator(), mlirBlockGetTerminator(), print(), print(), mlir::AsmPrinter::Impl::printIntegerSet(), propagateLiveness(), remainsLegalAfterInline(), mlir::LLVM::satisfiesLLVMModule(), mlir::function_like_impl::setFunctionType(), shouldPrintElementsAttrWithHex(), mlir::SymbolTable::SymbolTable(), verify(), mlir::OpTrait::impl::verifyIsIsolatedFromAbove(), mlir::SymbolTable::walkSymbolTables(), walkSymbolUses(), and wouldOpBeTriviallyDeadImpl().

◆ insertOperands()

void Operation::insertOperands ( unsigned  index,
ValueRange  operands 
)

Insert the given operands into the operand list at the given 'index'.

Definition at line 219 of file Operation.cpp.

References setOperands().

Referenced by mlir::gpu::addAsyncDependency(), addExecuteResults(), mlir::MutableOperandRange::append(), and replaceAllUsesWith().

◆ isAncestor()

bool mlir::Operation::isAncestor ( Operation other)
inline

Return true if this operation is an ancestor of the other operation.

An operation is considered as its own ancestor, use isProperAncestor to avoid this.

Definition at line 145 of file Operation.h.

References isProperAncestor(), and replaceUsesOfWith().

Referenced by collectValidReferencesFor(), dependsOnCarriedVals(), mlir::OpPassManager::getNesting(), and hasNoInterveningEffect().

◆ isBeforeInBlock()

bool Operation::isBeforeInBlock ( Operation other)

Given an operation 'other' that is within the same parent block, return whether the current operation is before 'other' in the operation list of the parent block.

Note: This function has an average complexity of O(1), but worst case may take O(N) where N is the number of operations within the parent block.

Definition at line 271 of file Operation.cpp.

References mlir::Block::back(), mlir::Block::front(), mlir::Block::isOpOrderValid(), and mlir::Block::recomputeOpOrder().

Referenced by mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), mlir::createLoopFusionPass(), funcsToCoroutines(), mlir::LivenessBlockInfo::getEndOperation(), getFusedLoopNestInsertionPoint(), hasNonAffineUsersOnThePath(), mlir::Liveness::isDeadAfter(), isFusionProfitable(), mlir::detail::DominanceInfoBase< true >::isReachableFromEntry(), mayExistInterleavedUses(), mlir::PostDominanceInfo::properlyPostDominates(), replaceAllUsesWith(), validateSupportedControlFlow(), and verifyResultTypesAreInferrable().

◆ isProperAncestor()

bool Operation::isProperAncestor ( Operation other)

Return true if this operation is a proper ancestor of the other operation.

Definition at line 182 of file Operation.cpp.

References getParentOp().

Referenced by getParentWithTrait(), happensBefore(), isAncestor(), mlir::AnalysisManager::nest(), and mlir::RewriterBase::replaceOpWithinBlock().

◆ isRegistered()

bool mlir::Operation::isRegistered ( )
inline

Returns true if this operation has a registered operation description, otherwise false.

Definition at line 67 of file Operation.h.

References clone(), cloneWithoutRegions(), erase(), getName(), and mlir::OperationName::isRegistered().

Referenced by mlir::OpPassManager::getNesting().

◆ isUsedOutsideOfBlock()

bool mlir::Operation::isUsedOutsideOfBlock ( Block block)
inline

Returns true if the results of this operation are used outside of the given block.

Definition at line 544 of file Operation.h.

References getOpResults(), and mlir::Value::isUsedOutsideOfBlock().

◆ mightHaveTrait()

template<template< typename T > class Trait>
bool mlir::Operation::mightHaveTrait ( )
inline

Returns true if the operation might have the provided trait.

This means that either the operation is unregistered, or it was registered with the provide trait.

Definition at line 477 of file Operation.h.

References mlir::OperationName::mightHaveTrait(), and mlir::PostOrder.

Referenced by create(), mlir::isNotBranchOpInterfaceOrReturnLikeOp(), isTerminator(), mlir::matchReduction(), mayBeValidWithoutTerminator(), and mlir::wouldOpBeTriviallyDead().

◆ moveAfter() [1/2]

void Operation::moveAfter ( Operation existingOp)

Unlink this operation from its current block and insert it right after existingOp which may be in the same or another block in the same function.

Definition at line 454 of file Operation.cpp.

References getBlock().

Referenced by replaceAllUsesWith(), and validateSupportedControlFlow().

◆ moveAfter() [2/2]

void Operation::moveAfter ( Block block,
llvm::iplist< Operation >::iterator  iterator 
)

Unlink this operation from its current block and insert it right after iterator in the specified block.

Definition at line 460 of file Operation.cpp.

References mlir::Block::end(), and moveBefore().

◆ moveBefore() [1/2]

void Operation::moveBefore ( Operation existingOp)

Unlink this operation from its current block and insert it right before existingOp which may be in the same or another block in the same function.

Definition at line 440 of file Operation.cpp.

References getBlock().

Referenced by checkInvarianceOfNestedIfOps(), hasAllocationScope(), moveAfter(), parseForOp(), print(), and replaceAllUsesWith().

◆ moveBefore() [2/2]

void Operation::moveBefore ( Block block,
llvm::iplist< Operation >::iterator  iterator 
)

Unlink this operation from its current block and insert it right before iterator in the specified block.

Unlink this operation from its current basic block and insert it right before iterator in the specified basic block.

Definition at line 446 of file Operation.cpp.

References getBlock(), and mlir::Block::getOperations().

◆ operand_begin()

operand_iterator mlir::Operation::operand_begin ( )
inline

◆ operand_end()

operand_iterator mlir::Operation::operand_end ( )
inline

◆ operand_type_begin()

operand_type_iterator mlir::Operation::operand_type_begin ( )
inline

◆ operand_type_end()

operand_type_iterator mlir::Operation::operand_type_end ( )
inline

Definition at line 265 of file Operation.h.

References operand_end().

Referenced by checkAndUpdateCapabilityRequirements(), and mlir::SPIRVConversionTarget::get().

◆ print() [1/2]

void Operation::print ( raw_ostream &  os,
const OpPrintingFlags flags = llvm::None 
)

◆ print() [2/2]

void Operation::print ( raw_ostream &  os,
AsmState state,
const OpPrintingFlags flags = llvm::None 
)

◆ remove()

void Operation::remove ( )

Remove the operation from its parent block, but don't delete it.

Definition at line 432 of file Operation.cpp.

References getBlock().

◆ removeAttr() [1/2]

Attribute mlir::Operation::removeAttr ( StringAttr  name)
inline

Remove the attribute with the specified name if it exists.

Return the attribute that was erased, or nullptr if there was no attribute with such name.

Definition at line 359 of file Operation.h.

References mlir::NamedAttrList::erase(), getContext(), and mlir::NamedAttrList::getDictionary().

Referenced by removeAttr(), mlir::linalg::LinalgTransformationFilter::replaceLinalgTransformationFilter(), setAllArgResAttrDicts(), mlir::function_like_impl::detail::setArgResAttrDict(), mlir::function_like_impl::setFunctionType(), and mlir::SymbolTable::setSymbolVisibility().

◆ removeAttr() [2/2]

Attribute mlir::Operation::removeAttr ( StringRef  name)
inline

Definition at line 366 of file Operation.h.

References getContext(), and removeAttr().

◆ replaceAllUsesWith()

template<typename ValuesT >
void mlir::Operation::replaceAllUsesWith ( ValuesT &&  values)
inline

◆ replaceUsesOfWith()

void Operation::replaceUsesOfWith ( Value  from,
Value  to 
)

Replace any uses of 'from' with 'to' within this operation.

Definition at line 190 of file Operation.cpp.

References getOpOperands().

Referenced by mlir::inlineCall(), and isAncestor().

◆ result_begin()

result_iterator mlir::Operation::result_begin ( )
inline

Definition at line 282 of file Operation.h.

References getResults().

Referenced by mlir::OperationFolder::create().

◆ result_end()

result_iterator mlir::Operation::result_end ( )
inline

Definition at line 283 of file Operation.h.

References getResults().

Referenced by mlir::OperationFolder::create().

◆ result_type_begin()

result_type_iterator mlir::Operation::result_type_begin ( )
inline

◆ result_type_end()

result_type_iterator mlir::Operation::result_type_end ( )
inline

◆ setAttr() [1/2]

void mlir::Operation::setAttr ( StringAttr  name,
Attribute  value 
)
inline

◆ setAttr() [2/2]

void mlir::Operation::setAttr ( StringRef  name,
Attribute  value 
)
inline

Definition at line 352 of file Operation.h.

References getContext(), and setAttr().

◆ setAttrs() [1/2]

void mlir::Operation::setAttrs ( DictionaryAttr  newAttrs)
inline

Set the attribute dictionary on this operation.

Definition at line 314 of file Operation.h.

Referenced by mlir::linalg::comprehensive_bufferize::std_ext::CallOpInterface::bufferize(), logFailure(), replaceAllSymbolUsesImpl(), setAttrs(), and setDialectAttrs().

◆ setAttrs() [2/2]

void mlir::Operation::setAttrs ( ArrayRef< NamedAttribute newAttrs)
inline

Definition at line 318 of file Operation.h.

References getContext(), and setAttrs().

◆ setDialectAttrs()

template<typename DialectAttrT >
void mlir::Operation::setDialectAttrs ( DialectAttrT &&  dialectAttrs)
inline

Set the dialect attributes for this operation, and preserve all dependent.

Definition at line 406 of file Operation.h.

References mlir::NamedAttrList::append(), getAttrs(), getContext(), mlir::NamedAttrList::getDictionary(), mlir::NamedAttrList::push_back(), and setAttrs().

◆ setLoc()

void mlir::Operation::setLoc ( Location  loc)
inline

Set the source location the operation was defined or derived from.

Definition at line 109 of file Operation.h.

Referenced by generateLocationsFromIR(), and logFailure().

◆ setOperand()

void mlir::Operation::setOperand ( unsigned  idx,
Value  value 
)
inline

◆ setOperands() [1/2]

void Operation::setOperands ( ValueRange  operands)

Replace the current operands of this operation with the ones provided in 'operands'.

Definition at line 200 of file Operation.cpp.

References mlir::detail::OperandStorage::setOperands().

Referenced by mlir::affineParallelize(), mlir::MutableOperandRange::assign(), generateUnrolledLoop(), insertOperands(), logFailure(), and replaceAllUsesWith().

◆ setOperands() [2/2]

void Operation::setOperands ( unsigned  start,
unsigned  length,
ValueRange  operands 
)

Replace the operands beginning at 'start' and ending at 'start' + 'length' with the ones provided in 'operands'.

'operands' may be smaller or larger than the range pointed to by 'start'+'length'.

Definition at line 209 of file Operation.cpp.

References getNumOperands(), and mlir::detail::OperandStorage::setOperands().

◆ setSuccessor()

void Operation::setSuccessor ( Block block,
unsigned  index 
)

Definition at line 490 of file Operation.cpp.

References getBlockOperands(), and getNumSuccessors().

Referenced by getSuccessor(), logFailure(), and walkReferenceCountedValues().

◆ successor_begin()

succ_iterator mlir::Operation::successor_begin ( )
inline

Definition at line 444 of file Operation.h.

References getSuccessors().

Referenced by logFailure().

◆ successor_end()

succ_iterator mlir::Operation::successor_end ( )
inline

Definition at line 445 of file Operation.h.

References getSuccessors().

Referenced by logFailure().

◆ use_begin()

use_iterator mlir::Operation::use_begin ( )
inline

Definition at line 530 of file Operation.h.

References getResults(), and mlir::ResultRange::use_begin().

Referenced by user_begin().

◆ use_empty()

bool mlir::Operation::use_empty ( )
inline

Returns true if this operation has no uses.

Definition at line 540 of file Operation.h.

References getResults(), and mlir::ResultRange::use_empty().

Referenced by checkInvarianceOfNestedIfOps(), create(), mlir::RewriterBase::eraseBlock(), mlir::RewriterBase::eraseOp(), and mlir::isOpTriviallyDead().

◆ use_end()

use_iterator mlir::Operation::use_end ( )
inline

Definition at line 531 of file Operation.h.

References getResults(), and mlir::ResultRange::use_end().

Referenced by user_end().

◆ user_begin()

user_iterator mlir::Operation::user_begin ( )
inline

Definition at line 557 of file Operation.h.

References use_begin().

Referenced by getUsers().

◆ user_end()

user_iterator mlir::Operation::user_end ( )
inline

Definition at line 558 of file Operation.h.

References use_end().

Referenced by getUsers().

◆ walk()

template<WalkOrder Order = WalkOrder::PostOrder, typename FnT , typename RetT = detail::walkResultType<FnT>>
RetT mlir::Operation::walk ( FnT &&  callback)
inline

Walk the operation by calling the callback for each nested operation (including this one), block or region, depending on the callback provided.

Regions, blocks and operations at the same nesting level are visited in lexicographical order. The walk order for enclosing regions, blocks and operations with respect to their nested ones is specified by 'Order' (post-order by default). A callback on a block or operation is allowed to erase that block or operation if either:

  • the walk is in post-order, or
  • the walk is in pre-order and the walk is skipped after the erasure.

The callback method can take any of the following forms: void(Operation*) : Walk all operations opaquely.

  • op->walk([](Operation nestedOp) { ...}); void(OpT) : Walk all operations of the given derived type.
  • op->walk([](ReturnOp returnOp) { ...}); WalkResult(Operation|OpT) : Walk operations, but allow for interruption/skipping.
  • op->walk([](... op) { // Skip the walk of this op based on some invariant. if (some_invariant) return WalkResult::skip(); // Interrupt, i.e cancel, the walk based on some invariant. if (another_invariant) return WalkResult::interrupt(); return WalkResult::advance(); });

Definition at line 513 of file Operation.h.

Referenced by annotateOpsWithBufferizationMarkers(), mlir::linalg::comprehensive_bufferize::BufferizationAliasInfo::BufferizationAliasInfo(), mlir::BufferPlacementAllocs::BufferPlacementAllocs(), buildBlockMapping(), mlir::OpBuilder::clone(), mlir::createLoopFusionPass(), mlir::DataLayoutAnalysis::DataLayoutAnalysis(), mlir::LLVM::detail::DebugTranslation::DebugTranslation(), mlir::LLVM::ensureDistinctSuccessors(), mlir::finalizeParallelLoopToGPUConversion(), generateLocationsFromIR(), getFirstDependentOpInRange(), getLastDependentOpInRange(), getLoadAndStoreMemRefAccesses(), getOpToConvert(), hasNonAffineUsersOnThePath(), mlir::detail::ConversionPatternRewriterImpl::markNestedOpsIgnored(), mlir::NestedPattern::match(), mlir::NumberOfExecutions::NumberOfExecutions(), mlir::Liveness::print(), mlir::NumberOfExecutions::printBlockExecutions(), mlir::NumberOfExecutions::printOperationExecutions(), mlir::BufferViewFlowAnalysis::remove(), and walkReferenceCountedValues().

Friends And Related Function Documentation

◆ Block

friend class Block
friend

Definition at line 695 of file Operation.h.

◆ llvm::ilist_node_with_parent< Operation, Block >

friend class llvm::ilist_node_with_parent< Operation, Block >
friend

Definition at line 701 of file Operation.h.

◆ llvm::ilist_traits< Operation >

friend struct llvm::ilist_traits< Operation >
friend

Definition at line 692 of file Operation.h.

◆ Value

friend class Value
friend

Definition at line 698 of file Operation.h.


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