Skip to content

Commit 104c2b8

Browse files
authored
[TableGen][Docs] Accept "code" as a Type (#124902)
Previously the Type production did not include "code", which was only accepted in one place in the grammar: BodyItem: (`Type` | "code") `TokIdentifier` ["=" `Value`] ";" However the parser implementation accepts "code" as a Type with only one place where it is *not* allowed, corresponding to this production: SimpleValue9: `BangOperator` ["<" `Type` ">"] "(" `ValueListNE` ")" This patch changes the production for Type to include "code", thereby fixing most occurrences of Type in the grammar, and documents the restriction for BangOperator Types in the text instead of codifying it in the grammar.
1 parent d553e5d commit 104c2b8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/docs/TableGen/ProgRef.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ high-level types (e.g., ``dag``). This flexibility allows you to describe a
268268
wide range of records conveniently and compactly.
269269

270270
.. productionlist::
271-
Type: "bit" | "int" | "string" | "dag"
271+
Type: "bit" | "int" | "string" | "dag" | "code"
272272
:| "bits" "<" `TokInteger` ">"
273273
:| "list" "<" `Type` ">"
274274
:| `ClassID`
@@ -285,6 +285,10 @@ wide range of records conveniently and compactly.
285285
The ``string`` type represents an ordered sequence of characters of arbitrary
286286
length.
287287

288+
``code``
289+
The keyword ``code`` is an alias for ``string`` which may be used to
290+
indicate string values that are code.
291+
288292
``bits<``\ *n*\ ``>``
289293
The ``bits`` type is a fixed-sized integer of arbitrary length *n* that
290294
is treated as separate bits. These bits can be accessed individually.
@@ -498,6 +502,8 @@ arguments, producing a value for that bang operator. The ``!cond`` operator
498502
takes a list of pairs of arguments separated by colons. See `Appendix A:
499503
Bang Operators`_ for a description of each bang operator.
500504

505+
The `Type` is only accepted for certain bang operators, and must not be
506+
``code``.
501507

502508
Suffixed values
503509
---------------
@@ -670,16 +676,15 @@ arguments.
670676

671677
.. productionlist::
672678
Body: ";" | "{" `BodyItem`* "}"
673-
BodyItem: (`Type` | "code") `TokIdentifier` ["=" `Value`] ";"
679+
BodyItem: `Type` `TokIdentifier` ["=" `Value`] ";"
674680
:| "let" `TokIdentifier` ["{" `RangeList` "}"] "=" `Value` ";"
675681
:| "defvar" `TokIdentifier` "=" `Value` ";"
676682
:| `Assert`
677683

678684
A field definition in the body specifies a field to be included in the class
679685
or record. If no initial value is specified, then the field's value is
680686
uninitialized. The type must be specified; TableGen will not infer it from
681-
the value. The keyword ``code`` may be used to emphasize that the field
682-
has a string value that is code.
687+
the value.
683688

684689
The ``let`` form is used to reset a field to a new value. This can be done
685690
for fields defined directly in the body or fields inherited from parent

0 commit comments

Comments
 (0)