MLIR  17.0.0git
Classes | Public Types | Public Member Functions | List of all members
mlir::tblgen::Operator Class Reference

Wrapper class that contains a MLIR op's information (e.g., operands, attributes) defined in TableGen and provides helper methods for accessing them. More...

#include "mlir/TableGen/Operator.h"

Classes

struct  OperandOrAttribute
 Pair consisting kind of argument and index into operands or attributes. More...
 
struct  VariableDecorator
 A class used to represent the decorators of an operator variable, i.e. More...
 
struct  VariableDecoratorIterator
 A utility iterator over a list of variable decorators. More...
 

Public Types

using var_decorator_iterator = VariableDecoratorIterator
 
using var_decorator_range = llvm::iterator_range< VariableDecoratorIterator >
 
using value_iterator = NamedTypeConstraint *
 
using const_value_iterator = const NamedTypeConstraint *
 
using value_range = llvm::iterator_range< value_iterator >
 
using const_value_range = llvm::iterator_range< const_value_iterator >
 
using attribute_iterator = const NamedAttribute *
 Op attribute iterators. More...
 
using arg_iterator = const Argument *
 
using arg_range = llvm::iterator_range< arg_iterator >
 
using const_region_iterator = const NamedRegion *
 Regions. More...
 
using const_successor_iterator = const NamedSuccessor *
 Successors. More...
 
using const_trait_iterator = const Trait *
 Trait. More...
 

Public Member Functions

 Operator (const llvm::Record &def)
 
 Operator (const llvm::Record *def)
 
StringRef getDialectName () const
 Returns this op's dialect name. More...
 
std::string getOperationName () const
 Returns the operation name. More...
 
StringRef getCppClassName () const
 Returns this op's C++ class name. More...
 
std::string getQualCppClassName () const
 Returns this op's C++ class name prefixed with namespaces. More...
 
StringRef getCppNamespace () const
 Returns this op's C++ namespace. More...
 
std::string getAdaptorName () const
 Returns the name of op's adaptor C++ class. More...
 
std::string getGenericAdaptorName () const
 Returns the name of op's generic adaptor C++ class. More...
 
void assertInvariants () const
 Check invariants (like no duplicated or conflicted names) and abort the process if any invariant is broken. More...
 
bool isVariadic () const
 Returns true if this op has variable length operands or results. More...
 
bool skipDefaultBuilders () const
 Returns true if default builders should not be generated. More...
 
const_value_iterator result_begin () const
 Op result iterators. More...
 
const_value_iterator result_end () const
 
const_value_range getResults () const
 
int getNumResults () const
 Returns the number of results this op produces. More...
 
NamedTypeConstraintgetResult (int index)
 Returns the op result at the given index. More...
 
const NamedTypeConstraintgetResult (int index) const
 
TypeConstraint getResultTypeConstraint (int index) const
 Returns the index-th result's type constraint. More...
 
StringRef getResultName (int index) const
 Returns the index-th result's name. More...
 
var_decorator_range getResultDecorators (int index) const
 Returns the index-th result's decorators. More...
 
unsigned getNumVariableLengthResults () const
 Returns the number of variable length results in this operation. More...
 
attribute_iterator attribute_begin () const
 
attribute_iterator attribute_end () const
 
llvm::iterator_range< attribute_iteratorgetAttributes () const
 
int getNumAttributes () const
 
int getNumNativeAttributes () const
 
NamedAttributegetAttribute (int index)
 Op attribute accessors. More...
 
const NamedAttributegetAttribute (int index) const
 
const_value_iterator operand_begin () const
 Op operand iterators. More...
 
const_value_iterator operand_end () const
 
const_value_range getOperands () const
 
int getNumOperands () const
 
NamedTypeConstraintgetOperand (int index)
 
const NamedTypeConstraintgetOperand (int index) const
 
unsigned getNumVariableLengthOperands () const
 Returns the number of variadic operands in this operation. More...
 
int getNumArgs () const
 Returns the total number of arguments. More...
 
bool hasSingleVariadicArg () const
 Returns true of the operation has a single variadic arg. More...
 
