@@ -23,7 +23,7 @@ operations. This open and extensible ecosystem leads to the "stringly" type IR
2323problem, e.g., repetitive string comparisons during optimization and analysis
2424passes, unintuitive accessor methods (e.g., generic/error prone ` getOperand(3) `
2525vs self-documenting ` getStride() ` ) with more generic return types, verbose and
26- generic constructors without default arguments, verbose textual IR dump , and so
26+ generic constructors without default arguments, verbose textual IR dumps , and so
2727on. Furthermore, operation verification is:
2828
29291 . best case: a central string-to-verification-function map,
@@ -57,7 +57,7 @@ including but not limited to:
5757
5858We use TableGen as the language for specifying operation information. TableGen
5959itself just provides syntax for writing records; the syntax and constructs
60- allowed in a TableGen file (typically with filename suffix ` .td ` ) can be found
60+ allowed in a TableGen file (typically with the filename suffix ` .td ` ) can be found
6161[ here] [ TableGenProgRef ] .
6262
6363* TableGen ` class ` is similar to C++ class; it can be templated and
@@ -80,7 +80,7 @@ types and expressions supported by TableGen.
8080MLIR defines several common constructs to help operation definition and provide
8181their semantics via a special [ TableGen backend] [ TableGenBackend ] :
8282[ ` OpDefinitionsGen ` ] [ OpDefinitionsGen ] . These constructs are defined in
83- [ ` OpBase.td ` ] [ OpBase ] . The main ones are
83+ [ ` OpBase.td ` ] [ OpBase ] . The main ones are:
8484
8585* The ` Op ` class: It is the main construct for defining operations. All facts
8686 regarding the operation are specified when specializing this class, with the
@@ -91,7 +91,7 @@ their semantics via a special [TableGen backend][TableGenBackend]:
9191 and constraints of the operation, including whether the operation has side
9292 effect or whether its output has the same shape as the input.
9393* The ` ins ` /` outs ` marker: These are two special markers builtin to the
94- ` OpDefinitionsGen ` backend. They lead the definitions of operands/attributes
94+ ` OpDefinitionsGen ` backend. They lead to the definitions of operands/attributes
9595 and results respectively.
9696* The ` TypeConstraint ` class hierarchy: They are used to specify the
9797 constraints over operands or results. A notable subclass hierarchy is
@@ -134,7 +134,7 @@ the `Op` class for the complete list of fields supported.
134134
135135### Operation name
136136
137- The operation name is a unique identifier of the operation within MLIR, e.g.,
137+ The operation name is a unique identifier for the operation within MLIR, e.g.,
138138` tf.Add ` for addition operation in the TensorFlow dialect. This is the
139139equivalent of the mnemonic in assembly language. It is used for parsing and
140140printing in the textual format. It is also used for pattern matching in graph
@@ -207,12 +207,13 @@ named argument a named getter will be generated that returns the argument with
207207the return type (in the case of attributes the return type will be constructed
208208from the storage type, while for operands it will be ` Value ` ). Each attribute's
209209raw value (e.g., as stored) can also be accessed via generated ` <name>Attr `
210- getters for use in transformation passes where the more user friendly return
210+ getters for use in transformation passes where the more user- friendly return
211211type is less suitable.
212212
213- All the arguments should be named to 1) provide documentation, 2) drive
214- auto-generation of getter methods, 3) provide a handle to reference for other
215- places like constraints.
213+ All the arguments should be named to:
214+ - provide documentation,
215+ - drive auto-generation of getter methods, and
216+ - provide a handle to reference for other places like constraints.
216217
217218#### Variadic operands
218219
@@ -221,7 +222,7 @@ To declare a variadic operand, wrap the `TypeConstraint` for the operand with
221222
222223Normally operations have no variadic operands or just one variadic operand. For
223224the latter case, it is easy to deduce which dynamic operands are for the static
224- variadic operand definition. Though , if an operation has more than one variable
225+ variadic operand definition. However , if an operation has more than one variable
225226length operands (either optional or variadic), it would be impossible to
226227attribute dynamic operands to the corresponding static variadic operand
227228definitions without further information from the operation. Therefore, either
@@ -247,7 +248,7 @@ To declare an optional operand, wrap the `TypeConstraint` for the operand with
247248
248249Normally operations have no optional operands or just one optional operand. For
249250the latter case, it is easy to deduce which dynamic operands are for the static
250- operand definition. Though , if an operation has more than one variable length
251+ operand definition. However , if an operation has more than one variable length
251252operands (either optional or variadic), it would be impossible to attribute
252253dynamic operands to the corresponding static variadic operand definitions
253254without further information from the operation. Therefore, either the
@@ -425,7 +426,7 @@ The first form provides basic uniformity so that we can create ops using the
425426same form regardless of the exact op. This is particularly useful for
426427implementing declarative pattern rewrites.
427428
428- The second and third forms are good for use in manually written code given that
429+ The second and third forms are good for use in manually written code, given that
429430they provide better guarantee via signatures.
430431
431432The third form will be generated if any of the op's attribute has different
@@ -434,14 +435,14 @@ from an unwrapped value (i.e., `Attr.constBuilderCall` is defined.)
434435Additionally, for the third form, if an attribute appearing later in the
435436`arguments` list has a default value, the default value will be supplied in the
436437declaration. This works for `BoolAttr`, `StrAttr`, `EnumAttr` for now and the
437- list can grow in the future. So if possible, default valued attribute should be
438+ list can grow in the future. So if possible, the default- valued attribute should be
438439placed at the end of the `arguments` list to leverage this feature. (This
439440behavior is essentially due to C++ function parameter default value placement
440441restrictions.) Otherwise, the builder of the third form will still be generated
441442but default values for the attributes not at the end of the `arguments` list
442443will not be supplied in the builder's signature.
443444
444- ODS will generate a builder that doesn't require return type specified if
445+ ODS will generate a builder that doesn't require the return type specified if
445446
446447* Op implements InferTypeOpInterface interface;
447448* All return types are either buildable types or are the same as a given
@@ -581,18 +582,18 @@ of these verification methods.
581582The verification of an operation involves several steps,
582583
5835841 . StructuralOpTrait will be verified first, they can be run independently.
584- 1 . ` verifyInvariants ` which is constructed by ODS, it verifies the type,
585+ 2 . ` verifyInvariants ` which is constructed by ODS, it verifies the type,
585586 attributes, .etc.
586- 1 . Other Traits/Interfaces that have marked their verifier as ` verifyTrait ` or
587+ 3 . Other Traits/Interfaces that have marked their verifier as ` verifyTrait ` or
587588 ` verifyWithRegions=0 ` .
588- 1 . Custom verifier which is defined in the op and has marked ` hasVerifier=1 `
589+ 4 . Custom verifier which is defined in the op and has been marked ` hasVerifier=1 `
589590
590591If an operation has regions, then it may have the second phase,
591592
5925931 . Traits/Interfaces that have marked their verifier as ` verifyRegionTrait ` or
593594 ` verifyWithRegions=1 ` . This implies the verifier needs to access the
594595 operations in its regions.
595- 1 . Custom verifier which is defined in the op and has marked
596+ 2 . Custom verifier which is defined in the op and has been marked
596597 ` hasRegionVerifier=1 `
597598
598599Note that the second phase will be run after the operations in the region are
0 commit comments