summaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/OptParserEmitter.cpp
AgeCommit message (Collapse)Author
2024-09-24[LLVM][TableGen] Rename Option emitter files (#109216)Rahul Joshi
Rename OptXXXEmitter.cpp to OptionXXXEmitter.cpp to have a less ambiguous name, as `Opt` could also mean optimization.
2024-09-13[LLVM][Option] Refactor option name comparison (#108219)Rahul Joshi
Move common functions shared by TableGen Option Emitter and Options library to Support: - Move `StrCmpOptionName` and base it on the existing version in OptTable.cpp, with an additional mode to control fall back to case insensitive comparison. - Add `StrCmpOptionPrefixes` to compare prefixes and use zip() to iterate through lists of prefixes. - Rename `CompareOptionRecords` to less ambiguous name `IsOptionRecordLess`. - Merge 2 back-to-back ifs with same condition in `IsOptionRecordLess`. Fixes https://github.com/llvm/llvm-project/issues/107723
2024-09-11[TableGen] Migrate Option Emitters to const RecordKeeper (#107696)Rahul Joshi
Migrate Opt/OptRST Emitters to 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-08-25[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)Kazu Hirata
S.substr(N) is simpler than S.slice(N, StringRef::npos) and S.slice(N, S.size()). Also, substr is probably better recognizable than slice thanks to std::string_view::substr.
2024-04-05Reland "[flang][clang] Add Visibility specific help text for options (#81869)"David Spickett
This reverts commit 67d20412b448533c77f54ac7a1e5d0775d273729. This includes fixes for clanginstallapi.
2024-04-05Revert "[flang][clang] Add Visibility specific help text for options (#81869)"David Spickett
This reverts commit 7e958f64efea6cb824e96ace51e021afbc150922. Failing on multiple bots.
2024-04-05[flang][clang] Add Visibility specific help text for options (#81869)David Spickett
And use it to print the correct default OpenMP version for flang and flang -fc1. This change adds an optional `HelpTextsForVariants` to options. This allows you to change the help text that gets shown in documentation and `--help` based on the program its being generated for. As `OptTable` needs to be constexpr compatible, I have used a std::array of help text variants. Each entry is: (list of visibilities) - > help text string So for the OpenMP version we have (flang, fc1) -> "OpenMP version for flang is...". So you can have multiple visibilities use the same string. The number of entries is currently set to 1, and the number of visibilities per entry is 2, because that's the maximum we need for now. The code is written so we can increase these numbers later, and the unused elements will be initialised. I have not applied this to group descriptions just because I don't know of one that needs changing. It could easily be enabled for those too if needed. There are minor changes to them just to get it all to compile. This approach of storing many help strings per option in the 1 driver library seemed preferable to making a whole new library for Flang (even if that would mostly be including stuff from Clang).
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-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
2023-08-15Reapply "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner
This reverts commit 4e3b89483a6922d3f48670bb1c50a37f342918c6, with fixes for places I'd missed updating in lld and lldb. I've also renamed OptionVisibility::Default to "DefaultVis" to avoid ambiguity since the undecorated name has to be available anywhere Options.inc is included. Original message follows: This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-14Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner
this is failing on bots, reverting to investigate. This reverts commit a16104e6da6f36f3d72dbf53d10ba56495a0d65a.
2023-08-14[Option] Add "Visibility" field and clone the OptTable APIs to use itJustin Bogner
This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-09[llvm] Construct option's prefixed name at compile-timeJan Svoboda
Some Clang command-line handling code could benefit from the option's prefixed name being a `StringLiteral`. This patch changes the `llvm::opt` TableGen backend to generate and emit that into the .inc file. Depends on D157028. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157029
2023-04-21[Coverity] Fix uninitialized scalar members in TableGenAkshay Khadse
This change fixes static code analysis warnings Reviewed By: skan Differential Revision: https://reviews.llvm.org/D148815
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-01-12[OptTable] Precompute OptTable prefixes union table through tablegenserge-sans-paille
This avoid rediscovering this table when reading each options, providing a sensible 2% speedup when processing and empty file, and a measurable speedup on typical workloads, see: This is optional, the legacy, on-the-fly, approach can still be used through the GenericOptTable class, while the new one is used through PrecomputedOptTable. https://llvm-compile-time-tracker.com/compare.php?from=4da6cb3202817ee2897d6b690e4af950459caea4&to=19a492b704e8f5c1dea120b9c0d3859bd78796be&stat=instructions:u Differential Revision: https://reviews.llvm.org/D140800
2023-01-12[OptTable] Make ValuesCode initialisation of Options constexprserge-sans-paille
Current implementation requires a copy of the initialization array to a vector to be able to modify their Values field. This is inefficient: it requires a large copy to update a value, while TableGen has all information to avoid this overwrite. Modify TableGen to emit the Values code and use it to perform the initialisation. The impact on performance is not amazing compared to the actual compilation, but still noticeable: https://llvm-compile-time-tracker.com/compare.php?from=d9ab3e82f30d646deff054230b0c742704a1cf26&to=f2b37fb65d5149f70b43d1801beb5239285a2a20&stat=instructions:u Differential Revision: https://reviews.llvm.org/D140699
2022-12-27[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This a recommit of e953ae5bbc313fd0cc980ce021d487e5b5199ea4 and the subsequent fixes caa713559bd38f337d7d35de35686775e8fb5175 and 06b90e2e9c991e211fecc97948e533320a825470. The above patchset caused some version of GCC to take eons to compile clang/lib/Basic/Targets/AArch64.cpp, as spotted in aa171833ab0017d9732e82b8682c9848ab25ff9e. The fix is to make BuiltinInfo tables a compilation unit static variable, instead of a private static variable. Differential Revision: https://reviews.llvm.org/D139881
2022-12-25Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵Vitaly Buka
builtin and call information" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4 (part 2)" Revert "Fix lldb option handling since e953ae5bbc313fd0cc980ce021d487e5b5199ea4" GCC build hangs on this bot https://lab.llvm.org/buildbot/#/builders/37/builds/19104 compiling CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.d The bot uses GNU 11.3.0, but I can reproduce locally with gcc (Debian 12.2.0-3) 12.2.0. This reverts commit caa713559bd38f337d7d35de35686775e8fb5175. This reverts commit 06b90e2e9c991e211fecc97948e533320a825470. This reverts commit e953ae5bbc313fd0cc980ce021d487e5b5199ea4.
2022-12-24[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 that into account a GGC issue (probably https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92181) when dealing with intiailizer_list and constant expressions. Workaround this by avoiding initializer list, at the expense of a temporary plain old array. Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille
builtin and call information" There are still remaining issues with GCC 12, see for instance https://lab.llvm.org/buildbot/#/builders/93/builds/12669 This reverts commit 5ce4e92264102de21760c94db9166afe8f71fcf6.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u This is a recommit of 719d98dfa841c522d8d452f0685e503538415a53 with a change to llvm/utils/TableGen/OptParserEmitter.cpp to cope with GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 Differential Revision: https://reviews.llvm.org/D139881
2022-12-23Revert "[clang] Use a StringRef instead of a raw char pointer to store ↵serge-sans-paille
builtin and call information" Failing builds: https://lab.llvm.org/buildbot#builders/9/builds/19030 This is GCC specific and has been reported upstream: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 This reverts commit 719d98dfa841c522d8d452f0685e503538415a53.
2022-12-23[clang] Use a StringRef instead of a raw char pointer to store builtin and ↵serge-sans-paille
call information This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139881
2022-12-09Recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e - part 2serge-sans-paille
Differential Revision: https://reviews.llvm.org/D139274
2022-12-09Revert "Recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e - part 2"serge-sans-paille
This reverts commit 4faf00006cf989f3ae212912994022c0486a2dc4.
2022-12-09Recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e - part 2serge-sans-paille
Differential Revision: https://reviews.llvm.org/D139274
2022-12-08[llvm] Call reserve before push_back in a loopGregory Alfonso
It is generally good practice, if you know how big the vector is going to be in the end, to reserve before continually calling "push_back" or "emplace_back" Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D139483
2022-12-07Revert "Store OptTable::Info::Name as a StringRef"serge-sans-paille
Another revert, for another set of issues I don't reproduce locally... see https://lab.llvm.org/buildbot/#/builders/139/builds/32327 This reverts commit bdfa3100dc3ea9e9ce4d3d4100ea6bb4c3fa2b81.
2022-12-07Store OptTable::Info::Name as a StringRefserge-sans-paille
This is a recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e, with a few cleanups. This avoids implicit conversion to StringRef at several points, which in turns avoid redundant calls to strlen. As a side effect, this greatly simplifies the implementation of StrCmpOptionNameIgnoreCase. It also eventually gives a consistent, humble speedup in compilation time (timing updated since original commit). https://llvm-compile-time-tracker.com/compare.php?from=76fcfea283472a80356d87c89270b0e2d106b54c&to=b70eb1f347f22fe4d2977360c4ed701eabc43994&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139274
2022-12-06Revert "Store OptTable::Info::Name as a StringRef"Douglas Yung
This reverts commit 5951b0bb23f3265bea16f28c2af9d278b9d829c6. This is causing 24 test failures on the PS4 linux bot: https://lab.llvm.org/buildbot/#/builders/139/builds/32263
2022-12-06Store OptTable::Info::Name as a StringRefserge-sans-paille
This is a recommit of 8ae18303f97d5dcfaecc90b4d87effb2011ed82e, with a few cleanups. This avoids implicit conversion to StringRef at several points, which in turns avoid redundant calls to strlen. As a side effect, this greatly simplifies the implementation of StrCmpOptionNameIgnoreCase. It also eventually gives a consistent, humble speedup in compilation time (timing updated since original commit). https://llvm-compile-time-tracker.com/compare.php?from=de4b6a1bc64db33643f001ad45fae7b92b4a4688&to=c23a93d1292052b4be2fbe8c586fa31143d0c7ed&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139274
2022-12-06Revert "Store OptTable::Info::Name as a StringRef"Nico Weber
This reverts commit 8ae18303f97d5dcfaecc90b4d87effb2011ed82e. Breaks buildling lldb, see https://reviews.llvm.org/D139274#3974171
2022-12-06Revert "Quick fix to unbreak tblgen past 8ae18303f97d"Nico Weber
This reverts commit e50a60d7349de151bd2b06d85a79201ebc372d8a. Prerequisite for reverting 8ae18303f97d5.
2022-12-06Quick fix to unbreak tblgen past 8ae18303f97dBenjamin Kramer
llvm/tools/llvm-objdump/llvm-objdump.cpp:128:38: error: constexpr variable 'ObjdumpInfoTable' must be initialized by a constant expression static constexpr opt::OptTable::Info ObjdumpInfoTable[] = { ^ ~ ObjdumpOpts.inc:30:45: note: non-constexpr function 'substr' cannot be used in a constant expression OPTION(prefix_0, llvm::StringRef("<input>").substr(0), INPUT, Input, INVALID, INVALID, nullptr, 0, 0, nullptr, nullptr, nullptr) ^
2022-12-06Store OptTable::Info::Name as a StringRefserge-sans-paille
This avoids implicit conversion to StringRef at several points, which in turns avoid redundant calls to strlen. As a side effect, this greatly simplifies the implementation of StrCmpOptionNameIgnoreCase. It also eventually gives a consistent, humble speedup in compilation time. https://llvm-compile-time-tracker.com/compare.php?from=5f5b942823474e98e43a27d515a87ce140396c53&to=60e13b778119fc32d50dc38ff1a564a87146e9c6&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139274
2022-12-06[TableGen] llvm::Optional => std::optionalFangrui Song
2022-11-26[TableGen] Use std::size (NFC)Kazu Hirata
std::size, introduced in C++17, allows us to directly obtain the number of elements of an array.
2022-06-18[llvm] Use value_or instead of getValueOr (NFC)Kazu Hirata
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
2021-07-09PR51018: A few more explicit conversions from SmallString to StringRefDavid Blaikie
Follow-up to 1def2579e10dd84405465f403e8c31acebff0c97 with a few more obscure cases.
2021-01-17[TableGen] Drop redundant const from return types (NFC)Kazu Hirata
Identified with readability-const-return-type.
2021-01-11Reapply "[clang][cli] Port DiagnosticOpts to new option parsing system"Jan Svoboda
This reverts commit 8e3e148c This commit fixes two issues with the original patch: * The sanitizer build bot reported an uninitialized value. This was caused by normalizeStringIntegral not returning None on failure. * Some build bots complained about inaccessible keypaths. To mitigate that, "this->" was added back to the keypath to restore the previous behavior.
2021-01-08Revert "[clang][cli] Port DiagnosticOpts to new option parsing system"Jan Svoboda
This reverts commit 8e3230ff
2021-01-08[clang][cli] Port DiagnosticOpts to new option parsing systemJan Svoboda
This patch introduces additional infrastructure necessary to accommodate DiagnosticOptions. DiagnosticOptions are unique in that they are parsed by the same function in cc1 AND in the Clang driver. The call to the parsing function from the driver occurs early on in the compilation process, where no proper DiagnosticEngine exists, because the diagnostic options (passed through command line) are not known yet. To preserve the current behavior, we need to be able to selectively parse: * all options (for -cc1), * only diagnostic options (for driver). This patch achieves that in the following way: * new MacroPrefix field is added to the Option TableGen class, * new IsDiag TableGen mixin sets MacroPrefix to "DIAG_", * TableGen backend serializes option records into a macro with the prefix, * CompilerInvocation parse/generate methods define the [DIAG_]OPTION_WITH_MARSHALLING macros to handle diagnostic options separately. Depends on D93700, D93701 & D93702. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D84673
2021-01-07Reapply "[clang][cli] Allow users to specify a conditional to prevent ↵Jan Svoboda
parsing options with MarshallingInfo" This reverts commit d0fa7a05 and fixes failing OptionMarshallingTest by adding the SHOULD_PARSE macro argument
2021-01-07Revert "[clang][cli] Allow users to specify a conditional to prevent parsing ↵Jan Svoboda
options with MarshallingInfo" This reverts commit 77db83ae
2021-01-07[clang][cli] Allow users to specify a conditional to prevent parsing options ↵Jan Svoboda
with MarshallingInfo Depends on D84189 & D93540. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D84674