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

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

#include "mlir/IR/Operation.h"

+ Inheritance diagram for mlir::Operation:

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< 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 (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...
 
Operationclone (CloneOptions options=CloneOptions::all())
 
OperationcloneWithoutRegions (IRMapping &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...
 
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< 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 ()
 
std::optional< AttributegetInherentAttr (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...
 
void setDiscardableAttr (StringRef name, Attribute value)
 
Attribute removeDiscardableAttr (StringAttr name)
 Remove the discardable attribute with the specified name if it exists. More...
 
Attribute removeDiscardableAttr (StringRef name)
 
auto getDiscardableAttrs ()
 Return a range of all of discardable attributes on this operation. More...
 
DictionaryAttr getDiscardableAttrDictionary ()
 Return all of the discardable attributes on this operation as a DictionaryAttr. More...
 
DictionaryAttr getRawDictionaryAttrs ()
 Return all attributes that are not stored as properties. More...
 
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 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< 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...
 
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()> emitError)
 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 Operationcreate (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 Operationcreate (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 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, 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 >
 

Detailed Description

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:

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.

Member Typedef Documentation

◆ dialect_attr_range

Definition at line 629 of file Operation.h.

◆ operand_iterator

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

Definition at line 367 of file Operation.h.

◆ operand_range

Definition at line 366 of file Operation.h.

◆ operand_type_iterator

Definition at line 388 of file Operation.h.

◆ operand_type_range

Definition at line 389 of file Operation.h.

◆ result_iterator

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

Definition at line 406 of file Operation.h.

◆ result_range

Support result iteration.

Definition at line 405 of file Operation.h.

◆ result_type_iterator

Support result type iteration.

Definition at line 419 of file Operation.h.

◆ result_type_range

Definition at line 420 of file Operation.h.

◆ succ_iterator

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

Definition at line 696 of file Operation.h.

◆ use_iterator

Definition at line 835 of file Operation.h.

◆ use_range

Definition at line 836 of file Operation.h.

◆ user_iterator

Definition at line 862 of file Operation.h.

◆ user_range

Definition at line 863 of file Operation.h.

Member Function Documentation

◆ clone() [1/2]

Operation * Operation::clone ( CloneOptions  options = CloneOptions::all())

Definition at line 751 of file Operation.cpp.

References clone(), and options.

◆ clone() [2/2]

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 717 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(), generateUnrolledLoop(), and mlir::transform::detail::interpreterBaseRunOnOperationImpl().

◆ cloneWithoutRegions() [1/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 707 of file Operation.cpp.

◆ cloneWithoutRegions() [2/2]

Operation * Operation::cloneWithoutRegions ( IRMapping 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. The mapResults flag specifies whether the results of the cloned operation should be added to the map.

Definition at line 703 of file Operation.cpp.

References mlir::Operation::CloneOptions::all(), and clone().

◆ copyProperties()

void Operation::copyProperties ( OpaqueProperties  rhs)

Copy properties from an existing other properties object.

The two objects must be the same type.

Definition at line 366 of file Operation.cpp.

References mlir::OperationName::copyOpProperties(), and getPropertiesStorage().

◆ create() [1/4]

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

Create a new Operation from the fields stored in state.

Create a new Operation from operation state.

Definition at line 34 of file Operation.cpp.

◆ create() [2/4]

Operation * Operation::create ( Location  location,
OperationName  name,
TypeRange  resultTypes,
ValueRange  operands,
DictionaryAttr  attributes,
OpaqueProperties  properties,
BlockRange  successors,
unsigned  numRegions 
)
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 82 of file Operation.cpp.

References mlir::OperationName::getOpPropertyByteSize(), and mlir::OperationName::hasTrait().

◆ create() [3/4]

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

Create a new Operation with the specific fields.

This constructor populates the provided attribute list with default attributes if necessary.

Definition at line 67 of file Operation.cpp.

References mlir::Location::getContext(), and mlir::OperationName::populateDefaultAttrs().

Referenced by clone(), and createCtlzFunc().

◆ create() [4/4]

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

Create a new Operation with the specific fields.

Definition at line 51 of file Operation.cpp.

◆ destroy()

void Operation::destroy ( )

Destroys this operation and its subclass data.

Destroy this operation or one of its subclasses.

Definition at line 208 of file Operation.cpp.

Referenced by erase().

◆ dialect_attr_begin()

dialect_attr_iterator mlir::Operation::dialect_attr_begin ( )
inline

Definition at line 637 of file Operation.h.

References getAttrs().

◆ dialect_attr_end()

dialect_attr_iterator mlir::Operation::dialect_attr_end ( )
inline

Definition at line 641 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 597 of file Operation.cpp.

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

◆ 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 584 of file Operation.cpp.

Referenced by mlir::Block::dropAllReferences().

◆ dropAllUses()

void mlir::Operation::dropAllUses ( )
inline

Drop all uses of results of this operation.

Definition at line 830 of file Operation.h.

References getOpResults().

Referenced by dropAllDefinedValueUses().

◆ dump()

void Operation::dump ( )

Definition at line 3931 of file AsmPrinter.cpp.

References print().

Referenced by mlir::affine::checkMemrefAccessDependence(), and mlir::OpState::dump().

◆ emitError()

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

◆ 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 671 of file Operation.cpp.

References emitError(), and getName().

Referenced by checkTransformationPreconditions(), mlir::ControlFlowToSCFTransformation::createStructuredBranchRegionOp(), and mlir::spirv::verifyGroupNonUniformArithmeticOp().

◆ 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 289 of file Operation.cpp.

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

Referenced by mlir::ROCDL::SerializeGPUModuleBase::appendStandardLibs(), emitRemarkForBlock(), and mlir::ROCDL::SerializeGPUModuleBase::getCommonBitcodeLibs().

◆ 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 280 of file Operation.cpp.

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

Referenced by mlir::affine::affineDataCopyGenerate(), and getMemoryFootprintBytes().

◆ erase()

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 539 of file Operation.cpp.

References destroy(), and getBlock().

Referenced by mlir::collapseParallelLoops(), mlir::OpState::erase(), mlir::SymbolTable::erase(), mlir::affine::normalizeMemRef(), transformCyclesToSCFLoops(), transformToStructuredCFBranches(), and mlir::detail::RecoveryReproducerContext::~RecoveryReproducerContext().

◆ eraseOperand()

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

Erase the operand at position idx.

Definition at line 351 of file Operation.h.

References eraseOperands().

◆ eraseOperands() [1/2]

void mlir::Operation::eraseOperands ( const BitVector &  eraseIndices)
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().

◆ eraseOperands() [2/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 355 of file Operation.h.

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

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

◆ fold() [1/2]

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 was successful, this function returns "success".

  • If this operation was modified in-place (but not folded away), results is empty.
  • Otherwise, results is filled with the folded results. If folding was unsuccessful, this function returns "failure".

Definition at line 632 of file Operation.cpp.

References checkFoldResultTypes(), mlir::failure(), mlir::OperationName::foldHook(), getDialect(), mlir::succeeded(), and mlir::success().

Referenced by fold().

◆ fold() [2/2]

LogicalResult Operation::fold ( SmallVectorImpl< OpFoldResult > &  results)

Attempt to fold this operation.

If folding was successful, this function returns "success".

  • If this operation was modified in-place (but not folded away), results is empty.
  • Otherwise, results is filled with the folded results. If folding was unsuccessful, this function returns "failure".

Definition at line 660 of file Operation.cpp.

References fold(), getNumOperands(), getOperand(), mlir::m_Constant(), and mlir::matchPattern().

◆ getAttr() [1/2]

Attribute mlir::Operation::getAttr ( StringAttr  name)
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 529 of file Operation.h.

References getInherentAttr(), and getPropertiesStorageSize().

Referenced by mlir::LLVM::detail::createIntrinsicCall(), getAttrOfType(), and lookupSymbolInImpl().

◆ getAttr() [2/2]

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

Definition at line 536 of file Operation.h.

References getInherentAttr(), and getPropertiesStorageSize().

◆ getAttrDictionary()

DictionaryAttr Operation::getAttrDictionary ( )

Return all of the attributes on this operation as a DictionaryAttr.

Definition at line 296 of file Operation.cpp.

References getContext(), mlir::NamedAttrList::getDictionary(), getName(), getPropertiesStorageSize(), and mlir::OperationName::populateInherentAttrs().

Referenced by getAttrs(), and populateDefaultAttrs().

◆ 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 549 of file Operation.h.

References getAttr().

◆ getAttrs()

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

Return all of the attributes on this operation.

Definition at line 507 of file Operation.h.

References getAttrDictionary().

Referenced by dialect_attr_begin(), dialect_attr_end(), getDialectAttrs(), printShortForm(), and setDialectAttrs().

◆ getBlock()

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

◆ getBlockOperands()

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

Definition at line 691 of file Operation.h.

Referenced by getSuccessor(), setSuccessor(), and mlir::SuccessorRange::SuccessorRange().

◆ getContext()

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

◆ getDialect()

Dialect* mlir::Operation::getDialect ( )
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().

◆ getDialectAttrs()

dialect_attr_range mlir::Operation::getDialectAttrs ( )
inline

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

Definition at line 632 of file Operation.h.

References getAttrs().

◆ getDiscardableAttr() [1/2]

Attribute mlir::Operation::getDiscardableAttr ( StringAttr  name)
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.

◆ getDiscardableAttr() [2/2]

Attribute mlir::Operation::getDiscardableAttr ( StringRef  name)
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().

◆ getDiscardableAttrDictionary()

DictionaryAttr mlir::Operation::getDiscardableAttrDictionary ( )
inline

Return all of the discardable attributes on this operation as a DictionaryAttr.

Definition at line 496 of file Operation.h.

References mlir::get(), getContext(), getDiscardableAttrs(), and getPropertiesStorage().

◆ getDiscardableAttrs()

auto mlir::Operation::getDiscardableAttrs ( )
inline

Return a range of all of discardable attributes on this operation.

Note that for unregistered operations that are not storing inherent attributes as properties, all attributes are considered discardable.

Definition at line 481 of file Operation.h.

References getRegisteredInfo().

Referenced by getDiscardableAttrDictionary().

◆ getInherentAttr()

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 341 of file Operation.cpp.

References mlir::OperationName::getInherentAttr(), and getName().

Referenced by getAttr(), hasAttr(), removeAttr(), setAttr(), and setAttrs().

◆ getLoc()

Location mlir::Operation::getLoc ( )
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::detail::createIntrinsicCall(), 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::amdgpu::optimizeSharedMemoryReadsAndWrites(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), prepareLLVMModule(), printConstantOp(), printFunctionArgs(), replaceAndPropagateMemRefType(), mlir::vector::splitFullAndPartialTransfer(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::scf::tileAndFuseProducerOfSlice(), transformCyclesToSCFLoops(), transformToStructuredCFBranches(), and mlir::scf::yieldReplacementForFusedProducer().

◆ getName()

OperationName mlir::Operation::getName ( )
inline

◆ getNumOperands()

unsigned mlir::Operation::getNumOperands ( )
inline

◆ getNumRegions()

unsigned mlir::Operation::getNumRegions ( )
inline

◆ getNumResults()

unsigned mlir::Operation::getNumResults ( )
inline

◆ getNumSuccessors()

unsigned mlir::Operation::getNumSuccessors ( )
inline

◆ getOperand()

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

◆ getOperands()

operand_range mlir::Operation::getOperands ( )
inline

◆ 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

Definition at line 416 of file Operation.h.

References getResult().

Referenced by applyTilingToAll().

◆ getOpResults()

result_range mlir::Operation::getOpResults ( )
inline

◆ getParentOfType()

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

◆ getParentOp()

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

◆ getParentRegion()

Region* mlir::Operation::getParentRegion ( )
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(), handleInlinedAllocas(), mlir::affine::isTopLevelValue(), mlir::affine::isValidSymbol(), and mlir::bufferization::ValueComparator::operator()().

◆ getParentWithTrait()

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

Returns the closest surrounding parent operation with trait Trait.

Definition at line 248 of file Operation.h.

◆ getPropertiesAsAttribute()

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 349 of file Operation.cpp.

References mlir::OpaqueProperties::as(), getPropertiesStorage(), and getRegisteredInfo().

◆ getPropertiesStorage() [1/2]

OpaqueProperties mlir::Operation::getPropertiesStorage ( )
inline

◆ getPropertiesStorage() [2/2]

OpaqueProperties mlir::Operation::getPropertiesStorage ( ) const
inline

Definition at line 902 of file Operation.h.

◆ getPropertiesStorageSize()

int mlir::Operation::getPropertiesStorageSize ( ) const
inline

Returns the properties storage size.

Definition at line 892 of file Operation.h.

Referenced by getAttr(), getAttrDictionary(), hasAttr(), removeAttr(), setAttr(), and setAttrs().

◆ getRawDictionaryAttrs()

DictionaryAttr mlir::Operation::getRawDictionaryAttrs ( )
inline

Return all attributes that are not stored as properties.

Definition at line 504 of file Operation.h.

Referenced by mlir::OperationEquivalence::isEquivalentTo().

◆ getRegion()

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

◆ getRegions()

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

◆ getRegisteredInfo()

std::optional<RegisteredOperationName> mlir::Operation::getRegisteredInfo ( )
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 getDiscardableAttrs(), getPropertiesAsAttribute(), and setPropertiesFromAttribute().

◆ getResult()

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

◆ getResults()

result_range mlir::Operation::getResults ( )
inline

◆ 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 842 of file Operation.h.

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

Referenced by hasOneUse(), and replaceUsesAndPropagateType().

◆ 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 555 of file Operation.h.

References getInherentAttr(), and getPropertiesStorageSize().

◆ hasAttr() [2/2]

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

Definition at line 562 of file Operation.h.

References getInherentAttr(), and getPropertiesStorageSize().

◆ hasAttrOfType()

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

Definition at line 570 of file Operation.h.

◆ hashProperties()

llvm::hash_code Operation::hashProperties ( )

Compute a hash for the op properties (if any).

Definition at line 370 of file Operation.cpp.

References getPropertiesStorage(), and mlir::OperationName::hashOpProperties().

◆ hasOneUse()

bool mlir::Operation::hasOneUse ( )
inline

Returns true if this operation has exactly one use.

Definition at line 845 of file Operation.h.

References getUses().

Referenced by mlir::matchReduction().

◆ hasPromiseOrImplementsInterface()

template<typename InterfaceT >
bool mlir::Operation::hasPromiseOrImplementsInterface ( ) const
inline

Returns true if InterfaceT has been promised by the dialect or implemented.

Definition at line 738 of file Operation.h.

References mlir::OperationName::hasPromiseOrImplementsInterface().

◆ hasSuccessors()

bool mlir::Operation::hasSuccessors ( )
inline

Definition at line 701 of file Operation.h.

◆ hasTrait()

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

◆ insertOperands()

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

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

Definition at line 256 of file Operation.cpp.

References setOperands().

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

◆ 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 263 of file Operation.h.

References isProperAncestor().

Referenced by collectValidReferencesFor(), printModuleForRepro(), and replaceForAllWithNewSignature().

◆ 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 386 of file Operation.cpp.

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

Referenced by canRemoveSrcNodeAfterFusion(), dominanceSort(), mlir::LivenessBlockInfo::getEndOperation(), getFusedLoopNestInsertionPoint(), happensBefore(), mlir::affine::MemRefDependenceGraph::hasDependencePath(), mlir::Liveness::isDeadAfter(), isOpSibling(), mayExistInterleavedUses(), mlir::bufferization::ValueComparator::operator()(), mlir::PostDominanceInfo::properlyPostDominates(), and srcAppearsBeforeDstInAncestralBlock().

◆ isProperAncestor()

bool Operation::isProperAncestor ( Operation other)

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

Definition at line 219 of file Operation.cpp.

References getParentOp().

Referenced by mlir::LocalAliasAnalysis::aliasImpl(), cloneAndFuseFirstUse(), happensBefore(), mlir::transform::detail::interpreterBaseRunOnOperationImpl(), isAncestor(), and isLocallyDefined().

◆ isRegistered()

bool mlir::Operation::isRegistered ( )
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().

◆ 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 852 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 753 of file Operation.h.

References mlir::OperationName::mightHaveTrait().

Referenced by ensureDistinctSuccessors(), mlir::linalg::detail::isContractionBody(), mlir::matchReduction(), and mlir::Block::mightHaveTerminator().

◆ moveAfter() [1/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 575 of file Operation.cpp.

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

◆ moveAfter() [2/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 569 of file Operation.cpp.

References getBlock().

Referenced by handleInlinedAllocas().

◆ moveBefore() [1/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 561 of file Operation.cpp.

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

◆ moveBefore() [2/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 555 of file Operation.cpp.

References getBlock().

Referenced by moveAfter().

◆ 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

◆ populateDefaultAttrs()

void mlir::Operation::populateDefaultAttrs ( )
inline

Sets default attributes on unset attributes.

Definition at line 658 of file Operation.h.

References getAttrDictionary(), getContext(), mlir::NamedAttrList::getDictionary(), mlir::OperationName::populateDefaultAttrs(), and setAttrs().

◆ print() [1/2]

void Operation::print ( raw_ostream &  os,
AsmState state 
)

Definition at line 3921 of file AsmPrinter.cpp.

◆ print() [2/2]

void Operation::print ( raw_ostream &  os,
const OpPrintingFlags flags = std::nullopt 
)

Definition at line 3915 of file AsmPrinter.cpp.

Referenced by mlir::OpState::print(), and printModuleForRepro().

◆ remove()

void Operation::remove ( )

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

Definition at line 547 of file Operation.cpp.

References getBlock().

Referenced by transformCyclesToSCFLoops().

◆ 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 595 of file Operation.h.

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

Referenced by performOptionalDebugActions(), removeAttr(), and mlir::SymbolTable::setSymbolVisibility().

◆ removeAttr() [2/2]

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

Definition at line 608 of file Operation.h.

References mlir::get(), getContext(), and removeAttr().

◆ removeDiscardableAttr() [1/2]

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

Remove the discardable 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 467 of file Operation.h.

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

Referenced by removeDiscardableAttr().

◆ removeDiscardableAttr() [2/2]

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

Definition at line 474 of file Operation.h.

References mlir::get(), getContext(), and removeDiscardableAttr().

◆ 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 227 of file Operation.cpp.

References getOpOperands().

◆ replaceUsesWithIf()

template<typename ValuesT >
void mlir::Operation::replaceUsesWithIf ( ValuesT &&  values,
function_ref< bool(OpOperand &)>  shouldReplace 
)
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().

◆ result_begin()

result_iterator mlir::Operation::result_begin ( )
inline

◆ result_end()

result_iterator mlir::Operation::result_end ( )
inline

◆ 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 588 of file Operation.h.

References mlir::get(), getContext(), and setAttr().

◆ setAttrs() [1/2]

void Operation::setAttrs ( ArrayRef< NamedAttribute newAttrs)

◆ setAttrs() [2/2]

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 305 of file Operation.cpp.

References mlir::get(), getContext(), getInherentAttr(), getPropertiesStorageSize(), and setInherentAttr().

Referenced by ConvertTypesInSCFForOp::matchAndRewrite(), populateDefaultAttrs(), and setDialectAttrs().

◆ setDialectAttrs()

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

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

Definition at line 648 of file Operation.h.

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

◆ setDiscardableAttr() [1/2]

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

Set a discardable attribute by name.

Definition at line 455 of file Operation.h.

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

Referenced by setDiscardableAttr().

◆ setDiscardableAttr() [2/2]

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

Definition at line 460 of file Operation.h.

References mlir::get(), getContext(), and setDiscardableAttr().

◆ setDiscardableAttrs() [1/2]

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

Definition at line 522 of file Operation.h.

References mlir::get(), getContext(), and setDiscardableAttrs().

◆ setDiscardableAttrs() [2/2]

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

Set the discardable attribute dictionary on this operation.

Definition at line 518 of file Operation.h.

Referenced by setDiscardableAttrs().

◆ setInherentAttr()

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 345 of file Operation.cpp.

References getName(), and mlir::OperationName::setInherentAttr().

Referenced by removeAttr(), setAttr(), and setAttrs().

◆ setLoc()

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

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

Definition at line 226 of file Operation.h.

◆ setOperand()

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

◆ setOperands() [1/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 246 of file Operation.cpp.

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

◆ setOperands() [2/2]

void Operation::setOperands ( ValueRange  operands)

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

Definition at line 237 of file Operation.cpp.

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

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

◆ setPropertiesFromAttribute()

LogicalResult Operation::setPropertiesFromAttribute ( Attribute  attr,
function_ref< InFlightDiagnostic()>  emitError 
)

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 355 of file Operation.cpp.

References mlir::OpaqueProperties::as(), emitError(), getName(), getPropertiesStorage(), getRegisteredInfo(), and mlir::success().

◆ setSuccessor()

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

◆ successor_begin()

succ_iterator mlir::Operation::successor_begin ( )
inline

Definition at line 697 of file Operation.h.

References getSuccessors().

◆ successor_end()

succ_iterator mlir::Operation::successor_end ( )
inline

Definition at line 698 of file Operation.h.

References getSuccessors().

◆ use_begin()

use_iterator mlir::Operation::use_begin ( )
inline

Definition at line 838 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 848 of file Operation.h.

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

Referenced by isResultValueDead(), and mlir::OpState::use_empty().

◆ use_end()

use_iterator mlir::Operation::use_end ( )
inline

Definition at line 839 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 865 of file Operation.h.

References use_begin().

Referenced by getUsers().

◆ user_end()

user_iterator mlir::Operation::user_end ( )
inline

Definition at line 866 of file Operation.h.

References use_end().

Referenced by getUsers().

◆ walk() [1/2]

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> 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.

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 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 793 of file Operation.h.

Referenced by buildBlockMapping(), mlir::affine::LoopNestStateCollector::collect(), mlir::LLVM::detail::DebugTranslation::DebugTranslation(), mlir::memref::eraseDeadAllocAndStores(), findOpWithTag(), findPayloadRoot(), mlir::transform::gpu::findTopLevelForallOp(), findTopLevelTransform(), getFirstDependentOpInRange(), getLastDependentOpInRange(), getLoadAndStoreMemRefAccesses(), mlir::query::matcher::MatchFinder::getMatches(), getShmReadAndWriteOps(), hasNonAffineUsersOnThePath(), mlir::linalg::hoistRedundantVectorTransfers(), mlir::transform::gpu::mapNestedForallToThreadsImpl(), mlir::amdgpu::optimizeSharedMemoryReadsAndWrites(), mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(), outlineKernelFuncImpl(), mlir::populateConversionTargetFromOperation(), mlir::Liveness::print(), printFunctionBody(), mlir::vector::transferOpflowOpt(), and mlir::OpState::walk().

◆ walk() [2/2]

template<typename FnT , typename RetT = detail::walkResultType<FnT>>
std::enable_if_t<llvm::function_traits<std::decay_t<FnT> >::num_args == 2, RetT> mlir::Operation::walk ( FnT &&  callback)
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 821 of file Operation.h.

References mlir::detail::walk().

Friends And Related Function Documentation

◆ Block

friend class Block
friend

Definition at line 1066 of file Operation.h.

◆ llvm::ilist_node_with_parent< Operation, Block >

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

Definition at line 1069 of file Operation.h.

◆ llvm::ilist_traits< Operation >

friend struct llvm::ilist_traits< Operation >
friend

Definition at line 1060 of file Operation.h.

◆ Value

friend class Value
friend

Definition at line 1069 of file Operation.h.


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