MLIR
18.0.0git
|
Operation is the basic unit of execution within MLIR. More...
#include "mlir/IR/Operation.h"
Classes | |
class | CloneOptions |
Class encompassing various options related to cloning an operation. More... | |
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... | |
std::optional< RegisteredOperationName > | getRegisteredInfo () |
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... | |
Operation * | clone (IRMapping &mapper, CloneOptions options=CloneOptions::all()) |
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... | |
Operation * | clone (CloneOptions options=CloneOptions::all()) |
Operation * | cloneWithoutRegions (IRMapping &mapper) |
Create a partial copy of this operation without traversing into attached regions. More... | |
Operation * | cloneWithoutRegions () |
Create a partial copy of this operation without traversing into attached regions. More... | |
Block * | getBlock () |
Returns the operation block that contains this operation. More... | |
MLIRContext * | getContext () |
Return the context this operation is associated with. More... | |
Dialect * | getDialect () |
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... | |
Region * | getParentRegion () |
Returns the region to which the instruction belongs. More... | |
Operation * | getParentOp () |
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> | |
Operation * | getParentWithTrait () |
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... | |
template<typename ValuesT > | |
void | replaceUsesWithIf (ValuesT &&values, function_ref< bool(OpOperand &)> shouldReplace) |
Replace uses of results of this operation with the provided values if the given callback returns true. 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=std::nullopt) |
void | print (raw_ostream &os, AsmState &state) |
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 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< OpOperand > | getOpOperands () |
OpOperand & | getOpOperand (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 () |
std::optional< Attribute > | getInherentAttr (StringRef name) |
Access an inherent attribute by name: returns an empty optional if there is no inherent attribute with this name. More... | |
void | setInherentAttr (StringAttr name, Attribute value) |
Set an inherent attribute by name. More... | |
Attribute | getDiscardableAttr (StringRef name) |
Access a discardable attribute by name, returns an null Attribute if the discardable attribute does not exist. More... | |
Attribute | getDiscardableAttr (StringAttr name) |
Access a discardable attribute by name, returns an null Attribute if the discardable attribute does not exist. More... | |
void | setDiscardableAttr (StringAttr name, Attribute value) |
Set a discardable attribute by name. More... | |
ArrayRef< NamedAttribute > | getDiscardableAttrs () |
Return all of the discardable attributes on this operation. More... | |
DictionaryAttr | getDiscardableAttrDictionary () |
Return all of the discardable attributes on this operation as a DictionaryAttr. More... | |
ArrayRef< NamedAttribute > | getAttrs () |
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 attributes from a dictionary on this operation. More... | |
void | setAttrs (ArrayRef< NamedAttribute > newAttrs) |
void | setDiscardableAttrs (DictionaryAttr newAttrs) |
Set the discardable attribute dictionary on this operation. More... | |
void | setDiscardableAttrs (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 inherent. More... | |
void | populateDefaultAttrs () |
Sets default attributes on unset attributes. More... | |
unsigned | getNumRegions () |
Returns the number of regions held by this operation. More... | |
MutableArrayRef< Region > | getRegions () |
Returns the regions held by this operation. More... | |
Region & | getRegion (unsigned index) |
Returns the region held by this operation at position 'index'. More... | |
MutableArrayRef< BlockOperand > | getBlockOperands () |
succ_iterator | successor_begin () |
succ_iterator | successor_end () |
SuccessorRange | getSuccessors () |
bool | hasSuccessors () |
unsigned | getNumSuccessors () |
Block * | getSuccessor (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... | |
LogicalResult | fold (SmallVectorImpl< OpFoldResult > &results) |
Attempt to fold this operation. More... | |
template<typename InterfaceT > | |
bool | hasPromiseOrImplementsInterface () const |
Returns true if InterfaceT has been promised by the dialect or implemented. 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 Iterator = ForwardIterator, typename FnT , typename RetT = detail::walkResultType<FnT>> | |
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, 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... | |
template<typename FnT , typename RetT = detail::walkResultType<FnT>> | |
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==2, RetT > | walk (FnT &&callback) |
Generic walker with a stage aware callback. 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... | |
int | getPropertiesStorageSize () const |
Returns the properties storage size. More... | |
OpaqueProperties | getPropertiesStorage () |
Returns the properties storage. More... | |
OpaqueProperties | getPropertiesStorage () const |
Attribute | getPropertiesAsAttribute () |
Return the properties converted to an attribute. More... | |
LogicalResult | setPropertiesFromAttribute (Attribute attr, function_ref< InFlightDiagnostic &()> getDiag) |
Set the properties from the provided attribute. More... | |
void | copyProperties (OpaqueProperties rhs) |
Copy properties from an existing other properties object. More... | |
llvm::hash_code | hashProperties () |
Compute a hash for the op properties (if any). More... | |
Static Public Member Functions | |
static Operation * | create (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, NamedAttrList &&attributes, OpaqueProperties properties, BlockRange successors, unsigned numRegions) |
Create a new Operation with the specific fields. More... | |
static Operation * | create (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, DictionaryAttr attributes, OpaqueProperties properties, BlockRange successors, unsigned numRegions) |
Create a new Operation with the specific fields. More... | |
static Operation * | create (const OperationState &state) |
Create a new Operation from the fields stored in state . More... | |
static Operation * | create (Location location, OperationName name, TypeRange resultTypes, ValueRange operands, NamedAttrList &&attributes, OpaqueProperties properties, 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 > |
Operation is the basic unit of execution within MLIR.
The following documentation are recommended to understand this class:
An Operation is defined first by its name, which is a unique string. The name is interpreted so that if it contains a '.' character, the part before is the dialect name this operation belongs to, and everything that follows is this operation name within the dialect.
An Operation defines zero or more SSA Value
that we refer to as the Operation results. This array of Value is actually stored in memory before the Operation itself in reverse order. That is for an Operation with 3 results we allocate the following memory layout:
[Result2, Result1, Result0, Operation] ^ this is where Operation*
pointer points to.
A consequence of this is that this class must be heap allocated, which is handled by the various create
methods. Each result contains:
OpOperand
)ValueImpl
, and more precisely as the only two subclasses of OpResultImpl
: InlineOpResult
and OutOfLineOpResult
. The former is used for the first 5 results and the latter for the subsequent ones. They differ in how they store their index: the first 5 results only need 3 bits and thus are packed with the Type pointer, while the subsequent one have an extra unsigned
value and thus need more space.An Operation also has zero or more operands: these are uses of SSA Value, which can be the results of other operations or Block arguments. Each of these uses is an instance of OpOperand
. This optional array is initially tail allocated with the operation class itself, but can be dynamically moved out-of-line in a dynamic allocation as needed.
An Operation may contain optionally one or multiple Regions, stored in a tail allocated array. Each Region
is a list of Blocks. Each Block
is itself a list of Operations. This structure is effectively forming a tree.
Some operations like branches also refer to other Block, in which case they would have an array of BlockOperand
.
An Operation may contain optionally a "Properties" object: this is a pre-defined C++ object with a fixed size. This object is owned by the operation and deleted with the operation. It can be converted to an Attribute on demand, or loaded from an Attribute.
Finally an Operation also contain an optional DictionaryAttr
, a Location, and a pointer to its parent Block (if any).
Definition at line 84 of file Operation.h.
Definition at line 595 of file Operation.h.
using mlir::Operation::operand_iterator = operand_range::iterator |
Definition at line 367 of file Operation.h.
Definition at line 366 of file Operation.h.
Definition at line 388 of file Operation.h.
Definition at line 389 of file Operation.h.
using mlir::Operation::result_iterator = result_range::iterator |
Definition at line 406 of file Operation.h.
Support result iteration.
Definition at line 405 of file Operation.h.
Support result type iteration.
Definition at line 419 of file Operation.h.
Definition at line 420 of file Operation.h.
using mlir::Operation::succ_iterator = SuccessorRange::iterator |
Definition at line 662 of file Operation.h.
Definition at line 801 of file Operation.h.
Definition at line 802 of file Operation.h.
Definition at line 828 of file Operation.h.
Definition at line 829 of file Operation.h.
Operation * Operation::clone | ( | CloneOptions | options = CloneOptions::all() | ) |
Definition at line 720 of file Operation.cpp.
Operation * Operation::clone | ( | IRMapping & | mapper, |
CloneOptions | options = CloneOptions::all() |
||
) |
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. Optionally, one may configure what parts of the operation to clone using the options parameter.
Calling this method from multiple threads is generally safe if through the process of cloning no new uses of 'Value's from outside the operation are created. Cloning an isolated-from-above operation with no operands, such as top level function operations, is therefore always safe. Using the mapper, it is possible to avoid adding uses to outside operands by remapping them to 'Value's owned by the caller thread.
Replaces references to cloned sub-operations to the corresponding operation that is copied, and adds those mappings to the map.
Definition at line 686 of file Operation.cpp.
References mlir::Region::cloneInto(), create(), getLoc(), getName(), getNumOperands(), getNumRegions(), getNumResults(), getNumSuccessors(), getOperands(), getPropertiesStorage(), getRegion(), getResult(), getResultTypes(), getSuccessors(), mlir::IRMapping::lookupOrDefault(), mlir::IRMapping::map(), and options.
Referenced by clone(), cloneWithoutRegions(), and generateUnrolledLoop().
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 676 of file Operation.cpp.
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. The mapResults
flag specifies whether the results of the cloned operation should be added to the map.
Definition at line 672 of file Operation.cpp.
References mlir::Operation::CloneOptions::all(), and clone().
void Operation::copyProperties | ( | OpaqueProperties | rhs | ) |
Copy properties from an existing other properties object.
The two objects must be the same type.
Definition at line 365 of file Operation.cpp.
References mlir::OperationName::copyOpProperties(), and getPropertiesStorage().
|
static |
Create a new Operation from the fields stored in state
.
Create a new Operation from operation state.
Definition at line 33 of file Operation.cpp.
|
static |
Create a new Operation with the specific fields.
Overload of create that takes an existing DictionaryAttr to avoid unnecessarily uniquing a list of attributes.
This constructor uses an existing attribute dictionary to avoid uniquing a list of attributes.
Definition at line 81 of file Operation.cpp.
References mlir::OperationName::getOpPropertyByteSize(), and mlir::OperationName::hasTrait().
|
static |
Create a new Operation with the specific fields.
This constructor populates the provided attribute list with default attributes if necessary.
Definition at line 66 of file Operation.cpp.
References mlir::Location::getContext(), and mlir::OperationName::populateDefaultAttrs().
Referenced by clone(), and createCtlzFunc().
|
static |
Create a new Operation with the specific fields.
Definition at line 50 of file Operation.cpp.
void Operation::destroy | ( | ) |
Destroys this operation and its subclass data.
Destroy this operation or one of its subclasses.
Definition at line 207 of file Operation.cpp.
Referenced by erase().
|
inline |
Definition at line 603 of file Operation.h.
References getAttrs().
|
inline |
Definition at line 607 of file Operation.h.
References getAttrs().
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 596 of file Operation.cpp.
References mlir::Block::dropAllDefinedValueUses(), dropAllUses(), and getRegions().
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 583 of file Operation.cpp.
Referenced by mlir::Block::dropAllReferences().
|
inline |
Drop all uses of results of this operation.
Definition at line 796 of file Operation.h.
References getOpResults().
Referenced by dropAllDefinedValueUses().
void Operation::dump | ( | ) |
Definition at line 3861 of file AsmPrinter.cpp.
References print().
Referenced by mlir::affine::checkMemrefAccessDependence(), and mlir::OpState::dump().
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 267 of file Operation.cpp.
References diag(), mlir::emitError(), getContext(), and getLoc().
Referenced by mlir::affine::affineDataCopyGenerate(), mlir::bufferization::allocateTensorForShapedValue(), mlir::NVVM::SerializeGPUModuleBase::appendStandardLibs(), applyTilingToAll(), checkAffineLoopNestMappableImpl(), convertOmpThreadprivate(), mlir::LLVM::ModuleToObject::createTargetMachine(), emitOpError(), findTopLevelTransform(), getMemoryFootprintBytes(), mlir::affine::insertBackwardComputationSlice(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), mlir::LLVM::ModuleToObject::linkFiles(), mlir::LLVM::ModuleToObject::loadBitcodeFile(), mlir::LLVM::ModuleToObject::loadBitcodeFilesFromList(), mlir::LLVM::ModuleToObject::optimizeModule(), printOperation(), mlir::LLVM::ModuleToObject::run(), and targetOpSupported().
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 640 of file Operation.cpp.
References emitError(), and getName().
Referenced by checkTransformationPreconditions(), mlir::ControlFlowToSCFTransformation::createStructuredBranchRegionOp(), and mlir::spirv::verifyGroupNonUniformArithmeticOp().
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 288 of file Operation.cpp.
References diag(), mlir::emitRemark(), getContext(), and getLoc().
Referenced by mlir::ROCDL::SerializeGPUModuleBase::appendStandardLibs(), emitRemarkForBlock(), and mlir::ROCDL::SerializeGPUModuleBase::getCommonBitcodeLibs().
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 279 of file Operation.cpp.
References diag(), mlir::emitWarning(), getContext(), and getLoc().
Referenced by mlir::affine::affineDataCopyGenerate(), and getMemoryFootprintBytes().
void Operation::erase | ( | ) |
Remove this operation from its parent block and delete it.
Remove this operation (and its descendants) from its Block and delete all of them.
Definition at line 538 of file Operation.cpp.
References destroy(), and getBlock().
Referenced by mlir::collapseParallelLoops(), mlir::OpState::erase(), mlir::SymbolTable::erase(), mlir::affine::normalizeMemRef(), replaceForOpWithNewSignature(), mlir::affine::replaceForOpWithNewYields(), transformCyclesToSCFLoops(), transformToStructuredCFBranches(), and mlir::detail::RecoveryReproducerContext::~RecoveryReproducerContext().
|
inline |
Erase the operand at position idx
.
Definition at line 351 of file Operation.h.
References eraseOperands().
|
inline |
Erases the operands that have their corresponding bit set in eraseIndices
and removes them from the operand list.
Definition at line 361 of file Operation.h.
References mlir::detail::OperandStorage::eraseOperands().
|
inline |
Erase the operands starting at position idx
and ending at position 'idx'+'length'.
Definition at line 355 of file Operation.h.
References mlir::detail::OperandStorage::eraseOperands().
Referenced by mlir::MutableOperandRange::clear(), mlir::MutableOperandRange::erase(), and eraseOperand().
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.
If folding was successful, this function returns "success".
results
is empty.results
is filled with the folded results. If folding was unsuccessful, this function returns "failure". Definition at line 610 of file Operation.cpp.
References mlir::failure(), mlir::OperationName::foldHook(), getDialect(), mlir::succeeded(), and mlir::success().
Referenced by fold().
LogicalResult Operation::fold | ( | SmallVectorImpl< OpFoldResult > & | results | ) |
Attempt to fold this operation.
If folding was successful, this function returns "success".
results
is empty.results
is filled with the folded results. If folding was unsuccessful, this function returns "failure". Definition at line 629 of file Operation.cpp.
References fold(), getNumOperands(), getOperand(), mlir::m_Constant(), and mlir::matchPattern().
|
inline |
Return the specified attribute if present, null otherwise.
These methods are expensive: if the dictionnary only contains discardable attributes, getDiscardableAttr
is more efficient.
Definition at line 495 of file Operation.h.
References getInherentAttr(), and getPropertiesStorageSize().
Referenced by getAttrOfType(), and lookupSymbolInImpl().
|
inline |
Definition at line 502 of file Operation.h.
References getInherentAttr(), and getPropertiesStorageSize().
DictionaryAttr Operation::getAttrDictionary | ( | ) |
Return all of the attributes on this operation as a DictionaryAttr.
Definition at line 295 of file Operation.cpp.
References getContext(), mlir::NamedAttrList::getDictionary(), getName(), getPropertiesStorageSize(), and mlir::OperationName::populateInherentAttrs().
Referenced by getAttrs(), and populateDefaultAttrs().
|
inline |
Definition at line 511 of file Operation.h.
References getAttr().
Referenced by convertOperationImpl(), mlir::SymbolTable::getSymbolVisibility(), mlir::spirv::printGroupNonUniformArithmeticOp(), and mlir::spirv::verifyGroupNonUniformArithmeticOp().
|
inline |
Definition at line 515 of file Operation.h.
References getAttr().
|
inline |
Return all of the attributes on this operation.
Definition at line 469 of file Operation.h.
References getAttrDictionary(), getDiscardableAttrs(), and getPropertiesStorage().
Referenced by dialect_attr_begin(), dialect_attr_end(), getDialectAttrs(), printShortForm(), and setDialectAttrs().
|
inline |
Returns the operation block that contains this operation.
Definition at line 213 of file Operation.h.
Referenced by mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), canRemoveSrcNodeAfterFusion(), constructTiledLoopNest(), erase(), mlir::Region::findAncestorBlockInRegion(), mlir::affine::generateCopyForMemRegion(), generateUnrolledLoop(), getPipelineStages(), mlir::bufferization::BufferPlacementAllocs::getStartOperation(), happensBefore(), hoistAffineIfOp(), mlir::inlineRegion(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), mlir::Liveness::isDeadAfter(), isOpSibling(), mlir::Value::isUsedOutsideOfBlock(), mayExistInterleavedUses(), moveAfter(), moveBefore(), mlir::DominanceInfo::properlyDominates(), mlir::PostDominanceInfo::properlyPostDominates(), remove(), and transformToReduceLoop().
|
inline |
Definition at line 657 of file Operation.h.
Referenced by getSuccessor(), setSuccessor(), and mlir::SuccessorRange::SuccessorRange().
|
inline |
Return the context this operation is associated with.
Definition at line 216 of file Operation.h.
References mlir::Attribute::getContext().
Referenced by mlir::ROCDL::SerializeGPUModuleBase::addControlVariables(), annotateConflict(), collectValidReferencesFor(), convertOperationImpl(), createNewAliasScopesFromNoAliasParameter(), emitError(), emitRemark(), emitWarning(), getAttrDictionary(), mlir::affine::getComputationSliceState(), mlir::OpState::getContext(), mlir::Region::getContext(), mlir::Pass::getContext(), mlir::LLVM::ModuleTranslation::getContext(), handleInlinedAllocas(), mlir::SymbolTable::insert(), mlir::NVVM::SerializeGPUModuleBase::loadBitcodeFiles(), mlir::ROCDL::SerializeGPUModuleBase::loadBitcodeFiles(), mlir::SymbolTable::lookup(), mlir::SymbolTable::lookupSymbolIn(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), performOptionalDebugActions(), populateDefaultAttrs(), prepareLLVMModule(), removeAttr(), setAttr(), setAttrs(), setDialectAttrs(), setDiscardableAttr(), setDiscardableAttrs(), mlir::SymbolTable::setSymbolName(), mlir::SymbolTable::setSymbolVisibility(), and mlir::SymbolTable::SymbolTable().
|
inline |
Return the dialect this operation is associated with, or nullptr if the associated dialect is not loaded.
Definition at line 220 of file Operation.h.
References mlir::OperationName::getDialect(), and getName().
Referenced by fold().
|
inline |
Return a range corresponding to the dialect attributes for this operation.
Definition at line 598 of file Operation.h.
References getAttrs().
|
inline |
Access a discardable attribute by name, returns an null Attribute if the discardable attribute does not exist.
Definition at line 452 of file Operation.h.
|
inline |
Access a discardable attribute by name, returns an null Attribute if the discardable attribute does not exist.
Definition at line 448 of file Operation.h.
Referenced by mlir::LLVM::detail::DebugTranslation::DebugTranslation(), and prepareLLVMModule().
|
inline |
Return all of the discardable attributes on this operation as a DictionaryAttr.
Definition at line 466 of file Operation.h.
Referenced by mlir::OperationEquivalence::isEquivalentTo().
|
inline |
Return all of the discardable attributes on this operation.
Definition at line 462 of file Operation.h.
Referenced by getAttrs().
std::optional< Attribute > Operation::getInherentAttr | ( | StringRef | name | ) |
Access an inherent attribute by name: returns an empty optional if there is no inherent attribute with this name.
This method is available as a transient facility in the migration process to use Properties instead.
Definition at line 340 of file Operation.cpp.
References mlir::OperationName::getInherentAttr(), and getName().
Referenced by getAttr(), hasAttr(), removeAttr(), setAttr(), and setAttrs().
|
inline |
The source location the operation was defined or derived from.
Definition at line 223 of file Operation.h.
Referenced by mlir::affine::affineDataCopyGenerate(), mlir::ROCDL::SerializeGPUModuleBase::assembleIsa(), buildMultiDimReduce(), mlir::transform::detail::checkApplyToOne(), checkDoubleConsume(), clone(), cloneAndFuseFirstUse(), mlir::LLVM::ModuleTranslation::convertBlock(), createNewAliasScopesFromNoAliasParameter(), createPrivateMemRef(), mlir::ControlFlowToSCFTransformation::createStructuredBranchRegionOp(), mlir::ControlFlowToSCFTransformation::createStructuredDoWhileLoopOp(), elementwiseMatchAndRewriteHelper(), emitError(), emitRemark(), emitWarning(), ensurePayloadIsSeparateFromTransform(), mlir::detail::PassCrashReproducerGenerator::finalize(), fuse(), mlir::OpState::getLoc(), mlir::Region::getLoc(), getMemoryFootprintBytes(), handleInlinedAllocas(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), mlir::OperationEquivalence::isEquivalentTo(), isFusionProfitable(), mlir::transform::gpu::mapNestedForallToThreadsImpl(), matchAndReplaceDepthwiseConv(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), prepareLLVMModule(), printConstantOp(), replaceAndPropagateMemRefType(), mlir::vector::splitFullAndPartialTransfer(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), transformCyclesToSCFLoops(), and transformToStructuredCFBranches().
|
inline |
The name of an operation is the key identifier for it.
Definition at line 119 of file Operation.h.
Referenced by mlir::transform::detail::checkApplyToOne(), clone(), mlir::ControlFlowToSCFTransformation::createUnreachableTerminator(), emitOpError(), mlir::detail::RecoveryReproducerContext::generate(), getAttrDictionary(), getDialect(), getInherentAttr(), getRegisteredInfo(), mlir::AsmParserState::initialize(), mlir::OperationEquivalence::isEquivalentTo(), isRegistered(), performOptionalDebugActions(), mlir::CallGraph::print(), printShortForm(), mlir::ConversionPatternRewriter::replaceUsesOfBlockArgument(), saveReproToTempFile(), setInherentAttr(), setPropertiesFromAttribute(), and shouldInline().
|
inline |
Definition at line 341 of file Operation.h.
References mlir::detail::OperandStorage::size().
Referenced by addExecuteResults(), mlir::sparse_tensor::Merger::buildExp(), clone(), convertOmpOpRegions(), mlir::affine::createAffineComputationSlice(), elementwiseMatchAndRewriteHelper(), emitElementwiseComputation(), findPayloadOp(), fold(), mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::getNumOperands(), mlir::linalg::detail::isContractionBody(), mlir::OperationEquivalence::isEquivalentTo(), mlir::matchReduction(), materializeConversion(), mlir::MutableOperandRange::MutableOperandRange(), mlir::spirv::printGroupNonUniformArithmeticOp(), setOperands(), and mlir::spirv::verifyGroupNonUniformArithmeticOp().
|
inline |
Returns the number of regions held by this operation.
Definition at line 635 of file Operation.h.
Referenced by clone(), mlir::OpTrait::detail::MultiRegionTraitBase< ConcreteType, TraitType >::getNumRegions(), mlir::OperationEquivalence::isEquivalentTo(), mlirRegionGetNextInOperation(), mlir::vector::splitFullAndPartialTransfer(), and mlir::SymbolTable::SymbolTable().
|
inline |
Return the number of results held by this operation.
Definition at line 399 of file Operation.h.
Referenced by mlir::transform::detail::checkApplyToOne(), clone(), convertOperationImpl(), elementwiseMatchAndRewriteHelper(), mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::getNumResults(), mlir::linalg::detail::isContractionBody(), mlir::OperationEquivalence::isEquivalentTo(), mlir::matchReduction(), materializeConversion(), printOperation(), replaceAndPropagateMemRefType(), and mlir::transform::detail::setApplyToOneResults().
|
inline |
Definition at line 668 of file Operation.h.
Referenced by checkTransformationPreconditions(), clone(), eraseTerminatorSuccessorOperands(), mlir::Block::getNumSuccessors(), mlir::OpTrait::detail::MultiSuccessorTraitBase< ConcreteType, TraitType >::getNumSuccessors(), getPHISourceValue(), getSuccessor(), mlir::OperationEquivalence::isEquivalentTo(), setSuccessor(), and mlir::SuccessorRange::SuccessorRange().
|
inline |
Definition at line 345 of file Operation.h.
References mlir::IROperand< DerivedT, IRValueT >::get(), and getOpOperand().
Referenced by mlir::affine::affineParallelize(), mlir::sparse_tensor::Merger::buildExp(), convertOmpOpRegions(), fold(), foldExtractFromBroadcast(), mlir::OpTrait::OneOperand< ConcreteType >::getOperand(), mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::getOperand(), getPHISourceValue(), mlir::linalg::detail::isContractionBody(), mlir::matchReduction(), materializeConversion(), printBinaryOperation(), mlir::spirv::printGroupNonUniformArithmeticOp(), and mlir::spirv::verifyGroupNonUniformArithmeticOp().
|
inline |
Returns an iterator on the underlying Value's.
Definition at line 373 of file Operation.h.
References getOpOperands().
Referenced by clone(), mlir::affine::createAffineComputationSlice(), defaultIsSmallAlloc(), expandInputRanks(), findPayloadOp(), mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::getOperands(), getOperandTypes(), getOutermostInvariantForOp(), mlir::transform::detail::getPotentialTopLevelEffects(), inlineConvertOmpRegions(), mlir::OperationEquivalence::isEquivalentTo(), isOpSibling(), mlir::makeRegionIsolatedFromAbove(), matchSimpleReduction(), operand_begin(), operand_end(), operandsAndResultsRanked(), mlir::MutableOperandRange::operator OperandRange(), mlir::outlineSingleBlockRegion(), CommutativeOperand::popFrontAndPushAdjacentUnvisitedAncestors(), printOperation(), and mlir::scf::tileConsumerAndFuseProducerGreedilyUsingSCFForOp().
|
inline |
Definition at line 392 of file Operation.h.
References getOperands(), and mlir::OperandRange::getTypes().
Referenced by checkSourceOpTypes(), mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::getOperandTypes(), and mlir::outlineSingleBlockRegion().
|
inline |
Definition at line 383 of file Operation.h.
References mlir::detail::OperandStorage::getOperands().
Referenced by getOperand(), mlir::linalg::hoistRedundantSubsetExtractInsert(), mlir::MutableOperandRange::operator[](), and setOperand().
|
inline |
Definition at line 378 of file Operation.h.
References mlir::detail::OperandStorage::getOperands().
Referenced by mlir::MutableOperandRange::begin(), mlir::MutableOperandRange::end(), getOperands(), replaceUsesOfWith(), and mlir::bufferization::detail::unknownGetAliasingOpOperands().
|
inline |
Definition at line 416 of file Operation.h.
References getResult().
Referenced by applyTilingToAll().
|
inline |
Definition at line 415 of file Operation.h.
References getResults().
Referenced by cloneAndFuseFirstUse(), dropAllUses(), isUsedOutsideOfBlock(), and mlir::bufferization::detail::unknownGetAliasingValues().
|
inline |
Return the closest surrounding parent operation that is of type 'OpTy'.
Definition at line 238 of file Operation.h.
Referenced by convertOmpTarget(), mlir::sparse_tensor::createFuncCall(), mlir::LLVM::createGlobalString(), mlir::linalg::hoistPaddingOnTensors(), mlir::scf::insideMutuallyExclusiveBranches(), mlir::insideMutuallyExclusiveRegions(), numEnclosingInvariantLoops(), and mlir::affine::replaceAllMemRefUsesWith().
|
inline |
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-level operation.
Definition at line 234 of file Operation.h.
References mlir::Block::getParentOp().
Referenced by collectParentLayouts(), collectSymbolScopes(), collectValidReferencesFor(), convertOmpReductionOp(), declareReduction(), ensurePayloadIsSeparateFromTransform(), findReductionDecl(), mlir::DataLayoutAnalysis::getAbove(), mlir::affine::getAffineParallelInductionVarOwner(), getAtMostNEnclosingLoops(), mlir::getBackwardSlice(), mlir::Pass::getCachedParentAnalysis(), getEnclosingLoopsUntil(), mlir::SymbolTable::getNearestSymbolTable(), mlir::bufferization::getOwnerOfValue(), getOwnerOfValue(), mlir::OpTrait::HasParent< ParentOpTypes >::Impl< ConcreteType >::getParentOp(), getRootOperation(), happensBefore(), mlir::SymbolTable::insert(), isProperAncestor(), isTensorChunkAccessedByUnknownOp(), mlir::affine::isTopLevelValue(), mlir::matchReduction(), movePaddingToFillOrGenericOp(), mlir::Block::print(), mlir::CallGraph::print(), printOperation(), and mlir::SymbolUserMap::replaceAllUsesWith().
|
inline |
Returns the region to which the instruction belongs.
Returns nullptr if the instruction is unlinked.
Definition at line 230 of file Operation.h.
References mlir::Block::getParent().
Referenced by createPrivateMemRef(), mlir::Region::getParentRegion(), mlir::affine::isTopLevelValue(), mlir::affine::isValidSymbol(), and mlir::bufferization::ValueComparator::operator()().
|
inline |
Returns the closest surrounding parent operation with trait Trait
.
Definition at line 248 of file Operation.h.
Attribute Operation::getPropertiesAsAttribute | ( | ) |
Return the properties converted to an attribute.
This is expensive, and mostly useful when dealing with unregistered operation. Returns an empty attribute if no properties are present.
Definition at line 348 of file Operation.cpp.
References mlir::OpaqueProperties::as(), getPropertiesStorage(), and getRegisteredInfo().
|
inline |
Returns the properties storage.
Definition at line 862 of file Operation.h.
Referenced by clone(), copyProperties(), getAttrs(), mlir::Op< ConcreteType, Traits >::getProperties(), getPropertiesAsAttribute(), hashProperties(), mlir::OperationEquivalence::isEquivalentTo(), and setPropertiesFromAttribute().
|
inline |
Definition at line 868 of file Operation.h.
|
inline |
Returns the properties storage size.
Definition at line 858 of file Operation.h.
Referenced by getAttr(), getAttrDictionary(), hasAttr(), removeAttr(), setAttr(), and setAttrs().
|
inline |
Returns the region held by this operation at position 'index'.
Definition at line 648 of file Operation.h.
References getRegions().
Referenced by mlir::affine::affineParallelize(), clone(), collectSymbolScopes(), mlir::ExecutionEngine::create(), mlir::OpTrait::SingleBlock< ConcreteType >::getBody(), mlir::transform::PossibleTopLevelTransformOpTrait< OpTy >::getBodyBlock(), mlir::OpTrait::SingleBlock< ConcreteType >::getBodyRegion(), getModuleBody(), mlir::OpTrait::OneRegion< ConcreteType >::getRegion(), mlir::OpTrait::detail::MultiRegionTraitBase< ConcreteType, TraitType >::getRegion(), mlir::SymbolTable::insert(), mlir::SymbolTable::lookupSymbolIn(), mlirRegionGetNextInOperation(), mlir::linalg::pack(), mlir::affine::replaceForOpWithNewYields(), mlir::vector::splitFullAndPartialTransfer(), mlir::SymbolTable::SymbolTable(), mlir::SymbolUserMap::SymbolUserMap(), transposeOneLinalgOperandAndReplace(), and vectorizeLinalgOpPrecondition().
|
inline |
Returns the regions held by this operation.
Definition at line 638 of file Operation.h.
Referenced by dropAllDefinedValueUses(), mlir::getInnermostParallelLoops(), getRegion(), mlir::Region::getRegionNumber(), mlir::OpTrait::detail::MultiRegionTraitBase< ConcreteType, TraitType >::getRegions(), mlir::dataflow::DeadCodeAnalysis::initialize(), mlir::dataflow::AbstractDenseForwardDataFlowAnalysis::initialize(), mlir::dataflow::AbstractDenseBackwardDataFlowAnalysis::initialize(), mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initialize(), mlir::OperationEquivalence::isEquivalentTo(), isOpSibling(), mlir::ForwardIterator::makeIterable(), mlir::bufferization::detail::unknownGetAliasingValues(), mlir::OpTrait::impl::verifyIsIsolatedFromAbove(), and walkSymbolUses().
|
inline |
If this operation has a registered operation description, return it.
Otherwise return std::nullopt.
Definition at line 123 of file Operation.h.
References getName(), and mlir::OperationName::getRegisteredInfo().
Referenced by getPropertiesAsAttribute(), and setPropertiesFromAttribute().
|
inline |
Get the 'idx'th result of this operation.
Definition at line 402 of file Operation.h.
Referenced by mlir::affine::affineParallelize(), mlir::bufferization::allocateTensorForShapedValue(), broadcastDynamicDimension(), mlir::tensor::bubbleUpPadSlice(), buildDivOp(), mlir::sparse_tensor::Merger::buildExp(), mlir::tensor::buildIndependentOp(), buildSubAndExpOp(), castToSourceType(), clone(), convertOmpThreadprivate(), convertOperationImpl(), getCollapsedOpOperand(), mlir::bufferization::DeallocationState::getMemrefsAndConditionsToDeallocate(), getOpResult(), mlir::OperationFolder::getOrCreateConstant(), mlir::OpTrait::OneTypedResult< ResultType >::Impl< ConcreteType >::getResult(), mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::getResult(), mlir::LLVMTypeConverter::LLVMTypeConverter(), matchAndReplaceDepthwiseConv(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsPackOpPattern::matchAndRewrite(), mlir::linalg::GeneralizeOuterUnitDimsUnPackOpPattern::matchAndRewrite(), materializeConversion(), mlir::outlineSingleBlockRegion(), printConstantOp(), mlir::spirv::printGroupNonUniformArithmeticOp(), reduce(), mlir::OpTrait::OneResult< ConcreteType >::replaceAllUsesWith(), replaceAndPropagateMemRefType(), replaceForAllWithNewSignature(), mlir::linalg::rewriteInIm2Col(), and vectorizeAsTensorPadOp().
|
inline |
Definition at line 410 of file Operation.h.
Referenced by addBodyWithPayloadOp(), mlir::transform::detail::checkApplyToOne(), mlir::sparse_tensor::FuncCallOrInlineGenerator< SubClass >::genCallOrInline(), getOpResults(), mlir::transform::detail::getPotentialTopLevelEffects(), mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::getResults(), getResultTypes(), getUses(), invertCollapseShapeIndexing(), mlir::OperationEquivalence::isEquivalentTo(), mlir::makeRegionIsolatedFromAbove(), VectorizationState::maskOperation(), operandsAndResultsRanked(), mlir::Liveness::print(), printOperation(), replaceAllUsesWith(), replaceAndPropagateMemRefType(), replaceUsesWithIf(), result_begin(), result_end(), mlir::transform::detail::setApplyToOneResults(), transformToStructuredCFBranches(), use_begin(), use_empty(), use_end(), and mlir::linalg::vectorizeCopy().
|
inline |
Definition at line 423 of file Operation.h.
References getResults(), and mlir::ResultRange::getTypes().
Referenced by checkSourceOpTypes(), clone(), emitElementwiseComputation(), expandInputRanks(), mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::getResultTypes(), mlir::outlineSingleBlockRegion(), result_type_begin(), and result_type_end().
|
inline |
Definition at line 670 of file Operation.h.
References getBlockOperands(), and getNumSuccessors().
Referenced by eraseTerminatorSuccessorOperands(), getPHISourceValue(), mlir::OpTrait::OneSuccessor< ConcreteType >::getSuccessor(), mlir::Block::getSuccessor(), mlir::OpTrait::detail::MultiSuccessorTraitBase< ConcreteType, TraitType >::getSuccessor(), and transformCyclesToSCFLoops().
|
inline |
Definition at line 665 of file Operation.h.
Referenced by clone(), mlir::OpTrait::detail::MultiSuccessorTraitBase< ConcreteType, TraitType >::getSuccessors(), mlir::OperationEquivalence::isRegionEquivalentTo(), successor_begin(), and successor_end().
|
inline |
Returns a range of all users.
Definition at line 835 of file Operation.h.
References user_begin(), and user_end().
Referenced by collapseBranch(), createNewAliasScopesFromNoAliasParameter(), mlir::bufferization::BufferPlacementTransformationBase::findCommonDominator(), findHoistableMatchingTransferRead(), findUnusedStore(), handleResultImpl(), insertionPointDominatesUses(), isOpSibling(), mlir::matchReduction(), and mlir::memref::multiBuffer().
|
inline |
Returns a range of all uses, which is useful for iterating over all uses.
Definition at line 808 of file Operation.h.
References getResults(), and mlir::ResultRange::getUses().
Referenced by hasOneUse(), and replaceUsesAndPropagateType().
|
inline |
Return true if the operation has an attribute with the provided name, false otherwise.
Definition at line 521 of file Operation.h.
References getInherentAttr(), and getPropertiesStorageSize().
|
inline |
Definition at line 528 of file Operation.h.
References getInherentAttr(), and getPropertiesStorageSize().
|
inline |
Definition at line 536 of file Operation.h.
llvm::hash_code Operation::hashProperties | ( | ) |
Compute a hash for the op properties (if any).
Definition at line 369 of file Operation.cpp.
References getPropertiesStorage(), and mlir::OperationName::hashOpProperties().
|
inline |
Returns true if this operation has exactly one use.
Definition at line 811 of file Operation.h.
References getUses().
Referenced by mlir::linalg::hoistRedundantSubsetExtractInsert(), and mlir::matchReduction().
|
inline |
Returns true if InterfaceT
has been promised by the dialect or implemented.
Definition at line 704 of file Operation.h.
References mlir::OperationName::hasPromiseOrImplementsInterface().
|
inline |
Definition at line 667 of file Operation.h.
|
inline |
Returns true if the operation was registered with a particular trait, e.g.
hasTrait<OperandsAreSignlessIntegerLike>().
Definition at line 711 of file Operation.h.
References mlir::OperationName::hasTrait().
Referenced by mlir::applyPatternsAndFoldGreedily(), collectSymbolScopes(), collectValidReferencesFor(), mlir::impl::ensureRegionTerminator(), mlir::SymbolTable::getNearestSymbolTable(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), mlir::affine::isTopLevelValue(), isUseSpeciallyKnownDead(), mlir::affine::isValidSymbol(), mlir::SymbolTable::lookupSymbolIn(), lookupSymbolInImpl(), mlirBlockGetTerminator(), mlir::sortTopologically(), mlir::SymbolTable::SymbolTable(), mlir::OpTrait::impl::verifyIsIsolatedFromAbove(), and walkSymbolUses().
void Operation::insertOperands | ( | unsigned | index, |
ValueRange | operands | ||
) |
Insert the given operands into the operand list at the given 'index'.
Definition at line 255 of file Operation.cpp.
References setOperands().
Referenced by addExecuteResults(), and mlir::MutableOperandRange::append().
|
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 263 of file Operation.h.
References isProperAncestor().
Referenced by collectValidReferencesFor(), isTensorChunkAccessedByUnknownOp(), printModuleForRepro(), and replaceForAllWithNewSignature().
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 385 of file Operation.cpp.
References mlir::Block::isOpOrderValid(), and mlir::Block::recomputeOpOrder().
Referenced by mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), canRemoveSrcNodeAfterFusion(), mlir::LivenessBlockInfo::getEndOperation(), getFusedLoopNestInsertionPoint(), happensBefore(), mlir::affine::MemRefDependenceGraph::hasDependencePath(), mlir::Liveness::isDeadAfter(), isOpSibling(), mayExistInterleavedUses(), mlir::bufferization::ValueComparator::operator()(), mlir::PostDominanceInfo::properlyPostDominates(), and srcAppearsBeforeDstInAncestralBlock().
bool Operation::isProperAncestor | ( | Operation * | other | ) |
Return true if this operation is a proper ancestor of the other
operation.
Definition at line 218 of file Operation.cpp.
References getParentOp().
Referenced by mlir::LocalAliasAnalysis::aliasImpl(), cloneAndFuseFirstUse(), happensBefore(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), isAncestor(), isLocallyDefined(), and mlir::replaceLoopWithNewYields().
|
inline |
Returns true if this operation has a registered operation description, otherwise false.
Definition at line 129 of file Operation.h.
References getName(), and mlir::OperationName::isRegistered().
Referenced by mlir::mayBeGraphRegion().
|
inline |
Returns true if the results of this operation are used outside of the given block.
Definition at line 818 of file Operation.h.
References getOpResults(), and mlir::Value::isUsedOutsideOfBlock().
|
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 719 of file Operation.h.
References mlir::OperationName::mightHaveTrait().
Referenced by ensureDistinctSuccessors(), mlir::linalg::detail::isContractionBody(), mlir::matchReduction(), and mlir::Block::mightHaveTerminator().
Unlink this operation from its current block and insert it right after iterator
in the specified block.
Definition at line 574 of file Operation.cpp.
References mlir::Block::end(), and moveBefore().
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 568 of file Operation.cpp.
References getBlock().
Referenced by handleInlinedAllocas().
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 560 of file Operation.cpp.
References getBlock(), and mlir::Block::getOperations().
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 554 of file Operation.cpp.
References getBlock().
Referenced by moveAfter().
|
inline |
Definition at line 369 of file Operation.h.
References getOperands().
Referenced by mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::operand_begin(), and operand_type_begin().
|
inline |
Definition at line 370 of file Operation.h.
References getOperands().
Referenced by mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::operand_end(), and operand_type_end().
|
inline |
Definition at line 390 of file Operation.h.
References operand_begin().
Referenced by mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::operand_type_begin().
|
inline |
Definition at line 391 of file Operation.h.
References operand_end().
Referenced by mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::operand_type_end().
|
inline |
Sets default attributes on unset attributes.
Definition at line 624 of file Operation.h.
References getAttrDictionary(), getContext(), mlir::NamedAttrList::getDictionary(), mlir::OperationName::populateDefaultAttrs(), and setAttrs().
void Operation::print | ( | raw_ostream & | os, |
AsmState & | state | ||
) |
Definition at line 3851 of file AsmPrinter.cpp.
void Operation::print | ( | raw_ostream & | os, |
const OpPrintingFlags & | flags = std::nullopt |
||
) |
Definition at line 3845 of file AsmPrinter.cpp.
Referenced by mlir::OpState::print(), and printModuleForRepro().
void Operation::remove | ( | ) |
Remove the operation from its parent block, but don't delete it.
Definition at line 546 of file Operation.cpp.
References getBlock().
Referenced by transformCyclesToSCFLoops().
|
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 561 of file Operation.h.
References mlir::NamedAttrList::erase(), getContext(), mlir::NamedAttrList::getDictionary(), getInherentAttr(), getPropertiesStorageSize(), and setInherentAttr().
Referenced by performOptionalDebugActions(), removeAttr(), and mlir::SymbolTable::setSymbolVisibility().
|
inline |
Definition at line 574 of file Operation.h.
References mlir::get(), getContext(), and removeAttr().
|
inline |
Replace all uses of results of this operation with the provided 'values'.
Definition at line 272 of file Operation.h.
References getResults(), and mlir::ResultRange::replaceAllUsesWith().
Referenced by convertToLaunchFuncOp(), mlir::affine::promoteIfSingleIteration(), mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::replaceAllUsesWith(), and transformToStructuredCFBranches().
Replace any uses of 'from' with 'to' within this operation.
Definition at line 226 of file Operation.cpp.
References getOpOperands().
|
inline |
Replace uses of results of this operation with the provided values
if the given callback returns true.
Definition at line 279 of file Operation.h.
References getResults(), and mlir::ResultRange::replaceUsesWithIf().
|
inline |
Definition at line 408 of file Operation.h.
References getResults().
Referenced by mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::result_begin().
|
inline |
Definition at line 409 of file Operation.h.
References getResults().
Referenced by mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::result_end().
|
inline |
Definition at line 421 of file Operation.h.
References getResultTypes().
Referenced by materializeConversion(), and mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::result_type_begin().
|
inline |
Definition at line 422 of file Operation.h.
References getResultTypes().
Referenced by mlir::OpTrait::detail::MultiResultTraitBase< ConcreteType, TraitType >::result_type_end().
|
inline |
If the an attribute exists with the specified name, change it to the new value.
Otherwise, add a new attribute with the specified name/value.
Definition at line 543 of file Operation.h.
References getContext(), mlir::NamedAttrList::getDictionary(), getInherentAttr(), getPropertiesStorageSize(), mlir::NamedAttrList::set(), and setInherentAttr().
Referenced by annotateConflict(), mlir::sparse_tensor::getFunc(), lowerAsEntryFunction(), outlineKernelFuncImpl(), performOptionalDebugActions(), setAttr(), mlir::SymbolTable::setSymbolName(), mlir::SymbolTable::setSymbolVisibility(), and mlir::vector::splitFullAndPartialTransfer().
|
inline |
Definition at line 554 of file Operation.h.
References mlir::get(), getContext(), and setAttr().
void Operation::setAttrs | ( | ArrayRef< NamedAttribute > | newAttrs | ) |
Definition at line 322 of file Operation.cpp.
References mlir::get(), getContext(), getInherentAttr(), getPropertiesStorageSize(), and setInherentAttr().
void Operation::setAttrs | ( | DictionaryAttr | newAttrs | ) |
Set the attributes from a dictionary on this operation.
These methods are expensive: if the dictionnary only contains discardable attributes, setDiscardableAttrs
is more efficient.
Definition at line 304 of file Operation.cpp.
References mlir::get(), getContext(), getInherentAttr(), getPropertiesStorageSize(), and setInherentAttr().
Referenced by ConvertTypesInSCFForOp::matchAndRewrite(), populateDefaultAttrs(), and setDialectAttrs().
|
inline |
Set the dialect attributes for this operation, and preserve all inherent.
Definition at line 614 of file Operation.h.
References mlir::NamedAttrList::append(), getAttrs(), getContext(), mlir::NamedAttrList::getDictionary(), mlir::NamedAttrList::push_back(), and setAttrs().
|
inline |
Set a discardable attribute by name.
Definition at line 455 of file Operation.h.
References getContext(), mlir::NamedAttrList::getDictionary(), and mlir::NamedAttrList::set().
|
inline |
Definition at line 488 of file Operation.h.
References mlir::get(), getContext(), and setDiscardableAttrs().
|
inline |
Set the discardable attribute dictionary on this operation.
Definition at line 484 of file Operation.h.
Referenced by setDiscardableAttrs().
void Operation::setInherentAttr | ( | StringAttr | name, |
Attribute | value | ||
) |
Set an inherent attribute by name.
This method is available as a transient facility in the migration process to use Properties instead.
Definition at line 344 of file Operation.cpp.
References getName(), and mlir::OperationName::setInherentAttr().
Referenced by removeAttr(), setAttr(), and setAttrs().
|
inline |
Set the source location the operation was defined or derived from.
Definition at line 226 of file Operation.h.
|
inline |
Definition at line 346 of file Operation.h.
References getOpOperand(), and mlir::IROperand< DerivedT, IRValueT >::set().
Referenced by mlir::MutableOperandRange::assign(), mlir::OpTrait::detail::MultiOperandTraitBase< ConcreteType, TraitType >::setOperand(), mlir::OpTrait::OneOperand< ConcreteType >::setOperand(), and tileAndFuseFirstExtractUseThroughContainingOpBlockArgument().
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 245 of file Operation.cpp.
References getNumOperands(), and mlir::detail::OperandStorage::setOperands().
void Operation::setOperands | ( | ValueRange | operands | ) |
Replace the current operands of this operation with the ones provided in 'operands'.
Definition at line 236 of file Operation.cpp.
References mlir::detail::OperandStorage::setOperands().
Referenced by mlir::affine::affineParallelize(), mlir::MutableOperandRange::assign(), generateUnrolledLoop(), and insertOperands().
LogicalResult Operation::setPropertiesFromAttribute | ( | Attribute | attr, |
function_ref< InFlightDiagnostic &()> | getDiag | ||
) |
Set the properties from the provided attribute.
This is an expensive operation that can fail if the attribute is not matching the expectations of the properties for this operation. This is mostly useful for unregistered operations or used when parsing the generic format. An optional diagnostic can be passed in for richer errors.
Definition at line 354 of file Operation.cpp.
References mlir::OpaqueProperties::as(), getName(), getPropertiesStorage(), getRegisteredInfo(), and mlir::success().
void Operation::setSuccessor | ( | Block * | block, |
unsigned | index | ||
) |
Definition at line 604 of file Operation.cpp.
References getBlockOperands(), and getNumSuccessors().
Referenced by mlir::OpTrait::detail::MultiSuccessorTraitBase< ConcreteType, TraitType >::setSuccessor(), and mlir::OpTrait::OneSuccessor< ConcreteType >::setSuccessor().
|
inline |
Definition at line 663 of file Operation.h.
References getSuccessors().
|
inline |
Definition at line 664 of file Operation.h.
References getSuccessors().
|
inline |
Definition at line 804 of file Operation.h.
References getResults(), and mlir::ResultRange::use_begin().
Referenced by user_begin().
|
inline |
Returns true if this operation has no uses.
Definition at line 814 of file Operation.h.
References getResults(), and mlir::ResultRange::use_empty().
Referenced by isResultValueDead(), and mlir::OpState::use_empty().
|
inline |
Definition at line 805 of file Operation.h.
References getResults(), and mlir::ResultRange::use_end().
Referenced by user_end().
|
inline |
|
inline |
|
inline |
Walk the operation by calling the callback for each nested operation (including this one), block or region, depending on the callback provided.
The order in which regions, blocks and operations at the same nesting level are visited (e.g., lexicographical or reverse lexicographical order) is determined by 'Iterator'. 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 callback method can take any of the following forms: void(Operation*) : Walk all operations opaquely.
Definition at line 759 of file Operation.h.
Referenced by buildBlockMapping(), mlir::affine::LoopNestStateCollector::collect(), mlir::LLVM::detail::DebugTranslation::DebugTranslation(), mlir::memref::eraseDeadAllocAndStores(), findOpWithTag(), mlir::transform::gpu::findTopLevelForallOp(), findTopLevelTransform(), getFirstDependentOpInRange(), getLastDependentOpInRange(), getLoadAndStoreMemRefAccesses(), getShmReadAndWriteOps(), hasNonAffineUsersOnThePath(), mlir::transform::gpu::mapNestedForallToThreadsImpl(), mlir::OperationFingerPrint::OperationFingerPrint(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), outlineKernelFuncImpl(), mlir::populateConversionTargetFromOperation(), mlir::Liveness::print(), mlir::vector::transferOpflowOpt(), and mlir::OpState::walk().
|
inline |
Generic walker with a stage aware callback.
Walk the operation by calling the callback for each nested operation (including this one) N+1 times, where N is the number of regions attached to that operation.
The callback method can take any of the following forms: void(Operation *, const WalkStage &) : Walk all operation opaquely
Definition at line 787 of file Operation.h.
References mlir::detail::walk().
Definition at line 1032 of file Operation.h.
Definition at line 1035 of file Operation.h.
Definition at line 1026 of file Operation.h.
Definition at line 1035 of file Operation.h.