Mercurial > hg > CbC > CbC_llvm
diff llvm/docs/TableGen/ProgRef.rst @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 79ff65ed7e25 |
children | 1f2b6ac9f198 |
line wrap: on
line diff
--- a/llvm/docs/TableGen/ProgRef.rst Wed Jul 21 10:27:27 2021 +0900 +++ b/llvm/docs/TableGen/ProgRef.rst Wed Nov 09 17:45:10 2022 +0900 @@ -208,7 +208,9 @@ multiclass string then true .. warning:: - The ``field`` reserved word is deprecated. + The ``field`` reserved word is deprecated, except when used with the + CodeEmitterGen backend where it's used to distinguish normal record + fields from encoding fields. Bang operators -------------- @@ -217,14 +219,14 @@ .. productionlist:: BangOperator: one of - : !add !and !cast !con !dag - : !empty !eq !filter !find !foldl - : !foreach !ge !getdagop !gt !head - : !if !interleave !isa !le !listconcat - : !listsplat !lt !mul !ne !not - : !or !setdagop !shl !size !sra - : !srl !strconcat !sub !subst !substr - : !tail !xor + : !add !and !cast !con !dag + : !div !empty !eq !filter !find + : !foldl !foreach !ge !getdagop !gt + : !head !if !interleave !isa !le + : !listconcat !listsplat !logtwo !lt !mul + : !ne !not !or !setdagop !shl + : !size !sra !srl !strconcat !sub + : !subst !substr !tail !xor The ``!cond`` operator has a slightly different syntax compared to other bang operators, so it is defined separately: @@ -330,7 +332,7 @@ .. productionlist:: Value: `SimpleValue` `ValueSuffix`* - :| `Value` "#" `Value` + :| `Value` "#" [`Value`] ValueSuffix: "{" `RangeList` "}" :| "[" `RangeList` "]" :| "." `TokIdentifier` @@ -536,6 +538,9 @@ global name, it is treated as a verbatim string of characters. The left-hand-side operand is treated normally. +Values can have a trailing paste operator, in which case the left-hand-side +operand is concatenated to an empty string. + `Appendix B: Paste Operator Examples`_ presents examples of the behavior of the paste operator. @@ -546,18 +551,19 @@ files. .. productionlist:: - TableGenFile: `Statement`* + TableGenFile: (`Statement` | `IncludeDirective` + :| `PreprocessorDirective`)* Statement: `Assert` | `Class` | `Def` | `Defm` | `Defset` | `Defvar` :| `Foreach` | `If` | `Let` | `MultiClass` -The following sections describe each of these top-level statements. +The following sections describe each of these top-level statements. ``class`` --- define an abstract record class --------------------------------------------- A ``class`` statement defines an abstract record class from which other -classes and records can inherit. +classes and records can inherit. .. productionlist:: Class: "class" `ClassID` [`TemplateArgList`] `RecordBody` @@ -694,7 +700,7 @@ dag the_dag = d; } - def rec1 : A<(ops rec1)> + def rec1 : A<(ops rec1)>; The DAG ``(ops rec1)`` is passed as a template argument to class ``A``. Notice that the DAG includes ``rec1``, the record being defined. @@ -846,7 +852,7 @@ values. A ``let`` cannot override the value of a template argument. Top-level ``let`` statements are often useful when a few fields need to be -overriden in several records. Here are two examples. Note that ``let`` +overridden in several records. Here are two examples. Note that ``let`` statements can be nested. .. code-block:: text @@ -886,9 +892,8 @@ .. productionlist:: MultiClass: "multiclass" `TokIdentifier` [`TemplateArgList`] - : [":" `ParentMultiClassList`] + : `ParentClassList` : "{" `MultiClassStatement`+ "}" - ParentMultiClassList: `MultiClassID` ("," `MultiClassID`)* MultiClassID: `TokIdentifier` MultiClassStatement: `Assert` | `Def` | `Defm` | `Defvar` | `Foreach` | `If` | `Let` @@ -924,7 +929,7 @@ Once multiclasses have been defined, you use the ``defm`` statement to "invoke" them and process the multiple record definitions in those -multiclasses. Those record definitions are specified by ``def`` +multiclasses. Those record definitions are specified by ``def`` statements in the multiclasses, and indirectly by ``defm`` statements. .. productionlist:: @@ -1194,7 +1199,7 @@ each loop iteration, so their value in one iteration is not available in the next iteration. The following ``defvar`` will not work:: - defvar i = !add(i, 1) + defvar i = !add(i, 1); Variables can also be defined with ``defvar`` in a record body. See `Defvar in a Record Body`_ for more details. @@ -1221,8 +1226,6 @@ values do not carry over from one iteration to the next. Foreach loops may be nested. -The ``foreach`` statement can also be used in a record :token:`Body`. - .. Note that the productions involving RangeList and RangePiece have precedence over the more generic value parsing based on the first token. @@ -1324,7 +1327,7 @@ ``dag`` datatype. A DAG node consists of an operator and zero or more arguments (or operands). Each argument can be of any desired type. By using another DAG node as an argument, an arbitrary graph of DAG nodes can be -built. +built. The syntax of a ``dag`` instance is: @@ -1332,7 +1335,7 @@ The operator must be present and must be a record. There can be zero or more arguments, separated by commas. The operator and arguments can have three -formats. +formats. ====================== ============================================= Format Meaning @@ -1398,7 +1401,7 @@ 5. Make a pass over all the fields to resolve any inter-field references. -6. Add the record to the master record list. +6. Add the record to the final record list. Because references between fields are resolved (step 5) after ``let`` bindings are applied (step 3), the ``let`` statement has unusual power. For example: @@ -1619,13 +1622,17 @@ Example: ``!dag(op, [a1, a2, ?], ["name1", "name2", "name3"])`` results in ``(op a1-value:$name1, a2-value:$name2, ?:$name3)``. +``!div(``\ *a*\ ``,`` *b*\ ``)`` + This operator preforms signed division of *a* by *b*, and produces the quotient. + Division by 0 produces an error. Division of INT64_MIN by -1 produces an error. + ``!empty(``\ *a*\ ``)`` This operator produces 1 if the string, list, or DAG *a* is empty; 0 otherwise. A dag is empty if it has no arguments; the operator does not count. ``!eq(`` *a*\ `,` *b*\ ``)`` This operator produces 1 if *a* is equal to *b*; 0 otherwise. - The arguments must be ``bit``, ``bits``, ``int``, ``string``, or + The arguments must be ``bit``, ``bits``, ``int``, ``string``, or record values. Use ``!cast<string>`` to compare other types of objects. ``!filter(``\ *var*\ ``,`` *list*\ ``,`` *predicate*\ ``)`` @@ -1721,6 +1728,10 @@ This operator produces 1 if the type of *a* is a subtype of the given *type*; 0 otherwise. +``!exists<``\ *type*\ ``>(``\ *name*\ ``)`` + This operator produces 1 if a record of the given *type* whose name is *name* + exists; 0 otherwise. *name* should be of type *string*. + ``!le(``\ *a*\ ``,`` *b*\ ``)`` This operator produces 1 if *a* is less than or equal to *b*; 0 otherwise. The arguments must be ``bit``, ``bits``, ``int``, or ``string`` values. @@ -1734,6 +1745,11 @@ equal to the *value*. For example, ``!listsplat(42, 3)`` results in ``[42, 42, 42]``. +``!logtwo(``\ *a*\ ``)`` + This operator produces the base 2 log of *a* and produces the integer + result. The log of 0 or a negative number produces an error. This + is a flooring operation. + ``!lt(``\ *a*\ `,` *b*\ ``)`` This operator produces 1 if *a* is less than *b*; 0 otherwise. The arguments must be ``bit``, ``bits``, ``int``, or ``string`` values.