[Mlir-commits] [mlir] 81af171 - [mlir][ods] Make Operator.h comments triple forward slash (NFC)Depends on D139447
Jeff Niu
llvmlistbot at llvm.org
Thu Dec 8 11:32:48 PST 2022
Author: Jeff Niu
Date: 2022-12-08T11:32:31-08:00
New Revision: 81af171112aec5a4e38fcbc5415b7b10ee31f359
URL: https://github.com/llvm/llvm-project/commit/81af171112aec5a4e38fcbc5415b7b10ee31f359
DIFF: https://github.com/llvm/llvm-project/commit/81af171112aec5a4e38fcbc5415b7b10ee31f359.diff
LOG: [mlir][ods] Make Operator.h comments triple forward slash (NFC)Depends on D139447
Depends on D139447
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D139470
Added:
Modified:
mlir/include/mlir/TableGen/Operator.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h
index 6deeca7ea01fa..ad906e45a25ba 100644
--- a/mlir/include/mlir/TableGen/Operator.h
+++ b/mlir/include/mlir/TableGen/Operator.h
@@ -37,35 +37,35 @@ class StringInit;
namespace mlir {
namespace tblgen {
-// Wrapper class that contains a MLIR op's information (e.g., operands,
-// attributes) defined in TableGen and provides helper methods for
-// accessing them.
+/// Wrapper class that contains a MLIR op's information (e.g., operands,
+/// attributes) defined in TableGen and provides helper methods for
+/// accessing them.
class Operator {
public:
explicit Operator(const llvm::Record &def);
explicit Operator(const llvm::Record *def) : Operator(*def) {}
- // Returns this op's dialect name.
+ /// Returns this op's dialect name.
StringRef getDialectName() const;
- // Returns the operation name. The name will follow the "<dialect>.<op-name>"
- // format if its dialect name is not empty.
+ /// Returns the operation name. The name will follow the "<dialect>.<op-name>"
+ /// format if its dialect name is not empty.
std::string getOperationName() const;
- // Returns this op's C++ class name.
+ /// Returns this op's C++ class name.
StringRef getCppClassName() const;
- // Returns this op's C++ class name prefixed with namespaces.
+ /// Returns this op's C++ class name prefixed with namespaces.
std::string getQualCppClassName() const;
- // Returns this op's C++ namespace.
+ /// Returns this op's C++ namespace.
StringRef getCppNamespace() const;
- // Returns the name of op's adaptor C++ class.
+ /// Returns the name of op's adaptor C++ class.
std::string getAdaptorName() const;
- // Check invariants (like no duplicated or conflicted names) and abort the
- // process if any invariant is broken.
+ /// Check invariants (like no duplicated or conflicted names) and abort the
+ /// process if any invariant is broken.
void assertInvariants() const;
/// A class used to represent the decorators of an operator variable, i.e.
@@ -76,11 +76,11 @@ class Operator {
const llvm::Record &getDef() const { return *def; }
protected:
- // The TableGen definition of this decorator.
+ /// The TableGen definition of this decorator.
const llvm::Record *def;
};
- // A utility iterator over a list of variable decorators.
+ /// A utility iterator over a list of variable decorators.
struct VariableDecoratorIterator
: public llvm::mapped_iterator<llvm::Init *const *,
VariableDecorator (*)(llvm::Init *)> {
@@ -99,37 +99,37 @@ class Operator {
using value_range = llvm::iterator_range<value_iterator>;
using const_value_range = llvm::iterator_range<const_value_iterator>;
- // Returns true if this op has variable length operands or results.
+ /// Returns true if this op has variable length operands or results.
bool isVariadic() const;
- // Returns true if default builders should not be generated.
+ /// Returns true if default builders should not be generated.
bool skipDefaultBuilders() const;
- // Op result iterators.
+ /// Op result iterators.
const_value_iterator result_begin() const;
const_value_iterator result_end() const;
const_value_range getResults() const;
- // Returns the number of results this op produces.
+ /// Returns the number of results this op produces.
int getNumResults() const;
- // Returns the op result at the given `index`.
+ /// Returns the op result at the given `index`.
NamedTypeConstraint &getResult(int index) { return results[index]; }
const NamedTypeConstraint &getResult(int index) const {
return results[index];
}
- // Returns the `index`-th result's type constraint.
+ /// Returns the `index`-th result's type constraint.
TypeConstraint getResultTypeConstraint(int index) const;
- // Returns the `index`-th result's name.
+ /// Returns the `index`-th result's name.
StringRef getResultName(int index) const;
- // Returns the `index`-th result's decorators.
+ /// Returns the `index`-th result's decorators.
var_decorator_range getResultDecorators(int index) const;
- // Returns the number of variable length results in this operation.
+ /// Returns the number of variable length results in this operation.
unsigned getNumVariableLengthResults() const;
- // Op attribute iterators.
+ /// Op attribute iterators.
using attribute_iterator = const NamedAttribute *;
attribute_iterator attribute_begin() const;
attribute_iterator attribute_end() const;
@@ -138,13 +138,13 @@ class Operator {
int getNumAttributes() const { return attributes.size(); }
int getNumNativeAttributes() const { return numNativeAttributes; }
- // Op attribute accessors.
+ /// Op attribute accessors.
NamedAttribute &getAttribute(int index) { return attributes[index]; }
const NamedAttribute &getAttribute(int index) const {
return attributes[index];
}
- // Op operand iterators.
+ /// Op operand iterators.
const_value_iterator operand_begin() const;
const_value_iterator operand_end() const;
const_value_range getOperands() const;
@@ -155,68 +155,68 @@ class Operator {
return operands[index];
}
- // Returns the number of variadic operands in this operation.
+ /// Returns the number of variadic operands in this operation.
unsigned getNumVariableLengthOperands() const;
- // Returns the total number of arguments.
+ /// Returns the total number of arguments.
int getNumArgs() const { return arguments.size(); }
- // Returns true of the operation has a single variadic arg.
+ /// Returns true of the operation has a single variadic arg.
bool hasSingleVariadicArg() const;
- // Returns true if the operation has a single variadic result.
+ /// Returns true if the operation has a single variadic result.
bool hasSingleVariadicResult() const {
return getNumResults() == 1 && getResult(0).isVariadic();
}
- // Returns true of the operation has no variadic regions.
+ /// Returns true of the operation has no variadic regions.
bool hasNoVariadicRegions() const { return getNumVariadicRegions() == 0; }
using arg_iterator = const Argument *;
using arg_range = llvm::iterator_range<arg_iterator>;
- // Op argument (attribute or operand) iterators.
+ /// Op argument (attribute or operand) iterators.
arg_iterator arg_begin() const;
arg_iterator arg_end() const;
arg_range getArgs() const;
- // Op argument (attribute or operand) accessors.
+ /// Op argument (attribute or operand) accessors.
Argument getArg(int index) const;
StringRef getArgName(int index) const;
var_decorator_range getArgDecorators(int index) const;
- // Returns the trait wrapper for the given MLIR C++ `trait`.
+ /// Returns the trait wrapper for the given MLIR C++ `trait`.
const Trait *getTrait(llvm::StringRef trait) const;
- // Regions.
+ /// Regions.
using const_region_iterator = const NamedRegion *;
const_region_iterator region_begin() const;
const_region_iterator region_end() const;
llvm::iterator_range<const_region_iterator> getRegions() const;
- // Returns the number of regions.
+ /// Returns the number of regions.
unsigned getNumRegions() const;
- // Returns the `index`-th region.
+ /// Returns the `index`-th region.
const NamedRegion &getRegion(unsigned index) const;
- // Returns the number of variadic regions in this operation.
+ /// Returns the number of variadic regions in this operation.
unsigned getNumVariadicRegions() const;
- // Successors.
+ /// Successors.
using const_successor_iterator = const NamedSuccessor *;
const_successor_iterator successor_begin() const;
const_successor_iterator successor_end() const;
llvm::iterator_range<const_successor_iterator> getSuccessors() const;
- // Returns the number of successors.
+ /// Returns the number of successors.
unsigned getNumSuccessors() const;
- // Returns the `index`-th successor.
+ /// Returns the `index`-th successor.
const NamedSuccessor &getSuccessor(unsigned index) const;
- // Returns the number of variadic successors in this operation.
+ /// Returns the number of variadic successors in this operation.
unsigned getNumVariadicSuccessors() const;
- // Trait.
+ /// Trait.
using const_trait_iterator = const Trait *;
const_trait_iterator trait_begin() const;
const_trait_iterator trait_end() const;
@@ -224,40 +224,40 @@ class Operator {
ArrayRef<SMLoc> getLoc() const;
- // Query functions for the documentation of the operator.
+ /// Query functions for the documentation of the operator.
bool hasDescription() const;
StringRef getDescription() const;
bool hasSummary() const;
StringRef getSummary() const;
- // Query functions for the assembly format of the operator.
+ /// Query functions for the assembly format of the operator.
bool hasAssemblyFormat() const;
StringRef getAssemblyFormat() const;
- // Returns this op's extra class declaration code.
+ /// Returns this op's extra class declaration code.
StringRef getExtraClassDeclaration() const;
- // Returns this op's extra class definition code.
+ /// Returns this op's extra class definition code.
StringRef getExtraClassDefinition() 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.
+ /// 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.
const llvm::Record &getDef() const;
- // Returns the dialect of the op.
+ /// Returns the dialect of the op.
const Dialect &getDialect() const { return dialect; }
- // Prints the contents in this operator to the given `os`. This is used for
- // debugging purposes.
+ /// Prints the contents in this operator to the given `os`. This is used for
+ /// debugging purposes.
void print(llvm::raw_ostream &os) const;
- // Return whether all the result types are known.
+ /// Return whether all the result types are known.
bool allResultTypesKnown() const { return allResultsHaveKnownTypes; };
- // Pair representing either a index to an argument or a type constraint. Only
- // one of these entries should have the non-default value.
+ /// Pair representing either a index to an argument or a type constraint. Only
+ /// one of these entries should have the non-default value.
struct ArgOrType {
explicit ArgOrType(int index) : index(index), constraint(std::nullopt) {}
explicit ArgOrType(TypeConstraint constraint)
@@ -279,11 +279,11 @@ class Operator {
std::optional<TypeConstraint> constraint;
};
- // Return all arguments or type constraints with same type as result[index].
- // Requires: all result types are known.
+ /// Return all arguments or type constraints with same type as result[index].
+ /// Requires: all result types are known.
ArrayRef<ArgOrType> getSameTypeAsResult(int index) const;
- // Pair consisting kind of argument and index into operands or attributes.
+ /// Pair consisting kind of argument and index into operands or attributes.
struct OperandOrAttribute {
enum class Kind { Operand, Attribute };
OperandOrAttribute(Kind kind, int index) {
@@ -296,77 +296,77 @@ class Operator {
int packed;
};
- // Returns the OperandOrAttribute corresponding to the index.
+ /// Returns the OperandOrAttribute corresponding to the index.
OperandOrAttribute getArgToOperandOrAttribute(int index) const;
- // Returns the builders of this operation.
+ /// Returns the builders of this operation.
ArrayRef<Builder> getBuilders() const { return builders; }
- // Returns the getter name for the accessor of `name`.
+ /// Returns the getter name for the accessor of `name`.
std::string getGetterName(StringRef name) const;
- // Returns the setter name for the accessor of `name`.
+ /// Returns the setter name for the accessor of `name`.
std::string getSetterName(StringRef name) const;
private:
- // Populates the vectors containing operands, attributes, results and traits.
+ /// Populates the vectors containing operands, attributes, results and traits.
void populateOpStructure();
- // Populates type inference info (mostly equality) with input a mapping from
- // names to indices for arguments and results.
+ /// Populates type inference info (mostly equality) with input a mapping from
+ /// names to indices for arguments and results.
void populateTypeInferenceInfo(
const llvm::StringMap<int> &argumentsAndResultsIndex);
- // The dialect of this op.
+ /// The dialect of this op.
Dialect dialect;
- // The unqualified C++ class name of the op.
+ /// The unqualified C++ class name of the op.
StringRef cppClassName;
- // The C++ namespace for this op.
+ /// The C++ namespace for this op.
StringRef cppNamespace;
- // The operands of the op.
+ /// The operands of the op.
SmallVector<NamedTypeConstraint, 4> operands;
- // The attributes of the op. Contains native attributes (corresponding to the
- // actual stored attributed of the operation) followed by derived attributes
- // (corresponding to dynamic properties of the operation that are computed
- // upon request).
+ /// The attributes of the op. Contains native attributes (corresponding to
+ /// the actual stored attributed of the operation) followed by derived
+ /// attributes (corresponding to dynamic properties of the operation that are
+ /// computed upon request).
SmallVector<NamedAttribute, 4> attributes;
- // The arguments of the op (operands and native attributes).
+ /// The arguments of the op (operands and native attributes).
SmallVector<Argument, 4> arguments;
- // The results of the op.
+ /// The results of the op.
SmallVector<NamedTypeConstraint, 4> results;
- // The successors of this op.
+ /// The successors of this op.
SmallVector<NamedSuccessor, 0> successors;
- // The traits of the op.
+ /// The traits of the op.
SmallVector<Trait, 4> traits;
- // The regions of this op.
+ /// The regions of this op.
SmallVector<NamedRegion, 1> regions;
- // The argument with the same type as the result.
+ /// The argument with the same type as the result.
SmallVector<SmallVector<ArgOrType, 2>, 4> resultTypeMapping;
- // Map from argument to attribute or operand number.
+ /// Map from argument to attribute or operand number.
SmallVector<OperandOrAttribute, 4> attrOrOperandMapping;
- // The builders of this operator.
+ /// The builders of this operator.
SmallVector<Builder> builders;
- // The number of native attributes stored in the leading positions of
- // `attributes`.
+ /// The number of native attributes stored in the leading positions of
+ /// `attributes`.
int numNativeAttributes;
- // The TableGen definition of this op.
+ /// The TableGen definition of this op.
const llvm::Record &def;
- // Whether the type of all results are known.
+ /// Whether the type of all results are known.
bool allResultsHaveKnownTypes;
};
More information about the Mlir-commits
mailing list