bool hasSingleVariadicResult () const
 Returns true if the operation has a single variadic result. More...
 
bool hasNoVariadicRegions () const
 Returns true of the operation has no variadic regions. More...
 
arg_iterator arg_begin () const
 Op argument (attribute or operand) iterators. More...
 
arg_iterator arg_end () const
 
arg_range getArgs () const
 
Argument getArg (int index) const
 Op argument (attribute or operand) accessors. More...
 
StringRef getArgName (int index) const
 
var_decorator_range getArgDecorators (int index) const
 
const TraitgetTrait (llvm::StringRef trait) const
 Returns the trait wrapper for the given MLIR C++ trait. More...
 
const_region_iterator region_begin () const
 
const_region_iterator region_end () const
 
llvm::iterator_range< const_region_iteratorgetRegions () const
 
unsigned getNumRegions () const
 Returns the number of regions. More...
 
const NamedRegiongetRegion (unsigned index) const
 Returns the index-th region. More...
 
unsigned getNumVariadicRegions () const
 Returns the number of variadic regions in this operation. More...
 
const_successor_iterator successor_begin () const
 
const_successor_iterator successor_end () const
 
llvm::iterator_range< const_successor_iteratorgetSuccessors () const
 
unsigned getNumSuccessors () const
 Returns the number of successors. More...
 
const NamedSuccessorgetSuccessor (unsigned index) const
 Returns the index-th successor. More...
 
unsigned getNumVariadicSuccessors () const
 Returns the number of variadic successors in this operation. More...
 
const_trait_iterator trait_begin () const
 
const_trait_iterator trait_end () const
 
llvm::iterator_range< const_trait_iteratorgetTraits () const
 
ArrayRef< SMLoc > getLoc () const
 
bool hasDescription () const
 Query functions for the documentation of the operator. More...
 
StringRef getDescription () const
 
bool hasSummary () const
 
StringRef getSummary () const
 
bool hasAssemblyFormat () const
 Query functions for the assembly format of the operator. More...
 
StringRef getAssemblyFormat () const
 
StringRef getExtraClassDeclaration () const
 Returns this op's extra class declaration code. More...
 
StringRef getExtraClassDefinition () const
 Returns this op's extra class definition code. More...
 
const llvm::Record & getDef () const
 Returns the Tablegen definition this operator was constructed from. More...
 
const DialectgetDialect () const
 Returns the dialect of the op. More...
 
void print (llvm::raw_ostream &os) const
 Prints the contents in this operator to the given os. More...
 
bool allResultTypesKnown () const
 Return whether all the result types are known. More...
 
const InferredResultTypegetInferredResultType (int index) const
 Return all arguments or type constraints with same type as result[index]. More...
 
OperandOrAttribute getArgToOperandOrAttribute (int index) const
 Returns the OperandOrAttribute corresponding to the index. More...
 
ArrayRef< BuildergetBuilders () const
 Returns the builders of this operation. More...
 
std::string getGetterName (StringRef name) const
 Returns the getter name for the accessor of name. More...
 
std::string getSetterName (StringRef name) const
 Returns the setter name for the accessor of name. More...
 
std::string getRemoverName (StringRef name) const
 Returns the remove name for the accessor of name. More...
 
bool hasFolder () const
 

Detailed Description

Wrapper class that contains a MLIR op's information (e.g., operands, attributes) defined in TableGen and provides helper methods for accessing them.

Definition at line 76 of file Operator.h.

Member Typedef Documentation

◆ arg_iterator

Definition at line 211 of file Operator.h.

◆ arg_range

Definition at line 212 of file Operator.h.

◆ attribute_iterator

Op attribute iterators.

Definition at line 169 of file Operator.h.

◆ const_region_iterator

Regions.

Definition at line 228 of file Operator.h.

◆ const_successor_iterator

Successors.

Definition at line 242 of file Operator.h.

◆ const_trait_iterator

Trait.

Definition at line 256 of file Operator.h.

◆ const_value_iterator

Definition at line 134 of file Operator.h.

◆ const_value_range

