summaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
AgeCommit message (Collapse)Author
2025-06-26[llvm] Use llvm::is_contained (NFC) (#145844)Kazu Hirata
llvm::is_contained is shorter than llvm::all_of plus a lambda.
2025-06-16[TableGen] Use default member initializers. NFC. (#144349)Jay Foad
Automated with clang-tidy -fix -checks=-*,modernize-use-default-member-init
2025-06-12[NFC] Use `llvm::includes` instead of `std::includes` (#143542)Longsheng Mou
This PR follows up #143297.
2025-06-11[TableGen] Simplify computeUberWeights. NFC. (#143716)Jay Foad
Using RegUnitIterator made the code more complicated than having two nested loops over each register and each register's regunits.
2025-06-09[TableGen] Move getSuperRegForSubReg into CodeGenRegBank. NFC. (#142979)Jay Foad
This method doesn't use anything from CodeGenTarget, so it seems to belong in CodeGenRegBank.
2025-06-07[TableGen] Use `emplace` instead of `insert` and similar. NFC. (#143164)Jay Foad
2025-06-07[TableGen] Use `contains` instead of `count`. NFC. (#143156)Jay Foad
2025-06-06[TableGen] Fix variable name in CodeGenRegBank::computeCompositesJay Foad
2025-06-05[TableGen] Make more use of findSubRegIdx. NFCI. (#142996)Jay Foad
Outside of CodeGenRegisters itself, we only want to find existing SubRegIdxs, not create new ones. Change findSubRegIdx to assert and use it consistently for this purpose.
2025-06-05[TableGen] Remove last remnant of CompositeIndices (#142960)Jay Foad
The rest of the support was removed in 2012 by: 599593630999 "Remove support for 'CompositeIndices' and sub-register cycles."
2025-06-04[TableGen] Fix typo in error messageJay Foad
2025-05-19[TableGen] Fix the buildKazu Hirata
This patch fixes: llvm/utils/TableGen/Common/CodeGenRegisters.cpp:653:57: error: 'getValues' is deprecated: Use getElements instead [-Werror,-Wdeprecated-declarations]
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-13[TableGen][CodeGen] Give every leaf register a unique regunit (#139526)Jay Foad
Give every leaf register a unique regunit, even if it has ad hoc aliases. Previously only leaf registers *without* ad hoc aliases would get a unique regunit, but that caused situations where regunits could not be used to distinguish a register from its subregs. For example: - Registers A and B alias. They both get regunit 0 only. - Register C has subregs A and B. It inherits regunits from its subregs, so it also gets regunit 0 only. After this fix, registers A and B will get a unique regunit in addition to the regunit representing the alias, for example: - A will get regunits 0 and 1. - B will get regunits 0 and 2. - C will get regunits 0, 1 and 2.
2025-05-05[NFC][TableGen] Code cleanup in CodeGenRegister (#137994)Rahul Joshi
- Use range for loops. - Wrap complex LLVM_DEBUG() macros in {} to have clang-format format the contents similar to regular code. - Extract repeated code snippets for debug dumping into helper lambda. - Add `BitsInit::getBits()` to get all contained bits.
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-17[llvm] Use llvm::binary_search (NFC) (#136228)Kazu Hirata
2025-04-16[llvm] Use llvm::append_range (NFC) (#135931)Kazu Hirata
2025-04-10TableGen: Optimize super-register class computation (#134865)Nicolai Hähnle
Inferring super-register classes naively requires checking every register class against every other register class and sub-register index. Each of those checks is itself a non-trivial operation on register sets. Culling as many (RC, RC, SubIdx) triples as possible is important for the running time of TableGen for architectures with complex sub-register relations. Use transitivity to cull many (RC, RC, SubIdx) triples. This unfortunately requires us to complete the transitive closure of super-register classes explicitly, but it still cuts down the running time on AMDGPU substantially -- in some upcoming work in the backend by more than half (in very rough measurements). This changes the names of some of the inferred register classes, since the order in which they are inferred changes. The names of the inferred register classes become shorter, which reduces the size of the generated files. Replacing some uses of SmallPtrSet by DenseSet shaves off a few more percent; there are hundreds of register classes in AMDGPU. Tweaking the topological signature check to skip reigsters without super-registers further helps skip register classes that have "pseudo" registers in them whose sub- and super-register structure is trivial.
2025-03-28[TableGen] Make more use of CodeGenRegisterClass::EnumValue. NFC. (#132749)Jay Foad
2025-03-27[llvm] Use *Set::insert_range (NFC) (#133353)Kazu Hirata
We can use *Set::insert_range to collapse: for (auto Elem : Range) Set.insert(E.first); down to: Set.insert_range(llvm::make_first_range(Range)); In some cases, we can further fold that into the set declaration.
2025-03-26[TableGen] Speed up inferMatchingSuperRegClass. NFC. (#133060)Jay Foad
SubToSuperRegs was a DenseMap of std::vectors, where the vectors typically had size 1. Switching to a vector of pairs avoids the overhead of allocating tiny vectors. I measured a 1.14x speed-up building AMDGPUGenRegisterInfo.inc with this patch.
2025-03-25[TableGen] Inherit properties from the nearest allocatable superclass. (#127018)Pete Chou
Previously isAlocatable was updated to allow inheritance from any superclass for a generated register class, but other properties are still inherited from its nearest superclass. This could cause a generated regclass inherit undesired properties, e.g., tsflags, from an unallocatable superclass due to the topological inheritance order. This change updates to inherit properties from the nearest allocatable superclass if possible and includes a test to demonstrate a potential incorrect inheritance of tsflags.
2025-03-04TableGen: Fix comment typoMatt Arsenault
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-11-04[TableGen] Fix calculation of Lanemask for RCs with artificial subregs. ↵Sander de Smalen
(#114392) TableGen builds up a map of "SubRegIdx -> Subclass" where Subclass is the largest class where all registers have SubRegIdx as a sub-register. When SubRegIdx (vis-a-vis the sub-register) is artificial it should still include it in the map. This map is used in various places, including in the calculation of the Lanemask of a register class, which otherwise calculates an incorrect lanemask.
2024-11-04[TableGen] Fix concatenation of subreg and artificial subregs (#114391)Sander de Smalen
When CoveredBySubRegs is true and a sub-register consists of two parts; a regular subreg and an artificial subreg, then TableGen should consider only concatenating the non-artificial subregs. For example, S0_S1 is a concatenated subreg from D0_D1, but S0_S1_HI should not be considered.
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-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-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-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-23[LLVM][TableGen] Use const record pointers in TableGen/Common files (#109467)Rahul Joshi
Use const record pointers in TableGen/Common files. 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-11[TableGen] Change CodeGenRegister to use const Record pointer (#108027)Rahul Joshi
Change CodeGenRegister to use 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-09-09[TableGen] Change CGIOperandList::OperandInfo::Rec to const pointer (#107858)Rahul Joshi
Change CGIOperandList::OperandInfo::Rec and CGIOperandList::TheDef to const 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-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-08-22[NFC][SetTheory] Refactor to use const pointers and range loops (#105544)Rahul Joshi
- Refactor SetTheory code to use const pointers when possible. - Use auto for variables initialized using dyn_cast<>. - Use range based for loops and early continue.
2024-06-25[TableGen] Check for duplicate register tuple definitions. (#95725)Jason Eckhardt
Currently TableGen does not directly detect duplicate synthesized registers as can happen in this example: def GPR128 : RegisterTuples<[sub0, sub1, sub2, sub3], [(decimate (shl GPR32, 0), 1), (decimate (shl GPR32, 1), 1), (decimate (shl GPR32, 2), 1), (decimate (shl GPR32, 3), 1)]>; def GPR128_Aligned : RegisterTuples<[sub0, sub1, sub2, sub3], [(decimate (shl GPR32, 0), 4), (decimate (shl GPR32, 1), 4), (decimate (shl GPR32, 2), 4), (decimate (shl GPR32, 3), 4)]>; TableGen does fail, but with an unrelated and difficult to understand error that happens downstream of tuple expansion: "error: No SubRegIndex for R0_R1_R2_R3 in R0_R1_R2_R3". This patch detects the problem directly during expansion and emits an error pointing the user to the actual issue: "error: Register tuple redefines register 'R0_R1_R2_R3'".
2024-06-02[TableGen] Use llvm::unique (NFC) (#94163)Kazu Hirata
2024-03-27[Target][RISCV] Add HwMode support to subregister index size/offset. (#86368)Craig Topper
This is needed to provide proper size and offset for the GPRPair subreg indices on RISC-V. The size of a GPR already uses HwMode. Previously we said the subreg indices have unknown size and offset, but this stops DwarfExpression::addMachineReg from being able to find the registers that make up the pair. I believe this fixes https://github.com/llvm/llvm-project/issues/85864 but need to verify.
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