aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen
AgeCommit message (Collapse)AuthorFilesLines
7 days[NFC][TableGen] Fix namespace usage in various files (#161839)Rahul Joshi4-41/+33
- Move standalone functions and variables out of anonymous namespace and make them static. - Eliminate `namespace llvm {}` wrapping all code in .cpp files, and instead use namespace qualifier to define such functions (https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions) - Add namespace for X86DisassemblerShared.h.
2025-09-04[NFC][TableGen] Use `BitsInit::convertInitializerToInt` in a few places ↵Rahul Joshi1-0/+8
(#156973) - Replace manual code to convert a `BitsInit` to a uint64_t by using `convertInitializerToInt` where applicable. - Add `BitsInit::convertKnownBitsToInt` to handle existing patterns in DFAEmitter.cpp and RegisterInfoEmitter.cpp. - Consolidate 3 copies of the same function in X86 emitters into a single function.
2025-08-29[llvm] Support building with c++23 (#154372)Kyle Krüger2-6/+12
closes #154331 This PR addresses all minimum changes needed to compile LLVM and MLIR with the c++23 standard. It is a work in progress and to be reviewed for better methods of handling the parts of the build broken by c++23.
2025-08-21[TableGen] Validate the shift amount for !srl, !shl, and !sra operators. ↵Craig Topper1-3/+18
(#132492) The C operator has undefined behavior for out of bounds shifts so we should check this.
2025-08-12[TableGen] Use `getValueInit` to reduce code duplication (NFC) (#153167)Sergei Barannikov1-59/+27
2025-08-05[NFC][TableGen] Capitalize comments in TGLexer.cpp (#152224)Rahul Joshi1-2/+2
2025-08-05[NFC] Run clang-format on TGLexer and TGParser (#151509)Rahul Joshi4-194/+277
In https://github.com/llvm/llvm-project/pull/149248, clang-format applied some formatting to lines untouched by that PR, because the existing code is not clang-format compliant. Hence applying clang-format on the entire files here.
2025-07-29[TableGen] Improve handling for dag op names (#149248)Nemanja Ivanovic4-18/+65
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-15TableGen: Fixed the string table definitions visibility. (#148946)Slava Zakharin1-2/+3
This fixes the buildbots issues reported in #148839.
2025-07-15TableGen: Avoid emitting trailing whitespace in StringToOffsetTable (#148840)Matt Arsenault1-1/+1
2025-07-15TableGen: Use StringOffsetTable for RuntimeLibcall names (#148839)Matt Arsenault1-5/+5
2025-07-09[TableGen] Minor cleanup in `StringToOffsetTable` (#147712)Rahul Joshi1-12/+17
Make `AppendZero` a class member instead of an argument to `GetOrAddStringOffset` to reflect the intended usage that for a given `StringToOffsetTable`, all strings must use the same value of `AppendZero`. Modify `EmitStringTableDef` to drop the `Indent` argument as its always set to `""`, and to fail if it's called for a table with non-null-terminated strings.
2025-07-04[NFC][TableGen] Delete extra spaces in comments (#147004)Rahul Joshi7-86/+84
2025-07-02[NFC][TableGen] Adopt `ArrayRef::consume_front()` in `PrintMessage` (#146775)Rahul Joshi1-6/+6
Adopt `ArrayRef::consume_front()` in `PrintMessage`, and convert the loop in that function to a range for loop.
2025-06-24[NFC][TableGen] Use ArrayRef instead of const vector reference (#145323)Rahul Joshi2-7/+8
- Use `ArrayRef` instead of `SmallVector` reference in a few places. - Drop redundant `llvm::` in a few places.
2025-06-13[TableGen] Avoid evaluating RHS of a BinOp until short-circuit is complete ↵Min-Yih Hsu1-5/+6
(#144021) This patch adds an even more aggressive short-circuit on `!and` and `!or` that completely avoids the evaluation of RHS operand until short circuiting decisions are made.
2025-06-04[llvm] Remove unused includes (NFC) (#142733)Kazu Hirata2-3/+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-05-23[TableGen] !subst on a dag should retain name of operator (#141195)Adam Nemet1-1/+1
Without this patch the !subst in the test drops the name "$frag" from (one_frag:$frag ...) and returns: ``` (set FPR32_NEW:$dst, (one_frag FPR32_NEW:$a, FPR32_NEW:$b)) ```
2025-05-22[TableGen] Add missing $ before the dag operator name (#140969)Adam Nemet1-1/+1
This way the dump output is roundtripable.
2025-05-22[NFC][TableGen] Code cleanup in StringMatcher (#141118)Rahul Joshi1-18/+15
- Use ArrayRef instead of const vector reference. - Use range for loops with enumerate and structured bindings.
2025-05-19[LLVM][TableGen] Rename `ListInit::getValues()` to `getElements()` (#140289)Rahul Joshi1-19/+21
Rename `ListInit::getValues()` to `getElements()` to better match with other `ListInit` members like `getElement`. Keep `getValues()` for existing downstream code but mark it deprecated.
2025-05-19[NFC][TableGen] Use SmallVector range constructor when possible (#140284)Rahul Joshi1-11/+7
Initialize vectors using constructor instead of llvm::append_range when possible.
2025-05-16[LLVM][TableGen] Simplify `DagInit::get` (#140056)Rahul Joshi1-4/+4
- Add `DagInit::get` overloads that do not need ValName to be specified. - Fix some calls to either not create temporary arrays for DAG args or use the std::pair<> overload.
2025-05-14[NFC][TableGen] Code cleanup in Record.h/cpp (#138876)Rahul Joshi1-194/+124
- Use range for loops in several places. - Change some variable names to conform to LLVM coding standard. - Use ListSeparator instead of manual code to generate comma interleaved strings. - Remove unnecessary copies in SETDAGOP evaluation in BinOpInit::Fold. - Eliminate duplicated code in the 2 overloads of RecordVal::setValue. - Use explicit type in some range for loops. - Tested by verifying that all the .inc files generated by building all the *CommonTableGen targets stay unchanged.
2025-05-13[TableGen] Use std::string::find (NFC) (#139681)Kazu Hirata1-6/+5
This patch partially reverts #139661 for a better solution. Specifically, we can take advantage of the fact that std::string::find accepts anything that can be converted to std::string_view, including StringRef, starting with C++17. This way, we do not need to cast Val to StringRef or LHSs->getValue() to std::string.
2025-05-12[llvm] Use StringRef::{starts_with,find} (NFC) (#139661)Kazu Hirata1-4/+4
Calling find/contains in the StringRef domain allows us to avoid creating temporary instances of std::string.
2025-05-12[NFCI][LLVM/MLIR] Adopt `TrailingObjects` convenience API (#138554)Rahul Joshi1-6/+6
Adopt `TrailingObjects` convenience API that was added in https://github.com/llvm/llvm-project/pull/138970 in LLVM and MLIR code.
2025-05-12[NFC][TableGen] Use StringRef::str() instead of casting (#139332)Rahul Joshi4-10/+9
- Also eliminate unneeded std::string() around some literal strings.
2025-05-12[NFC][TableGen] Add {} for `else` when `if` body has {} (#139420)Rahul Joshi2-3/+5
2025-05-07[NFC][Support] Add llvm::uninitialized_copy (#138174)Rahul Joshi1-15/+8
Add `llvm::uninitialized_copy` that accepts a range instead of start/end iterator for the source of the copy.
2025-05-02[NFC][TableGen] Use private inheritance for TrailingObjects (#138027)Rahul Joshi1-65/+85
- Use private inheritance for `TrailingObjects` as suggested in the documentation for `TrailingObjects` class. - Move std::uninitialized_copy calls from various `get` functions to the constructors of respective classes. - Eliminate `NumArgNames` from `DagInit`. Its always equal to `NumArgs`. - Eliminate unused `name_size/name_empty` from `DagInit`.
2025-04-24[TableGen] Only store direct superclasses in Record (#123072)Jay Foad5-53/+13
In Record only store the direct superclasses instead of all superclasses. getSuperClasses recurses to find all superclasses when necessary. This gives a small reduction in memory usage. On lib/Target/X86/X86.td I measured about 2.0% reduction in total bytes allocated (measured by valgrind) and 1.3% reduction in peak memory usage (measured by /usr/bin/time -v). --------- Co-authored-by: Min-Yih Hsu <min@myhsu.dev>
2025-04-13[StrTable] Use string literal emission for intrinsics on non-MSVC platforms ↵Reid Kleckner3-0/+130
(#124856) This mainly transitions the LLVM intrinsic string table from character emission to string literal emission, which I confirmed happens for me locally. I moved the guts of StringToOffsetTable to a cpp file so I could move the `EmitLongStrLiterals` cl::opt global to a non-vague linkage home in the `TableGen` library. I had to add missing FormatVariadic.h includes to account for moving other includes to a cpp file.
2025-03-30[llvm] Use llvm::append_range (NFC) (#133658)Kazu Hirata1-2/+1
2025-03-28[TableGen] Add `!instances` operator to get defined records (#129680)Pengcheng Wang4-0/+110
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-20[llvm] Use *Set::insert_range (NFC) (#132325)Kazu Hirata1-2/+2
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src); This patch does not touch custom begin like succ_begin for now.
2025-03-18[tblgen] Fix behavior of !isa to prevent premature folding (#130442)Krzysztof Drewniak1-4/+6
The test included with this commit shows a case where, even though a record's true type was !isa<> some unrelated class, the isa<> operator wolud use the declared type of the argument it was examining in order to conclude that the !isa<> expression had to be be false. The issues is fixed by checking to make sure that the argument to the !isa operator is fully concrete before declaring its result to be false.
2025-03-13[TableGen] Add `!match` operator to do regex matching (#130759)Pengcheng Wang4-0/+31
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-27[TableGen] Add assert to validate `Objects` list for `HwModeSelect` (#123794)Rahul Joshi2-3/+10
- Bail out of TableGen if any asserts fail before running the backend. - Add asserts to validate that the `Objects` and `Modes` lists for various `HwModeSelect` subclasses are of same length. - Eliminate equivalent check in CodeGenHWModes.cpp
2025-01-23[TableGen] Add StringInit pools to RecordKeeperImpl::dumpAllocationStats. ↵Craig Topper1-1/+2
(#124164) Remove duplicate print of TheBitsInitPool. I don't know who or what uses this information. I happened to notice TheBitsInitPool was printed twice which lead to auditing the whole list.
2025-01-16[TableGen] Use std::pair instead of std::make_pair. NFC. (#123174)Jay Foad4-11/+10
Also use brace initialization and emplace to avoid explicitly constructing std::pair, and the same for std::tuple.
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 Foad2-43/+25
Do not use the PrintFatalError diagnostic machinery for conditions that can never happen with any input.
2025-01-06[TableGen] Do not exit in template argument check (#121636)Markus Böck2-18/+27
The signature of `CheckTemplateArgValues` implements error handling via the `bool` return type, yet always returned false. The single possible error case instead used `PrintFatalError,` which exits the program afterward. This behavior is undesirable: It prevents any further errors from being printed and makes TableGen less usable as a library as it crashes the entire process (e.g. `tblgen-lsp-server`). This PR therefore fixes the issue by using `Error` instead and returning true if an error occurred. All callers already perform proper error handling. As `llvm-tblgen` exits on error, a test was also added to the LSP to ensure it exits normally despite the error.
2025-01-03[TableGen] Use SmallVectors for preprocessor include stack. NFC. (#121571)Jay Foad2-29/+17
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 Drewniak4-9/+27
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-12-09[llvm][TableGen] Fix misleading error for invalid use of let (#118616)David Spickett1-1/+1
Fixes #118490 Point to the value name, otherwise it implies that the part after the '=' is the problem. Before: ``` /tmp/test.td:2:27: error: Value 'FlattenedFeatures' unknown! let FlattenedFeatures = []; ^ ``` After: ``` /tmp/test.td:2:7: error: Value 'FlattenedFeatures' unknown! let FlattenedFeatures = []; ^ ```
2024-11-07[TableGen] Make `!and` and `!or` short-circuit (#113963)Min-Yih Hsu1-0/+17
The idea is that by preemptively simplifying the result of `!and` and `!or`, we can fold some of the conditional operators, like `!if` or `!cond`, as early as possible.
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.