aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/RegisterInfoEmitter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-16[TableGen] Add a bitvector of members of CodeGenRegisterClass (#149122)Jay Foad1-1/+1
This makes CodeGenRegisterClass::contains fast. Use this to simplify inferMatchingSuperRegClass.
2025-06-15[TableGen] Use range-based for loops (NFC) (#144283)Kazu Hirata1-6/+6
2025-06-11[X86][BreakFalseDeps] Using reverse order for undef register selection (#137569)Phoebe Wang1-5/+5
BreakFalseDeps picks the best register for undef operands if instructions have false dependency. The problem is if the instruction is close to the beginning of the function, ReachingDefAnalysis is over optimism to the unused registers, which results in collision with registers just defined in the caller. This patch changes the selection of undef register in an reverse order, which reduces the probability of register collisions between caller and callee. It brings improvement in some of our internal benchmarks with negligible effect on other benchmarks.
2025-05-13[TableGen][CodeGen] Give every leaf register a unique regunit (#139526)Jay Foad1-0/+2
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-12[NFC][TableGen] Use StringRef::str() instead of casting (#139332)Rahul Joshi1-5/+5
- Also eliminate unneeded std::string() around some literal strings.
2025-04-16[llvm] Use llvm::append_range (NFC) (#135931)Kazu Hirata1-1/+1
2025-03-03[NFC]Make file-local cl::opt global variables static (#126486)chrisPyr1-1/+1
#125983
2025-02-17TableGen: Generate reverseComposeSubRegIndices (#127050)Matt Arsenault1-3/+51
This is necessary to enable composing subregisters in peephole-opt. For now use a brute force table to find the return value. The worst case target is AMDGPU with a 399 x 399 entry table.
2025-02-13TableGen: Add missing consts to CodeGenSubRegIndexMatt Arsenault1-4/+4
2025-01-28[TableGen] Use MCRegister::id() to avoid an implicit conversion from ↵Craig Topper1-1/+1
MCRegister to unsigned. NFC
2025-01-16[TableGen] Use std::pair instead of std::make_pair. NFC. (#123174)Jay Foad1-3/+2
Also use brace initialization and emplace to avoid explicitly constructing std::pair, and the same for std::tuple.
2024-12-13[TableGen] Allow empty terminator in SequenceToOffsetTable (#119751)Sergei Barannikov1-10/+10
Some clients do not want to emit a terminator after each sub-sequence (they have other means of determining the length of sub-sequences). This moves `Term` argument from `emit` method to the constructor and makes it optional. It couldn't be made optional while still on the `emit` method because if the terminator wasn't specified, it has to be taken into account in `layout` method as well. The fact that `layout` method was called is now recorded in a dedicated member variable, `IsLaidOut`. `Entries != 0` can no longer be used to reliably check if `layout` method was called because it may be zero for a different reason: the terminator wasn't specified and all added sequences (if any) were empty. This reduces the size of `*LaneMaskLists` and `*SubRegIdxLists` a bit and resolves the removed TODO.
2024-12-12CodeGen: Eliminate dynamic relocations in the register superclass tables. ↵Owen Anderson1-11/+8
(#119487) This reapplies #119122 with a fix for UBSAN errors in the X86 backend related to incrementing a nullptr.
2024-12-11Revert "CodeGen: Eliminate dynamic relocations in the register superclass ↵Owen Anderson1-8/+11
tables. (#119122)" Reverting due to UBSan failures in X86RegisterInfo::getLargestLegalSuperClass This reverts commit c4873819a98f59ce4e2664f94c73c2dfec3393f8.
2024-12-11CodeGen: Eliminate dynamic relocations in the register superclass tables. ↵Owen Anderson1-11/+8
(#119122)
2024-11-27Reland "[AArch64] Define high bits of FPR and GPR registers (take 2) (#114827)"Sander de Smalen1-3/+3
The issue with slow compile-time was caused by an assert in AArch64RegisterInfo.cpp. The assert invokes 'checkAllSuperRegsMarked' after adding all the reserved registers. This call gets very expensive after adding the _HI registers due to the way the function searches in the 'Exception' list, which is expected to be a small list but isn't (the patch added 190 _HI regs). It was possible to rewrite the code in such a way that the _HI registers are marked as reserved after the check. This makes the problem go away entirely and restores compile-time to what it was before (tested for `check-runtimes`, which previously showed a ~5x slowdown). This reverts commits: 1434d2ab215e3ea9c5f34689d056edd3d4423a78 2704647fb7986673b89cef1def729e3b022e2607
2024-11-22Revert "[AArch64] Define high bits of FPR and GPR registers (take 2) ↵Vitaly Buka1-3/+3
(#114827)" (#117307) Details in #114827 This reverts commit c1c68baf7e0fcaef1f4ee86b527210f1391b55f6.
2024-11-14[AArch64] Define high bits of FPR and GPR registers (take 2) (#114827)Sander de Smalen1-3/+3
This is a step towards enabling subreg liveness tracking for AArch64, which requires that registers are fully covered by their subregisters, as covered here #109797. There are several changes in this patch: * AArch64RegisterInfo.td and tests: Define the high bits like B0_HI, H0_HI, S0_HI, D0_HI, Q0_HI. Because the bits must be defined by some register class, this added a register class which meant that we had to update 'magic numbers' in several tests. The use of ComposedSubRegIndex helped 'compress' the number of bits required for the lanemask. The correctness of the masks is tested by an explicit unit tests. * LoadStoreOptimizer: previously 'HasDisjunctSubRegs' was only true for register tuples, but with this change to describe the high bits, a register like 'D0' will also have 'HasDisjunctSubRegs' set to true (because it's fullly covered by S0 and S0_HI). The fix here is to explicitly test if the register class is one of the known D/Q/Z tuples.
2024-10-18[LLVM][TableGen] Change all `Init` pointers to const (#112705)Rahul Joshi1-3/+3
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 Joshi1-4/+6
Factor out the timer related functionality from `RecordKeeper` to a new `TGTimer` class in a new file.
2024-09-20[LLVM][TableGen] Change RegisterInfoEmitter to use const RecordKeeper (#109237)Rahul Joshi1-16/+13
Change RegisterInfoEmitter 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-19[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)Jay Foad1-2/+2
It is almost always simpler to use {} instead of std::nullopt to initialize an empty ArrayRef. This patch changes all occurrences I could find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor could be deprecated or removed.
2024-09-18[NFC] Cleanup RegisterInfoEmitter code (#109199)Rahul Joshi1-51/+38
Change variable name `o` to `OS` to match definition, and `ClName` to `ClassName` for better clarity. Cache RegBank reference in the class and do no pass around class members to functions.
2024-09-18[Target] Use 'unsigned' as the underlying type for the tablegened physical ↵Craig Topper1-1/+1
register enums. (#109086) Otherwise, the enum defaults to 'int'. Update a few places that used 'int' for registers that now need to change to avoid a signed/unsigned compare warning. I was hoping this would allow us to remove the 'int' comparison operators in Register.h and MCRegister.h, but compares with literal 0 still need them.
2024-09-15[LLVM][TableGen] Change CodeGenTarget to use const RecordKeeper (#108752)Rahul Joshi1-2/+1
Change CodeGenTarget 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 Joshi1-15/+15
Change SetTheory::RecSet/RecVec to use const Record pointers.
2024-08-06[X86][RA] Add two address hints for compressible NDD instructions. (#98603)Freddy Ye1-0/+16
To address @topperc 's comment at https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/5?u=kanrobert
2024-06-02[TableGen] Use llvm::unique (NFC) (#94163)Kazu Hirata1-5/+4
2024-05-03[llvm-mca] Teach MCA constant registers do not create dependencies (#89387)Rin Dobrescu1-2/+3
Constant registers like the zero registers XZR and WZR are treated as any other register by LLVM-MCA. This can create non existent dependency chains. Currently there is no method in MCA to query if a register is constant. This patch fixes the issue by adding a bool Constant variable to MCRegisterDesc that is true for constant registers. Since constant registers do not create dependencies, it makes sense to add this check to MCA.
2024-03-27[Target][RISCV] Add HwMode support to subregister index size/offset. (#86368)Craig Topper1-5/+14
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 Houtryve1-6/+6
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-22[Target] Move SubRegIdxRanges from MCSubtargetInfo to TargetInfo. (#86245)Craig Topper1-16/+13
I'm planning to add HwMode support to SubRegIdxRanges for RISC-V GPR pairs. The MC layer is currently unaware of the HwMode for registers and I'd like to keep it that way. This information is not used by the MC layer so I think it is safe to move it.
2024-03-10Add llvm::min/max_element and use it in llvm/ and mlir/ directories. (#84678)Justin Lebar1-2/+2
For some reason this was missing from STLExtras.
2024-02-09[NFC] clang-format utils/TableGen (#80973)Pierre van Houtryve1-115/+111
``` find llvm/utils/TableGen -iname "*.h" -o -iname "*.cpp" | xargs clang-format-16 -i ``` Split from #80847
2024-01-30[AMDGPU] Speed up SIRegisterInfo::getReservedRegs (#79844)Jay Foad1-1/+3
reserveRegisterTuples is slow because it uses MCRegAliasIterator and hence ends up reserving the same aliased registers many times. This patch changes getReservedRegs not to use it for reserving SGPRs, VGPRs and AGPRs. Instead it iterates through base register classes, which should come closer to reserving each register once only. Overall this speeds up the time to run check-llvm-codegen-amdgpu in my Release build from 18.4 seconds to 16.9 seconds (all timings +/- 0.2).
2024-01-25[llvm] Move CodeGenTypes library to its own directory (#79444)Nico Weber1-1/+1
Finally addresses https://reviews.llvm.org/D148769#4311232 :) No behavior change.
2023-08-21Move VTList pointer out of RegClassInfosBenjamin Kramer1-2/+2
Store it in TargetRegisterInfo instead. Worth 54k on llc size.
2023-08-14[CodeGen] Set regunitmasks for leaf regs to all instead of noneJay Foad1-6/+2
This simplifies every use of MCRegUnitMaskIterator. Differential Revision: https://reviews.llvm.org/D157864
2023-08-03[TableGen][NFC] Refine obtaining qualified register class ids.Ivan Kosarev1-6/+4
Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D156110
2023-07-27[TableGen][RegisterInfoEmitter] Make entries of base register class tables ↵Ivan Kosarev1-21/+26
human-readable. Helps tracking changes in the tables on adding new register classes and updating BaseClassOrder values. Also eliminates tables translating base register class indexes into TargetRegisterClass pointers. Reviewed By: critson Differential Revision: https://reviews.llvm.org/D156097
2023-07-05[RISCV][TableGen] Remove f32 from XLenFVT for RV32.Craig Topper1-2/+4
We don't expect this to be used on RV32 currently so remove it to reduce number of entries in the isel table. Teach RegisterInfoEmitter.cpp to allow a type to be missing for a particular HwMode.
2023-06-04[CodeGen] Fix incorrect usage of MCPhysReg for diff list elementsSergei Barannikov1-42/+21
The lists contain differences between register numbers, not the register numbers themselves. Since a difference can also be negative, this also changes its type to signed. Changing the type to signed exposed a "bug". For AMDGPU, which has many registers, the first element of a sequence could be as big as ~45k. The value does not fit into int16_t, but fits into uint16_t. The bug didn't show up because of unsigned wrapping and truncation of the Val field in the advance() method. To fix the issue, I changed the way regunit difflists are encoded. The 4-bit 'scale' field of MCRegisterDesc::RegUnit was replaced by 12-bit number of the first regunit, and the first element of each of the lists was removed. The higher 20 bits of RegUnit field contain the initial offset into DiffLists array. AMDGPU has 1'409 regunits (2^12 = 4'096), and the biggest offset is 80'041 (2^20 = 1'048'576). That is, there is enough room. Changing the encoding method also resulted in a smaller array size, the numbers are below (I omitted targets with less than 100 elements). ``` AMDGPU | 80052 | 78741 | -1,6% RISCV | 6498 | 6297 | -3,1% ARM | 4181 | 3966 | -5,1% AArch64 | 2770 | 2592 | -6,4% PPC | 1578 | 1441 | -8,7% Hexagon | 994 | 740 | -25,6% R600 | 508 | 398 | -21,7% VE | 471 | 459 | -2,5% Sparc | 381 | 363 | -4,7% X86 | 326 | 208 | -36,2% Mips | 253 | 200 | -20,9% SystemZ | 186 | 162 | -12,9% ``` Reviewed By: foad, arsenm Differential Revision: https://reviews.llvm.org/D151036
2023-05-23Revert "[CodeGen] Fix incorrect usage of MCPhysReg for diff list elements"Sergei Barannikov1-21/+42
This reverts commit fa2827f0796c08e36b0b157fc526dd59cd6368e3. Causes build bot failres: https://lab.llvm.org/buildbot/#/builders/38/builds/12037
2023-05-23[CodeGen] Fix incorrect usage of MCPhysReg for diff list elementsSergei Barannikov1-42/+21
The lists contain differences between register numbers, not the register numbers themselves. Since a difference can also be negative, this also changes its type to signed. Changing the type to signed exposed a "bug". For AMDGPU, which has many registers, the first element of a sequence could be as big as ~45k. The value does not fit into int16_t, but fits into uint16_t. The bug didn't show up because of unsigned wrapping and truncation of the Val field in the advance() method. To fix the issue, I changed the way regunit difflists are encoded. The 4-bit 'scale' field of MCRegisterDesc::RegUnit was replaced by 12-bit number of the first regunit, and the first element of each of the lists was removed. The higher 20 bits of RegUnit field contain the initial offset into DiffLists array. AMDGPU has 1'409 regunits (2^12 = 4'096), and the biggest offset is 80'041 (2^20 = 1'048'576). That is, there is enough room. Changing the encoding method also resulted in a smaller array size, the numbers are below (I omitted targets with less than 100 elements). ``` AMDGPU | 80052 | 78741 | -1,6% RISCV | 6498 | 6297 | -3,1% ARM | 4181 | 3966 | -5,1% AArch64 | 2770 | 2592 | -6,4% PPC | 1578 | 1441 | -8,7% Hexagon | 994 | 740 | -25,6% R600 | 508 | 398 | -21,7% VE | 471 | 459 | -2,5% Sparc | 381 | 363 | -4,7% X86 | 326 | 208 | -36,2% Mips | 253 | 200 | -20,9% SystemZ | 186 | 162 | -12,9% ``` Reviewed By: foad, arsenm Differential Revision: https://reviews.llvm.org/D151036
2023-05-03Restore CodeGen/MachineValueType.h from `Support`NAKAMURA Takumi1-1/+1
This is rework of; - rG13e77db2df94 (r328395; MVT) Since `LowLevelType.h` has been restored to `CodeGen`, `MachinveValueType.h` can be restored as well. Depends on D148767 Differential Revision: https://reviews.llvm.org/D149024
2023-03-21llvm-tblgen: Rewrite emitters to use `TableGen::Emitter`NAKAMURA Takumi1-8/+2
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 Takumi1-0/+1
"TableGenBackends.h" has declarations of emitters.
2023-02-17llvm-tblgen: Apply IWYU partiallyNAKAMURA Takumi1-0/+2
2023-01-05Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ partserge-sans-paille1-4/+4
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-12-20[TableGen] Emit table mapping physical registers to base classesCarl Ritson1-2/+54
Allow targets to define a mapping from registers to register classes such that each register has exactly one base class. As registers may be in multiple register classes the base class is determined by the container class with the lowest BaseClassOrder. Only register classes with BaseClassOrder set are considered when determining the base classes. By default BaseClassOrder is unset in RegisterClass so no code is generated unless a target explicit defines one or more base register classes. Reviewed By: arsenm, foad Differential Revision: https://reviews.llvm.org/D139616