[PATCH] D45818: Fix BNF nits in TableGen language reference.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 07:58:06 PDT 2018


simon_tatham created this revision.
Herald added a subscriber: llvm-commits.

In the course of writing an experimental ANTLR grammar based on this
document, I found three errors in the documented BNF:

SimpleValues of dag type are allowed to have no operands at all after
the initial DagArg specifying the operator. For example, the value
(outs) is extremely common in backends; an example in the test suite
is test/TableGen/AsmVariant.td line 30. But the BNF doesn't allow
DagArgList to expand to the empty string (it must contain at least one
DagArg), and therefore the DagArgList specifying the operands in the
dag-shaped production for SimpleValue should be optional.

In the production for BodyItem with a 'let' and an optional RangeList,
the RangeList should have braces around it if it's present, matching
code such as "let E{7-0} = ..." on test/TableGen/BitsInit.td line 42.
Those braces aren't included in the RangeList nonterminal itself, so
instead they need to be part of the optional segment of the BodyItem
production.

Finally, the identifier after 'defm' should be optional. Again, this
is very common in the real back end .td files; an example in the test
suite is in test/TableGen/defmclass.td line 49.


Repository:
  rL LLVM

https://reviews.llvm.org/D45818

Files:
  docs/TableGen/LangRef.rst


Index: docs/TableGen/LangRef.rst
===================================================================
--- docs/TableGen/LangRef.rst
+++ docs/TableGen/LangRef.rst
@@ -294,7 +294,7 @@
    leave it out.
 
 .. productionlist::
-   SimpleValue: "(" `DagArg` `DagArgList` ")"
+   SimpleValue: "(" `DagArg` [`DagArgList`] ")"
    DagArgList: `DagArg` ("," `DagArg`)*
    DagArg: `Value` [":" `TokVarName`] | `TokVarName`
 
@@ -325,7 +325,7 @@
    Body: ";" | "{" BodyList "}"
    BodyList: BodyItem*
    BodyItem: `Declaration` ";"
-           :| "let" `TokIdentifier` [`RangeList`] "=" `Value` ";"
+           :| "let" `TokIdentifier` [ "{" `RangeList` "}" ] "=" `Value` ";"
 
 The ``let`` form allows overriding the value of an inherited field.
 
@@ -353,7 +353,7 @@
 --------
 
 .. productionlist::
-   Defm: "defm" `TokIdentifier` ":" `BaseClassListNE` ";"
+   Defm: "defm" [`TokIdentifier`] ":" `BaseClassListNE` ";"
 
 Note that in the :token:`BaseClassList`, all of the ``multiclass``'s must
 precede any ``class``'s that appear.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45818.143095.patch
Type: text/x-patch
Size: 1029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180419/05fd0396/attachment.bin>


More information about the llvm-commits mailing list