MLIR 22.0.0git
mlir::OperationState Struct Reference

This represents an operation in an abstracted form, suitable for use with the builder APIs. More...

#include "mlir/IR/OperationSupport.h"

Public Member Functions

 OperationState (Location location, StringRef name)
 OperationState (Location location, OperationName name)
 OperationState (Location location, OperationName name, ValueRange operands, TypeRange types, ArrayRef< NamedAttribute > attributes={}, BlockRange successors={}, MutableArrayRef< std::unique_ptr< Region > > regions={})
 OperationState (Location location, StringRef name, ValueRange operands, TypeRange types, ArrayRef< NamedAttribute > attributes={}, BlockRange successors={}, MutableArrayRef< std::unique_ptr< Region > > regions={})
 OperationState (OperationState &&other)=default
OperationStateoperator= (OperationState &&other)=default
 OperationState (const OperationState &other)=delete
OperationStateoperator= (const OperationState &other)=delete
 ~OperationState ()
template<typename T>
T & getOrAddProperties ()
 Get (or create) a properties of the provided type to be set on the operation on creation.
OpaqueProperties getRawProperties ()
LogicalResult setProperties (Operation *op, function_ref< InFlightDiagnostic()> emitError) const
template<typename T>
void useProperties (T &newProperties)
void addOperands (ValueRange newOperands)
void addTypes (ArrayRef< Type > newTypes)
template<typename RangeT>
std::enable_if_t<!std::is_convertible< RangeT, ArrayRef< Type > >::value > addTypes (RangeT &&newTypes)
void addAttribute (StringRef name, Attribute attr)
 Add an attribute with the specified name.
void addAttribute (StringAttr name, Attribute attr)
 Add an attribute with the specified name.
void addAttributes (ArrayRef< NamedAttribute > newAttributes)
 Add an array of named attributes.
void addSuccessors (Block *successor)
 Adds a successor to the operation sate. successor must not be null.
void addSuccessors (BlockRange newSuccessors)
RegionaddRegion ()
 Create a region that should be attached to the operation.
void addRegion (std::unique_ptr< Region > &&region)
 Take a region that should be attached to the Operation.
void addRegions (MutableArrayRef< std::unique_ptr< Region > > regions)
 Take ownership of a set of regions that should be attached to the Operation.
MLIRContextgetContext () const
 Get the context held by this operation state.

Public Attributes

Location location
OperationName name
SmallVector< Value, 4 > operands
SmallVector< Type, 4 > types
 Types of the results of this operation.
NamedAttrList attributes
SmallVector< Block *, 1 > successors
 Successors of this operation and their respective operands.
SmallVector< std::unique_ptr< Region >, 1 > regions
 Regions that the op will hold.
Attribute propertiesAttr
 This Attribute is used to opaquely construct the properties of the operation.

Friends

class Operation

Detailed Description

This represents an operation in an abstracted form, suitable for use with the builder APIs.

This object is a large and heavy weight object meant to be used as a temporary object on the stack. It is generally unwise to put this in a collection.

Definition at line 948 of file OperationSupport.h.

Constructor & Destructor Documentation

◆ OperationState() [1/6]

OperationState::OperationState ( Location location,
StringRef name )

Definition at line 163 of file OperationSupport.cpp.

References getContext(), location, and name.

Referenced by OperationState(), OperationState(), OperationState(), operator=(), and operator=().

◆ OperationState() [2/6]

OperationState::OperationState ( Location location,
OperationName name )

Definition at line 166 of file OperationSupport.cpp.

References location, and name.

◆ OperationState() [3/6]

OperationState::OperationState ( Location location,
OperationName name,
ValueRange operands,
TypeRange types,
ArrayRef< NamedAttribute > attributes = {},
BlockRange successors = {},
MutableArrayRef< std::unique_ptr< Region > > regions = {} )

Definition at line 169 of file OperationSupport.cpp.

References attributes, location, name, operands, regions, successors, and types.

◆ OperationState() [4/6]

OperationState::OperationState ( Location location,
StringRef name,
ValueRange operands,
TypeRange types,
ArrayRef< NamedAttribute > attributes = {},
BlockRange successors = {},
MutableArrayRef< std::unique_ptr< Region > > regions = {} )

◆ OperationState() [5/6]

mlir::OperationState::OperationState ( OperationState && other)
default

References OperationState().

◆ OperationState() [6/6]

mlir::OperationState::OperationState ( const OperationState & other)
delete

References OperationState().

◆ ~OperationState()

OperationState::~OperationState ( )

Definition at line 190 of file OperationSupport.cpp.

Member Function Documentation

◆ addAttribute() [1/2]

void mlir::OperationState::addAttribute ( StringAttr name,
Attribute attr )
inline

Add an attribute with the specified name.

name and attr must not be null.

Definition at line 1081 of file OperationSupport.h.

References attributes, and name.

◆ addAttribute() [2/2]

◆ addAttributes()

void mlir::OperationState::addAttributes ( ArrayRef< NamedAttribute > newAttributes)
inline

