aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen/TGLexer.cpp
AgeCommit message (Collapse)AuthorFilesLines
6 days[TableGen] Improve handling for dag op names (#149248)Nemanja Ivanovic1-0/+2
There are currently no ways to add names to dag operators other than when defining them. Furthermore a !con operation as well as some others, drops the operator names. This patch propagates the name from the LHS dag for !con and adds a way to get and set the operator name for a dag (!getdagopname, !setdagopname). --------- Co-authored-by: Nemanja Ivanovic <nemanja@synopsys.com>
2025-07-16[TableGen] Remove explicit recursion in LexToken (#143697)Jay Foad1-111/+156
When profiling a Release+Asserts build of llvm-tblgen I noticed that it was recursing hundreds of times to lex a sequence of hundreds of space characters.
2025-07-04[NFC][TableGen] Delete extra spaces in comments (#147004)Rahul Joshi1-19/+19
2025-06-04[llvm] Remove unused includes (NFC) (#142733)Kazu Hirata1-2/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-03-28[TableGen] Add `!instances` operator to get defined records (#129680)Pengcheng Wang1-0/+1
The format is: `!instances<T>([regex])`. This operator produces a list of records whose type is `T`. If `regex` is provided, only records whose name matches the regular expression `regex` will be included. The format of `regex` is ERE (Extended POSIX Regular Expressions).
2025-03-13[TableGen] Add `!match` operator to do regex matching (#130759)Pengcheng Wang1-0/+1
The grammar is `!match(str, regex)` and this operator produces 1 if the `str` matches the regular expression `regex`. The format of `regex` is ERE (Extended POSIX Regular Expressions).
2025-01-13Fix an unused-variable warning in release build.Haojian Wu1-1/+1
2025-01-13[TableGen] Use assert instead of PrintFatalError in TGLexer. NFC. (#122303)Jay Foad1-40/+23
Do not use the PrintFatalError diagnostic machinery for conditions that can never happen with any input.
2025-01-03[TableGen] Use SmallVectors for preprocessor include stack. NFC. (#121571)Jay Foad1-26/+15
This is just a minor cleanup and a small step in the direction of using LLVM containers in preference to STL containers in lib/TableGen.
2024-12-17[llvm][TableGen] Add a !initialized predicate to allow testing for ? (#117964)Krzysztof Drewniak1-0/+1
There are cases (like in an upcoming patch to MLIR's `Property` class) where the ? value is a useful null value. However, existing predicates make ti difficult to test if the value in a record one is operating is ? or not. This commit adds the !initialized predicate, which is 1 on concrete, non-? values and 0 on ?. --------- Co-authored-by: Akshat Oke <Akshat.Oke@amd.com>
2024-10-29[LLVM] Change error messages to start with lower case (#113748)Rahul Joshi1-36/+37
Change LLVM Asm and TableGen Lexer/Parser error messages to begin with lower case.
2024-09-24[TableGen] Add a !listflatten operator to TableGen (#109346)Rahul Joshi1-0/+1
Add a !listflatten operator that will transform an input list of type `list<list<X>>` to `list<X>` by concatenating elements of the constituent lists of the input argument.
2024-08-20[NFC][TableGen] Elminate use of isalpha/isdigit from TGLexer (#104837)Rahul Joshi1-15/+26
- Replace use of std::isalpha, std::isdigit, std:isxdigit with LLVM's StringExtras versions, to avoid possibly locale dependent behavior (e.g. glibc). - Create helper function for common checks for valid identifier characters.
2024-08-19[TableGen] Detect invalid -D arguments and fail (#102813)Rahul Joshi1-13/+31
- Detect invalid macro names specified on command line and fail if one found. - Specifically, -DXYZ=1 for example, will fail instead is being silently accepted.
2024-08-13[TableGen] Fix build failure by using int type for NextChar (#103000)Rahul Joshi1-1/+1
Fixes an issue in https://github.com/llvm/llvm-project/pull/102967, which inddvertently changed the type of `NextChar` from int to char, causing ppc64le build failures.
2024-08-13[NFC][TableGen] Refactor preprocessor directive handling (#102967)Rahul Joshi1-54/+43
- Make `PreprocessorDirs` array constexpr, move its definition outside the anonymous namespace, and make it static. - Change `Word` field to a StringRef. - Simplify `prepIsDirective` to use StringRef comparison and early `continue` per LLVM coding standards. - Use C++17 structured bindings to iterate over the array.
2024-02-08[TableGen] Simplify prepSkipToLineEnd for preprocessingFangrui Song1-6/+2
The MemoryBuffer is created using `RequiresNullTerminator`, so we can safely skip the `CurPtr != CurBuf.end()` check. The redundant check causes a cppcheck report. In addition, elsewhere, including `*CurPtr == '#'` below, makes the null terminator assumption as well. Close #81120
2024-02-02[TableGen] Support type aliases via new keyword deftypeWang Pengcheng1-0/+1
We can use `deftype` (not using `typedef` here to be consistent with `def`, `defm`, `defset`, `defvar`, etc) to define type aliases. Currently, only primitive types and type aliases are supported to be the source type and `deftype` statements can only appear at the top level. Reviewers: fpetrogalli, Artem-B, nhaehnle, jroelofs Reviewed By: jroelofs, nhaehnle, Artem-B Pull Request: https://github.com/llvm/llvm-project/pull/79570
2023-10-19[Tablegen] Add keyword `dump`. (#68793)Francesco Petrogalli1-25/+26
The keyword is intended for debugging purpose. It prints a message to stderr. This patch is based on code originally written by Adam Nemet, and on the feedback received by the reviewers in https://reviews.llvm.org/D157492.
2023-10-11[TableGen] New bang operator `!repr`. (#68716)Francesco Petrogalli1-0/+1
The !repr operator represents the content of a variable or of a record as a string. This patch is based on code originally written by Adam Nemet, and on the feedback received by the reviewers in https://reviews.llvm.org/D157492.
2023-09-07[TableGen] Fix incorrect handling of nested `#ifndef` directivesMin-Yih Hsu1-5/+4
TableGen's lexer was unable to handle nested #ifndef when the outer `#ifdef` / `#ifndef` scope is subject to skip. This was caused by returning the canonicalized token when it should have returned the original one. Fix #65100. Differential Revision: https://reviews.llvm.org/D159236
2023-08-20[TableGen] Fix wrong lex result on 64-bit integer boundariesSenran Zhang1-40/+46
Binary and decimal values were reconginzed by strtoll, which returns error when the msb is 1, and the error was ignored, resulting to wrong results. This patch fixes the issue. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157079
2023-06-07[TableGen] Add !setdagarg and !setdagnameMichael Liao1-0/+2
- This patch proposes to add `!setdagarg` and `!setdagname` bang operators to produce a new DAG node after replacing the specified argument value/name from the given input DAG node. E.g., `!setdagarg((foo 1, 2), 0, "x")` produces `(foo "x", 2)` and `!setdagname((foo 1:$a, 2:$b), 1, "c")` produces `(foo 1:$a, 2:$c)`. Reviewed By: simon_tatham Differential Revision: https://reviews.llvm.org/D151842
2023-05-31[TableGen] Add !getdagarg and !getdagnameMichael Liao1-0/+2
- This patch proposes to add `!getdagarg` and `!getdagname` bang operators as the inverse operation of `!dag`. They allow us to examine arguments of a given dag. Reviewed By: simon_tatham Differential Revision: https://reviews.llvm.org/D151602
2023-04-25TableGen: Introduce `!range` operator for half-opened intervalNAKAMURA Takumi1-0/+1
`!range(a, b)` generates a list `[a,b)`. `a` is optional and `0` by default. - `!range(-1, 4)` generates `[-1, 0, 1, 2, 3]` - `!range(4)` generates `[0, 1, 2, 3]` - `!range(2, 2)` generates `[]<list<int>>` `!range(list)` is equivalent to `!range(0, !size(list))`. Differential Revision: https://reviews.llvm.org/D145871
2023-03-07[TableGen] add !toupper and !tolower operators to change the casing of strings.Zain Jaffal1-44/+46
Reviewed By: fpetrogalli Differential Revision: https://reviews.llvm.org/D145300
2022-12-09[TableGen] Add a !listremove() bang operatorSimon Pilgrim1-0/+1
This patch proposes to add a !listremove() bang operator to allow us to prune list entries by removing any entries from the first list arg that are also contained in the second list arg. The particular use case I have in mind is for improved analysis of x86 scheduler models for which I'm hoping to start using the CodeGenProcModel 'Unsupported' features lists, which lists the ISA features a particular model DOESN'T support - with such a diverse and growing list of x86 ISAs, I don't want to have to update all these lists with every ISA change to every model - so I'm intending to keep a single central list of all x86 features, and then have the each model "remove" the features that it supports via a !listremove() - leaving just the unsupported ones. Differential Revision: https://reviews.llvm.org/D139642
2022-10-26[TableGen] Add log bang operatorMichael Maitland1-0/+1
This patch adds base 2 logarithm that returns integer result. I initially wanted to name it `!log2`, but numbers are not permitted in the name. The documentation makes sure to clarify that it is base 2 since it is not explicit in the operator name. Differential Revision: https://reviews.llvm.org/D134068
2022-09-30[TableGen] Add div bang operatorMichael Maitland1-0/+1
This patch adds the div bang operator which performs division. Differential Revision: https://reviews.llvm.org/D134001
2022-09-27[TableGen] Track reference locations of Records/RecordValsRiver Riddle1-0/+4
This is extremely useful for language tooling as it allows for providing go-to-def/find-references/etc. for many more situations than what is currently possible. Differential Revision: https://reviews.llvm.org/D134087
2022-08-08[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-2/+2
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-06-23[TableGen] Add new operator !existswangpc1-0/+1
We can cast a string to a record via !cast, but we have no mechanism to check if it is valid and TableGen will raise an error if failed to cast. Besides, we have no semantic null in TableGen (we have `?` but different backends handle uninitialized value differently), so operator like `dyn_cast<>` is hard to implement. In this patch, we add a new operator `!exists<T>(s)` to check whether a record with type `T` and name `s` exists. Self-references are allowed just like `!cast`. By doing these, we can write code like: ``` class dyn_cast_to_record<string name> { R value = !if(!exists<R>(name), !cast<R>(name), default_value); } defvar v = dyn_cast_to_record<"R0">.value; // R0 or default_value. ``` Reviewed By: tra, nhaehnle Differential Revision: https://reviews.llvm.org/D127948
2022-06-05[llvm] Convert for_each to range-based for loops (NFC)Kazu Hirata1-4/+2
2021-11-28[llvm] Use range-based for loops (NFC)Kazu Hirata1-5/+3
2021-05-13[TableGen] Make the NUL character invalid in .td filesPaul C. Anagnostopoulos1-23/+15
Now uses tr instead of sed. Differential Revision: https://reviews.llvm.org/D102254
2021-05-11Revert "[TableGen] Make the NUL character invalid in .td files"Paul C. Anagnostopoulos1-15/+23
At least one build uses a 'sed' that does not understand \x00. This reverts commit cf9647011c4f05e1eb4423c6637d84e2f26b2042.
2021-05-11[TableGen] Make the NUL character invalid in .td filesPaul C. Anagnostopoulos1-23/+15
Differential Revision: https://reviews.llvm.org/D101923
2021-04-28[TableGen] Add the !find bang operatorPaul C. Anagnostopoulos1-0/+1
!find searches a source string for a target string and returns the position. Differential Revision: https://reviews.llvm.org/D101318
2021-03-06[TableGen] Use range-based for loops (NFC)Kazu Hirata1-7/+7
2021-01-08[TableGen] Add the assert statement, step 1Paul C. Anagnostopoulos1-0/+1
Differential Revision: https://reviews.llvm.org/D93911 This first step adds the assert statement and supports it at top level and in record definitions. Later steps will support it in class definitions and multiclasses.
2020-12-23[TableGen] Add the !substr() bang operatorPaul C. Anagnostopoulos1-0/+1
Update the documentation and add a test. Build failed: Change SIZE_MAX to std::numeric_limits<int64_t>::max(). Differential Revision: https://reviews.llvm.org/D93419
2020-12-21Revert "[TableGen] Add the !substr() bang operator"Paul C. Anagnostopoulos1-1/+0
This reverts commit 3a675c777dd5788e2313cb06fb27b01f8a2e7573.
2020-12-21[TableGen] Add the !substr() bang operatorPaul C. Anagnostopoulos1-0/+1
Update the documentation and add a test. Differential Revision: https://reviews.llvm.org/D93419
2020-12-03[TableGen] Eliminate the 'code' typePaul C. Anagnostopoulos1-1/+1
Update the documentation. Rework various backends that relied on the code type. Differential Revision: https://reviews.llvm.org/D92269
2020-11-09[TableGen] Add the !filter bang operator.Paul C. Anagnostopoulos1-0/+1
Add a test. Update the Programmer's Reference. Use it in some TableGen files. Differential Revision: https://reviews.llvm.org/D91008
2020-11-05[TableGen] Add true and false literals to represent booleansPaul C. Anagnostopoulos1-9/+17
Update the Programmer's Reference document. Add a test. Update a couple of tests with an improved error message. Differential Revision: https://reviews.llvm.org/D90635
2020-11-04[TableGen] Add !interleave operator to concatenate a list of values with ↵Paul C. Anagnostopoulos1-0/+1
delimiters Add a test. Use it in some TableGen files. Differential Revision: https://reviews.llvm.org/D90469
2020-10-28[TableGen] [AMDGPU] Add !sub operator for subtractionPaul C. Anagnostopoulos1-0/+1
Use it in the AMDGPU target to eliminate !add(value1, !mul(value2, -1)) Differential Revision: https://reviews.llvm.org/D90107
2020-10-23[TableGen] Change !getop and !setop to !getdagop and !setdagop.Paul C. Anagnostopoulos1-2/+2
Differential Revision: https://reviews.llvm.org/D89814
2020-10-15[TableGen] Add the !not and !xor operators.Paul C. Anagnostopoulos1-0/+2
Update the TableGen Programmer's Reference.