LLVM 20.0.0git
MCTargetOptionsCommandFlags.cpp
Go to the documentation of this file.
1//===-- MCTargetOptionsCommandFlags.cpp -----------------------*- C++ //-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains machine code-specific flags that are shared between
10// different command line tools.
11//
12//===----------------------------------------------------------------------===//
13
17
18using namespace llvm;
19
20#define MCOPT(TY, NAME) \
21 static cl::opt<TY> *NAME##View; \
22 TY llvm::mc::get##NAME() { \
23 assert(NAME##View && "RegisterMCTargetOptionsFlags not created."); \
24 return *NAME##View; \
25 }
26
27#define MCOPT_EXP(TY, NAME) \
28 MCOPT(TY, NAME) \
29 std::optional<TY> llvm::mc::getExplicit##NAME() { \
30 if (NAME##View->getNumOccurrences()) { \
31 TY res = *NAME##View; \
32 return res; \
33 } \
34 return std::nullopt; \
35 }
36
37MCOPT_EXP(bool, RelaxAll)
38MCOPT(bool, IncrementalLinkerCompatible)
39MCOPT(bool, FDPIC)
40MCOPT(int, DwarfVersion)
41MCOPT(bool, Dwarf64)
42MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
43MCOPT(bool, EmitCompactUnwindNonCanonical)
44MCOPT(bool, ShowMCInst)
45MCOPT(bool, FatalWarnings)
46MCOPT(bool, NoWarn)
47MCOPT(bool, NoDeprecatedWarn)
48MCOPT(bool, NoTypeCheck)
49MCOPT(bool, SaveTempLabels)
50MCOPT(bool, Crel)
51MCOPT(bool, ImplicitMapSyms)
52MCOPT(bool, X86RelaxRelocations)
53MCOPT(bool, X86Sse2Avx)
54MCOPT(std::string, ABIName)
55MCOPT(std::string, AsSecureLogFile)
56
58#define MCBINDOPT(NAME) \
59 do { \
60 NAME##View = std::addressof(NAME); \
61 } while (0)
62
63 static cl::opt<bool> RelaxAll(
64 "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
65 "in the emitted object file"));
66 MCBINDOPT(RelaxAll);
67
68 static cl::opt<bool> IncrementalLinkerCompatible(
69 "incremental-linker-compatible",
71 "When used with filetype=obj, "
72 "emit an object file which can be used with an incremental linker"));
73 MCBINDOPT(IncrementalLinkerCompatible);
74
75 static cl::opt<bool> FDPIC("fdpic", cl::desc("Use the FDPIC ABI"));
76 MCBINDOPT(FDPIC);
77
78 static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
79 cl::init(0));
80 MCBINDOPT(DwarfVersion);
81
82 static cl::opt<bool> Dwarf64(
83 "dwarf64",
84 cl::desc("Generate debugging info in the 64-bit DWARF format"));
85 MCBINDOPT(Dwarf64);
86
87 static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
88 "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
89 cl::init(EmitDwarfUnwindType::Default),
90 cl::values(clEnumValN(EmitDwarfUnwindType::Always, "always",
91 "Always emit EH frame entries"),
92 clEnumValN(EmitDwarfUnwindType::NoCompactUnwind,
93 "no-compact-unwind",
94 "Only emit EH frame entries when compact unwind is "
95 "not available"),
96 clEnumValN(EmitDwarfUnwindType::Default, "default",
97 "Use target platform default")));
98 MCBINDOPT(EmitDwarfUnwind);
99
100 static cl::opt<bool> EmitCompactUnwindNonCanonical(
101 "emit-compact-unwind-non-canonical",
102 cl::desc(
103 "Whether to try to emit Compact Unwind for non canonical entries."),
104 cl::init(
105 false)); // By default, use DWARF for non-canonical personalities.
106 MCBINDOPT(EmitCompactUnwindNonCanonical);
107
108 static cl::opt<bool> ShowMCInst(
109 "asm-show-inst",
110 cl::desc("Emit internal instruction representation to assembly file"));
111 MCBINDOPT(ShowMCInst);
112
113 static cl::opt<bool> FatalWarnings("fatal-warnings",
114 cl::desc("Treat warnings as errors"));
115 MCBINDOPT(FatalWarnings);
116
117 static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
118 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
119 cl::aliasopt(NoWarn));
120 MCBINDOPT(NoWarn);
121
122 static cl::opt<bool> NoDeprecatedWarn(
123 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
124 MCBINDOPT(NoDeprecatedWarn);
125
126 static cl::opt<bool> NoTypeCheck(
127 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
128 MCBINDOPT(NoTypeCheck);
129
130 static cl::opt<bool> SaveTempLabels(
131 "save-temp-labels", cl::desc("Don't discard temporary labels"));
132 MCBINDOPT(SaveTempLabels);
133
134 static cl::opt<bool> Crel("crel",
135 cl::desc("Use CREL relocation format for ELF"));
136 MCBINDOPT(Crel);
137
138 static cl::opt<bool> ImplicitMapSyms(
139 "implicit-mapsyms",
140 cl::desc("Allow mapping symbol at section beginning to be implicit, "
141 "lowering number of mapping symbols at the expense of some "
142 "portability. Recommended for projects that can build all their "
143 "object files using this option"));
144 MCBINDOPT(ImplicitMapSyms);
145
146 static cl::opt<bool> X86RelaxRelocations(
147 "x86-relax-relocations",
148 cl::desc("Emit GOTPCRELX/REX_GOTPCRELX/CODE_4_GOTPCRELX instead of "
149 "GOTPCREL on x86-64 ELF"),
150 cl::init(true));
151 MCBINDOPT(X86RelaxRelocations);
152
153 static cl::opt<bool> X86Sse2Avx(
154 "x86-sse2avx", cl::desc("Specify that the assembler should encode SSE "
155 "instructions with VEX prefix"));
156 MCBINDOPT(X86Sse2Avx);
157
158 static cl::opt<std::string> ABIName(
159 "target-abi", cl::Hidden,
160 cl::desc("The name of the ABI to be targeted from the backend."),
161 cl::init(""));
162 MCBINDOPT(ABIName);
163
164 static cl::opt<std::string> AsSecureLogFile(
165 "as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
166 MCBINDOPT(AsSecureLogFile);
167
168#undef MCBINDOPT
169}
170
173 Options.MCRelaxAll = getRelaxAll();
174 Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
175 Options.FDPIC = getFDPIC();
176 Options.Dwarf64 = getDwarf64();
177 Options.DwarfVersion = getDwarfVersion();
178 Options.ShowMCInst = getShowMCInst();
179 Options.ABIName = getABIName();
180 Options.MCFatalWarnings = getFatalWarnings();
181 Options.MCNoWarn = getNoWarn();
182 Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
183 Options.MCNoTypeCheck = getNoTypeCheck();
184 Options.MCSaveTempLabels = getSaveTempLabels();
185 Options.Crel = getCrel();
186 Options.ImplicitMapSyms = getImplicitMapSyms();
187 Options.X86RelaxRelocations = getX86RelaxRelocations();
188 Options.X86Sse2Avx = getX86Sse2Avx();
189 Options.EmitDwarfUnwind = getEmitDwarfUnwind();
190 Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
191 Options.AsSecureLogFile = getAsSecureLogFile();
192
193 return Options;
194}
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:686
static LVOptions Options
Definition: LVOptions.cpp:25
#define MCBINDOPT(NAME)
#define MCOPT(TY, NAME)
#define MCOPT_EXP(TY, NAME)
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:711
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
bool getNoWarn()
bool getIncrementalLinkerCompatible()
int getDwarfVersion()
bool getX86Sse2Avx()
std::string getAsSecureLogFile()
bool getShowMCInst()
MCTargetOptions InitMCTargetOptionsFromFlags()
bool getEmitCompactUnwindNonCanonical()
bool getFatalWarnings()
bool getNoDeprecatedWarn()
bool getNoTypeCheck()
bool getFDPIC()
bool getSaveTempLabels()
EmitDwarfUnwindType getEmitDwarfUnwind()
bool getX86RelaxRelocations()
bool getRelaxAll()
bool getImplicitMapSyms()
std::string getABIName()
bool getDwarf64()
bool getCrel()
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
EmitDwarfUnwindType
Create this object with static storage to register mc-related command line options.