summaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
AgeCommit message (Collapse)Author
2025-11-05TableGen: Split RuntimeLibcallsEmitter into separate utility header (#166583)Matt Arsenault
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 Arsenault
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-01[TableGen] Use "= default" (NFC) (#165968)Kazu Hirata
Identified with modernize-use-equals-default.
2025-10-21TableGen: Use IfDefEmitter (#164209)Matt Arsenault
2025-10-13TableGen: Account for Unsupporte LibcallImpl in bitset size (#163083)Matt Arsenault
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 Arsenault
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 Arsenault
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)Nadharm
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-09-02[NFC] RuntimeLibcalls: Prefix the impls with 'Impl_' (#153850)Daniel Paoliello
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 Arsenault
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 Arsenault
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 Arsenault
(#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… ↵gulfemsavrun
(#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
2025-08-15RuntimeLibcalls: Generate table of libcall name lengths (#153210)Matt Arsenault
Avoids strlen when constructing the returned StringRef. We were emitting these in the libcall name lookup anyway, so split out the offsets for general use. Currently emitted as a separate table, not sure if it would be better to change the string offset table to store pairs of offset and width instead.
2025-08-15TableGen: Emit statically generated hash table for runtime libcalls (#150192)Matt Arsenault
a96121089b9c94e08c6632f91f2dffc73c0ffa28 reverted a change to use a binary search on the string name table because it was too slow. This replaces it with a static string hash table based on the known set of libcall names. Microbenchmarking shows this is similarly fast to using DenseMap. It's possibly slightly slower than using StringSet, though these aren't an exact comparison. This also saves on the one time use construction of the map, so it could be better in practice. This search isn't simple set check, since it does find the range of possible matches with the same name. There's also an additional check for whether the current target supports the name. The runtime constructed set doesn't require this, since it only adds the symbols live for the target. Followed algorithm from this post http://0x80.pl/notesen/2023-04-30-lookup-in-strings.html I'm also thinking the 2 special case global symbols should just be added to RuntimeLibcalls. There are also other global references emitted in the backend that aren't tracked; we probably should just use this as a centralized database for all compiler selected symbols.
2025-08-14ARM: Move more aeabi libcall config into tablegen (#152109)Matt Arsenault
2025-08-13TableGen: Add failing function to libcall emitter error message (#153390)Matt Arsenault
2025-08-13[TableGen] Avoid duplicate variable names in RuntimeLibcallsEmitter (partial ↵Benjamin Maxwell
reland of #152505) (#153398)
2025-08-13Revert "[AArch64][SME] Port all SME routines to RuntimeLibcalls" (#153392)Nikita Popov
This introduced a 5% compile-time regression on AArch64, see https://llvm-compile-time-tracker.com/compare.php?from=b9138bde3562de5c28a239dbd303caf2406678c6&to=271688b87abe7cf45aceaff8266270a25eb7b436&stat=instructions:u. Reverts llvm/llvm-project#152505.
2025-08-13[AArch64][SME] Port all SME routines to RuntimeLibcalls (#152505)Benjamin Maxwell
This updates everywhere we emit/check an SME routines to use RuntimeLibcalls to get the function name and calling convention. Note: RuntimeLibcallEmitter had some issues with emitting non-unique variable names for sets of libcalls, so I tweaked the output to avoid the need for variables.
2025-08-04RuntimeLibcalls: Really move default libcall handling to tablegen (#148780)Matt Arsenault
Hack in the default setting so it's consistently generated like the other cases. Maintain a list of targets where this applies. The alternative would require new infrastructure to sort the system library initialization in some way. I wanted the unhandled target case to be treated as a fatal error, but it turns out there's a hack in IRSymtab using RuntimeLibcalls, which will fail out in many tests that do not have a triple set. Many of the failures are simply running llvm-as with no triple, which probably should not depend on knowing an accurate set of calls.
2025-07-26TableGen: Sort RuntimeLibcallImpls secondarily by enum names (#150728)Matt Arsenault
Extracted from #150192, this hopefully fixes occasional EXPENSIVE_CHECKS failures.
2025-07-18Partially Reapply "RuntimeLibcalls: Add methods to recognize libcall names ↵Matt Arsenault
(#149001)" This partially reverts commit a96121089b9c94e08c6632f91f2dffc73c0ffa28. Drop the IRSymtab changes for now
2025-07-18Revert "RuntimeLibcalls: Add methods to recognize libcall names (#149001)"Nikita Popov
This reverts commit 45477add8dfe9851605697bd908b49f0ec244625. This causes a significant LTO compile-time regression.
2025-07-18RuntimeLibcalls: Add methods to recognize libcall names (#149001)Matt Arsenault
Also replace the current static DenseMap of preserved symbol names in the Symtab hack with this. That was broken statefulness across compiles, so this at least fixes that. However this is still broken, llvm-as shouldn't really depend on the triple.
2025-07-15TableGen: Use StringOffsetTable for RuntimeLibcall names (#148839)Matt Arsenault
2025-07-10ARM: Start moving runtime libcalls into tablegen (#146084)Matt Arsenault
We still need to manually set the calling conventions of some libcalls until the lowering is separated out.
2025-07-08TableGen: Try to fix expensive checks assert on compareMatt Arsenault
Attempt to fix regression after #144978
2025-07-08TableGen: Handle setting runtime libcall calling conventions (#144980)Matt Arsenault
Allow associating a non-default CallingConv with a set of library functions, and applying a default for a SystemLibrary. I also wanted to be able to apply a default calling conv to a RuntimeLibcallImpl, but that turned out to be annoying so leave it for later.
2025-07-08TableGen: Allow defining sets of runtime libraries (#144978)Matt Arsenault
Add a way to define a SystemLibrary for a complete set of libcalls, subdivided by a predicate based on the triple. Libraries can be defined using dag set operations, and the prior default set can be subtracted from and added to (though I think eventually all targets should move to explicit opt-ins. We're still doing things like reporting ppcf128 libcalls as available dy default on all targets). Start migrating some of the easier targets to only use the new system. Targets that don't define a SystemLibrary are still manually mutating a table set to the old defaults.
2025-06-27TableGen: Generate enum for runtime libcall implementations (#144973)Matt Arsenault
Work towards separating the ABI existence of libcalls vs. the lowering selection. Set libcall selection through enums, rather than through raw string names.
2025-06-27TableGen: Add runtime libcall backend (#144972)Matt Arsenault
Replace RuntimeLibcalls.def with a tablegenerated version. This is in preparation for splitting RuntimeLibcalls into two components. For now match the existing functionality.