12 Commits

Author SHA1 Message Date
Rahul Joshi
63aa8cf6be
[NFC][Clang][TableGen] Fix file header comments (#116491) 2024-11-17 07:54:10 -08:00
Rahul Joshi
46b275716a
[NFC][Clang] Use StringRef and range for loops in SA/Syntax Emitters (#115972)
Use StringRef and range for loops in Clang SACheckers and Syntax
emitters.
2024-11-13 07:07:58 -08:00
Rahul Joshi
adb7004514
[LLVM][CLange] Rename NodeType::Record to NodeType::Rec (#108826)
Fixes build failure by avoiding conflicting with `Record` class name.
2024-09-16 06:59:36 -07:00
Rahul Joshi
0e948bfd31
[NFC][clang][TableGen] Remove redundant llvm:: namespace qualifier (#108627)
Remove llvm:: from .cpp files, and add "using namespace llvm" if needed.
2024-09-16 06:35:34 -07:00
Rahul Joshi
d757bbf68f
[clang][TableGen] Change SyntaxEmitter to use const RecordKeeper (#108478)
Change SyntaxEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-09-13 07:51:42 -07:00
Rahul Joshi
16df489fda
[TableGen] Add const variants of accessors for backend (#106658)
Split RecordKeeper `getAllDerivedDefinitions` family of functions into
two variants:
  (a) non-const ones that return vectors of `Record *` and 
  (b) const ones, that return vector/ArrayRef of `const Record *`.

This will help gradual migration of TableGen backends to use 
`const RecordKeeper` and by implication change code to work 
with const pointers and better const correctness.

Existing backends are not yet compatible with the const family of
functions, so change them to use a non-constant `RecordKeeper` 
reference, till they are migrated.
2024-09-05 18:35:55 -07:00
Shao-Ce SUN
b0e28eb832
[llvm][tblgen] Add Source Filename for emitSourceFileHeader (#65744)
I think this is very helpful for reading generated `.inc` files.
2023-09-26 13:40:56 +08:00
Sam McCall
ea4d24c899 [Syntax] Tablegen Sequence classes. NFC
Similar to the previous patch, this doesn't convert *all* the classes that
could be converted. It also doesn't enforce any new invariants etc.

It *does* include some data we don't use yet: specific token types that are
allowed and optional/required status of sequence items. (Similar to Dmitri's
prototype). I think these are easier to add as we go than later, and serve
a useful documentation purpose.

Differential Revision: https://reviews.llvm.org/D90659
2020-11-11 16:29:19 +01:00
Sam McCall
98aa067109 [Syntax] Start to move trivial Node class definitions to TableGen. NFC
This defines two node archetypes with trivial class definitions:
 - Alternatives: the generated abstract classes are trivial as all
   functionality is via LLVM RTTI
 - Unconstrained: this is a placeholder, I think all of these are going to be
   Lists but today they have no special accessors etc, so we just say
   "could contain anything", and migrate them one-by-one to Sequence later.

Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy and
less like a grammar. (E.g. variants list the Alternatives parent rather than
vice versa).
The main reasons for this:
 - the hierarchy is an important part of the API we want direct control over.
   - e.g. we may introduce abstract bases like "loop" that the grammar doesn't
     care about in order to model is-a concepts that might make refactorings
     more expressive. This is less natural in a grammar-like idiom.
   - e.g. we're likely to have to model some alternatives as variants and others
     as class hierarchies, the choice will probably be based on natural is-a
     relationships.
 - it reduces the cognitive load of switching from editing *.td to working with
   code that uses the generated classes

Differential Revision: https://reviews.llvm.org/D90543
2020-11-11 12:39:43 +01:00
Sam McCall
454579e46a Reland [Syntax] Add minimal TableGen for syntax nodes. NFC
This reverts commit 09c6259d6d0eb51b282f6c3a28052a8146bc095b.
(Fixed side-effecting code being buried in an assert)
2020-11-11 11:24:47 +01:00
Sam McCall
09c6259d6d Revert "[Syntax] Add minimal TableGen for syntax nodes. NFC"
This reverts commit 55120f74ca12faea0e90fe552c85c14485f1fd91.

Segfaults during build:
http://lab.llvm.org:8011/#/builders/36/builds/1310
2020-11-09 23:59:11 +01:00
Sam McCall
55120f74ca [Syntax] Add minimal TableGen for syntax nodes. NFC
So far, only used to generate Kind and implement classof().

My plan is to have this general-purpose Nodes.inc in the style of AST
DeclNodes.inc etc, and additionally a special-purpose backend generating
the actual class definitions. But baby steps...

Differential Revision: https://reviews.llvm.org/D90540
2020-11-09 23:45:50 +01:00