Definition at line 136 of file Operator.h.

◆ value_iterator

Definition at line 133 of file Operator.h.

◆ value_range

Definition at line 135 of file Operator.h.

◆ var_decorator_iterator

Definition at line 130 of file Operator.h.

◆ var_decorator_range

Definition at line 131 of file Operator.h.

Constructor & Destructor Documentation

◆ Operator() [1/2]

Operator::Operator ( const llvm::Record &  def)
explicit

Definition at line 39 of file Operator.cpp.

References assertInvariants().

◆ Operator() [2/2]

mlir::tblgen::Operator::Operator ( const llvm::Record *  def)
inlineexplicit

Definition at line 79 of file Operator.h.

Member Function Documentation

◆ allResultTypesKnown()

bool mlir::tblgen::Operator::allResultTypesKnown ( ) const
inline

Return whether all the result types are known.

Definition at line 293 of file Operator.h.

Referenced by getInferredResultType().

◆ arg_begin()

Operator::arg_iterator Operator::arg_begin ( ) const

Op argument (attribute or operand) iterators.

Definition at line 234 of file Operator.cpp.

Referenced by getArgs().

◆ arg_end()

Operator::arg_iterator Operator::arg_end ( ) const

Definition at line 236 of file Operator.cpp.

Referenced by getArgs().

◆ assertInvariants()

void Operator::assertInvariants ( ) const

Check invariants (like no duplicated or conflicted names) and abort the process if any invariant is broken.

Definition at line 112 of file Operator.cpp.

References assertAccessorInvariants(), getLoc(), getNumOperands(), getNumRegions(), getNumResults(), getNumSuccessors(), getOperand(), getRegion(), getResult(), and getSuccessor().

Referenced by Operator().

◆ attribute_begin()

auto Operator::attribute_begin ( ) const

Definition at line 325 of file Operator.cpp.

Referenced by getAttributes().

◆ attribute_end()

auto Operator::attribute_end ( ) const

Definition at line 328 of file Operator.cpp.

Referenced by getAttributes().

◆ getAdaptorName()

std::string Operator::getAdaptorName ( ) const

Returns the name of op's adaptor C++ class.

Definition at line 69 of file Operator.cpp.

References getCppClassName().

◆ getArg()

auto Operator::getArg ( int  index) const

Op argument (attribute or operand) accessors.

Definition at line 346 of file Operator.cpp.

Referenced by mlir::tblgen::SymbolInfoMap::bindOpArgument(), and hasSingleVariadicArg().

◆ getArgDecorators()

auto Operator::getArgDecorators ( int  index) const

Definition at line 247 of file Operator.cpp.

◆ getArgName()

StringRef Operator::getArgName ( int  index) const

Definition at line 242 of file Operator.cpp.

◆ getArgs()

Operator::arg_range Operator::getArgs ( ) const

Definition at line 238 of file Operator.cpp.

References arg_begin(), and arg_end().

◆ getArgToOperandOrAttribute()

auto Operator::getArgToOperandOrAttribute ( int  index) const

Returns the OperandOrAttribute corresponding to the index.

Definition at line 821 of file Operator.cpp.

◆ getAssemblyFormat()

StringRef Operator::getAssemblyFormat ( ) const

Definition at line 801 of file Operator.cpp.

◆ getAttribute() [1/2]

NamedAttribute& mlir::tblgen::Operator::getAttribute ( int  index)
inline

Op attribute accessors.

Definition at line 178 of file Operator.h.

◆ getAttribute() [2/2]

const NamedAttribute& mlir::tblgen::Operator::getAttribute ( int  index) const
inline

Definition at line 179 of file Operator.h.

◆ getAttributes()

auto Operator::getAttributes ( ) const

Definition at line 331 of file Operator.cpp.

References attribute_begin(), and attribute_end().

◆ getBuilders()

ArrayRef<Builder> mlir::tblgen::Operator::getBuilders ( ) const
inline

Returns the builders of this operation.

Definition at line 316 of file Operator.h.

◆ getCppClassName()

StringRef Operator::getCppClassName ( ) const

Returns this op's C++ class name.

