diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -4,16 +4,17 @@ defining operations and data types in a table-driven manner. This is achieved via [TableGen][TableGen], which is both a generic language and its tooling to maintain records of domain-specific information. Facts regarding an operation -are specified concisely into a TableGen record, which will be expanded into -an equivalent `mlir::Op` C++ template specialization at compiler build time. +are specified concisely into a TableGen record, which will be expanded into an +equivalent `mlir::Op` C++ template specialization at compiler build time. This manual explains in detail all the available mechanisms for defining operations in such a table-driven manner. It aims to be a specification instead -of a tutorial. Please refer to [Quickstart tutorial to adding MLIR graph -rewrite](Tutorials/QuickstartRewrites.md) for the latter. +of a tutorial. Please refer to +[Quickstart tutorial to adding MLIR graph rewrite](Tutorials/QuickstartRewrites.md) +for the latter. -In addition to detailing each mechanism, this manual also tries to capture -best practices. They are rendered as quoted bullet points. +In addition to detailing each mechanism, this manual also tries to capture best +practices. They are rendered as quoted bullet points. ## Motivation @@ -22,12 +23,12 @@ problem, e.g., repetitive string comparisons during optimization and analysis passes, unintuitive accessor methods (e.g., generic/error prone `getOperand(3)` vs self-documenting `getStride()`) with more generic return types, verbose and -generic constructors without default arguments, verbose textual IR dump, and -so on. Furthermore, operation verification is: +generic constructors without default arguments, verbose textual IR dump, and so +on. Furthermore, operation verification is: -1. best case: a central string-to-verification-function map, -1. middle case: duplication of verification across the code base, or -1. worst case: no verification functions. +1. best case: a central string-to-verification-function map, +1. middle case: duplication of verification across the code base, or +1. worst case: no verification functions. The fix is to support defining ops in a table-driven manner. Then for each dialect, we can have a central place that contains everything you need to know @@ -40,17 +41,17 @@ Compared to the C++ template, this table-driven approach has several benefits including but not limited to: -* **Single source of truth**: We strive to encode all facts regarding an - operation into the record, so that readers don't need to jump among code - snippets to fully understand an operation. -* **Removing boilerplate**: We can automatically generate - operand/attribute/result getter methods, operation build methods, operation - verify methods, and many more utilities from the record. This greatly reduces - the boilerplate needed for defining a new op. -* **Facilitating auto-generation**: The usage of these operation information - records are by no means limited to op definition itself. We can use them to - drive the auto-generation of many other components, like computation graph - serialization. +* **Single source of truth**: We strive to encode all facts regarding an + operation into the record, so that readers don't need to jump among code + snippets to fully understand an operation. +* **Removing boilerplate**: We can automatically generate + operand/attribute/result getter methods, operation build methods, operation + verify methods, and many more utilities from the record. This greatly + reduces the boilerplate needed for defining a new op. +* **Facilitating auto-generation**: The usage of these operation information + records are by no means limited to op definition itself. We can use them to + drive the auto-generation of many other components, like computation graph + serialization. ## TableGen Syntax @@ -128,8 +129,8 @@ } ``` -In the following we describe all the fields needed. Please see the definition -of the `Op` class for the complete list of fields supported. +In the following we describe all the fields needed. Please see the definition of +the `Op` class for the complete list of fields supported. ### Operation name @@ -159,12 +160,12 @@ `description` should be written in Markdown syntax. -Placing the documentation at the beginning is recommended since -it helps in understanding the operation. +Placing the documentation at the beginning is recommended since it helps in +understanding the operation. -> * Place documentation at the beginning of the operation definition -> * The summary should be short and concise. It should be a one-liner without -> trailing punctuation. Put expanded explanation in description. +> * Place documentation at the beginning of the operation definition +> * The summary should be short and concise. It should be a one-liner without +> trailing punctuation. Put expanded explanation in description. ### Operation arguments @@ -172,16 +173,16 @@ values produced by other ops; while attributes are compile-time known constant values, including two categories: -1. Natural attributes: these attributes affect the behavior of the operations - (e.g., padding for convolution); -1. Derived attributes: these attributes are not needed to define the operation - but are instead derived from information of the operation. E.g., the output - shape of type. This is mostly used for convenience interface generation or - interaction with other frameworks/translation. +1. Natural attributes: these attributes affect the behavior of the operations + (e.g., padding for convolution); +1. Derived attributes: these attributes are not needed to define the operation + but are instead derived from information of the operation. E.g., the output + shape of type. This is mostly used for convenience interface generation or + interaction with other frameworks/translation. - All derived attributes should be materializable as an Attribute. That is, - even though they are not materialized, it should be possible to store as - an attribute. + All derived attributes should be materializable as an Attribute. That is, + even though they are not materialized, it should be possible to store as an + attribute. Both operands and attributes are specified inside the `dag`-typed `arguments`, led by `ins`: @@ -203,11 +204,11 @@ There is no requirements on the relative order of operands and attributes; they can mix freely. The relative order of operands themselves matters. From each named argument a named getter will be generated that returns the argument with -the return type (in the case of attributes the return type will be -constructed from the storage type, while for operands it will be `Value`). Each -attribute's raw value (e.g., as stored) can also be accessed via generated -`Attr` getters for use in transformation passes where the more user -friendly return type is less suitable. +the return type (in the case of attributes the return type will be constructed +from the storage type, while for operands it will be `Value`). Each attribute's +raw value (e.g., as stored) can also be accessed via generated `Attr` +getters for use in transformation passes where the more user friendly return +type is less suitable. All the arguments should be named to 1) provide documentation, 2) drive auto-generation of getter methods, 3) provide a handle to reference for other @@ -313,9 +314,9 @@ #### Variadic results -Similar to variadic operands, `Variadic<...>` can also be used for results. -And similarly, `SameVariadicResultSize` for multiple variadic results in the -same operation. +Similar to variadic operands, `Variadic<...>` can also be used for results. And +similarly, `SameVariadicResultSize` for multiple variadic results in the same +operation. ### Operation successors @@ -337,8 +338,8 @@ ### Operation traits and constraints -Traits are operation properties that affect syntax or semantics. MLIR C++ -models various traits in the `mlir::OpTrait` namespace. +Traits are operation properties that affect syntax or semantics. MLIR C++ models +various traits in the `mlir::OpTrait` namespace. Both operation traits, [interfaces](Interfaces.md#utilizing-the-ods-framework), and constraints involving multiple operands/attributes/results are provided as @@ -548,8 +549,8 @@ ### Custom verifier code Verification code will be automatically generated for -[constraints](#constraints) specified on various entities of the op. To -perform _additional_ verification, you can use +[constraints](#constraints) specified on various entities of the op. To perform +_additional_ verification, you can use ```tablegen let verifier = [{ @@ -700,8 +701,8 @@ would result in calls to `parseMyDirective` and `printMyDirective` within the parser and printer respectively. `Params` may be any combination of variables (i.e. Attribute, Operand, Successor, etc.), type directives, and `attr-dict`. -The type directives must refer to a variable, but that variable need not also -be a parameter to the custom directive. +The type directives must refer to a variable, but that variable need not also be +a parameter to the custom directive. The arguments to the `parse` method are firstly a reference to the `OpAsmParser`(`OpAsmParser &`), and secondly a set of output parameters @@ -734,9 +735,9 @@ When a variable is optional, the value should only be specified if the variable is present. Otherwise, the value should remain `None` or null. -The arguments to the `print` method is firstly a reference to -the `OpAsmPrinter`(`OpAsmPrinter &`), second the op (e.g. `FooOp op` which -can be `Operation *op` alternatively), and finally a set of output parameters +The arguments to the `print` method is firstly a reference to the +`OpAsmPrinter`(`OpAsmPrinter &`), second the op (e.g. `FooOp op` which can be +`Operation *op` alternatively), and finally a set of output parameters corresponding to the parameters specified in the format. The mapping of declarative parameter to `print` method argument is detailed below: @@ -866,21 +867,21 @@ via type constraints or other information available. In these cases, the type of that variable may be elided from the format. -* Buildable Types +* Buildable Types -Some type constraints may only have one representation, allowing for them to -be directly buildable; for example the `I32` or `Index` types. Types in `ODS` -may mark themselves as buildable by setting the `builderCall` field or -inheriting from the `BuildableType` class. +Some type constraints may only have one representation, allowing for them to be +directly buildable; for example the `I32` or `Index` types. Types in `ODS` may +mark themselves as buildable by setting the `builderCall` field or inheriting +from the `BuildableType` class. -* Trait Equality Constraints +* Trait Equality Constraints There are many operations that have known type equality constraints registered as traits on the operation; for example the true, false, and result values of a `select` operation often have the same type. The assembly format may inspect these equal constraints to discern the types of missing variables. The currently -supported traits are: `AllTypesMatch`, `TypesMatchWith`, `SameTypeOperands`, -and `SameOperandsAndResultType`. +supported traits are: `AllTypesMatch`, `TypesMatchWith`, `SameTypeOperands`, and +`SameOperandsAndResultType`. ### `hasCanonicalizer` @@ -890,8 +891,8 @@ ### `hasFolder` -This boolean field indicate whether general folding rules have been defined -for this operation. If it is `1`, then `::fold()` should be defined. +This boolean field indicate whether general folding rules have been defined for +this operation. If it is `1`, then `::fold()` should be defined. ### Extra declarations @@ -901,8 +902,8 @@ `extraClassDeclaration`. Code in `extraClassDeclaration` will be copied literally to the generated C++ op class. -Note that `extraClassDeclaration` is a mechanism intended for long-tail cases -by power users; for not-yet-implemented widely-applicable cases, improving the +Note that `extraClassDeclaration` is a mechanism intended for long-tail cases by +power users; for not-yet-implemented widely-applicable cases, improving the infrastructure is preferable. ### Generated C++ code @@ -922,16 +923,16 @@ #### Class name and namespaces For each operation, its generated C++ class name is the symbol `def`ed with -TableGen with dialect prefix removed. The first `_` serves as the delimiter. -For example, for `def TF_AddOp`, the C++ class name would be `AddOp`. -We remove the `TF` prefix because it is for scoping ops; other dialects -may as well define their own `AddOp`s. +TableGen with dialect prefix removed. The first `_` serves as the delimiter. For +example, for `def TF_AddOp`, the C++ class name would be `AddOp`. We remove the +`TF` prefix because it is for scoping ops; other dialects may as well define +their own `AddOp`s. The namespaces of the generated C++ class will come from the dialect's -`cppNamespace` field. For example, if a dialect's `cppNamespace` is `A::B`, -then an op of that dialect will be placed in -`namespace A { namespace B { ... } }`. If a dialect does not specify a -`cppNamespace`, we then use the dialect's name as the namespace. +`cppNamespace` field. For example, if a dialect's `cppNamespace` is `A::B`, then +an op of that dialect will be placed in `namespace A { namespace B { ... } }`. +If a dialect does not specify a `cppNamespace`, we then use the dialect's name +as the namespace. This means the qualified name of the generated C++ class does not necessarily match exactly with the operation name as explained in @@ -976,10 +977,11 @@ An operation's constraint can cover different range; it may -* Only concern a single attribute (e.g. being a 32-bit integer greater than 5), -* Multiple operands and results (e.g., the 1st result's shape must be the same - as the 1st operand), or -* Intrinsic to the operation itself (e.g., having no side effect). +* Only concern a single attribute (e.g. being a 32-bit integer greater than + 5), +* Multiple operands and results (e.g., the 1st result's shape must be the same + as the 1st operand), or +* Intrinsic to the operation itself (e.g., having no side effect). We call them as single-entity constraint, multi-entity constraint, and traits, respectively. @@ -993,8 +995,8 @@ To help modelling constraints of common types, a set of `TypeConstraint`s are created; they are the `Type` subclass hierarchy. It includes `F32` for the -constraints of being a float, `TensorOf<[F32]>` for the constraints of being -a float tensor, and so on. +constraints of being a float, `TensorOf<[F32]>` for the constraints of being a +float tensor, and so on. Similarly, a set of `AttrConstraint`s are created for helping modelling constraints of common attribute kinds. They are the `Attr` subclass hierarchy. @@ -1003,8 +1005,8 @@ ### Multi-entity constraint -Constraints involving more than one operand/attribute/result are quite common -on operations, like the element type and shape relation between operands and +Constraints involving more than one operand/attribute/result are quite common on +operations, like the element type and shape relation between operands and results. These constraints should be specified as the `Op` class template parameter as described in [Operation traits and constraints](#operation-traits-and-constraints). @@ -1037,31 +1039,31 @@ substitution: `SubstLeaves`, concatenation: `Concat`). `CPred` is the basis for composing more complex predicates. It is the "atom" -predicate from the perspective of TableGen and the "interface" between -TableGen and C++. What is inside is already C++ code, which will be treated -as opaque strings with special placeholders to be substituted. +predicate from the perspective of TableGen and the "interface" between TableGen +and C++. What is inside is already C++ code, which will be treated as opaque +strings with special placeholders to be substituted. You can put any C++ code that returns a boolean value inside a `CPred`, -including evaluating expressions, calling functions, calling class methods, -and so on. +including evaluating expressions, calling functions, calling class methods, and +so on. To help interaction with the C++ environment, there are a few special placeholders provided to refer to entities in the context where this predicate -is used. They serve as "hooks" to the enclosing environment. This includes +is used. They serve as "hooks" to the enclosing environment. This includes `$_builder`, `$_op`, and `$_self`: -* `$_builder` will be replaced by a `mlir::Builder` instance so that you can - access common build methods. -* `$_op` will be replaced by the current operation so that you can access - information of the current operation. -* `$_self` will be replaced with the entity this predicate is attached to. - E.g., `BoolAttr` is an attribute constraint that wraps a - `CPred<"$_self.isa()">`. Then for `F32:$attr`,`$_self` will be - replaced by `$attr`. For type constraints, it's a little bit special since - we want the constraints on each type definition reads naturally and we want - to attach type constraints directly to an operand/result, `$_self` will be - replaced by the operand/result's type. E.g., for `F32` in `F32:$operand`, its - `$_self` will be expanded as `getOperand(...).getType()`. +* `$_builder` will be replaced by a `mlir::Builder` instance so that you can + access common build methods. +* `$_op` will be replaced by the current operation so that you can access + information of the current operation. +* `$_self` will be replaced with the entity this predicate is attached to. + E.g., `BoolAttr` is an attribute constraint that wraps a + `CPred<"$_self.isa()">`. Then for `F32:$attr`,`$_self` will be + replaced by `$attr`. For type constraints, it's a little bit special since + we want the constraints on each type definition reads naturally and we want + to attach type constraints directly to an operand/result, `$_self` will be + replaced by the operand/result's type. E.g., for `F32` in `F32:$operand`, + its `$_self` will be expanded as `getOperand(...).getType()`. TODO: Reconsider the leading symbol for special placeholders. Eventually we want to allow referencing operand/result $-names; such $-names can start with @@ -1072,10 +1074,9 @@ `$_self.isa()`, with `$_self` as the special placeholder to be replaced by the current attribute `attr` at expansion time. -For more complicated predicates, you can wrap it in a single `CPred`, or you -can use predicate combiners to combine them. For example, to write the -constraint that an attribute `attr` is a 32-bit or 64-bit integer, you can -write it as +For more complicated predicates, you can wrap it in a single `CPred`, or you can +use predicate combiners to combine them. For example, to write the constraint +that an attribute `attr` is a 32-bit or 64-bit integer, you can write it as ```tablegen And<[ @@ -1096,9 +1097,9 @@ TODO: Build up a library of reusable primitive constraints If the predicate is very complex to write with `CPred` together with predicate -combiners, you can also write it as a normal C++ function and use the `CPred` -as a way to "invoke" the function. For example, to verify an attribute `attr` -has some property, you can write a C++ function like +combiners, you can also write it as a normal C++ function and use the `CPred` as +a way to "invoke" the function. For example, to verify an attribute `attr` has +some property, you can write a C++ function like ```cpp bool HasSomeProperty(Attribute attr) { ... } @@ -1118,13 +1119,13 @@ } ``` -As to whether we should define the predicate using a single `CPred` wrapping -the whole expression, multiple `CPred`s with predicate combiners, or a single +As to whether we should define the predicate using a single `CPred` wrapping the +whole expression, multiple `CPred`s with predicate combiners, or a single `CPred` "invoking" a function, there are no clear-cut criteria. Defining using `CPred` and predicate combiners is preferable since it exposes more information (instead hiding all the logic behind a C++ function) into the op definition spec -so that it can potentially drive more auto-generation cases. But it will -require a nice library of common predicates as the building blocks to avoid the +so that it can potentially drive more auto-generation cases. But it will require +a nice library of common predicates as the building blocks to avoid the duplication, which is being worked on right now. ## Attribute Definition @@ -1133,11 +1134,11 @@ ODS provides attribute wrappers over C++ attribute classes. There are a few common C++ [attribute classes][AttrClasses] defined in MLIR's core IR library -and one is free to define dialect-specific attribute classes. ODS allows one -to use these attributes in TableGen to define operations, potentially with -more fine-grained constraints. For example, `StrAttr` directly maps to -`StringAttr`; `F32Attr`/`F64Attr` requires the `FloatAttr` to additionally -be of a certain bitwidth. +and one is free to define dialect-specific attribute classes. ODS allows one to +use these attributes in TableGen to define operations, potentially with more +fine-grained constraints. For example, `StrAttr` directly maps to `StringAttr`; +`F32Attr`/`F64Attr` requires the `FloatAttr` to additionally be of a certain +bitwidth. ODS attributes are defined as having a storage type (corresponding to a backing `mlir::Attribute` that _stores_ the attribute), a return type (corresponding to @@ -1440,8 +1441,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! @@ -1539,8 +1540,8 @@ ### Run `mlir-tblgen` to see the generated content -TableGen syntax sometimes can be obscure; reading the generated content can be -a very helpful way to understand and debug issues. To build `mlir-tblgen`, run +TableGen syntax sometimes can be obscure; reading the generated content can be a +very helpful way to understand and debug issues. To build `mlir-tblgen`, run `cmake --build . --target mlir-tblgen` in your build directory and find the `mlir-tblgen` binary in the `bin/` subdirectory. All the supported generators can be found via `mlir-tblgen --help`. For example, `--gen-op-decls` and @@ -1571,8 +1572,8 @@ The op description should as declarative as possible to allow a wide range of tools to work with them and query methods generated from them. In particular -this means specifying traits, constraints and shape inference information in -a way that is easily analyzable (e.g., avoid opaque calls to C++ functions where +this means specifying traits, constraints and shape inference information in a +way that is easily analyzable (e.g., avoid opaque calls to C++ functions where possible). We considered the approaches of several contemporary systems and focused on 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 @@ -290,7 +290,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"; @@ -576,7 +576,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"; @@ -1991,7 +1991,7 @@ body << tgfmt(" if (!($0))\n " "return emitOpError(\"failed to verify that $1\");\n", &verifyCtx, tgfmt(t->getPredTemplate(), &verifyCtx), - t->getDescription()); + t->getSummary()); } } @@ -2086,7 +2086,7 @@ "verify constraint: {2}\";\n }\n", constraint, region.name.empty() ? "" : "('" + region.name + "') ", - region.constraint.getDescription()) + region.constraint.getSummary()) << " ++index;\n" << " }\n"; } @@ -2125,7 +2125,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"; }