summaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen/Record.cpp
AgeCommit message (Collapse)Author
2025-06-13[TableGen] Avoid evaluating RHS of a BinOp until short-circuit is complete ↵Min-Yih Hsu
(#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-05-23[TableGen] !subst on a dag should retain name of operator (#141195)Adam Nemet
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 Nemet
This way the dump output is roundtripable.
2025-05-19[LLVM][TableGen] Rename `ListInit::getValues()` to `getElements()` (#140289)Rahul Joshi
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 Joshi
Initialize vectors using constructor instead of llvm::append_range when possible.
2025-05-16[LLVM][TableGen] Simplify `DagInit::get` (#140056)Rahul Joshi
- 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 Joshi
- 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 Hirata
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 Hirata
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 Joshi
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 Joshi
- Also eliminate unneeded std::string() around some literal strings.
2025-05-12[NFC][TableGen] Add {} for `else` when `if` body has {} (#139420)Rahul Joshi
2025-05-07[NFC][Support] Add llvm::uninitialized_copy (#138174)Rahul Joshi
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 Joshi
- 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 Foad
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-03-30[llvm] Use llvm::append_range (NFC) (#133658)Kazu Hirata
2025-03-28[TableGen] Add `!instances` operator to get defined records (#129680)Pengcheng Wang
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-18[tblgen] Fix behavior of !isa to prevent premature folding (#130442)Krzysztof Drewniak
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 Wang
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-23[TableGen] Add StringInit pools to RecordKeeperImpl::dumpAllocationStats. ↵Craig Topper
(#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 Foad
Also use brace initialization and emplace to avoid explicitly constructing std::pair, and the same for std::tuple.
2024-12-17[llvm][TableGen] Add a !initialized predicate to allow testing for ? (#117964)Krzysztof Drewniak
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-11-07[TableGen] Make `!and` and `!or` short-circuit (#113963)Min-Yih Hsu
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-23[NFC][LLVM][TableGen] Change `RecordKeeper::getClass` to return const ↵Rahul Joshi
pointer (#112261) Change `RecordKeeper::getClass` to return const record pointer. 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-10-21[NFC][TableGen] Use auto when initializing variables with cast<> (#113171)Rahul Joshi
Use `auto` when initializing a variable with `cast<>`. Remove some unneeded `const_cast` (since all Init pointers are now const).
2024-10-18[LLVM][TableGen] Change all `Init` pointers to const (#112705)Rahul Joshi
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-10-04[TableGen] Factor out timer code into a new `TGTimer` class (#111054)Rahul Joshi
Factor out the timer related functionality from `RecordKeeper` to a new `TGTimer` class in a new file.
2024-10-04[TableGen] Print record location when record asserts fail (#111029)Rahul Joshi
When record assertions fail, print an error message with the record's location, so it's easier to see where the record that caused the assert to fail was instantiated. This is useful when the assert condition in a class depends on a template parameter, so we need to know the context of the definition to determine why the assert failed. Also enhanced the assert.td test to check for these context messages, and also add checks for some assert failures that were missing in the test.
2024-10-03[NFC][TableGen] Change `RecordKeeper::getDef()` to return const pointer ↵Rahul Joshi
(#110992) 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-10-03[TableGen] Delete non-const overloads of `getAllDerivedDefinitions` (#110990)Rahul Joshi
Now that all TableGen backends have transitioned to const versions of these functions, we do not need the non-const versions anymore. 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-10-03[TableGen] Fix source location for anonymous records (#110935)Rahul Joshi
Fix source location for anonymous records to be the one of the locations where that record is instantiated as opposed to the location of the class that was anonymously instantiated. Currently, when a record is anonymously instantiated (via `VarDefInit::instantiate`), we use the location of the class for the record, which is not correct. Instead, pass in the `SMLoc` for the location where the anonymous instantiation happens and use that location when the record is instantiated. If there are multiple anonymous instantiations with the same parameters, the location for the (single) record created will be one of these instantiation locations as opposed to the class location.
2024-10-02[NFC][TableGen] Change `Record::getSuperClasses` to use const Record* (#110845)Rahul Joshi
Change `Record::getSuperClasses` to return a const pointer to the superclass records. 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-10-02[TableGen] Change `DefInit::Def` to a const Record pointer (#110747)Rahul Joshi
This change undoes a const_cast<> introduced in an earlier change to help transition to const pointers. It 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-10-01[TableGen] Change `getValueAsListOfDefs` to return const pointer vector ↵Rahul Joshi
(#110713) Change `getValueAsListOfDefs` to return a vector of const Record pointer, and remove `getValueAsListOfConstDefs` that was added as a transition aid. 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-10-01[TableGen] Change all type pointers to const (#110602)Rahul Joshi
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-30[LLVM][TableGen] Change SeachableTableEmitter to use const RecordKeeper ↵Rahul Joshi
(#110032) Change SeachableTableEmitter to use const RecordKeeper. Also change RecordRecTy to use const Record pointers for its classes. 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-24[TableGen] Add a !listflatten operator to TableGen (#109346)Rahul Joshi
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-09-20[llvm] Don't call raw_string_ostream::flush() (NFC)Youngsuk Kim
Don't call raw_string_ostream::flush(), which is essentially a no-op. As specified in the docs, raw_string_ostream is always unbuffered. ( 65b13610a5226b84889b923bae884ba395ad084d for further reference )
2024-09-18[LLVM][TableGen] Change CallingConvEmitter to use const RecordKeeper (#108955)Rahul Joshi
Change CallingConvEmitter 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-18[LLVM][TableGen] Change WebAsm Emitter to use const RecordKeeper (#109051)Rahul Joshi
Change WebAssemblyDisassemblerEmitter 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-15[LLVM][TableGen] Change CodeGenSchedule to use const RecordKeeper (#108617)Rahul Joshi
Change CodeGenSchedule 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-09[TableGen] Change SetTheory set/vec to use const Record * (#107692)Rahul Joshi
Change SetTheory::RecSet/RecVec to use const Record pointers.
2024-09-08[NFC][TableGen] Replace DefInit::get() with Record::getDefInit() (#107762)Rahul Joshi
Eliminate DefInit::get() as its a duplicate of Record::getDefInit(). Use early return in `VarDefInit::instantiate`.
2024-09-07[libc][TableGen] Migrate libc-hdrgen backend to use const RecordKeeper (#107542)Rahul Joshi
Migrate libc-hdrgen backend to use const RecordKeeper
2024-09-05[TableGen] Add const variants of accessors for backend (#106658)Rahul Joshi
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-04[TableGen] Print memory stats in detailed record emitter (#106990)Rahul Joshi
Print memory allocation and related statistics when dumping detailed record information.
2024-08-11[llvm] Construct SmallVector with ArrayRef (NFC) (#102799)Kazu Hirata
2024-08-04[TableGen] Construct SmallVector with ArrayRef (NFC) (#101870)Kazu Hirata
2024-07-09[TableGen] Use range-based for loops (NFC) (#97678)Kazu Hirata
2024-05-16[TableGen] Use LessRecord() for the sort in getAllDerivedDefinitions instead ↵Craig Topper
of re-implementing it. NFC