Definition at line 152 of file Operator.cpp.

Referenced by getAdaptorName(), and getGenericAdaptorName().

◆ getCppNamespace()

StringRef Operator::getCppNamespace ( ) const

Returns this op's C++ namespace.

Definition at line 160 of file Operator.cpp.

◆ getDef()

const llvm::Record & Operator::getDef ( ) const

Returns the Tablegen definition this operator was constructed from.

TODO: do not expose the TableGen record, this is a temporary solution to OpEmitter requiring a Record because Operator does not provide enough methods.

Definition at line 181 of file Operator.cpp.

Referenced by mlir::tblgen::DagNode::getDialectOp().

◆ getDescription()

StringRef Operator::getDescription ( ) const

Definition at line 786 of file Operator.cpp.

◆ getDialect()

const Dialect& mlir::tblgen::Operator::getDialect ( ) const
inline

Returns the dialect of the op.

Definition at line 286 of file Operator.h.

◆ getDialectName()

StringRef Operator::getDialectName ( ) const

Returns this op's dialect name.

Definition at line 150 of file Operator.cpp.

References mlir::tblgen::Dialect::getName().

◆ getExtraClassDeclaration()

StringRef Operator::getExtraClassDeclaration ( ) const

Returns this op's extra class declaration code.

Definition at line 167 of file Operator.cpp.

◆ getExtraClassDefinition()

StringRef Operator::getExtraClassDefinition ( ) const

Returns this op's extra class definition code.

Definition at line 174 of file Operator.cpp.

◆ getGenericAdaptorName()

std::string Operator::getGenericAdaptorName ( ) const

Returns the name of op's generic adaptor C++ class.

Definition at line 73 of file Operator.cpp.

References getCppClassName().

◆ getGetterName()

std::string Operator::getGetterName ( StringRef  name) const

Returns the getter name for the accessor of name.

Definition at line 826 of file Operator.cpp.

◆ getInferredResultType()

const InferredResultType & Operator::getInferredResultType ( int  index) const

Return all arguments or type constraints with same type as result[index].

Requires: all result types are known.

Definition at line 775 of file Operator.cpp.

References allResultTypesKnown().

◆ getLoc()

ArrayRef< SMLoc > Operator::getLoc ( ) const

Definition at line 780 of file Operator.cpp.

Referenced by assertAccessorInvariants(), and assertInvariants().

◆ getNumArgs()

int mlir::tblgen::Operator::getNumArgs ( ) const
inline

Returns the total number of arguments.

Definition at line 198 of file Operator.h.

Referenced by hasSingleVariadicArg().

◆ getNumAttributes()

int mlir::tblgen::Operator::getNumAttributes ( ) const
inline

Definition at line 174 of file Operator.h.

◆ getNumNativeAttributes()

int mlir::tblgen::Operator::getNumNativeAttributes ( ) const
inline

Definition at line 175 of file Operator.h.

◆ getNumOperands()

int mlir::tblgen::Operator::getNumOperands ( ) const
inline

Definition at line 188 of file Operator.h.

Referenced by assertAccessorInvariants(), and assertInvariants().

◆ getNumRegions()

unsigned Operator::getNumRegions ( ) const

Returns the number of regions.

Definition at line 282 of file Operator.cpp.

Referenced by assertAccessorInvariants(), and assertInvariants().

◆ getNumResults()

int Operator::getNumResults ( ) const

Returns the number of results this op produces.

Definition at line 162 of file Operator.cpp.

Referenced by assertAccessorInvariants(), assertInvariants(), and hasSingleVariadicResult().

◆ getNumSuccessors()

unsigned Operator::getNumSuccessors ( ) const

Returns the number of successors.

Definition at line 304 of file Operator.cpp.

Referenced by assertInvariants().

◆ getNumVariableLengthOperands()

unsigned Operator::getNumVariableLengthOperands ( ) const

Returns the number of variadic operands in this operation.

Definition at line 223 of file Operator.cpp.

References mlir::tblgen::NamedTypeConstraint::constraint, and mlir::tblgen::TypeConstraint::isVariableLength().

