LLVM 24.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 MCSTROPT(NAME) \
28 static cl::opt<std::string> *NAME##View; \
29 StringRef llvm::mc::get##NAME() { \
30 assert(NAME##View && "RegisterMCTargetOptionsFlags not created."); \
31 return *NAME##View; \
32 }
33
34#define MCOPT_EXP(TY, NAME) \
35 MCOPT(TY, NAME) \
36 std::optional<TY> llvm::mc::getExplicit##NAME() { \
37 if (NAME##View->getNumOccurrences()) { \
38 TY res = *NAME##View; \
39 return res; \
40 } \
41 return std::nullopt; \
42 }
43
44MCOPT_EXP(bool, RelaxAll)
45MCOPT(bool, IncrementalLinkerCompatible)
46MCOPT(bool, FDPIC)
47MCOPT(int, DwarfVersion)
48MCOPT(bool, Dwarf64)
49MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
50MCOPT(bool, EmitCompactUnwindNonCanonical)
51MCOPT(bool, EmitSFrameUnwind)
52MCOPT(bool, ShowMCInst)
53MCOPT(bool, FatalWarnings)
54MCOPT(bool, NoWarn)
55MCOPT(bool, NoDeprecatedWarn)
56MCOPT(bool, NoTypeCheck)
57MCOPT(bool, SaveTempLabels)
58MCOPT(bool, Crel)
59MCOPT(bool, ImplicitMapSyms)
60MCOPT(bool, X86RelaxRelocations)
61MCOPT(bool, X86Sse2Avx)
62MCOPT(bool, DisableIntegratedAS)
63MCOPT(RelocSectionSymType, RelocSectionSym)
64MCOPT(bool, LargeEHEncoding)
65MCSTROPT(ABIName)
66MCSTROPT(AsSecureLogFile)
67
69#define MCBINDOPT(NAME) \
70 do { \
71 NAME##View = std::addressof(NAME); \
72 } while (0)
73
74 static cl::opt<bool> RelaxAll(
75 "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
76 "in the emitted object file"));
77 MCBINDOPT(RelaxAll);
78
79 static cl::opt<bool> IncrementalLinkerCompatible(
80 "incremental-linker-compatible",
82 "When used with filetype=obj, "
83 "emit an object file which can be used with an incremental linker"));
84 MCBINDOPT(IncrementalLinkerCompatible);
85
86 static cl::opt<bool> FDPIC("fdpic", cl::desc("Use the FDPIC ABI"));
87 MCBINDOPT(FDPIC);
88
89 static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
90 cl::init(0));
91 MCBINDOPT(DwarfVersion);
92
93 static cl::opt<bool> Dwarf64(
94 "dwarf64",
95 cl::desc("Generate debugging info in the 64-bit DWARF format"));
96 MCBINDOPT(Dwarf64);
97
98 static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
99 "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
102 "Always emit EH frame entries"),
104 "no-compact-unwind",
105 "Only emit EH frame entries when compact unwind is "
106 "not available"),
108 "Force compact unwind to reference DWARF"),
110 "Use target platform default")));
111 MCBINDOPT(EmitDwarfUnwind);
112
113 static cl::opt<bool> EmitCompactUnwindNonCanonical(
114 "emit-compact-unwind-non-canonical",
115 cl::desc(
116 "Whether to try to emit Compact Unwind for non canonical entries."),
117 cl::init(
118 false)); // By default, use DWARF for non-canonical personalities.
119 MCBINDOPT(EmitCompactUnwindNonCanonical);
120
121 static cl::opt<bool> EmitSFrameUnwind(
122 "gsframe", cl::desc("Whether to emit .sframe unwind sections."),
123 cl::init(false));
124 MCBINDOPT(EmitSFrameUnwind);
125
126 static cl::opt<bool> ShowMCInst(
127 "asm-show-inst",
128 cl::desc("Emit internal instruction representation to assembly file"));
129 MCBINDOPT(ShowMCInst);
130
131 static cl::opt<bool> FatalWarnings("fatal-warnings",
132 cl::desc("Treat warnings as errors"));
133 MCBINDOPT(FatalWarnings);
134
135 static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
136 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
137 cl::aliasopt(NoWarn));
138 MCBINDOPT(NoWarn);
139
140 static cl::opt<bool> NoDeprecatedWarn(
141 "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
142 MCBINDOPT(NoDeprecatedWarn);
143
144 static cl::opt<bool> NoTypeCheck(
145 "no-type-check", cl::desc("Suppress type errors (Wasm)"));
146 MCBINDOPT(NoTypeCheck);
147
148 static cl::opt<bool> SaveTempLabels(
149 "save-temp-labels", cl::desc("Don't discard temporary labels"));
150 MCBINDOPT(SaveTempLabels);
151
152 static cl::opt<bool> Crel("crel",
153 cl::desc("Use CREL relocation format for ELF"));
154 MCBINDOPT(Crel);
155
156 static cl::opt<bool> ImplicitMapSyms(
157 "implicit-mapsyms",
158 cl::desc("Allow mapping symbol at section beginning to be implicit, "
159 "lowering number of mapping symbols at the expense of some "
160 "portability. Recommended for projects that can build all their "
161 "object files using this option"));
162 MCBINDOPT(ImplicitMapSyms);
163
164 static cl::opt<bool> X86RelaxRelocations(
165 "x86-relax-relocations",
166 cl::desc("Emit GOTPCRELX/REX_GOTPCRELX/CODE_4_GOTPCRELX instead of "
167 "GOTPCREL on x86-64 ELF"),
168 cl::init(true));
169 MCBINDOPT(X86RelaxRelocations);
170
171 static cl::opt<bool> X86Sse2Avx(
172 "x86-sse2avx", cl::desc("Specify that the assembler should encode SSE "
173 "instructions with VEX prefix"));
174 MCBINDOPT(X86Sse2Avx);
175
176 static cl::opt<bool> DisableIntegratedAS(
177 "no-integrated-as", cl::desc("Disable integrated assembler"),
178 cl::init(false));
179 MCBINDOPT(DisableIntegratedAS);
180
181 static cl::opt<RelocSectionSymType> RelocSectionSym(
182 "reloc-section-sym",
183 cl::desc("Control section symbol conversion for relocations"),
187 "Use section symbols for all eligible local symbols"),
189 "Only use section symbols for internal local symbols"),
191 "Never use section symbols")));
192 MCBINDOPT(RelocSectionSym);
193
194 static cl::opt<bool> LargeEHEncoding(
195 "large-eh-encoding",
196 cl::desc("Force 8-byte (sdata8) pointer encodings for ELF "
197 "exception-handling sections to avoid relocation overflows in "
198 "large binaries (x86_64: FDE/personality/LSDA/TType; "
199 "AArch64/PPC64: FDE only, the rest are already sdata8)"));
200 MCBINDOPT(LargeEHEncoding);
201
202 static cl::opt<std::string> ABIName(
203 "target-abi",
204 cl::desc("The name of the ABI to be targeted from the backend."),
205 cl::init(""));
206 MCBINDOPT(ABIName);
207
208 static cl::opt<std::string> AsSecureLogFile(
209 "as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
210 MCBINDOPT(AsSecureLogFile);
211
212#undef MCBINDOPT
213}
214
217 Options.MCRelaxAll = getRelaxAll();
218 Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
219 Options.FDPIC = getFDPIC();
220 Options.Dwarf64 = getDwarf64();
221 Options.DwarfVersion = getDwarfVersion();
222 Options.ShowMCInst = getShowMCInst();
223 Options.ABIName = getABIName();
224 Options.MCFatalWarnings = getFatalWarnings();
225 Options.MCNoWarn = getNoWarn();
226 Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
227 Options.MCNoTypeCheck = getNoTypeCheck();
228 Options.MCSaveTempLabels = getSaveTempLabels();
229 Options.Crel = getCrel();
230 Options.ImplicitMapSyms = getImplicitMapSyms();
231 Options.X86RelaxRelocations = getX86RelaxRelocations();
232 Options.X86Sse2Avx = getX86Sse2Avx();
233 Options.DisableIntegratedAS = getDisableIntegratedAS();
234 Options.RelocSectionSym = getRelocSectionSym();
235 Options.LargeEHEncoding = getLargeEHEncoding();
236 Options.EmitDwarfUnwind = getEmitDwarfUnwind();
237 Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
238 Options.EmitSFrameUnwind = getEmitSFrameUnwind();
239 Options.AsSecureLogFile = getAsSecureLogFile();
240
241 return Options;
242}
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static LVOptions Options
Definition LVOptions.cpp:25
#define MCBINDOPT(NAME)
#define MCOPT(TY, NAME)
#define MCSTROPT(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 ...
initializer< Ty > init(const Ty &Val)
LLVM_ABI bool getEmitCompactUnwindNonCanonical()
LLVM_ABI bool getDwarf64()
LLVM_ABI bool getLargeEHEncoding()
LLVM_ABI bool getEmitSFrameUnwind()
LLVM_ABI bool getX86Sse2Avx()
LLVM_ABI MCTargetOptions InitMCTargetOptionsFromFlags()
LLVM_ABI bool getIncrementalLinkerCompatible()
LLVM_ABI bool getDisableIntegratedAS()
LLVM_ABI bool getNoDeprecatedWarn()
LLVM_ABI bool getNoTypeCheck()
LLVM_ABI EmitDwarfUnwindType getEmitDwarfUnwind()
LLVM_ABI bool getSaveTempLabels()
LLVM_ABI bool getImplicitMapSyms()
LLVM_ABI bool getFDPIC()
LLVM_ABI bool getCrel()
LLVM_ABI bool getFatalWarnings()
LLVM_ABI bool getRelaxAll()
LLVM_ABI bool getX86RelaxRelocations()
LLVM_ABI bool getShowMCInst()
LLVM_ABI StringRef getAsSecureLogFile()
LLVM_ABI RelocSectionSymType getRelocSectionSym()
LLVM_ABI int getDwarfVersion()
LLVM_ABI StringRef getABIName()
LLVM_ABI bool getNoWarn()
This is an optimization pass for GlobalISel generic memory operations.
RelocSectionSymType
EmitDwarfUnwindType