MLIR
17.0.0git
|
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... | |
NamedTypeConstraint & | getResult (int index) |
Returns the op result at the given index . More... | |
const NamedTypeConstraint & | getResult (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_iterator > | getAttributes () const |
int | getNumAttributes () const |
int | getNumNativeAttributes () const |
NamedAttribute & | getAttribute (int index) |
Op attribute accessors. More... | |
const NamedAttribute & | getAttribute (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 |
NamedTypeConstraint & | getOperand (int index) |
const NamedTypeConstraint & | getOperand (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 Trait * | getTrait (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_iterator > | getRegions () const |
unsigned | getNumRegions () const |
Returns the number of regions. More... | |
const NamedRegion & | getRegion (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_iterator > | getSuccessors () const |
unsigned | getNumSuccessors () const |
Returns the number of successors. More... | |
const NamedSuccessor & | getSuccessor (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_iterator > | getTraits () 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 Dialect & | getDialect () 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 InferredResultType & | getInferredResultType (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< Builder > | getBuilders () 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 |
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.
using mlir::tblgen::Operator::arg_iterator = const Argument * |
Definition at line 211 of file Operator.h.
Definition at line 212 of file Operator.h.
using mlir::tblgen::Operator::attribute_iterator = const NamedAttribute * |
Op attribute iterators.
Definition at line 169 of file Operator.h.
using mlir::tblgen::Operator::const_region_iterator = const NamedRegion * |
Regions.
Definition at line 228 of file Operator.h.
using mlir::tblgen::Operator::const_successor_iterator = const NamedSuccessor * |
Successors.
Definition at line 242 of file Operator.h.
using mlir::tblgen::Operator::const_trait_iterator = const Trait * |
Definition at line 256 of file Operator.h.
using mlir::tblgen::Operator::const_value_iterator = const NamedTypeConstraint * |
Definition at line 134 of file Operator.h.
Definition at line 136 of file Operator.h.
Definition at line 133 of file Operator.h.
Definition at line 135 of file Operator.h.
Definition at line 130 of file Operator.h.
Definition at line 131 of file Operator.h.
|
explicit |
Definition at line 39 of file Operator.cpp.
References assertInvariants().
|
inlineexplicit |
Definition at line 79 of file Operator.h.
|
inline |
Return whether all the result types are known.
Definition at line 293 of file Operator.h.
Referenced by getInferredResultType().
Operator::arg_iterator Operator::arg_begin | ( | ) | const |
Op argument (attribute or operand) iterators.
Definition at line 234 of file Operator.cpp.
Referenced by getArgs().
Operator::arg_iterator Operator::arg_end | ( | ) | const |
Definition at line 236 of file Operator.cpp.
Referenced by getArgs().
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().
auto Operator::attribute_begin | ( | ) | const |
Definition at line 325 of file Operator.cpp.
Referenced by getAttributes().
auto Operator::attribute_end | ( | ) | const |
Definition at line 328 of file Operator.cpp.
Referenced by getAttributes().
std::string Operator::getAdaptorName | ( | ) | const |
Returns the name of op's adaptor C++ class.
Definition at line 69 of file Operator.cpp.
References getCppClassName().
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().
auto Operator::getArgDecorators | ( | int | index | ) | const |
Definition at line 247 of file Operator.cpp.
StringRef Operator::getArgName | ( | int | index | ) | const |
Definition at line 242 of file Operator.cpp.
Operator::arg_range Operator::getArgs | ( | ) | const |
Definition at line 238 of file Operator.cpp.
References arg_begin(), and arg_end().
auto Operator::getArgToOperandOrAttribute | ( | int | index | ) | const |
Returns the OperandOrAttribute corresponding to the index.
Definition at line 821 of file Operator.cpp.
StringRef Operator::getAssemblyFormat | ( | ) | const |
Definition at line 801 of file Operator.cpp.
|
inline |
Op attribute accessors.
Definition at line 178 of file Operator.h.
|
inline |
Definition at line 179 of file Operator.h.
auto Operator::getAttributes | ( | ) | const |
Definition at line 331 of file Operator.cpp.
References attribute_begin(), and attribute_end().
Returns the builders of this operation.
Definition at line 316 of file Operator.h.
StringRef Operator::getCppClassName | ( | ) | const |
Returns this op's C++ class name.
Definition at line 152 of file Operator.cpp.
Referenced by getAdaptorName(), and getGenericAdaptorName().
StringRef Operator::getCppNamespace | ( | ) | const |
Returns this op's C++ namespace.
Definition at line 160 of file Operator.cpp.
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().
StringRef Operator::getDescription | ( | ) | const |
Definition at line 786 of file Operator.cpp.
|
inline |
Returns the dialect of the op.
Definition at line 286 of file Operator.h.
StringRef Operator::getDialectName | ( | ) | const |
Returns this op's dialect name.
Definition at line 150 of file Operator.cpp.
References mlir::tblgen::Dialect::getName().
StringRef Operator::getExtraClassDeclaration | ( | ) | const |
Returns this op's extra class declaration code.
Definition at line 167 of file Operator.cpp.
StringRef Operator::getExtraClassDefinition | ( | ) | const |
Returns this op's extra class definition code.
Definition at line 174 of file Operator.cpp.
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().
std::string Operator::getGetterName | ( | StringRef | name | ) | const |
Returns the getter name for the accessor of name
.
Definition at line 826 of file Operator.cpp.
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().
ArrayRef< SMLoc > Operator::getLoc | ( | ) | const |
Definition at line 780 of file Operator.cpp.
Referenced by assertAccessorInvariants(), and assertInvariants().
|
inline |
Returns the total number of arguments.
Definition at line 198 of file Operator.h.
Referenced by hasSingleVariadicArg().
|
inline |
Definition at line 174 of file Operator.h.
|
inline |
Definition at line 175 of file Operator.h.
|
inline |
Definition at line 188 of file Operator.h.
Referenced by assertAccessorInvariants(), and assertInvariants().
unsigned Operator::getNumRegions | ( | ) | const |
Returns the number of regions.
Definition at line 282 of file Operator.cpp.
Referenced by assertAccessorInvariants(), and assertInvariants().
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().
unsigned Operator::getNumSuccessors | ( | ) | const |
Returns the number of successors.
Definition at line 304 of file Operator.cpp.
Referenced by assertInvariants().
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().
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().
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().
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().
|
inline |
Definition at line 189 of file Operator.h.
Referenced by assertInvariants(), and hasSingleVariadicArg().
|
inline |
Definition at line 190 of file Operator.h.
auto Operator::getOperands | ( | ) | const |
Definition at line 342 of file Operator.cpp.
References operand_begin(), and operand_end().
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().
std::string Operator::getQualCppClassName | ( | ) | const |
Returns this op's C++ class name prefixed with namespaces.
Definition at line 154 of file Operator.cpp.
const NamedRegion & Operator::getRegion | ( | unsigned | index | ) | const |
Returns the index
-th region.
Definition at line 284 of file Operator.cpp.
Referenced by assertInvariants().
auto Operator::getRegions | ( | ) | const |
Definition at line 277 of file Operator.cpp.
References region_begin(), and region_end().
std::string Operator::getRemoverName | ( | StringRef | name | ) | const |
Returns the remove name for the accessor of name
.
Definition at line 834 of file Operator.cpp.
|
inline |
Returns the op result at the given index
.
Definition at line 153 of file Operator.h.
Referenced by assertInvariants(), and hasSingleVariadicResult().
|
inline |
Definition at line 154 of file Operator.h.
auto Operator::getResultDecorators | ( | int | index | ) | const |
Returns the index
-th result's decorators.
Definition at line 209 of file Operator.cpp.
StringRef Operator::getResultName | ( | int | index | ) | const |
Returns the index
-th result's name.
Definition at line 204 of file Operator.cpp.
auto Operator::getResults | ( | ) | const |
Definition at line 195 of file Operator.cpp.
References result_begin(), and result_end().
TypeConstraint Operator::getResultTypeConstraint | ( | int | index | ) | const |
Returns the index
-th result's type constraint.
Definition at line 199 of file Operator.cpp.
std::string Operator::getSetterName | ( | StringRef | name | ) | const |
Returns the setter name for the accessor of name
.
Definition at line 830 of file Operator.cpp.
const NamedSuccessor & Operator::getSuccessor | ( | unsigned | index | ) | const |
Returns the index
-th successor.
Definition at line 306 of file Operator.cpp.
Referenced by assertInvariants().
auto Operator::getSuccessors | ( | ) | const |
Definition at line 299 of file Operator.cpp.
References successor_begin(), and successor_end().
StringRef Operator::getSummary | ( | ) | const |
Definition at line 792 of file Operator.cpp.
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.
auto Operator::getTraits | ( | ) | const |
Definition at line 321 of file Operator.cpp.
References trait_begin(), and trait_end().
bool Operator::hasAssemblyFormat | ( | ) | const |
Query functions for the assembly format of the operator.
Definition at line 796 of file Operator.cpp.
bool Operator::hasDescription | ( | ) | const |
Query functions for the documentation of the operator.
Definition at line 782 of file Operator.cpp.
bool Operator::hasFolder | ( | ) | const |
Definition at line 838 of file Operator.cpp.
|
inline |
Returns true of the operation has no variadic regions.
Definition at line 209 of file Operator.h.
References getNumVariadicRegions().
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().
|
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().
bool Operator::hasSummary | ( | ) | const |
Definition at line 790 of file Operator.cpp.
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().
auto Operator::operand_begin | ( | ) | const |
auto Operator::operand_end | ( | ) | const |
Definition at line 339 of file Operator.cpp.
Referenced by getOperands().
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().
auto Operator::region_begin | ( | ) | const |
Definition at line 271 of file Operator.cpp.
Referenced by getRegions().
auto Operator::region_end | ( | ) | const |
Definition at line 274 of file Operator.cpp.
Referenced by getRegions().
auto Operator::result_begin | ( | ) | const |
auto Operator::result_end | ( | ) | const |
Definition at line 191 of file Operator.cpp.
Referenced by getResults().
bool Operator::skipDefaultBuilders | ( | ) | const |
Returns true if default builders should not be generated.
Definition at line 183 of file Operator.cpp.
auto Operator::successor_begin | ( | ) | const |
Definition at line 293 of file Operator.cpp.
Referenced by getSuccessors().
auto Operator::successor_end | ( | ) | const |
Definition at line 296 of file Operator.cpp.
Referenced by getSuccessors().
auto Operator::trait_begin | ( | ) | const |
Definition at line 315 of file Operator.cpp.
Referenced by getTraits().
auto Operator::trait_end | ( | ) | const |
Definition at line 318 of file Operator.cpp.
Referenced by getTraits().