Referenced by assertAccessorInvariants().

◆ getNumVariableLengthResults()

unsigned Operator::getNumVariableLengthResults ( ) const

Returns the number of variable length results in this operation.

Definition at line 217 of file Operator.cpp.

References mlir::tblgen::NamedTypeConstraint::constraint, and mlir::tblgen::TypeConstraint::isVariableLength().

◆ getNumVariadicRegions()

unsigned Operator::getNumVariadicRegions ( ) const

Returns the number of variadic regions in this operation.

Definition at line 288 of file Operator.cpp.

References mlir::tblgen::NamedRegion::isVariadic().

Referenced by assertAccessorInvariants(), and hasNoVariadicRegions().

◆ getNumVariadicSuccessors()

unsigned Operator::getNumVariadicSuccessors ( ) const

Returns the number of variadic successors in this operation.

Definition at line 310 of file Operator.cpp.

References mlir::tblgen::NamedSuccessor::isVariadic().

◆ getOperand() [1/2]

NamedTypeConstraint& mlir::tblgen::Operator::getOperand ( int  index)
inline

Definition at line 189 of file Operator.h.

Referenced by assertInvariants(), and hasSingleVariadicArg().

◆ getOperand() [2/2]

const NamedTypeConstraint& mlir::tblgen::Operator::getOperand ( int  index) const
inline

Definition at line 190 of file Operator.h.

◆ getOperands()

auto Operator::getOperands ( ) const

Definition at line 342 of file Operator.cpp.

References operand_begin(), and operand_end().

◆ getOperationName()

std::string Operator::getOperationName ( ) const

Returns the operation name.

The name will follow the "<dialect>.<op-name>" format if its dialect name is not empty.

Definition at line 61 of file Operator.cpp.

References mlir::tblgen::Dialect::getName().

Referenced by print().

◆ getQualCppClassName()

std::string Operator::getQualCppClassName ( ) const

Returns this op's C++ class name prefixed with namespaces.

Definition at line 154 of file Operator.cpp.

◆ getRegion()

const NamedRegion & Operator::getRegion ( unsigned  index) const

Returns the index-th region.

Definition at line 284 of file Operator.cpp.

Referenced by assertInvariants().

◆ getRegions()

auto Operator::getRegions ( ) const

Definition at line 277 of file Operator.cpp.

References region_begin(), and region_end().

◆ getRemoverName()

std::string Operator::getRemoverName ( StringRef  name) const

Returns the remove name for the accessor of name.

Definition at line 834 of file Operator.cpp.

◆ getResult() [1/2]

NamedTypeConstraint& mlir::tblgen::Operator::getResult ( int  index)
inline

Returns the op result at the given index.

Definition at line 153 of file Operator.h.

Referenced by assertInvariants(), and hasSingleVariadicResult().

◆ getResult() [2/2]

const NamedTypeConstraint& mlir::tblgen::Operator::getResult ( int  index) const
inline

Definition at line 154 of file Operator.h.

◆ getResultDecorators()

auto Operator::getResultDecorators ( int  index) const

Returns the index-th result's decorators.

Definition at line 209 of file Operator.cpp.

◆ getResultName()

StringRef Operator::getResultName ( int  index) const

Returns the index-th result's name.

Definition at line 204 of file Operator.cpp.

◆ getResults()

auto Operator::getResults ( ) const

Definition at line 195 of file Operator.cpp.

References result_begin(), and result_end().

◆ getResultTypeConstraint()

TypeConstraint Operator::getResultTypeConstraint ( int  index) const

Returns the index-th result's type constraint.

Definition at line 199 of file Operator.cpp.

◆ getSetterName()

std::string Operator::getSetterName ( StringRef  name) const

Returns the setter name for the accessor of name.

Definition at line 830 of file Operator.cpp.

◆ getSuccessor()

const NamedSuccessor & Operator::getSuccessor ( unsigned  index) const

Returns the index-th successor.

Definition at line 306 of file Operator.cpp.

Referenced by assertInvariants().

◆ getSuccessors()

auto Operator::getSuccessors ( ) const

