13 #ifndef MLIR_TABLEGEN_OPERATOR_H_
14 #define MLIR_TABLEGEN_OPERATOR_H_
26 #include "llvm/ADT/PointerUnion.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringMap.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/Support/SMLoc.h"
47 : index(index), transformer(std::move(transformer)) {}
71 std::string transformer;
122 :
public llvm::mapped_iterator<const llvm::Init *const *,
123 VariableDecorator (*)(
124 const llvm::Init *)> {
127 :
llvm::mapped_iterator<const
llvm::Init *const *,
157 return results[index];
186 return attributes[index];
197 return properties.begin();
212 return properties[index];
218 return operands[index];
310 const llvm::Record &
getDef()
const;
317 void print(llvm::raw_ostream &os)
const;
362 void populateOpStructure();
366 void populateTypeInferenceInfo(
367 const llvm::StringMap<int> &argumentsAndResultsIndex);
373 StringRef cppClassName;
376 StringRef cppNamespace;
416 int numNativeAttributes;
419 const llvm::Record &def;
422 bool allResultsHaveKnownTypes;
This class represents an inferred result type.
StringRef getTransformer() const
static int mapResultIndex(int i)
static int unmapResultIndex(int i)
int getResultIndex() const
If the type is inferred from a result, return the result index.
int getIndex() const
Return the mapped argument or result index.
InferredResultType(int index, std::string transformer)
static bool isResultIndex(int i)
static bool isArgIndex(int i)
bool isArg() const
Returns true if result type is inferred from an argument type.
Wrapper class that contains a MLIR op's information (e.g., operands, attributes) defined in TableGen ...
std::string getQualCppClassName() const
Returns this op's C++ class name prefixed with namespaces.
const NamedAttribute & getAttribute(int index) const
unsigned getNumSuccessors() const
Returns the number of successors.
bool hasSingleVariadicResult() const
Returns true if the operation has a single variadic result.
const NamedRegion & getRegion(unsigned index) const
Returns the index-th region.
TypeConstraint getResultTypeConstraint(int index) const
Returns the index-th result's type constraint.
ArrayRef< SMLoc > getLoc() const
Operator(const llvm::Record &def)
const NamedTypeConstraint * const_value_iterator
llvm::iterator_range< const_region_iterator > getRegions() const
OperandOrAttribute getArgToOperandOrAttribute(int index) const
Returns the OperandOrAttribute corresponding to the index.
NamedTypeConstraint & getOperand(int index)
StringRef getCppNamespace() const
Returns this op's C++ namespace.
const_attribute_iterator attribute_begin() const
std::string getGetterName(StringRef name) const
Returns the getter name for the accessor of name.
const_successor_iterator successor_end() const
int getNumOperands() const
StringRef getDescription() const
const_value_range getResults() const
const NamedTypeConstraint & getResult(int index) const
arg_range getArgs() const
const_value_range getOperands() const
const_region_iterator region_begin() const
bool useCustomPropertiesEncoding() const
Whether to generate the readProperty/writeProperty methods for bytecode emission.
property_iterator properties_begin()
StringRef getResultName(int index) const
Returns the index-th result's name.
var_decorator_range getArgDecorators(int index) const
unsigned getNumVariableLengthOperands() const
Returns the number of variadic operands in this operation.
var_decorator_range getResultDecorators(int index) const
Returns the index-th result's decorators.
std::string getGenericAdaptorName() const
Returns the name of op's generic adaptor C++ class.
StringRef getExtraClassDefinition() const
Returns this op's extra class definition code.
NamedTypeConstraint & getResult(int index)
Returns the op result at the given index.
const_value_iterator result_begin() const
Op result iterators.
const_attribute_iterator attribute_end() const
const_trait_iterator trait_end() const
Operator(const llvm::Record *def)
llvm::iterator_range< VariableDecoratorIterator > var_decorator_range
std::string getAdaptorName() const
Returns the name of op's adaptor C++ class.
int getNumResults() const
Returns the number of results this op produces.
llvm::iterator_range< const_attribute_iterator > getAttributes() const
NamedProperty & getProperty(int index)
llvm::iterator_range< const_value_iterator > const_value_range
const NamedTypeConstraint & getOperand(int index) const
ArrayRef< Builder > getBuilders() const
Returns the builders of this operation.
const_value_iterator operand_end() const
arg_iterator arg_end() const
int getNumArgs() const
Returns the total number of arguments.
int getNumAttributes() const
const_value_iterator operand_begin() const
Op operand iterators.
void assertInvariants() const
Check invariants (like no duplicated or conflicted names) and abort the process if any invariant is b...
StringRef getArgName(int index) const
StringRef getDialectName() const
Returns this op's dialect name.
const_region_iterator region_end() const
unsigned getNumVariableLengthResults() const
Returns the number of variable length results in this operation.
bool hasSingleVariadicArg() const
Returns true of the operation has a single variadic arg.
unsigned getNumVariadicSuccessors() const
Returns the number of variadic successors in this operation.
const NamedProperty & getProperty(int index) const
StringRef getSummary() const
NamedAttribute & getAttribute(int index)
Op attribute accessors.
bool isVariadic() const
Returns true if this op has variable length operands or results.
llvm::iterator_range< const_trait_iterator > getTraits() const
int getNumCoreAttributes() const
const Trait * getTrait(llvm::StringRef trait) const
Returns the trait wrapper for the given MLIR C++ trait.
llvm::iterator_range< const_successor_iterator > getSuccessors() const
property_iterator properties_end()
const_successor_iterator successor_begin() const
void print(llvm::raw_ostream &os) const
Prints the contents in this operator to the given os.
unsigned getNumRegions() const
Returns the number of regions.
const_trait_iterator trait_begin() const
bool hasNoVariadicRegions() const
Returns true of the operation has no variadic regions.
const_property_iterator properties_end() const
int getNumNativeAttributes() const
const Dialect & getDialect() const
Returns the dialect of the op.
StringRef getExtraClassDeclaration() const
Returns this op's extra class declaration code.
StringRef getAssemblyFormat() const
std::string getSetterName(StringRef name) const
Returns the setter name for the accessor of name.
const_property_iterator properties_begin() const
std::string getOperationName() const
Returns the operation name.
const NamedSuccessor & getSuccessor(unsigned index) const
Returns the index-th successor.
llvm::iterator_range< const_property_iterator > getProperties() const
StringRef getCppClassName() const
Returns this op's C++ class name.
bool allResultTypesKnown() const
Return whether all the result types are known.
bool hasAssemblyFormat() const
Query functions for the assembly format of the operator.
unsigned getNumVariadicRegions() const
Returns the number of variadic regions in this operation.
llvm::iterator_range< property_iterator > getProperties()
bool skipDefaultBuilders() const
Returns true if default builders should not be generated.
arg_iterator arg_begin() const
Op argument (attribute or operand) iterators.
const InferredResultType & getInferredResultType(int index) const
Return all arguments or type constraints with same type as result[index].
const llvm::Record & getDef() const
Returns the Tablegen definition this operator was constructed from.
const_value_iterator result_end() const
std::string getRemoverName(StringRef name) const
Returns the remove name for the accessor of name.
Argument getArg(int index) const
Op argument (attribute or operand) accessors.
bool hasDescription() const
Query functions for the documentation of the operator.
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
Pair consisting kind of argument and index into operands or attributes.
int operandOrAttributeIndex() const
OperandOrAttribute(Kind kind, int index)
A utility iterator over a list of variable decorators.
VariableDecoratorIterator(const llvm::Init *const *it)
Initializes the iterator to the specified iterator.
static VariableDecorator unwrap(const llvm::Init *init)
A class used to represent the decorators of an operator variable, i.e.
const llvm::Record & getDef() const
const llvm::Record * def
The TableGen definition of this decorator.
VariableDecorator(const llvm::Record *def)