diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -1440,8 +1440,8 @@ ### TypeParameter tablegen class This is used to further specify attributes about each of the types parameters. -It includes documentation (`description` and `syntax`), the C++ type to use, and -a custom allocator to use in the storage constructor method. +It includes documentation (`summary` and `syntax`), the C++ type to use, and a +custom allocator to use in the storage constructor method. ```tablegen // DO NOT DO THIS! diff --git a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td --- a/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td +++ b/mlir/include/mlir/Dialect/ArmSVE/ArmSVE.td @@ -38,7 +38,7 @@ CPred<"$_self.isa()">, "scalable vector type">, BuildableType<"$_builder.getType()"> { - let typeDescription = [{ + let description = [{ `arm_sve.vector` represents vectors that will be processed by a scalable vector architecture. }]; @@ -119,8 +119,8 @@ list allowedTypes> : Type< And<[ScalableVectorOf.predicate, ScalableVectorOfLength.predicate]>, - ScalableVectorOf.description # - ScalableVectorOfLength.description>; + ScalableVectorOf.summary # + ScalableVectorOfLength.summary>; //===----------------------------------------------------------------------===// // ArmSVE op definitions diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncBase.td b/mlir/include/mlir/Dialect/Async/IR/AsyncBase.td --- a/mlir/include/mlir/Dialect/Async/IR/AsyncBase.td +++ b/mlir/include/mlir/Dialect/Async/IR/AsyncBase.td @@ -33,7 +33,7 @@ def Async_TokenType : DialectType()">, "token type">, BuildableType<"$_builder.getType<::mlir::async::TokenType>()"> { - let typeDescription = [{ + let description = [{ `async.token` is a type returned by asynchronous operations, and it becomes `ready` when the asynchronous operations that created it is completed. }]; @@ -46,8 +46,8 @@ SubstLeaves<"$_self", "$_self.cast<::mlir::async::ValueType>().getValueType()", type.predicate> - ]>, "async value type with " # type.description # " underlying type"> { - let typeDescription = [{ + ]>, "async value type with " # type.summary # " underlying type"> { + let description = [{ `async.value` represents a value returned by asynchronous operations, which may or may not be available currently, but will be available at some point in the future. @@ -59,7 +59,7 @@ def Async_GroupType : DialectType()">, "group type">, BuildableType<"$_builder.getType<::mlir::async::GroupType>()"> { - let typeDescription = [{ + let description = [{ `async.group` represent a set of async tokens or values and allows to execute async operations on all of them together (e.g. wait for the completion of all/any of them). diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -102,7 +102,7 @@ "$_self", "$_self.cast<::mlir::LLVM::LLVMPointerType>().getElementType()", pointee.predicate>]>, - "LLVM pointer to " # pointee.description>; + "LLVM pointer to " # pointee.summary>; // Type constraint accepting any LLVM structure type. def LLVM_AnyStruct : Type()">, @@ -142,7 +142,7 @@ "$_self", "$_self.cast<::mlir::LLVM::LLVMVectorType>().getElementType()", element.predicate>]>, - "LLVM vector of " # element.description>; + "LLVM vector of " # element.summary>; // Type constraint accepting a constrained type, or a vector of such types. class LLVM_ScalarOrVectorOf : diff --git a/mlir/include/mlir/Dialect/Quant/QuantOpsBase.td b/mlir/include/mlir/Dialect/Quant/QuantOpsBase.td --- a/mlir/include/mlir/Dialect/Quant/QuantOpsBase.td +++ b/mlir/include/mlir/Dialect/Quant/QuantOpsBase.td @@ -28,7 +28,7 @@ Type.predicate, VectorOf<[etype]>.predicate]>, - "primitive/tensor/vector of " # etype.description>; + "primitive/tensor/vector of " # etype.summary>; // An implementation of QuantizedType. def quant_QuantizedType : diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeBase.td @@ -43,7 +43,7 @@ def Shape_ShapeType : DialectType()">, "shape">, BuildableType<"$_builder.getType<::mlir::shape::ShapeType>()"> { - let typeDescription = [{ + let description = [{ `shape.shape` represents either an unranked shape, a ranked shape with possibly unknown dimensions or an invalid shape. The rank is of type `shape.size` and, if rank is known, the extent is a 1D tensor of type @@ -62,7 +62,7 @@ def Shape_SizeType : DialectType()">, "size">, BuildableType<"$_builder.getType<::mlir::shape::SizeType>()"> { - let typeDescription = [{ + let description = [{ `shape.size` represents a non-negative integer with support for being unknown and invalid. @@ -76,7 +76,7 @@ CPred<"$_self.isa<::mlir::shape::ValueShapeType>()">, "value shape">, BuildableType<"::mlir::shape::ValueShapeType::get($_builder.getContext())"> { - let typeDescription = [{ + let description = [{ `shape.value_shape` represents the value produced by an operation (this corresponds to `Value` in the compiler) and a shape. Conceptually this is a tuple of a value (potentially unknown) and `shape.shape`. The value and @@ -93,7 +93,7 @@ 1DTensorOf<[Index]>, BuildableType<"::mlir::RankedTensorType::get({ShapedType::kDynamicSize}, " "$_builder.getType<::mlir::IndexType>())"> { - let typeDescription = [{ + let description = [{ The extent tensor is a tensor of rank one with arbitrarily many index elements (tensor). Like `!shape.shape`, it is used to represent shapes with the difference that it is guaranteed to be error-free. @@ -112,7 +112,7 @@ def Shape_WitnessType : DialectType()">, "witness">, BuildableType<"$_builder.getType<::mlir::shape::WitnessType>()"> { - let typeDescription = [{ + let description = [{ A witness is a structural device in the compiler to maintain ordering of code relying on information obtained from passing assertions. Witnesses do not represent any physical data. diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td --- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td +++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td @@ -63,7 +63,7 @@ StructFieldAttr<"input_zp", I32Attr>, StructFieldAttr<"output_zp", I32Attr> ]> { - let description = "Attribute for UnaryOp quantization information."; + let summary = "Attribute for UnaryOp quantization information."; } // There is no explicit BinaryOpQuantizationAttr for 2-input/1-output ops. In @@ -82,7 +82,7 @@ StructFieldAttr<"input_zp", I32Attr>, StructFieldAttr<"weight_zp", I32Attr> ]> { - let description = "Attribute for Conv type op quantization information."; + let summary = "Attribute for Conv type op quantization information."; } def Tosa_MatMulOpQuantizationAttr : StructAttr<"MatMulOpQuantizationAttr", @@ -90,7 +90,7 @@ StructFieldAttr<"a_zp", I32Attr>, StructFieldAttr<"b_zp", I32Attr> ]> { - let description = "Attribute for MatMulOp quantization information."; + let summary = "Attribute for MatMulOp quantization information."; } // This attribute holds input zero point correction applied to the padding @@ -101,7 +101,7 @@ Tosa_Dialect, [ StructFieldAttr<"input_zp", I32Attr> ]> { - let description = "Attribute for PadOp quantization information."; + let summary = "Attribute for PadOp quantization information."; } //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -154,9 +154,9 @@ class Constraint { // The predicates that this constraint requires. Pred predicate = pred; - // User-readable description used in error reporting messages. If empty, a - // generic message will be used. - string description = desc; + // User-readable one line summary used in error reporting messages. If empty, + // a generic message will be used. + string summary = desc; } // Subclasses used to differentiate different constraint kinds. These are used @@ -165,24 +165,24 @@ // are considered as uncategorized constraints. // Subclass for constraints on a type. -class TypeConstraint : - Constraint { + Constraint { // The name of the C++ Type class if known, or Type if not. string cppClassName = cppClassNameParam; } // Subclass for constraints on an attribute. -class AttrConstraint : - Constraint; +class AttrConstraint : + Constraint; // Subclass for constraints on a region. -class RegionConstraint : - Constraint; +class RegionConstraint : + Constraint; // Subclass for constraints on a successor. -class SuccessorConstraint : - Constraint; +class SuccessorConstraint : + Constraint; // How to use these constraint categories: // @@ -282,14 +282,14 @@ class Type : TypeConstraint { - string typeDescription = ""; + string description = ""; string builderCall = ""; } -// Allows providing an alternative name and description to an existing type def. -class TypeAlias : - Type { - let typeDescription = t.typeDescription; +// Allows providing an alternative name and summary to an existing type def. +class TypeAlias : + Type { + let description = t.description; let builderCall = t.builderCall; } @@ -302,13 +302,13 @@ // A variadic type constraint. It expands to zero or more of the base type. This // class is used for supporting variadic operands/results. -class Variadic : TypeConstraint { +class Variadic : TypeConstraint { Type baseType = type; } // An optional type constraint. It expands to either zero or one of the base // type. This class is used for supporting optional operands/results. -class Optional : TypeConstraint { +class Optional : TypeConstraint { Type baseType = type; } @@ -339,13 +339,13 @@ BuildableType<"$_builder.getType<::mlir::NoneType>()">; // Any type from the given list -class AnyTypeOf allowedTypes, string description = "", +class AnyTypeOf allowedTypes, string summary = "", string cppClassName = "::mlir::Type"> : Type< // Satisfy any of the allowed type's condition Or, - !if(!eq(description, ""), - !interleave(!foreach(t, allowedTypes, t.description), " or "), - description)>; + !if(!eq(summary, ""), + !interleave(!foreach(t, allowedTypes, t.summary), " or "), + summary)>; // Integer types. @@ -475,7 +475,7 @@ SubstLeaves<"$_self", "$_self.cast<::mlir::ComplexType>().getElementType()", type.predicate>]>, - "complex type with " # type.description # " elements", + "complex type with " # type.summary # " elements", "::mlir::ComplexType">, SameBuildabilityAs { @@ -485,9 +485,9 @@ def AnyComplex : Type()">, "complex-type", "::mlir::ComplexType">; -class OpaqueType +class OpaqueType : Type, - description, "::mlir::OpaqueType">, + summary, "::mlir::OpaqueType">, BuildableType<"::mlir::OpaqueType::get($_builder.getContext(), " "$_builder.getIdentifier(\"" # dialect # "\"), \"" # name # "\")">; @@ -506,7 +506,7 @@ Type(elementTypeCall), etype.predicate>]>, - descr # " of " # etype.description # " values", cppClassName> { + descr # " of " # etype.summary # " values", cppClassName> { // The type of elements in the container. Type elementType = etype; @@ -558,8 +558,7 @@ list allowedTypes> : Type< And<[VectorOf.predicate, VectorOfRank.predicate]>, - VectorOf.description # - VectorOfRank.description, + VectorOf.summary # VectorOfRank.summary, "::mlir::VectorType">; // Whether the number of elements of a vector is from the given @@ -585,8 +584,7 @@ list allowedTypes> : Type< And<[VectorOf.predicate, VectorOfLength.predicate]>, - VectorOf.description # - VectorOfLength.description, + VectorOf.summary # VectorOfLength.summary, "::mlir::VectorType">; def AnyVector : VectorOf<[AnyType]>; @@ -612,7 +610,7 @@ // TODO: Have an easy way to add another constraint to a type. class StaticShapeTensorOf allowedTypes> : Type.predicate, HasStaticShapePred]>, - "statically shaped " # TensorOf.description, + "statically shaped " # TensorOf.summary, "::mlir::TensorType">; def AnyStaticShapeTensor : StaticShapeTensorOf<[AnyType]>; @@ -633,7 +631,7 @@ class TensorRankOf allowedTypes, list ranks> : Type.predicate, HasAnyRankOfPred]>, !interleave(!foreach(rank, ranks, rank # "D"), "/") # " " # - TensorOf.description, "::mlir::TensorType">; + TensorOf.summary, "::mlir::TensorType">; class 0DTensorOf allowedTypes> : TensorRankOf; class 1DTensorOf allowedTypes> : TensorRankOf; @@ -674,11 +672,11 @@ class MemRefRankOf allowedTypes, list ranks> : Type.predicate, HasAnyRankOfPred]>, !interleave(!foreach(rank, ranks, rank # "D"), "/") # " " # - MemRefOf.description>; + MemRefOf.summary>; class StaticShapeMemRefOf allowedTypes> : Type.predicate, HasStaticShapePred]>, - "statically shaped " # MemRefOf.description>; + "statically shaped " # MemRefOf.summary>; def AnyStaticShapeMemRef : StaticShapeMemRefOf<[AnyType]>; @@ -687,19 +685,19 @@ class StridedMemRefOf allowedTypes> : Type.predicate, HasStridesPred]>, - "strided " # MemRefOf.description>; + "strided " # MemRefOf.summary>; def AnyStridedMemRef : StridedMemRefOf<[AnyType]>; class AnyStridedMemRefOfRank : Type.predicate]>, - AnyStridedMemRef.description # " of rank " # rank>; + AnyStridedMemRef.summary # " of rank " # rank>; class StridedMemRefRankOf allowedTypes, list ranks> : Type.predicate, HasAnyRankOfPred]>, !interleave(!foreach(rank, ranks, rank # "D"), "/") # " " # - MemRefOf.description>; + MemRefOf.summary>; // This represents a generic tuple without any constraints on element type. def AnyTuple : Type; @@ -718,7 +716,7 @@ "; })" > ]>, - descr # " with any combination of " # etype.description # " values"> { + descr # " with any combination of " # etype.summary # " values"> { // The type of elements in the container. Type elementType = etype; @@ -838,7 +836,7 @@ // Decorates an attribute to have an (unvalidated) default value if not present. class DefaultValuedAttr : - Attr { + Attr { // Construct this attribute with the input attribute and change only // the default value. // Note: this has to be kept up to date with Attr above. @@ -854,7 +852,7 @@ // Decorates an attribute as optional. The return type of the generated // attribute accessor method will be Optional<>. -class OptionalAttr : Attr { +class OptionalAttr : Attr { // Rewrite the attribute to be optional. // Note: this has to be kept up to date with Attr above. let storageType = attr.storageType; @@ -1057,12 +1055,12 @@ // Base class for attributes containing types. Example: // def IntTypeAttr : TypeAttrBase<"IntegerType", "integer type attribute"> // defines a type attribute containing an integer type. -class TypeAttrBase : +class TypeAttrBase : Attr()">, CPred<"$_self.cast<::mlir::TypeAttr>().getValue().isa<" # retType # ">()">]>, - description> { + summary> { let storageType = [{ ::mlir::TypeAttr }]; let returnType = retType; let valueType = NoneType; @@ -1188,43 +1186,42 @@ // Op attributes of this kind are stored as StringAttr. Extra verification will // be generated on the string though: only the symbols of the allowed cases are // permitted as the string value. -class StrEnumAttr cases> : - EnumAttrInfo, +class StrEnumAttr cases> + : EnumAttrInfo, StringBasedAttr< And<[StrAttr.predicate, Or]>, - !if(!empty(description), "allowed string cases: " # + !if(!empty(summary), "allowed string cases: " # !interleave(!foreach(case, cases, "'" # case.symbol # "'"), ", "), - description)>; + summary)>; // An enum attribute backed by IntegerAttr. // // Op attributes of this kind are stored as IntegerAttr. Extra verification will // be generated on the integer though: only the values of the allowed cases are // permitted as the integer value. -class IntEnumAttr cases> : EnumAttrInfo, SignlessIntegerAttrBase { + !if(!empty(summary), "allowed " # intType.summary # " cases: " # + !interleave(!foreach(case, cases, case.value), ", "), summary)> { let predicate = And<[ SignlessIntegerAttrBase.predicate, Or]>; } -class I32EnumAttr cases> : - IntEnumAttr { + IntEnumAttr { let returnType = cppNamespace # "::" # name; let underlyingType = "uint32_t"; let convertFromStorage = "static_cast<" # returnType # ">($_self.getInt())"; let constBuilderCall = "$_builder.getI32IntegerAttr(static_cast($0))"; } -class I64EnumAttr cases> : - IntEnumAttr { + IntEnumAttr { let returnType = cppNamespace # "::" # name; let underlyingType = "uint64_t"; let convertFromStorage = "static_cast<" # returnType # ">($_self.getInt())"; @@ -1238,9 +1235,9 @@ // be generated on the integer to make sure only allowed bit are set. Besides, // helper methods are generated to parse a string separated with a specified // delimiter to a symbol and vice versa. -class BitEnumAttr cases> : - EnumAttrInfo, SignlessIntegerAttrBase { + EnumAttrInfo, SignlessIntegerAttrBase { let predicate = And<[ I32Attr.predicate, // Make sure we don't have unknown bit set. @@ -1266,8 +1263,8 @@ //===----------------------------------------------------------------------===// // Composite attribute kinds -class DictionaryAttrBase : - Attr { +class DictionaryAttrBase : + Attr { let storageType = [{ ::mlir::DictionaryAttr }]; let returnType = [{ ::mlir::DictionaryAttr }]; let valueType = NoneType; @@ -1278,8 +1275,8 @@ : DictionaryAttrBase()">, "dictionary of named attribute values">; -class ElementsAttrBase : - Attr { +class ElementsAttrBase : + Attr { let storageType = [{ ::mlir::ElementsAttr }]; let returnType = [{ ::mlir::ElementsAttr }]; let convertFromStorage = "$_self"; @@ -1288,10 +1285,10 @@ def ElementsAttr : ElementsAttrBase()">, "constant vector/tensor attribute">; -class IntElementsAttrBase : +class IntElementsAttrBase : ElementsAttrBase()">, condition]>, - description> { + summary> { let storageType = [{ ::mlir::DenseIntElementsAttr }]; let returnType = [{ ::mlir::DenseIntElementsAttr }]; @@ -1338,8 +1335,8 @@ CPred<"$_self.cast<::mlir::DenseIntElementsAttr>().getType().getShape() == " "::mlir::ArrayRef({" # !interleave(dims, ", ") # "})">]>; - let description = width # "-bit signless int elements attribute of shape [" # - !interleave(dims, ", ") # "]"; + let summary = width # "-bit signless int elements attribute of shape [" # + !interleave(dims, ", ") # "]"; let constBuilderCall = "::mlir::DenseIntElementsAttr::get(" "::mlir::RankedTensorType::get({" # !interleave(dims, ", ") # @@ -1415,8 +1412,7 @@ } // Base class for array attributes. -class ArrayAttrBase : - Attr { +class ArrayAttrBase : Attr { let storageType = [{ ::mlir::ArrayAttr }]; let returnType = [{ ::mlir::ArrayAttr }]; let valueType = NoneType; @@ -1428,7 +1424,7 @@ // Base class for array attributes whose elements are of the same kind. // `element` specifies the element attribute kind stored in this array. -class TypedArrayAttrBase: ArrayAttrBase< +class TypedArrayAttrBase: ArrayAttrBase< And<[ // Guarantee this is an ArrayAttr first CPred<"$_self.isa<::mlir::ArrayAttr>()">, @@ -1437,7 +1433,7 @@ "[](::mlir::Attribute attr) { return ", SubstLeaves<"$_self", "attr", element.predicate>, "; })">]>, - description> { + summary> { let constBuilderCall = "$_builder.getArrayAttr($0)"; Attr elementAttr = element; @@ -1597,8 +1593,8 @@ class Confined constraints> : Attr< And, - !foldl(/*init*/attr.description, /*list*/constraints, - prev, cur, prev # " " # cur.description)> { + !foldl(/*init*/attr.summary, /*list*/constraints, + prev, cur, prev # " " # cur.summary)> { let storageType = attr.storageType; let returnType = attr.returnType; let convertFromStorage = attr.convertFromStorage; @@ -1615,7 +1611,7 @@ class AllAttrConstraintsOf constraints> : AttrConstraint< And, - !interleave(!foreach(con, constraints, con.description), " and ")> { + !interleave(!foreach(con, constraints, con.summary), " and ")> { } class IntMinValue : AttrConstraint< @@ -1688,7 +1684,7 @@ // A variadic region constraint. It expands to zero or more of the base region. class VariadicRegion - : Region; + : Region; //===----------------------------------------------------------------------===// // Successor definitions @@ -1703,7 +1699,7 @@ // A variadic successor constraint. It expands to zero or more of the base // successor. class VariadicSuccessor - : Successor; + : Successor; //===----------------------------------------------------------------------===// // OpTrait definitions @@ -1736,7 +1732,7 @@ // PredOpTrait is an op trait implemented by way of a predicate on the op. class PredOpTrait : OpTrait { - string description = descr; + string summary = descr; Pred predicate = pred; } @@ -2015,8 +2011,8 @@ // The constraint, either attribute or type, of the argument. Constraint constraint = varConstraint; - // A description for the argument. - string description = desc; + // One-line human-readable description of the argument. + string summary = desc; // The list of decorators for this variable, e.g. side effects. list decorators = varDecorators; @@ -2161,17 +2157,17 @@ CPred<"::llvm::is_splat(::llvm::makeArrayRef({" # !interleave(values, ", ") #"}))">; -class AllMatch values, string description> : - PredOpTrait>; +class AllMatch values, string summary> : + PredOpTrait>; // TODO: Only works for non-variadic. class AllMatchSameOperatorPred names, string operator> : AllMatchPred; class AllMatchSameOperatorTrait names, string operator, - string description> : + string summary> : PredOpTrait< - "all of {" # !interleave(names, ", ") # "} have same " # description, + "all of {" # !interleave(names, ", ") # "} have same " # summary, AllMatchSameOperatorPred> { list values = names; } @@ -2194,9 +2190,9 @@ AllMatchSameOperatorTrait; // A type constraint that denotes `transform(lhs.getType()) == rhs.getType()`. -class TypesMatchWith : - PredOpTrait> { string lhs = lhsArg; @@ -2217,7 +2213,7 @@ class TypeIsPred : SubstLeaves<"$_self", "$" # name # ".getType()", type.predicate>; class TypeIs : PredOpTrait< - "'" # name # "' is " # type.description, TypeIsPred>; + "'" # name # "' is " # type.summary, TypeIsPred>; // Predicate to verify that a named argument or result's element type matches a // given type. @@ -2226,7 +2222,7 @@ SubstLeaves<"$_self", "getElementTypeOrSelf($" # name # ")", type.predicate>]>; class ElementTypeIs : PredOpTrait< - "'" # name # "' is " # type.description, ElementTypeIsPred>; + "'" # name # "' is " # type.summary, ElementTypeIsPred>; // Predicate to verify that the i'th operand and the j'th operand have the same // elemental type. @@ -2441,8 +2437,8 @@ // The name of the C++ base class to use for this Type. string cppBaseClassName = baseCppClass; - // Short summary of the type. - string summary = ?; + // Additional, longer human-readable description of what the op does. + string description = ""; // Name of storage class to generate or use. string storageClass = name # "TypeStorage"; @@ -2514,8 +2510,8 @@ code allocator = ?; // The C++ type of this parameter. string cppType = type; - // A description of this parameter. - string description = desc; + // One-line human-readable description of the argument. + string summary = desc; // The format string for the asm syntax (documentation only). string syntax = ?; } diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h --- a/mlir/include/mlir/TableGen/Constraint.h +++ b/mlir/include/mlir/TableGen/Constraint.h @@ -45,7 +45,7 @@ // Returns the user-readable description of this constraint. If the // description is not provided, returns the TableGen def name. - StringRef getDescription() const; + StringRef getSummary() const; // Constraint kind enum Kind { CK_Attr, CK_Region, CK_Successor, CK_Type, CK_Uncategorized }; diff --git a/mlir/include/mlir/TableGen/OpTrait.h b/mlir/include/mlir/TableGen/OpTrait.h --- a/mlir/include/mlir/TableGen/OpTrait.h +++ b/mlir/include/mlir/TableGen/OpTrait.h @@ -75,7 +75,7 @@ std::string getPredTemplate() const; // Returns the description of what the predicate is verifying. - StringRef getDescription() const; + StringRef getSummary() const; static bool classof(const OpTrait *t) { return t->getKind() == Kind::Pred; } }; diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -58,7 +58,7 @@ explicit Type(const llvm::Record *record); // Returns the description of the type. - StringRef getTypeDescription() const; + StringRef getDescription() const; // Returns the dialect for the type if defined. Dialect getDialect() const; diff --git a/mlir/include/mlir/TableGen/TypeDef.h b/mlir/include/mlir/TableGen/TypeDef.h --- a/mlir/include/mlir/TableGen/TypeDef.h +++ b/mlir/include/mlir/TableGen/TypeDef.h @@ -119,11 +119,11 @@ // Get the parameter name. StringRef getName() const; // If specified, get the custom allocator code for this parameter. - llvm::Optional getAllocator() const; + Optional getAllocator() const; // Get the C++ type of this parameter. StringRef getCppType() const; // Get a description of this parameter for documentation purposes. - llvm::Optional getDescription() const; + Optional getSummary() const; // Get the assembly syntax documentation. StringRef getSyntax() const; diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp --- a/mlir/lib/TableGen/Constraint.cpp +++ b/mlir/lib/TableGen/Constraint.cpp @@ -57,17 +57,9 @@ return getPredicate().getCondition(); } -StringRef Constraint::getDescription() const { - // If a summary is found, we use that given that it is a focused single line - // comment. +StringRef Constraint::getSummary() const { if (Optional summary = def->getValueAsOptionalString("summary")) return *summary; - // If a summary can't be found, look for a specific description field to use - // for the constraint. - StringRef desc = def->getValueAsString("description"); - if (!desc.empty()) - return desc; - // Otherwise, fallback to the name of the constraint definition. return def->getName(); } diff --git a/mlir/lib/TableGen/OpTrait.cpp b/mlir/lib/TableGen/OpTrait.cpp --- a/mlir/lib/TableGen/OpTrait.cpp +++ b/mlir/lib/TableGen/OpTrait.cpp @@ -48,8 +48,8 @@ return pred.getCondition(); } -llvm::StringRef PredOpTrait::getDescription() const { - return def->getValueAsString("description"); +llvm::StringRef PredOpTrait::getSummary() const { + return def->getValueAsString("summary"); } OpInterface InterfaceOpTrait::getOpInterface() const { diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -60,8 +60,8 @@ Type::Type(const llvm::Record *record) : TypeConstraint(record) {} -StringRef Type::getTypeDescription() const { - return def->getValueAsString("typeDescription"); +StringRef Type::getDescription() const { + return def->getValueAsString("description"); } Dialect Type::getDialect() const { diff --git a/mlir/lib/TableGen/TypeDef.cpp b/mlir/lib/TableGen/TypeDef.cpp --- a/mlir/lib/TableGen/TypeDef.cpp +++ b/mlir/lib/TableGen/TypeDef.cpp @@ -109,7 +109,7 @@ StringRef TypeParameter::getName() const { return def->getArgName(num)->getValue(); } -llvm::Optional TypeParameter::getAllocator() const { +Optional TypeParameter::getAllocator() const { llvm::Init *parameterType = def->getArg(num); if (isa(parameterType)) return llvm::Optional(); @@ -142,14 +142,14 @@ "Parameters DAG arguments must be either strings or defs " "which inherit from TypeParameter\n"); } -llvm::Optional TypeParameter::getDescription() const { +Optional TypeParameter::getSummary() const { auto *parameterType = def->getArg(num); if (auto *typeParameter = dyn_cast(parameterType)) { const auto *desc = typeParameter->getDef()->getValue("description"); if (llvm::StringInit *ci = dyn_cast(desc->getValue())) return ci->getValue(); } - return llvm::Optional(); + return Optional(); } StringRef TypeParameter::getSyntax() const { auto *parameterType = def->getArg(num); diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -281,7 +281,7 @@ } def MyStruct : StructAttr<"MyStruct", Test_Dialect_2, [StructFieldAttr<"potatoes", I64ElementsAttr>]> { - let description = "A structure describing a number of potatoes."; + let summary = "A structure describing a number of potatoes."; } def StructAttrOp : NS_Op<"struct_attr_op", []> { diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -336,7 +336,7 @@ StringRef enumName = enumAttr.getEnumClassName(); StringRef cppNamespace = enumAttr.getCppNamespace(); std::string underlyingType = std::string(enumAttr.getUnderlyingType()); - StringRef description = enumAttr.getDescription(); + StringRef description = enumAttr.getSummary(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -248,7 +248,7 @@ << formatv( " return op->emitOpError(valueKind) << \" #\" << " "valueGroupStartIndex << \" must be {0}, but got \" << type;\n", - constraint.getDescription()) + constraint.getSummary()) << " }\n" << " return ::mlir::success();\n" << "}\n\n"; @@ -573,7 +573,7 @@ body << tgfmt(" if (!($0)) return $1\"attribute '$2' " "failed to satisfy constraint: $3\");\n", /*ctx=*/nullptr, tgfmt(condition, &ctx.withSelf(varName)), - emitErrorPrefix, attrName, attr.getDescription()); + emitErrorPrefix, attrName, attr.getSummary()); if (allowMissingAttr) body << " }\n"; body << " }\n"; @@ -1965,7 +1965,7 @@ body << tgfmt(" if (!($0))\n " "return emitOpError(\"failed to verify that $1\");\n", &verifyCtx, tgfmt(t->getPredTemplate(), &verifyCtx), - t->getDescription()); + t->getSummary()); } } @@ -2060,7 +2060,7 @@ "verify constraint: {2}\";\n }\n", constraint, region.name.empty() ? "" : "('" + region.name + "') ", - region.constraint.getDescription()) + region.constraint.getSummary()) << " ++index;\n" << " }\n"; } @@ -2099,7 +2099,7 @@ "failed to " "verify constraint: {2}\";\n }\n", constraint, successor.name, - successor.constraint.getDescription()) + successor.constraint.getSummary()) << " ++index;\n" << " }\n"; } diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -58,7 +58,7 @@ os << "`" << it.name << "`"; else os << "«unnamed»"; - os << " | " << it.constraint.getDescription() << "\n"; + os << " | " << it.constraint.getSummary() << "\n"; } //===----------------------------------------------------------------------===// @@ -106,7 +106,7 @@ for (const auto &it : op.getAttributes()) { StringRef storageType = it.attr.getStorageType(); os << "`" << it.name << "` | " << storageType << " | " - << it.attr.getDescription() << "\n"; + << it.attr.getSummary() << "\n"; } } @@ -153,8 +153,8 @@ //===----------------------------------------------------------------------===// static void emitTypeDoc(const Type &type, raw_ostream &os) { - os << "### " << type.getDescription() << "\n"; - emitDescription(type.getTypeDescription(), os); + os << "### " << type.getSummary() << "\n"; + emitDescription(type.getDescription(), os); os << "\n"; } @@ -198,12 +198,12 @@ // Emit attribute documentation. SmallVector parameters; td.getParameters(parameters); - if (parameters.size() != 0) { + if (!parameters.empty()) { os << "\n#### Type parameters:\n\n"; os << "| Parameter | C++ type | Description |\n" << "| :-------: | :-------: | ----------- |\n"; for (const auto &it : parameters) { - auto desc = it.getDescription(); + auto desc = it.getSummary(); os << "| " << it.getName() << " | `" << td.getCppClassName() << "` | " << (desc ? *desc : "") << " |\n"; } diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -1268,7 +1268,7 @@ << ")) {\n" << formatv(" return parser.emitError(parser.getNameLoc()) << " "\"'{0}' must be {1}, but got \" << type;\n", - variable->name, constraint.getDescription()) + variable->name, constraint.getSummary()) << " }\n" << " }\n"; } diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -315,7 +315,7 @@ formatv("\"operand {0} of native code call '{1}' failed to satisfy " "constraint: " "'{2}'\"", - i, tree.getNativeCodeTemplate(), constraint.getDescription())); + i, tree.getNativeCodeTemplate(), constraint.getSummary())); } LLVM_DEBUG(llvm::dbgs() << "done emitting match for native code call\n"); @@ -425,7 +425,7 @@ formatv("\"operand {0} of op '{1}' failed to satisfy constraint: " "'{2}'\"", operand - op.operand_begin(), op.getOperationName(), - constraint.getDescription())); + constraint.getSummary())); } } @@ -491,7 +491,7 @@ formatv("\"op '{0}' attribute '{1}' failed to satisfy constraint: " "{2}\"", op.getOperationName(), namedAttr->name, - matcher.getAsConstraint().getDescription())); + matcher.getAsConstraint().getSummary())); } // Capture the value @@ -536,7 +536,7 @@ emitMatchCheck( opName, tgfmt(condition, &fmtCtx.withSelf(self.str())), formatv("\"value entity '{0}' failed to satisfy constraint: {1}\"", - entities.front(), constraint.getDescription())); + entities.front(), constraint.getSummary())); } else if (isa(constraint)) { PrintFatalError( @@ -562,7 +562,7 @@ formatv("\"entities '{0}' failed to satisfy constraint: " "{1}\"", llvm::join(entities, ", "), - constraint.getDescription())); + constraint.getSummary())); } } diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp --- a/mlir/tools/mlir-tblgen/StructsGen.cpp +++ b/mlir/tools/mlir-tblgen/StructsGen.cpp @@ -78,7 +78,7 @@ StructAttr structAttr(&structDef); StringRef structName = structAttr.getStructClassName(); StringRef cppNamespace = structAttr.getCppNamespace(); - StringRef description = structAttr.getDescription(); + StringRef description = structAttr.getSummary(); auto fields = structAttr.getAllFields(); // Wrap in the appropriate namespace. diff --git a/mlir/unittests/TableGen/structs.td b/mlir/unittests/TableGen/structs.td --- a/mlir/unittests/TableGen/structs.td +++ b/mlir/unittests/TableGen/structs.td @@ -20,5 +20,5 @@ OptionalAttr>, StructFieldAttr<"sample_default_valued_integer", DefaultValuedAttr>] > { - let description = "Structure for test data"; + let summary = "Structure for test data"; }