Definition at line 299 of file Operator.cpp.

References successor_begin(), and successor_end().

◆ getSummary()

StringRef Operator::getSummary ( ) const

Definition at line 792 of file Operator.cpp.

◆ getTrait()

const Trait * Operator::getTrait ( llvm::StringRef  trait) const

Returns the trait wrapper for the given MLIR C++ trait.

Definition at line 255 of file Operator.cpp.

◆ getTraits()

auto Operator::getTraits ( ) const

Definition at line 321 of file Operator.cpp.

References trait_begin(), and trait_end().

◆ hasAssemblyFormat()

bool Operator::hasAssemblyFormat ( ) const

Query functions for the assembly format of the operator.

Definition at line 796 of file Operator.cpp.

◆ hasDescription()

bool Operator::hasDescription ( ) const

Query functions for the documentation of the operator.

Definition at line 782 of file Operator.cpp.

◆ hasFolder()

bool Operator::hasFolder ( ) const

Definition at line 838 of file Operator.cpp.

◆ hasNoVariadicRegions()

bool mlir::tblgen::Operator::hasNoVariadicRegions ( ) const
inline

Returns true of the operation has no variadic regions.

Definition at line 209 of file Operator.h.

References getNumVariadicRegions().

◆ hasSingleVariadicArg()

bool Operator::hasSingleVariadicArg ( ) const

Returns true of the operation has a single variadic arg.

Definition at line 229 of file Operator.cpp.

References getArg(), getNumArgs(), getOperand(), and mlir::tblgen::NamedTypeConstraint::isVariadic().

◆ hasSingleVariadicResult()

bool mlir::tblgen::Operator::hasSingleVariadicResult ( ) const
inline

Returns true if the operation has a single variadic result.

Definition at line 204 of file Operator.h.

References getNumResults(), getResult(), and mlir::tblgen::NamedTypeConstraint::isVariadic().

◆ hasSummary()

bool Operator::hasSummary ( ) const

Definition at line 790 of file Operator.cpp.

◆ isVariadic()

bool Operator::isVariadic ( ) const

Returns true if this op has variable length operands or results.

Definition at line 348 of file Operator.cpp.

References mlir::tblgen::NamedTypeConstraint::isVariadic().

◆ operand_begin()

auto Operator::operand_begin ( ) const

Op operand iterators.

Definition at line 336 of file Operator.cpp.

Referenced by getOperands().

◆ operand_end()

auto Operator::operand_end ( ) const

Definition at line 339 of file Operator.cpp.

Referenced by getOperands().

◆ print()

void Operator::print ( llvm::raw_ostream &  os) const

Prints the contents in this operator to the given os.

This is used for debugging purposes.

Definition at line 806 of file Operator.cpp.

References getOperationName().

◆ region_begin()

auto Operator::region_begin ( ) const

Definition at line 271 of file Operator.cpp.

Referenced by getRegions().

◆ region_end()

auto Operator::region_end ( ) const

Definition at line 274 of file Operator.cpp.

Referenced by getRegions().

◆ result_begin()

auto Operator::result_begin ( ) const

Op result iterators.

Definition at line 187 of file Operator.cpp.

Referenced by getResults().

◆ result_end()

auto Operator::result_end ( ) const

Definition at line 191 of file Operator.cpp.

Referenced by getResults().

◆ skipDefaultBuilders()

bool Operator::skipDefaultBuilders ( ) const

Returns true if default builders should not be generated.

Definition at line 183 of file Operator.cpp.

◆ successor_begin()

auto Operator::successor_begin ( ) const

Definition at line 293 of file Operator.cpp.

Referenced by getSuccessors().

◆ successor_end()

auto Operator::successor_end ( ) const

Definition at line 296 of file Operator.cpp.

Referenced by getSuccessors().

◆ trait_begin()

auto Operator::trait_begin ( ) const

Definition at line 315 of file Operator.cpp.

Referenced by getTraits().

◆ trait_end()

auto Operator::trait_end ( ) const

Definition at line 318 of file Operator.cpp.

Referenced by getTraits().


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