Add an array of named attributes.

Definition at line 1088 of file OperationSupport.h.

References attributes.

Referenced by buildStructuredOp(), and mlir::spirv::Deserializer::processOpWithoutGrammarAttr().

◆ addOperands()

void OperationState::addOperands ( ValueRange newOperands)

◆ addRegion() [1/2]

Region * OperationState::addRegion ( )

Create a region that should be attached to the operation.

These regions can be filled in immediately without waiting for Operation to be created. When it is, the region bodies will be transferred.

Definition at line 214 of file OperationSupport.cpp.

References regions.

Referenced by addRegions(), buildQuantifier(), buildStructuredOp(), mlir::clone(), mlir::cloneWithoutRegions(), mlirOperationCreate(), and parseRegions().

◆ addRegion() [2/2]

void OperationState::addRegion ( std::unique_ptr< Region > && region)

Take a region that should be attached to the Operation.

The body of the region will be transferred when the Operation is constructed. If the region is null, a new empty region will be attached to the Operation.

Definition at line 219 of file OperationSupport.cpp.

References regions.

◆ addRegions()

void OperationState::addRegions ( MutableArrayRef< std::unique_ptr< Region > > regions)

Take ownership of a set of regions that should be attached to the Operation.

Definition at line 223 of file OperationSupport.cpp.

References addRegion(), and regions.

◆ addSuccessors() [1/2]

void mlir::OperationState::addSuccessors ( Block * successor)
inline

Adds a successor to the operation sate. successor must not be null.

Definition at line 1093 of file OperationSupport.h.

References successors.

Referenced by mlirOperationCreate().

◆ addSuccessors() [2/2]

void OperationState::addSuccessors ( BlockRange newSuccessors)

Definition at line 210 of file OperationSupport.cpp.

References successors.

◆ addTypes() [1/2]

void mlir::OperationState::addTypes ( ArrayRef< Type > newTypes)
inline

◆ addTypes() [2/2]

template<typename RangeT>
std::enable_if_t<!std::is_convertible< RangeT, ArrayRef< Type > >::value > mlir::OperationState::addTypes ( RangeT && newTypes)
inline

Definition at line 1070 of file OperationSupport.h.

References types.

◆ getContext()

MLIRContext * mlir::OperationState::getContext ( ) const
inline

Get the context held by this operation state.

Definition at line 1114 of file OperationSupport.h.

References location.

Referenced by addAttribute(), mlir::Operation::create(), inferOperationTypes(), OperationState(), and OperationState().

◆ getOrAddProperties()

template<typename T>
T & mlir::OperationState::getOrAddProperties ( )
inline

Get (or create) a properties of the provided type to be set on the operation on creation.

Definition at line 997 of file OperationSupport.h.

References mlir::OpaqueProperties::as(), and mlir::TypeID::get().

Referenced by buildQuantifier().

◆ getRawProperties()

OpaqueProperties mlir::OperationState::getRawProperties ( )
inline

Definition at line 1025 of file OperationSupport.h.

Referenced by inferOperationTypes().

◆ operator=() [1/2]

OperationState & mlir::OperationState::operator= ( const OperationState & other)
delete

References OperationState().

◆ operator=() [2/2]

OperationState & mlir::OperationState::operator= ( OperationState && other)
default

References OperationState().

◆ setProperties()

LogicalResult OperationState::setProperties ( Operation * op,
function_ref< InFlightDiagnostic()> emitError ) const

◆ useProperties()

template<typename T>
void mlir::OperationState::useProperties ( T & newProperties)
inline

Definition at line 1039 of file OperationSupport.h.

References mlir::OpaqueProperties::as(), and mlir::TypeID::get().

◆ Operation

friend class Operation
friend

Definition at line 974 of file OperationSupport.h.

References attributes, location, name, operands, Operation, and types.

Referenced by Operation, and setProperties().

Member Data Documentation

◆ attributes

◆ location

◆ name

◆ operands

◆ propertiesAttr

Attribute mlir::OperationState::propertiesAttr

This Attribute is used to opaquely construct the properties of the operation.

If we're creating an unregistered operation, the Attribute is used as-is as the Properties storage of the operation. Otherwise, the operation properties are constructed opaquely using its setPropertiesFromAttr hook. Note that getOrAddProperties is the preferred method to construct properties from C++.

Definition at line 966 of file OperationSupport.h.

Referenced by mlir::Operation::create(), mlir::LLVM::detail::oneToOneRewrite(), setProperties(), and mlir::LLVM::detail::vectorOneToOneRewrite().

◆ regions

SmallVector<std::unique_ptr<Region>, 1> mlir::OperationState::regions

◆ successors

SmallVector<Block *, 1> mlir::OperationState::successors

Successors of this operation and their respective operands.

Definition at line 956 of file OperationSupport.h.

Referenced by addSuccessors(), addSuccessors(), mlir::Operation::create(), OperationState(), and OperationState().

◆ types

SmallVector<Type, 4> mlir::OperationState::types

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