summaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/SearchableTableEmitter.cpp
AgeCommit message (Collapse)Author
2025-05-24[TableGen] Remove unused includes (NFC) (#141356)Kazu Hirata
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-12[NFC][TableGen] Use StringRef::str() instead of casting (#139332)Rahul Joshi
- Also eliminate unneeded std::string() around some literal strings.
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-04-16[llvm] Use llvm::append_range (NFC) (#136066)Kazu Hirata
This patch replaces: llvm::copy(Src, std::back_inserter(Dst)); with: llvm::append_range(Dst, Src); for breavity. One side benefit is that llvm::append_range eventually calls llvm::SmallVector::reserve if Dst is of llvm::SmallVector.
2025-01-20[TableGen][NFC] Factor early-out range check. (#123645)Jason Eckhardt
Combine the EarlyOut and IsContiguous range check. Also avoid "comparison is always false" warnings in emitted code when the lower-bound check is against 0.
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-10-21[NFC][TableGen] Delete unused class member (#113165)Rahul Joshi
Delete unused class member in `SearchableTableEmitter` class.
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-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-20[TableGen] Eliminate use of `convertInitializerTo` in SearchableTable (#109206)Rahul Joshi
Eliminate use of `convertInitializerTo` as that needs a non-const RecordKeeper (which we want to make const).
2024-09-07[TableGen] Eliminate static CodeGenIntrinsicMap in PatternParser (#107339)Rahul Joshi
Instead, move it to CodeGenTarget class, and use it in both PatternParser and SearchableTableEmitter.
2024-09-04[TableGen] Add `CodeGenIntrinsicsMap` for on-demand intrinsic creation (#107100)Rahul Joshi
- Add class `CodeGenIntrinsicMap` for on-demand creation of `CodeGenIntrinsic`. - Add class `CodeGenIntrinsicContext` to capture global information required to build `CodeGenIntrinsic` objects. - Adopt GlobalISel PatternParser and SearchableTableEmitter to use it.
2024-08-16[TableGen] Refactor Intrinsic handling in TableGen (#103980)Rahul Joshi
CodeGenIntrinsic changes: - Use `const` Record pointers, and `StringRef` when possible. - Default initialize several fields with their definition instead of in the constructor. - Simplify various string checks in the constructor using StringRef starts_with()/ends_with() functions. - Eliminate first argument to `setDefaultProperties` and use `TheDef` class member instead. IntrinsicEmitter changes: - Emit `namespace llvm::Intrinsic` instead of nested namespaces. - End generated comments with a . - Use range based for loops, and early continue within loops. - Emit `static constexpr` instead of `static const` for arrays. - Change `compareFnAttributes` to use std::tie() to compare intrinsic attributes and return a default value when all attributes are equal. STLExtras: - Add std::replace wrapper which takes a range.
2024-07-11[TableGen] Add support for emitting new function definition to return a ↵Garvit Gupta
range of results for Primary Key (#96174) In the RISC-V architecture, multiple vendor-specific Control and Status Registers (CSRs) share the same encoding. However, the existing lookup function, which currently returns only a single result, falls short. During disassembly, it consistently returns the first CSR encountered, which may not be the correct CSR for the subtarget. To address this issue, we modify the function definition to return a range of results. These results can then be iterated upon to identify the CSR that best fits the subtarget’s feature requirements. The behavior of this new definition is controlled by a variable named `ReturnRange`, which defaults to `false`. Specifically, this patch introduces support for emitting a new lookup function for the primary key. This function returns a pair of iterators pointing to the first and last values, providing a comprehensive range of values that satisfy the query
2024-03-25[RFC][TableGen] Restructure TableGen Source (#80847)Pierre van Houtryve
Refactor of the llvm-tblgen source into: - a "Basic" library, which contains the bare minimum utilities to build `llvm-min-tablegen` - a "Common" library which contains all of the helpers for TableGen backends. Such helpers can be shared by more than one backend, and even unit tested (e.g. CodeExpander is, maybe we can add more over time) Fixes #80647
2024-03-01[TableGen] Use consistent field kind checking in getNumericKey. (#83284)Jason Eckhardt
Fields GenericField::IsInstruction and GenericField::Enum can be simultaneously active for a given field. Methods compareBy and primaryRepresentation both order the checking of IsInstruction before GenericField::Enum. Do the same in getNumericKey for consistency.
2024-02-14[TableGen] Stop using make_pair and make_tuple. NFC. (#81730)Jay Foad
These are unnecessary since C++17.
2024-02-09[NFC] clang-format utils/TableGen (#80973)Pierre van Houtryve
``` find llvm/utils/TableGen -iname "*.h" -o -iname "*.cpp" | xargs clang-format-16 -i ``` Split from #80847
2024-02-07[TableGen] Extend direct lookup to instruction values in generic tables. ↵Jason Eckhardt
(#80486) Currently, for some tables involving a single primary key field which is integral and densely numbered, a direct lookup is generated rather than a binary search. This patch extends the direct lookup function generation to instructions, where the integral value corresponds to the instruction's enum value. While this isn't as common as for other tables, it does occur in at least one downstream backend and one in-tree backend. Added a unit test and minimally updated the documentation.
2023-09-25[TableGen] Fix wrong bits output in GenericTable (#66867)Wang Pengcheng
We used to return `int` in `getAsInt`, while `IntInit::getValue` returns `int64_t` and `utohexstr` needs `uint64_t`. The casting causes the wrong hex value when printing bits value.
2023-09-08[TableGen] Add a field to filter out GenericTable entries (#65458)Wang Pengcheng
A field `FilterClassField` is added to `GenericTable` class, which is an optional bit field of `FilterClass`. If specified, only those records with this field being true will have corresponding entries in the table.
2023-06-06Fix unused variable warning. NFC.Simon Pilgrim
2023-06-02[TableGen] Allow bit fields in SearchableTables.Stanislav Mekhanoshin
Differential Revision: https://reviews.llvm.org/D151756
2023-03-21llvm-tblgen: Rewrite emitters to use `TableGen::Emitter`NAKAMURA Takumi
Each emitter became self-contained since it has the registration of option. Differential Revision: https://reviews.llvm.org/D144351
2023-02-19llvm-tblgen: Add "TableGenBackends.h" to each emitter.NAKAMURA Takumi
"TableGenBackends.h" has declarations of emitters.
2023-02-19llvm-tblgen: ReformatNAKAMURA Takumi
2023-01-05Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ partserge-sans-paille
Use deduction guides instead of helper functions. The only non-automatic changes have been: 1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*)) 2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase. 3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated. 4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that). Per reviewers' comment, some useless makeArrayRef have been removed in the process. This is a follow-up to https://reviews.llvm.org/D140896 that introduced the deduction guides. Differential Revision: https://reviews.llvm.org/D140955
2022-09-03[llvm] Qualify auto in range-based for loops (NFC)Kazu Hirata
Identified with readability-qualified-auto.
2022-07-23Use llvm::sort instead of std::sort where possibleDmitri Gribenko
llvm::sort is beneficial even when we use the iterator-based overload, since it can optionally shuffle the elements (to detect non-determinism). However llvm::sort is not usable everywhere, for example, in compiler-rt. Reviewed By: nhaehnle Differential Revision: https://reviews.llvm.org/D130406
2022-05-11[TableGen] Remove the use of global Record stateRiver Riddle
This commits removes TableGens reliance on managed static global record state by moving the RecordContext into the RecordKeeper. The RecordKeeper is now treated similarly to a (LLVM|MLIR|etc)Context object and is passed to static construction functions. This is an important step forward in removing TableGens reliance on global state, and in a followup will allow for users that parse tablegen to parse multiple tablegen files without worrying about Record lifetime. Differential Revision: https://reviews.llvm.org/D125276
2022-01-31Cleanup llvm/utils/TableGen headersserge-sans-paille
Based on the output of include-what-you-use. It's an utility directory, so no much impact on other code areas. clang++ -E -Iinclude -I../llvm/include ../llvm/utils/TableGen/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before: 4327274 after: 4316190 Related discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D118466
2022-01-18TableGen: sort SearchableTable emission order by fields, not top-level nameTim Northover
This is often used for anonymous definitions, so we were sorting by "anonymous_1234" record names, which while less bad than pointers can be easily perturbed by adding code even in completely unrelated systems. That causes test failures on AArch64 when sysregs with multiple valid names suddenly start printing a different one.
2021-02-08[TableGen] Use ListSeparator (NFC)Kazu Hirata
2021-01-31[TableGen] Use ListSeparator (NFC)Kazu Hirata
2021-01-13[llvm] Use llvm::stable_sort (NFC)Kazu Hirata
2020-12-03[TableGen] Eliminate the 'code' typePaul C. Anagnostopoulos
Update the documentation. Rework various backends that relied on the code type. Differential Revision: https://reviews.llvm.org/D92269
2020-11-06[TableGen] Indentation and whitespace fixes in generated code. NFC.Jay Foad
Some of these were found by running clang-format over the generated code, although that complains about far more issues than I have fixed here. Differential Revision: https://reviews.llvm.org/D90937
2020-09-23Enhance TableGen so that backends can produce better error messages.Paul C. Anagnostopoulos
Modify SearchableTableEmitter.cpp to take advantage. Clean up formatting and capitalization issues.
2020-08-26Reland [IR] Intrinsics default attributes and opt-out flagsstefan1
Intrinsic properties can now be set to default and applied to all intrinsics. If the attributes are not needed, the user can opt-out by setting the DisableDefaultAttributes flag to true. Differential Revision: https://reviews.llvm.org/D70365
2020-06-23[TableGen] Add error messagesSebastian Neubauer
Print an error instead of crashing in two places. Differential Revision: https://reviews.llvm.org/D81074
2020-02-19[TableGen] Diagnose undefined fields when generating searchable tablesJay Foad
Summary: Previously TableGen would crash trying to print the undefined value as an integer. Change-Id: I3900071ceaa07c26acafb33bc49966d7d7a02828 Reviewers: nhaehnle Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74210
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-09Fix uninitialized variable warnings. NFCI.Simon Pilgrim
2019-08-24Use a bit of relaxed constexpr to make FeatureBitset costant intializableBenjamin Kramer
This requires std::intializer_list to be a literal type, which it is starting with C++14. The downside is that std::bitset is still not constexpr-friendly so this change contains a re-implementation of most of it. Shrinks clang by ~60k. llvm-svn: 369847
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-05-13[AMDGPU] gfx1010 SearchableTableEmitter patch for NSAStanislav Mekhanoshin
This part was accidentally missing from NSA image support commit. Differential Revision: https://reviews.llvm.org/D61868 llvm-svn: 360623
2019-04-29[TableGen] Fix null pointer dereferencing.Simon Pilgrim
Reported in https://www.viva64.com/en/b/0629/ llvm-svn: 359474
2019-02-12[tablegen] Add locations to many PrintFatalError() callsDaniel Sanders
Summary: While working on the GISel Combiner, I noticed I was producing location-less error messages fairly often and set about fixing this. In the process, I noticed quite a few places elsewhere in TableGen that also neglected to include a relevant location. This patch adds locations to errors that relate to a specific record (or a field within it) and also have easy access to the relevant location. This is particularly useful when multiclasses are involved as many of these errors refer to the full name of a record and it's difficult to guess which substring is grep-able. Unfortunately, tablegen currently only supports Record granularity so it's not currently possible to point at a specific Init so these sometimes point at the record that caused the error rather than the precise origin of the error. Reviewers: bogner, aditya_nandakumar, volkan, aemerson, paquette, nhaehnle Reviewed By: nhaehnle Subscribers: jdoerfert, nhaehnle, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58077 llvm-svn: 353862
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636