[clang] [lld] [llvm] [CodeGen] Declare most CommandFlags options in TableGen (PR #242159)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 12 20:04:11 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-wasm
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
Move the 34 RegisterCodeGenFlags options that only
codegen::getTargetOptions and codegen::setFunctionAttributes read into a
private CodeGenToolOptions struct, which codegen::getToolOptions adds to
the tool options, and remove their getters from CommandFlags.h.
getNumOccurrences checks become optional fields.
Like other tool options, these are listed only by -help-hidden.
clang-linker-wrapper, which does not pass the tool options, now rejects
them in -mllvm and --offload-opt.
LLM-aided
---
Patch is 78.12 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/242159.diff
24 Files Affected:
- (modified) clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (+12-10)
- (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+1-1)
- (modified) lld/COFF/LTO.cpp (+2-2)
- (modified) lld/Common/TargetOptionsCommandFlags.cpp (+14-6)
- (modified) lld/ELF/LTO.cpp (+4-4)
- (modified) lld/MachO/LTO.cpp (+3-3)
- (modified) lld/include/lld/Common/TargetOptionsCommandFlags.h (+7-4)
- (modified) lld/wasm/LTO.cpp (+3-3)
- (modified) llvm/include/llvm/CodeGen/CommandFlags.h (+37-99)
- (modified) llvm/lib/CodeGen/CMakeLists.txt (+4)
- (added) llvm/lib/CodeGen/CodeGenToolOptions.td (+93)
- (modified) llvm/lib/CodeGen/CommandFlags.cpp (+103-371)
- (modified) llvm/lib/LTO/LTOCodeGenerator.cpp (+1-1)
- (modified) llvm/lib/LTO/ThinLTOCodeGenerator.cpp (+8-6)
- (modified) llvm/tools/gold/gold-plugin.cpp (+4-4)
- (modified) llvm/tools/llc/lib/NewPMDriver.cpp (+2-1)
- (modified) llvm/tools/llc/lib/llcdriver.cpp (+35-24)
- (modified) llvm/tools/lli/lli.cpp (+13-13)
- (modified) llvm/tools/llvm-lto/llvm-lto.cpp (+6-5)
- (modified) llvm/tools/llvm-lto2/llvm-lto2.cpp (+5-5)
- (modified) llvm/tools/lto/lto.cpp (+1-1)
- (modified) llvm/tools/opt/optdriver.cpp (+17-13)
- (modified) llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn (+6)
- (modified) utils/bazel/llvm-project-overlay/llvm/BUILD.bazel (+10)
``````````diff
diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index 10b973fa8308f..bf9dc2d04f641 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -124,20 +124,22 @@ static std::string OptLLVM(const std::string &IR, CodeGenOptLevel OLvl) {
const TargetOptions Options =
codegen::getTargetOptions(Context.getLibraryOptions(), ModuleTriple);
std::string E;
- const Target *TheTarget =
- TargetRegistry::lookupTarget(codegen::getMArch(), ModuleTriple, E);
+ const Target *TheTarget = TargetRegistry::lookupTarget(
+ codegen::getMArch(Context.getLibraryOptions()), ModuleTriple, E);
if (!TheTarget)
ErrorAndExit(E);
std::unique_ptr<TargetMachine> TM(TheTarget->createTargetMachine(
- M->getTargetTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
- Options, codegen::getExplicitRelocModel(),
- codegen::getExplicitCodeModel(), OLvl));
+ M->getTargetTriple(), codegen::getCPUStr(Context.getLibraryOptions()),
+ codegen::getFeaturesStr(Context.getLibraryOptions()), Options,
+ codegen::getExplicitRelocModel(Context.getLibraryOptions()),
+ codegen::getExplicitCodeModel(Context.getLibraryOptions()), OLvl));
if (!TM)
ErrorAndExit("Could not create target machine");
- codegen::setFunctionAttributes(*M, codegen::getCPUStr(),
- codegen::getFeaturesStr());
+ codegen::setFunctionAttributes(
+ *M, codegen::getCPUStr(Context.getLibraryOptions()),
+ codegen::getFeaturesStr(Context.getLibraryOptions()));
// Add a pass that writes the optimized IR to an output stream
std::string outString;
@@ -171,9 +173,9 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOptLevel OLvl) {
Triple ModuleTriple(M->getTargetTriple());
EngineBuilder builder(std::move(M));
- builder.setMArch(codegen::getMArch());
- builder.setMCPU(codegen::getCPUStr());
- builder.setMAttrs(codegen::getFeatureList());
+ builder.setMArch(codegen::getMArch(Context.getLibraryOptions()));
+ builder.setMCPU(codegen::getCPUStr(Context.getLibraryOptions()));
+ builder.setMAttrs(codegen::getFeatureList(Context.getLibraryOptions()));
builder.setErrorStr(&ErrorMsg);
builder.setEngineKind(EngineKind::JIT);
builder.setMCJITMemoryManager(std::make_unique<SectionMemoryManager>());
diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
index 9229783a3dd23..2451612e0ddb0 100644
--- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
+++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
@@ -406,7 +406,7 @@ createLTO(const cl::LibraryOptionsContext &LibraryOptions,
Args.hasArg(OPT_opt_remarks_with_hotness) || RemarksWithHotness;
Conf.RemarksHotnessThreshold = RemarksHotnessThreshold;
- Conf.MAttrs = llvm::codegen::getMAttrs();
+ Conf.MAttrs = llvm::codegen::getMAttrs(LibraryOptions);
std::optional<CodeGenOptLevel> CGOptLevelOrNone =
CodeGenOpt::parseLevel(Args.getLastArgValue(OPT_O, "2")[0]);
assert(CGOptLevelOrNone && "Invalid optimization level");
diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index 03180209111af..d2519a51efe63 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -84,8 +84,8 @@ lto::Config BitcodeCompiler::createConfig() {
c.DiagHandler = diagnosticHandler;
c.DwoDir = ctx.config.dwoDir.str();
c.OptLevel = ctx.config.ltoo;
- c.CPU = getCPUStr();
- c.MAttrs = getMAttrs();
+ c.CPU = getCPUStr(ctx.config.libraryOptions);
+ c.MAttrs = getMAttrs(ctx.config.libraryOptions);
std::optional<CodeGenOptLevel> optLevelOrNone = CodeGenOpt::getLevel(
ctx.config.ltoCgo.value_or(args::getCGOptLevel(ctx.config.ltoo)));
assert(optLevelOrNone && "Invalid optimization level!");
diff --git a/lld/Common/TargetOptionsCommandFlags.cpp b/lld/Common/TargetOptionsCommandFlags.cpp
index c9adaf115e2b7..8e8552301d2f0 100644
--- a/lld/Common/TargetOptionsCommandFlags.cpp
+++ b/lld/Common/TargetOptionsCommandFlags.cpp
@@ -21,14 +21,22 @@ llvm::ArrayRef<const llvm::cl::LibraryOptions *> lld::getToolOptions() {
return llvm::codegen::getToolOptions();
}
-std::optional<llvm::Reloc::Model> lld::getRelocModelFromCMModel() {
- return llvm::codegen::getExplicitRelocModel();
+std::optional<llvm::Reloc::Model> lld::getRelocModelFromCMModel(
+ const llvm::cl::LibraryOptionsContext &libraryOptions) {
+ return llvm::codegen::getExplicitRelocModel(libraryOptions);
}
-std::optional<llvm::CodeModel::Model> lld::getCodeModelFromCMModel() {
- return llvm::codegen::getExplicitCodeModel();
+std::optional<llvm::CodeModel::Model> lld::getCodeModelFromCMModel(
+ const llvm::cl::LibraryOptionsContext &libraryOptions) {
+ return llvm::codegen::getExplicitCodeModel(libraryOptions);
}
-std::string lld::getCPUStr() { return llvm::codegen::getCPUStr(); }
+std::string
+lld::getCPUStr(const llvm::cl::LibraryOptionsContext &libraryOptions) {
+ return llvm::codegen::getCPUStr(libraryOptions);
+}
-std::vector<std::string> lld::getMAttrs() { return llvm::codegen::getMAttrs(); }
+std::vector<std::string>
+lld::getMAttrs(const llvm::cl::LibraryOptionsContext &libraryOptions) {
+ return llvm::codegen::getMAttrs(libraryOptions);
+}
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 84bae5325afeb..63a5c6130e8e0 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -100,7 +100,7 @@ static lto::Config createConfig(Ctx &ctx) {
c.Options.UniqueBasicBlockSectionNames =
ctx.arg.ltoUniqueBasicBlockSectionNames;
- if (auto relocModel = getRelocModelFromCMModel())
+ if (auto relocModel = getRelocModelFromCMModel(ctx.arg.libraryOptions))
c.RelocModel = *relocModel;
else if (ctx.arg.relocatable)
c.RelocModel = std::nullopt;
@@ -109,12 +109,12 @@ static lto::Config createConfig(Ctx &ctx) {
else
c.RelocModel = Reloc::Static;
- c.CodeModel = getCodeModelFromCMModel();
+ c.CodeModel = getCodeModelFromCMModel(ctx.arg.libraryOptions);
c.DisableVerify = ctx.arg.disableVerify;
c.DiagHandler = diagnosticHandler;
c.OptLevel = ctx.arg.ltoo;
- c.CPU = getCPUStr();
- c.MAttrs = getMAttrs();
+ c.CPU = getCPUStr(ctx.arg.libraryOptions);
+ c.MAttrs = getMAttrs(ctx.arg.libraryOptions);
c.CGOptLevel = ctx.arg.ltoCgo;
c.PTO.LoopVectorization = c.OptLevel > 1;
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index ccdd1a39ffb53..3bb10040f5dee 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -47,9 +47,9 @@ static lto::Config createConfig() {
for (StringRef pluginFn : config->passPlugins)
c.PassPluginFilenames.push_back(std::string(pluginFn));
c.OptPipeline = std::string(config->ltoNewPmPasses);
- c.CodeModel = getCodeModelFromCMModel();
- c.CPU = getCPUStr();
- c.MAttrs = getMAttrs();
+ c.CodeModel = getCodeModelFromCMModel(config->libraryOptions);
+ c.CPU = getCPUStr(config->libraryOptions);
+ c.MAttrs = getMAttrs(config->libraryOptions);
c.DiagHandler = diagnosticHandler;
c.AlwaysEmitRegularLTOObj = !config->ltoObjPath.empty();
diff --git a/lld/include/lld/Common/TargetOptionsCommandFlags.h b/lld/include/lld/Common/TargetOptionsCommandFlags.h
index fc1db20874c1f..2cf913661c0f4 100644
--- a/lld/include/lld/Common/TargetOptionsCommandFlags.h
+++ b/lld/include/lld/Common/TargetOptionsCommandFlags.h
@@ -26,10 +26,13 @@ namespace lld {
llvm::TargetOptions
getTargetOptions(const llvm::cl::LibraryOptionsContext &libraryOptions);
llvm::ArrayRef<const llvm::cl::LibraryOptions *> getToolOptions();
-std::optional<llvm::Reloc::Model> getRelocModelFromCMModel();
-std::optional<llvm::CodeModel::Model> getCodeModelFromCMModel();
-std::string getCPUStr();
-std::vector<std::string> getMAttrs();
+std::optional<llvm::Reloc::Model>
+getRelocModelFromCMModel(const llvm::cl::LibraryOptionsContext &libraryOptions);
+std::optional<llvm::CodeModel::Model>
+getCodeModelFromCMModel(const llvm::cl::LibraryOptionsContext &libraryOptions);
+std::string getCPUStr(const llvm::cl::LibraryOptionsContext &libraryOptions);
+std::vector<std::string>
+getMAttrs(const llvm::cl::LibraryOptionsContext &libraryOptions);
}
#endif
diff --git a/lld/wasm/LTO.cpp b/lld/wasm/LTO.cpp
index 1a88c175ac939..67e462b358b4f 100644
--- a/lld/wasm/LTO.cpp
+++ b/lld/wasm/LTO.cpp
@@ -52,8 +52,8 @@ static lto::Config createConfig() {
c.DisableVerify = ctx.arg.disableVerify;
c.DiagHandler = diagnosticHandler;
c.OptLevel = ctx.arg.ltoo;
- c.CPU = getCPUStr();
- c.MAttrs = getMAttrs();
+ c.CPU = getCPUStr(ctx.arg.libraryOptions);
+ c.MAttrs = getMAttrs(ctx.arg.libraryOptions);
// If shared memory is enabled, ensure the TargetMachine backend is
// instantiated with atomics and bulk-memory features so that empty
@@ -71,7 +71,7 @@ static lto::Config createConfig() {
c.DebugPassManager = ctx.arg.ltoDebugPassManager;
c.AlwaysEmitRegularLTOObj = !ctx.arg.ltoObjPath.empty();
- if (auto relocModel = getRelocModelFromCMModel())
+ if (auto relocModel = getRelocModelFromCMModel(ctx.arg.libraryOptions))
c.RelocModel = *relocModel;
else if (ctx.arg.relocatable)
c.RelocModel = std::nullopt;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h
index 332905197b810..f2a3c05e87dd2 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.h
+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
@@ -16,7 +16,6 @@
#define LLVM_CODEGEN_COMMANDFLAGS_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/FloatingPointMode.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetOptions.h"
@@ -38,107 +37,49 @@ class LibraryOptions;
namespace codegen {
-LLVM_ABI std::string getMArch();
+LLVM_ABI std::string getMArch(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::string getMCPU();
+LLVM_ABI std::string getMCPU(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::string getMTune();
+LLVM_ABI std::string getMTune(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::vector<std::string> getMAttrs();
+LLVM_ABI std::vector<std::string> getMAttrs(const cl::LibraryOptionsContext &C);
-LLVM_ABI Reloc::Model getRelocModel();
-LLVM_ABI std::optional<Reloc::Model> getExplicitRelocModel();
+LLVM_ABI Reloc::Model getRelocModel(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<Reloc::Model>
+getExplicitRelocModel(const cl::LibraryOptionsContext &C);
-LLVM_ABI CodeModel::Model getCodeModel();
-LLVM_ABI std::optional<CodeModel::Model> getExplicitCodeModel();
+LLVM_ABI CodeModel::Model getCodeModel(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<CodeModel::Model>
+getExplicitCodeModel(const cl::LibraryOptionsContext &C);
-LLVM_ABI uint64_t getLargeDataThreshold();
-LLVM_ABI std::optional<uint64_t> getExplicitLargeDataThreshold();
+LLVM_ABI uint64_t getLargeDataThreshold(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<uint64_t>
+getExplicitLargeDataThreshold(const cl::LibraryOptionsContext &C);
-LLVM_ABI llvm::ExceptionHandling getExceptionModel();
+LLVM_ABI std::optional<CodeGenFileType>
+getExplicitFileType(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::optional<CodeGenFileType> getExplicitFileType();
+LLVM_ABI CodeGenFileType getFileType(const cl::LibraryOptionsContext &C);
-LLVM_ABI CodeGenFileType getFileType();
+LLVM_ABI llvm::FloatABI::ABIType
+getFloatABIForCalls(const cl::LibraryOptionsContext &C);
-LLVM_ABI FramePointerKind getFramePointerUsage();
+LLVM_ABI bool getDataSections(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<bool>
+getExplicitDataSections(const cl::LibraryOptionsContext &C);
-LLVM_ABI DenormalMode::DenormalModeKind getDenormalFPMath();
-LLVM_ABI DenormalMode::DenormalModeKind getDenormalFP32Math();
+LLVM_ABI bool getFunctionSections(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<bool>
+getExplicitFunctionSections(const cl::LibraryOptionsContext &C);
-LLVM_ABI llvm::FloatABI::ABIType getFloatABIForCalls();
-
-LLVM_ABI SwiftAsyncFramePointerMode getSwiftAsyncFramePointer();
-
-LLVM_ABI bool getDontPlaceZerosInBSS();
-
-LLVM_ABI bool getEnableGuaranteedTailCallOpt();
-
-LLVM_ABI bool getDisableTailCalls();
-
-LLVM_ABI bool getStackSymbolOrdering();
-
-LLVM_ABI bool getStackRealign();
-
-LLVM_ABI std::string getTrapFuncName();
-
-LLVM_ABI bool getUseCtors();
-
-LLVM_ABI bool getDataSections();
-LLVM_ABI std::optional<bool> getExplicitDataSections();
-
-LLVM_ABI bool getFunctionSections();
-LLVM_ABI std::optional<bool> getExplicitFunctionSections();
-
-LLVM_ABI bool getIgnoreXCOFFVisibility();
-
-LLVM_ABI bool getXCOFFTracebackTable();
-
-LLVM_ABI std::string getBBSections();
-
-LLVM_ABI unsigned getTLSSize();
-
-LLVM_ABI bool getEmulatedTLS();
-LLVM_ABI std::optional<bool> getExplicitEmulatedTLS();
-
-LLVM_ABI bool getEnableTLSDESC();
-LLVM_ABI std::optional<bool> getExplicitEnableTLSDESC();
-
-LLVM_ABI bool getUniqueSectionNames();
-
-LLVM_ABI bool getUniqueBasicBlockSectionNames();
-
-LLVM_ABI bool getSeparateNamedSections();
-
-LLVM_ABI llvm::VectorLibrary getVectorLibrary();
-
-LLVM_ABI bool getEnableStackSizeSection();
-
-LLVM_ABI bool getEnableAddrsig();
-
-LLVM_ABI bool getEnableCallGraphSection();
-
-LLVM_ABI bool getEmitCallSiteInfo();
-
-LLVM_ABI bool getEnableStaticDataPartitioning();
-
-LLVM_ABI bool getEnableDebugEntryValues();
-
-LLVM_ABI bool getForceDwarfFrameSection();
-
-LLVM_ABI bool getXRayFunctionIndex();
-
-LLVM_ABI bool getDebugStrictDwarf();
-
-LLVM_ABI unsigned getAlignLoops();
-
-LLVM_ABI bool getJMCInstrument();
-
-LLVM_ABI bool getXCOFFReadOnlyPointers();
+LLVM_ABI bool getEmulatedTLS(const cl::LibraryOptionsContext &C);
+LLVM_ABI std::optional<bool>
+getExplicitEmulatedTLS(const cl::LibraryOptionsContext &C);
enum SaveStatsMode { None, Cwd, Obj };
-LLVM_ABI SaveStatsMode getSaveStats();
+LLVM_ABI SaveStatsMode getSaveStats(const cl::LibraryOptionsContext &C);
/// Create this object with static storage to register codegen-related command
/// line options.
@@ -162,11 +103,6 @@ struct RegisterSaveStatsFlag {
LLVM_ABI RegisterSaveStatsFlag();
};
-LLVM_ABI bool getEnableBBAddrMap();
-
-LLVM_ABI llvm::BasicBlockSection
-getBBSectionsMode(llvm::TargetOptions &Options);
-
/// Common utility function tightly tied to the options listed here. Initializes
/// a TargetOptions object with CodeGen options and returns it.
/// \p TheTriple is used to determine the default value for options if
@@ -177,13 +113,14 @@ LLVM_ABI TargetOptions
getTargetOptions(const cl::LibraryOptionsContext &LibraryOptions,
const llvm::Triple &TheTriple);
-LLVM_ABI std::string getCPUStr();
+LLVM_ABI std::string getCPUStr(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::string getTuneCPUStr();
+LLVM_ABI std::string getTuneCPUStr(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::string getFeaturesStr();
+LLVM_ABI std::string getFeaturesStr(const cl::LibraryOptionsContext &C);
-LLVM_ABI std::vector<std::string> getFeatureList();
+LLVM_ABI std::vector<std::string>
+getFeatureList(const cl::LibraryOptionsContext &C);
LLVM_ABI void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
@@ -207,13 +144,14 @@ LLVM_ABI Expected<std::unique_ptr<TargetMachine>> createTargetMachineForTriple(
/// Conditionally enables the collection of LLVM statistics during the tool run,
/// based on the value of the flag. Must be called before the tool run to
/// actually collect data.
-LLVM_ABI void MaybeEnableStatistics();
+LLVM_ABI void maybeEnableStatistics(const cl::LibraryOptionsContext &C);
/// Conditionally saves the collected LLVM statistics to the received output
/// file, based on the value of the flag. Should be called after the tool run,
-/// and must follow a call to `MaybeEnableStatistics()` to actually have data to
+/// and must follow a call to `maybeEnableStatistics()` to actually have data to
/// write.
-LLVM_ABI int MaybeSaveStatistics(StringRef OutputFilename, StringRef ToolName);
+LLVM_ABI int maybeSaveStatistics(const cl::LibraryOptionsContext &C,
+ StringRef OutputFilename, StringRef ToolName);
} // namespace codegen
} // namespace llvm
diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index f29fe857b7a71..e604d6c0521a5 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -38,6 +38,9 @@ set(LLVM_TABLEGEN_PROJECT LLVM_HEADERS)
set(LLVM_TARGET_DEFINITIONS CodeGenOptions.td)
llvm_tablegen(CodeGenOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(CodeGenOptionsTableGen)
+set(LLVM_TARGET_DEFINITIONS CodeGenToolOptions.td)
+llvm_tablegen(CodeGenToolOptions.inc -gen-opt-parser-defs)
+add_public_tablegen_target(CodeGenToolOptionsTableGen)
add_llvm_component_library(LLVMCodeGen
AggressiveAntiDepBreaker.cpp
@@ -290,6 +293,7 @@ add_llvm_component_library(LLVMCodeGen
DEPENDS
CodeGenOptionsTableGen
+ CodeGenToolOptionsTableGen
intrinsics_gen
vt_gen
${MLDeps}
diff --git a/llvm/lib/CodeGen/CodeGenToolOptions.td b/llvm/lib/CodeGen/CodeGenToolOptions.td
new file mode 100644
index 0000000000000..accc38d972231
--- /dev/null
+++ b/llvm/lib/CodeGen/CodeGenToolOptions.td
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+include "llvm/Option/LibraryOptions.td"
+
+def CodeGenToolOptions : OptionsStruct;
+
+defm : BoolField<"addrsig", "false",
+ "Emit an address-significance table">;
+defm : ValueField<"align-loops", "unsigned", "0",
+ "Default alignment for loops">;
+defm : BoolField<"basic-block-address-map", "false",
+ "Emit the basic block address map section">;
+defm : ValueField<"basic-block-sections", "StringRef", "\"none\"",
+ "Emit basic blocks into separate sections">;
+defm : BoolField<"call-graph-section", "false",
+ "Emit a call graph section">;
+defm : BoolField<"debug-entry-values", "false",
+ "Enable debug info for the debug entry values">;
+// FIXME: Doesn't have way to specify separate input and output modes.
+defm : OptionalEnumField<"denormal-fp-math", "DenormalMode::DenormalModeKind",
+ "ieee,preserve-sign,positive-zero,dynamic",
+ ["DenormalMode::IEEE", "DenormalMode::PreserveSign", "DenormalMode::PositiveZero", "DenormalMode::Dynamic"],
+ "Select which denormal numbers the code is permitted to require">;
+defm : OptionalEnumField<"denormal-fp-math-f32", "DenormalMode::DenormalModeKind",
+ "ieee,preserve-sign,positive-zero,dynamic",
+ ["DenormalMode::IEEE", "DenormalMode::PreserveSign", "DenormalMode::PositiveZero", "DenormalMode::Dynamic"],
+ "Select which denormal numbers the code is permitted to require for float">;
+defm : OptionalBoolField<"disable-tail-calls",
+ "Never emit tail calls">;
+defm : BoolField<"emit-call-site-info", "false",
+ "Emit call site debug information, if debug information is enabled">;
+defm : BoolField<"enable-jmc-instrument", "false",
+ "Instrument functions with a call to __CheckForDebuggerJustMyCode">;
+defm : OptionalBoolField<"enable-tlsdesc",
+ "Enable the use of TLS Descriptors">;
+defm : EnumField<"exception-model", "ExceptionHandling", "ExceptionHandling::Default",
+ "default,none,dwarf,sjlj,arm,wineh,wasm,emscripten",
+ ["ExceptionHandling::Default", "ExceptionHandling::None", "ExceptionHandling::DwarfCFI", "ExceptionHandling::SjLj", "ExceptionHandling::ARM", "ExceptionHandling::WinEH", "ExceptionHandling::Wasm", "ExceptionHandling::Emscripten"],
+ "Exception model">;
+defm : BoolField<"force-dwarf-frame-section", "false",
+ "Always emit a debug frame section">;
+defm : OptionalEnumField<"frame-pointer", "FramePointerKind",
+ "all,non-leaf,non-leaf-no-reserve,reserved,none",
+ ["FramePointerKind::All", "FramePointerKind::NonLeaf", "FramePointerKind::NonLeafNoReserve", "FramePointerKind::Reserved", "FramePointerKind::None"],
+ "Specify frame pointer elimination optimization">;
+defm : BoolField<"ignore-xcoff-visibility", "false",
+ "Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">;
+def...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/242159
More information about the cfe-commits
mailing list