aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Basic
AgeCommit message (Collapse)AuthorFilesLines
2026-02-05[RISCV] Introduce a new syntax for processor-specific tuning feature strings ↵Min-Yih Hsu1-1/+119
(#175063) This patch proposes new a tuning feature string format that helps users to build a performance model by "configuring" an existing tune CPU, along with its scheduling model. For example, this string ``` "sifive-x280:single-element-vec-fp64" ``` takes ``sifive-x280`` as the "base" tune CPU and configured it with ``single-element-vec-fp64``. This gives us a performance model that looks exactly like that of ``sifive-x280``, except some of the 64-bit vector floating point instructions now produce only a single element per cycle due to ``single-element-vec-fp64``. This string could eventually be used in places like ``-mtune`` at the frontend. Right now, this patch only implements the parser part, which is put under the TargetParser library. The grammar for this string is: ``` tune-cpu ::= 'tuning CPU name in lower case' directive ::= "[a-zA-Z0-9_-]+" tune-features ::= directive ["," directive]* ``` A *directive* can and can only _enable_ or _disable_ a certain tuning feature from the tuning CPU. A **positive directive**, like the ``single-element-vec-fp64`` we just saw, enables an additional tuning feature in the associated tuning model. A **negative directive**, on the other hand, removes a certain tuning feature. For example, ``sifive-x390`` already has the ``single-element-vec-fp64`` feature, and we can use "sifive-x390:no-single-element-vec-fp64" to create a new performance model that looks nearly the same as ``sifive-x390`` except ``single-element-vec-fp64`` being cut out. In this case, ``no-single-element-vec-fp64`` is a negative directive. There are additional restrictions on what we can put in the list of directives, please refer to the documentations for more details. Right now, this string only accepts directives that are explicitly supported by the tune CPU. For example, "sifive-x280:prefer-w-inst" is not a valide string as ``prefer-w-inst`` is not supported by ``sifive-x280`` at this moment. Vendors of these processors are expected to maintain the compatibility of their supported directives across different versions. --------- Co-authored-by: Sam Elliott <aelliott@qti.qualcomm.com>
2026-02-04[TableGen] Remove warning IntrinsicsToAttributesMap needs > 16 bits (#179533)Rahul Joshi1-4/+0
Remove the warning issued by intrinsic emitter when an entry in the `IntrinsicsToAttributesMap` is > 16 bits. The exact conditions under which this happen is tightly coupled with how the intrinsic emitter represents intrinsic attributes and generally this warning may not be actionable in any way without changing the semantics of the intrinsics being compiled (i.e., changing their attributes to have less number of unique attributes).
2026-02-03[NFC][TableGen] Adopt IfDefEmitter in TargetLibraryInfoEmitter (#179388)Rahul Joshi1-34/+29
2026-02-03[NFC][TableGen] Adopt CodeGenHelpers in IntrinsicEmitter (#179310)Rahul Joshi1-53/+30
- Adopt IfDefEmitter in IntrinsicEmitter. - Remove #undef for various flags in Intrinsics.cpp/Intrinsics.h as the TableGen generated code does that now.
2026-02-02[LLVM][Intrinsics] Allow IIT fixed encoding table to be 32-bit (#178531)Rahul Joshi1-5/+6
Change Intrinsics.cpp to rely on the type `FixedEncodingTy` emitted by the intrinsic emitter in `getIntrinsicInfoTableEntries` to process the intrinsic type table. This enables downstream targets that need a 32-bit fixed encoding table to just change the value of `Use16BitFixedEncoding` in the intrinsic emitter to enable 32-bit fixed encoding table.
2026-01-30[NFC][TableGen] Minor cleanup in SequenceToOffsetTable (#178564)Rahul Joshi1-10/+9
Use `auto` for iterators, range for loop in `layout` and rename `Entries` to a more canonical `Size`.
2026-01-21Revert "[TableGen] Emit constexpr versions of some directive/clause f… ↵Krzysztof Parzyszek1-106/+37
(#177161) …unctions (#176253)" This reverts commit cf68af690ba7f98943e5f0f5cb39a91868d62098. It increased the compilation time for a number of clang source files. See comments in https://github.com/llvm/llvm-project/pull/176253 for more information.
2026-01-20[TableGen] Emit constexpr versions of some directive/clause functions (#176253)Krzysztof Parzyszek1-37/+106
Several of the functions that TableGen emits into the .cpp files for OpenACC or OpenMP could be constexpr. They can't just be emitted into the header files as constexpr as they are because they use "assert" and "llvm_unreachable". To preserve the existing functionality, this patch will cause TableGen to emit the constexpr variants that return the value as std::optional, where std::nullopt indicates an error. The exisiting functions will invoke the constexpr versions and call assert/llvm_unreachable if nullopt is returned. E.g. ``` // .h constexpr std::optional<Association> getDirectiveAssociationOpt(Directive D) { switch (D) { case ...: return Association::Block; ... } // switch (D) return std::nullopt; } // .cpp Association getDirectiveAssociation(Directive D) { if (auto X = getDirectiveAssociationOpt(D)) { return *X; } llvm_unreachable("Unexpected directive"); } ```
2026-01-14[NFC] Exactly one kind typo fixes, change defintions to definitions. (#174333)willmafh1-1/+1
2025-12-09[FMV][AArch64] Allow user to override version priority. (#150267)Alexandros Lamprineas1-3/+6
Implements https://github.com/ARM-software/acle/pull/404 This allows the user to specify "featA+featB;priority=[1-255]" where priority=255 means highest priority. If the explicit priority string is omitted then the priority of "featA+featB" is implied, which is lower than priority=1. Internally this gets expanded using special FMV features P0 ... P7 which can encode up to 256-1 priority levels (excluding all zeros). Those do not have corresponding detection bit at pos FEAT_#enum so I made this field optional in FMVInfo. Also they don't affect the codegen or name mangling of versioned functions.
2025-11-27[CodeGenTypes] Remove explicit VT numbers from ValueTypes.td (#169670)Jay Foad1-8/+9
Remove explicit VT numbers from ValueTypes.td so that patches that add a new VT do not have to renumber the entire file. In TableGen VTs are now identified by ValueType.LLVMName instead of ValueType.Value. This is important for target-defined types (typically based on PtrValueType) which are not mentioned in ValueTypes.td itself.
2025-11-22[llvm] Remove unused local variables (NFC) (#169171)Kazu Hirata1-1/+0
Identified with bugprone-unused-local-non-trivial-variable.
2025-11-21[OpenMP] Introduce "loop sequence" as directive association (#168934)Krzysztof Parzyszek1-9/+10
OpenMP 6.0 introduced a `fuse` directive, and with it a "loop sequence" as the associated code. What used to be "loop association" has become "loop-nest association". Rename Association::Loop to LoopNest, add Association::LoopSeq to represent the "loop sequence" association. Change the association of fuse from "block" to "loop sequence".
2025-11-19[Analysis] Move TargetLibraryInfo data to TableGen (#165009)Kai Nacke2-0/+187
The collection of library function names in TargetLibraryInfo faces similar challenges as RuntimeLibCalls in the IR component. The number of function names is large, there are numerous customizations based on the triple (including alternate names), and there is a lot of replicated data in the signature table. The ultimate goal would be to capture all lbrary function related information in a .td file. This PR brings the current .def file to TableGen, almost as a 1:1 replacement. However, there are some improvements which are not possible in the current implementation: - the function names are now stored as a long string together with an offset table. - the table of signatures is now deduplicated, using an offset table for access. The size of the object file decreases about 34kB with these changes. The hash table of all function names is still constructed dynamically. A static table like for RuntimeLibCalls is the next logical step. The main motivation for this change is that I have to add a large number of custom names for z/OS (like in RuntimeLibCalls.td), and the current infrastructur does not support this very well.
2025-11-18[NFC][TableGen] Remove `close` member from various CodeGenHelpers (#167904)Rahul Joshi1-61/+62
Always rely on local scopes to enforce the lifetime of these helper objects and by extension where the "closing" of various C++ code constructs happens.
2025-11-18[TableGen][NFCI] Change TableGenMain() to take function_ref. (#167888)Ivan Kosarev1-1/+1
It was switched from a function pointer to std::function in TableGen: Make 2nd arg MainFn of TableGenMain(argv0, MainFn) optional. f675ec6165ab6add5e57cd43a2e9fa1a9bc21d81 but there's no mention of any particular reason for that.
2025-11-18Extend MemoryEffects to Support Target-Specific Memory Locations (#148650)CarolineConcatto3-3/+34
This patch introduces preliminary support for additional memory locations. They are: target_mem0 and target_mem1 and they model memory locations that cannot be represented with existing memory locations. It was a solution suggested in : https://discourse.llvm.org/t/rfc-improving-fpmr-handling-for-fp8-intrinsics-in-llvm/86868/6 Currently, these locations are not yet target-specific. The goal is to enable the compiler to express read/write effects on these resources.
2025-11-17[LLVM-Tablegen] Pretty Printing Arguments in LLVM Intrinsics (#162629)Dharuni R Acharya3-18/+139
This patch adds LLVM infrastructure to support pretty printing of the intrinsic arguments. The motivation is to improve the readability of LLVM intrinsics and facilitate easy modifications and debugging of LLVM IR. This feature adds a property `ArgInfo<ArgIndex, [ArgName<"argName">, ImmArgPrinter<"functionName">]>` to the intrinsic arguments to print self-explanatory inline comments for the arguments. The addition of pretty print support can provide a simple, low-overhead feature that enhances the usability of LLVM intrinsics without disrupting existing workflows. Link to the RFC, where this feature was discussed: https://discourse.llvm.org/t/rfc-pretty-printing-immediate-arguments-in-llvm-intrinsics/88536 --------- Signed-off-by: Dharuni R Acharya <dharunira@nvidia.com> Co-authored-by: Rahul Joshi <rjoshi@nvidia.com>
2025-11-16[SelectionDAG] Verify SDTCisVT and SDTCVecEltisVT constraints (#150125)Sergei Barannikov1-1/+2
Teach `SDNodeInfoEmitter` TableGen backend to process `SDTypeConstraint` records and emit tables for them. The tables are used by `SDNodeInfo::verifyNode()` to validate a node being created. This PR only adds validation code for `SDTCisVT` and `SDTCVecEltisVT` constraints to keep it smaller. Pull Request: https://github.com/llvm/llvm-project/pull/150125
2025-11-14[TableGen] Split *GenRegisterInfo.inc. (#167700)Ivan Kosarev1-2/+5
Reduces memory usage compiling backend sources, most notably for AMDGPU by ~98 MB per source on average. AMDGPUGenRegisterInfo.inc is tens of megabytes in size now, and is even larger downstream. At the same time, it is included in nearly all backend sources, typically just for a small portion of its content, resulting in compilation being unnecessarily memory-hungry, which in turn stresses buildbots and wastes their resources. Splitting .inc files also helps avoiding extra ccache misses where changes in .td files don't cause changes in all parts of what previously was a single .inc file. It is thought that rather than building on top of the current single-output-file design of TableGen, e.g., using `split-file`, it would be more preferable to recognise the need for multi-file outputs and give it a proper first-class support directly in TableGen.
2025-11-08[TableGen] Use "using" instead of "typedef" (NFC) (#167168)Kazu Hirata1-2/+2
Identified with modernize-use-using.
2025-11-05TableGen: Split RuntimeLibcallsEmitter into separate utility header (#166583)Matt Arsenault4-250/+308
This information will be needed in more emitters, so start factoring it to be more reusable.
2025-11-05RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (#164987)Matt Arsenault1-11/+8
Introduce a new class for the TargetLowering usage. This tracks the subtarget specific lowering decisions for which libcall to use. RuntimeLibcallsInfo is a module level property, which may have multiple implementations of a particular libcall available. This attempts to be a minimum boilerplate patch to introduce the new concept. In the future we should have a tablegen way of selecting which implementations should be used for a subtarget. Currently we do have some conflicting implementations added, it just happens to work out that the default cases to prefer is alphabetically first (plus some of these still are using manual overrides in TargetLowering constructors).
2025-11-05[NFC][TableGen] Adopt NamespaceEmitter in DirectiveEmitter (#165600)Rahul Joshi1-26/+10
2025-11-04[NFC][TableGen] Emit empty lines after/before namespace scope (#166217)Rahul Joshi1-17/+8
Emit empty line after a namespace scope is opened and before its closed. Adjust DirectiveEmitter code empty line emission in response to this to avoid lot of unit test changes.
2025-11-04[IR] Add new function attribute nocreateundeforpoison (#164809)Jay Foad3-2/+11
Also add a corresponding intrinsic property that can be used to mark intrinsics that do not introduce poison, for example simple arithmetic intrinsics that propagate poison just like a simple arithmetic instruction. As a smoke test this patch adds the new property to llvm.amdgcn.fmul.legacy.
2025-11-02[TableGen] Use std::move properly (NFC) (#166104)Kazu Hirata1-1/+1
This patch removes const to allow std::move a couple of lines below to perform a move operation as intended. Identified with performance-move-const.
2025-11-01[TableGen] Use "= default" (NFC) (#165968)Kazu Hirata2-2/+2
Identified with modernize-use-equals-default.
2025-10-23[LLVM][Intrinsics] Print note if manual name matches default name (#164716)Rahul Joshi1-2/+8
Print a note when the manually specified name in an intrinsic matches the default name it would have been assigned based on the record name, in which case the manual specification is redundant and can be eliminated. Also remove existing redundant manual names.
2025-10-21TableGen: Use IfDefEmitter (#164209)Matt Arsenault1-50/+52
2025-10-15[TableGen][RISCV] Don't use auto where the type isn't obvious. NFC (#163611)Craig Topper1-12/+16
2025-10-14[NFC][TableGen] Add `IncludeGuardEmitter` to emit header include guards ↵Rahul Joshi1-4/+2
(#163283) Add a RAII class `IncludeGuardEmitter` which is similar to `IfDefEmitter` but emits header include guards and adopt it in DirectiveEmitter.
2025-10-13TableGen: Account for Unsupporte LibcallImpl in bitset size (#163083)Matt Arsenault1-1/+1
The Unsupported case is special and doesn't have an entry in the vector, and is directly emitted as the 0 case. This should be harmless as it is, but could break if the right number of new libcalls is added.
2025-10-10RuntimeLibcalls: Add bitset for available libcalls (#150869)Matt Arsenault1-1/+30
This is a step towards separating the set of available libcalls from the lowering decision of which call to use. Libcall recognition now directly checks availability instead of indirectly checking through the lowering table.
2025-10-07TableGen: Go back to using range loop over runtime libcall sets (#162221)Matt Arsenault1-11/+30
This reverts 9c361cc and replaces f490dbdc. Instead of using the lambda to try avoid naming the variables, just disambiguate the different AlwaysAvailable sets with the calling convention name.
2025-10-07[TableGen] Reduce stack usage of setTargetRuntimeLibcallSets (#162194)Nadharm1-25/+15
This change resolves a stack usage issue seen in the TableGen'd function `setTargetRuntimeLibcallSets` when compiled with MSVC. This change reduces the frame size from 47720 bytes to 48 bytes.
2025-10-06[RISCV][TableGen] Correct vTtoGetLlvmTyString for RISC-V tuples. (#162152)Craig Topper1-2/+2
RISC-V tuples use "NF" not "nElem" to store the number of fields in the segment. This fixes a crash when lowering a function with tuple return. getReturnInfo in CallLowering.cpp does Type*->EVT->Type* and we were incorrectly converting EVT to Type*.
2025-10-04[NFC][TableGen] Migrate IfDef/Namespace emitter from MLIR to LLVM (#161744)Rahul Joshi2-74/+35
2025-09-30[LLVM] Fix a bug in `Intrinsic::getFnAttributes` (#161248)Rahul Joshi1-1/+4
2025-09-26[Intrinsic] Unify IIT_STRUCT{2-9} into ITT_STRUCT to support upto 257 return ↵Michael Liao2-16/+10
values - Currently, Intrinsic can only have up to 9 return values. In case new intrinsics require more than 9 return values, additional ITT_STRUCTxxx values need to be added to support > 9 return values. Instead, this patch unifies them into a single IIT_STRUCT followed by a BYTE specifying the minimal 2 (encoded as 0) and maximal 257 (encoded as 255) return values.
2025-09-18[IntrinsicEmitter] Make AttributesMap PackedID type-adaptive (#158383)Elvin Wang1-22/+33
2025-09-18[IntrinsicEmitter] Make AttributesMap bound inclusive (#158714)Elvin Wang1-2/+2
This is a minor fix from comment https://github.com/llvm/llvm-project/pull/157965/files#r2347317186 introduced in #157965.
2025-09-12[IntrinsicEmitter] Make AttributesMap bits adaptive (#157965)Elvin Wang1-14/+27
Make IntrinsicsToAttributesMap's func. and arg. fields be able to have adaptive sizes based on input other than hardcoded 8bits/8bits. This will ease the pressure for adding new intrinsics in private downstreams. func. attr bitsize will become 7(127/128) vs 8(255/256)
2025-09-11[CodeGen, CHERI] Add capability types to MVT. (#156616)Owen Anderson1-0/+2
This adds value types for representing capability types, enabling their use in instruction selection and other parts of the backend. These types are distinguished from each other only by size. This is sufficient, at least today, because no existing CHERI configuration supports multiple capability sizes simultaneously. Hybrid configurations supporting intermixed integral pointers and capabilities do exist, and are one of the reasons why these value types are needed beyond existing integral types. Co-authored-by: David Chisnall <theraven@theravensnest.org> Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
2025-09-04[NFC][IntrinsicEmitter] Include source location with enum definition (#156800)Rahul Joshi1-2/+5
2025-09-02[NFC] RuntimeLibcalls: Prefix the impls with 'Impl_' (#153850)Daniel Paoliello1-6/+7
As noted in #153256, TableGen is generating reserved names for RuntimeLibcalls, which resulted in a build failure for Arm64EC since `vcruntime.h` defines `__security_check_cookie` as a macro. To avoid using reserved names, all impl names will now be prefixed with `Impl_`. `NumLibcallImpls` was lifted out as a `constexpr size_t` instead of being an enum field. While I was churning the dependent code, I also removed the TODO to move the impl enum into its own namespace and use an `enum class`: I experimented with using an `enum class` and adding a namespace, but we decided it was too verbose so it was dropped.
2025-08-25RuntimeLibcalls: Fix building hash table with duplicate entries (#153801)Matt Arsenault1-43/+33
We were sizing the table appropriately for the number of LibcallImpls, but many of those have identical names which were pushing up the collision count unnecessarily. This ends up decreasing the table size slightly, and makes it a bit faster. BM_LookupRuntimeLibcallByNameRandomCalls improves by ~25% and BM_LookupRuntimeLibcallByNameSampleData by ~5%. As a secondary change, align the table size up to the next power of 2. This makes the table larger than before, but improves the sample data benchmark by an additional 5%.
2025-08-19RuntimeLibcalls: Move exception call config to tablegen (#151948)Matt Arsenault1-1/+2
Also starts pruning out these calls if the exception model is forced to none. I worked backwards from the logic in addPassesToHandleExceptions and the pass content. There appears to be some tolerance for mixing and matching exception modes inside of a single module. As far as I can tell _Unwind_CallPersonality is only relevant for wasm, so just add it there. As usual, the arm64ec case makes things difficult and is missing test coverage. The set of calls in list form is necessary to use foreach for the duplication, but in every other context a dag is more convenient. You cannot use foreach over a dag, and I haven't found a way to flatten a dag into a list. This removes the last manual setLibcallImpl call in generic code.
2025-08-16Reapply "RuntimeLibcalls: Generate table of libcall name lengths (#153… ↵Matt Arsenault1-8/+200
(#153864) This reverts commit 334e9bf2dd01fbbfe785624c0de477b725cde6f2. Check if llvm-nm exists before building the benchmark.
2025-08-15Revert "RuntimeLibcalls: Generate table of libcall name lengths (#153… ↵gulfemsavrun1-200/+8
(#153864) …210)" This reverts commit 9a14b1d254a43dc0d4445c3ffa3d393bca007ba3. Revert "RuntimeLibcalls: Return StringRef for libcall names (#153209)" This reverts commit cb1228fbd535b8f9fe78505a15292b0ba23b17de. Revert "TableGen: Emit statically generated hash table for runtime libcalls (#150192)" This reverts commit 769a9058c8d04fc920994f6a5bbb03c8a4fbcd05. Reverted three changes because of a CMake error while building llvm-nm as reported in the following PR: https://github.com/llvm/llvm-project/pull/150192#issuecomment-3192223073