llvm.org GIT mirror llvm / 461bf52
Rename *CommandFlags.def to *CommandFlags.inc These aren't the .def style files used in LLVM that require a macro defined before their inclusion - they're just basic non-modular includes to stamp out command line flag variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329840 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 1 year, 4 months ago
19 changed file(s) with 485 addition(s) and 486 deletion(s). Raw diff Collapse all Expand all
+0
-389
include/llvm/CodeGen/CommandFlags.def less more
None //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains codegen-specific flags that are shared between different
10 // command line tools. The tools "llc" and "opt" both use this file to prevent
11 // flag duplication.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/ADT/StringExtras.h"
16 #include "llvm/IR/Instructions.h"
17 #include "llvm/IR/Intrinsics.h"
18 #include "llvm/IR/Module.h"
19 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
20 #include "llvm/MC/SubtargetFeature.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Support/CommandLine.h"
23 #include "llvm/Support/Host.h"
24 #include "llvm/Target/TargetMachine.h"
25 #include "llvm/Target/TargetOptions.h"
26 #include
27 using namespace llvm;
28
29 static cl::opt
30 MArch("march",
31 cl::desc("Architecture to generate code for (see --version)"));
32
33 static cl::opt
34 MCPU("mcpu",
35 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
36 cl::value_desc("cpu-name"), cl::init(""));
37
38 static cl::list
39 MAttrs("mattr", cl::CommaSeparated,
40 cl::desc("Target specific attributes (-mattr=help for details)"),
41 cl::value_desc("a1,+a2,-a3,..."));
42
43 static cl::opt RelocModel(
44 "relocation-model", cl::desc("Choose relocation model"),
45 cl::values(
46 clEnumValN(Reloc::Static, "static", "Non-relocatable code"),
47 clEnumValN(Reloc::PIC_, "pic",
48 "Fully relocatable, position independent code"),
49 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
50 "Relocatable external references, non-relocatable code"),
51 clEnumValN(Reloc::ROPI, "ropi",
52 "Code and read-only data relocatable, accessed PC-relative"),
53 clEnumValN(
54 Reloc::RWPI, "rwpi",
55 "Read-write data relocatable, accessed relative to static base"),
56 clEnumValN(Reloc::ROPI_RWPI, "ropi-rwpi",
57 "Combination of ropi and rwpi")));
58
59 LLVM_ATTRIBUTE_UNUSED static Optional getRelocModel() {
60 if (RelocModel.getNumOccurrences()) {
61 Reloc::Model R = RelocModel;
62 return R;
63 }
64 return None;
65 }
66
67 static cl::opt TMModel(
68 "thread-model", cl::desc("Choose threading model"),
69 cl::init(ThreadModel::POSIX),
70 cl::values(clEnumValN(ThreadModel::POSIX, "posix", "POSIX thread model"),
71 clEnumValN(ThreadModel::Single, "single",
72 "Single thread model")));
73
74 static cl::opt CMModel(
75 "code-model", cl::desc("Choose code model"),
76 cl::values(clEnumValN(CodeModel::Small, "small", "Small code model"),
77 clEnumValN(CodeModel::Kernel, "kernel", "Kernel code model"),
78 clEnumValN(CodeModel::Medium, "medium", "Medium code model"),
79 clEnumValN(CodeModel::Large, "large", "Large code model")));
80
81 LLVM_ATTRIBUTE_UNUSED static Optional getCodeModel() {
82 if (CMModel.getNumOccurrences()) {
83 CodeModel::Model M = CMModel;
84 return M;
85 }
86 return None;
87 }
88
89 static cl::opt ExceptionModel(
90 "exception-model", cl::desc("exception model"),
91 cl::init(ExceptionHandling::None),
92 cl::values(
93 clEnumValN(ExceptionHandling::None, "default",
94 "default exception handling model"),
95 clEnumValN(ExceptionHandling::DwarfCFI, "dwarf",
96 "DWARF-like CFI based exception handling"),
97 clEnumValN(ExceptionHandling::SjLj, "sjlj", "SjLj exception handling"),
98 clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
99 clEnumValN(ExceptionHandling::WinEH, "wineh",
100 "Windows exception model"),
101 clEnumValN(ExceptionHandling::Wasm, "wasm",
102 "WebAssembly exception handling")));
103
104 static cl::opt FileType(
105 "filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
106 cl::desc(
107 "Choose a file type (not all types are supported by all targets):"),
108 cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
109 "Emit an assembly ('.s') file"),
110 clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
111 "Emit a native object ('.o') file"),
112 clEnumValN(TargetMachine::CGFT_Null, "null",
113 "Emit nothing, for performance testing")));
114
115 static cl::opt
116 DisableFPElim("disable-fp-elim",
117 cl::desc("Disable frame pointer elimination optimization"),
118 cl::init(false));
119
120 static cl::opt EnableUnsafeFPMath(
121 "enable-unsafe-fp-math",
122 cl::desc("Enable optimizations that may decrease FP precision"),
123 cl::init(false));
124
125 static cl::opt EnableNoInfsFPMath(
126 "enable-no-infs-fp-math",
127 cl::desc("Enable FP math optimizations that assume no +-Infs"),
128 cl::init(false));
129
130 static cl::opt EnableNoNaNsFPMath(
131 "enable-no-nans-fp-math",
132 cl::desc("Enable FP math optimizations that assume no NaNs"),
133 cl::init(false));
134
135 static cl::opt EnableNoSignedZerosFPMath(
136 "enable-no-signed-zeros-fp-math",
137 cl::desc("Enable FP math optimizations that assume "
138 "the sign of 0 is insignificant"),
139 cl::init(false));
140
141 static cl::opt
142 EnableNoTrappingFPMath("enable-no-trapping-fp-math",
143 cl::desc("Enable setting the FP exceptions build "
144 "attribute not to use exceptions"),
145 cl::init(false));
146
147 static cl::opt DenormalMode(
148 "denormal-fp-math",
149 cl::desc("Select which denormal numbers the code is permitted to require"),
150 cl::init(FPDenormal::IEEE),
151 cl::values(clEnumValN(FPDenormal::IEEE, "ieee",
152 "IEEE 754 denormal numbers"),
153 clEnumValN(FPDenormal::PreserveSign, "preserve-sign",
154 "the sign of a flushed-to-zero number is preserved "
155 "in the sign of 0"),
156 clEnumValN(FPDenormal::PositiveZero, "positive-zero",
157 "denormals are flushed to positive zero")));
158
159 static cl::opt EnableHonorSignDependentRoundingFPMath(
160 "enable-sign-dependent-rounding-fp-math", cl::Hidden,
161 cl::desc("Force codegen to assume rounding mode can change dynamically"),
162 cl::init(false));
163
164 static cl::opt FloatABIForCalls(
165 "float-abi", cl::desc("Choose float ABI type"), cl::init(FloatABI::Default),
166 cl::values(clEnumValN(FloatABI::Default, "default",
167 "Target default float ABI type"),
168 clEnumValN(FloatABI::Soft, "soft",
169 "Soft float ABI (implied by -soft-float)"),
170 clEnumValN(FloatABI::Hard, "hard",
171 "Hard float ABI (uses FP registers)")));
172
173 static cl::opt FuseFPOps(
174 "fp-contract", cl::desc("Enable aggressive formation of fused FP ops"),
175 cl::init(FPOpFusion::Standard),
176 cl::values(
177 clEnumValN(FPOpFusion::Fast, "fast", "Fuse FP ops whenever profitable"),
178 clEnumValN(FPOpFusion::Standard, "on", "Only fuse 'blessed' FP ops."),
179 clEnumValN(FPOpFusion::Strict, "off",
180 "Only fuse FP ops when the result won't be affected.")));
181
182 static cl::opt DontPlaceZerosInBSS(
183 "nozero-initialized-in-bss",
184 cl::desc("Don't place zero-initialized symbols into bss section"),
185 cl::init(false));
186
187 static cl::opt EnableGuaranteedTailCallOpt(
188 "tailcallopt",
189 cl::desc(
190 "Turn fastcc calls into tail calls by (potentially) changing ABI."),
191 cl::init(false));
192
193 static cl::opt DisableTailCalls("disable-tail-calls",
194 cl::desc("Never emit tail calls"),
195 cl::init(false));
196
197 static cl::opt StackSymbolOrdering("stack-symbol-ordering",
198 cl::desc("Order local stack symbols."),
199 cl::init(true));
200
201 static cl::opt
202 OverrideStackAlignment("stack-alignment",
203 cl::desc("Override default stack alignment"),
204 cl::init(0));
205
206 static cl::opt
207 StackRealign("stackrealign",
208 cl::desc("Force align the stack to the minimum alignment"),
209 cl::init(false));
210
211 static cl::opt TrapFuncName(
212 "trap-func", cl::Hidden,
213 cl::desc("Emit a call to trap function rather than a trap instruction"),
214 cl::init(""));
215
216 static cl::opt UseCtors("use-ctors",
217 cl::desc("Use .ctors instead of .init_array."),
218 cl::init(false));
219
220 static cl::opt RelaxELFRelocations(
221 "relax-elf-relocations",
222 cl::desc("Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
223 cl::init(false));
224
225 static cl::opt DataSections("data-sections",
226 cl::desc("Emit data into separate sections"),
227 cl::init(false));
228
229 static cl::opt
230 FunctionSections("function-sections",
231 cl::desc("Emit functions into separate sections"),
232 cl::init(false));
233
234 static cl::opt EmulatedTLS("emulated-tls",
235 cl::desc("Use emulated TLS model"),
236 cl::init(false));
237
238 static cl::opt
239 UniqueSectionNames("unique-section-names",
240 cl::desc("Give unique names to every section"),
241 cl::init(true));
242
243 static cl::opt
244 EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"),
245 cl::init(EABI::Default),
246 cl::values(clEnumValN(EABI::Default, "default",
247 "Triple default EABI version"),
248 clEnumValN(EABI::EABI4, "4", "EABI version 4"),
249 clEnumValN(EABI::EABI5, "5", "EABI version 5"),
250 clEnumValN(EABI::GNU, "gnu", "EABI GNU")));
251
252 static cl::opt DebuggerTuningOpt(
253 "debugger-tune", cl::desc("Tune debug info for a particular debugger"),
254 cl::init(DebuggerKind::Default),
255 cl::values(clEnumValN(DebuggerKind::GDB, "gdb", "gdb"),
256 clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
257 clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
258
259 static cl::opt EnableStackSizeSection(
260 "stack-size-section",
261 cl::desc("Emit a section containing stack size metadata"), cl::init(false));
262
263 // Common utility function tightly tied to the options listed here. Initializes
264 // a TargetOptions object with CodeGen flags and returns it.
265 static TargetOptions InitTargetOptionsFromCodeGenFlags() {
266 TargetOptions Options;
267 Options.AllowFPOpFusion = FuseFPOps;
268 Options.UnsafeFPMath = EnableUnsafeFPMath;
269 Options.NoInfsFPMath = EnableNoInfsFPMath;
270 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
271 Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
272 Options.NoTrappingFPMath = EnableNoTrappingFPMath;
273 Options.FPDenormalMode = DenormalMode;
274 Options.HonorSignDependentRoundingFPMathOption =
275 EnableHonorSignDependentRoundingFPMath;
276 if (FloatABIForCalls != FloatABI::Default)
277 Options.FloatABIType = FloatABIForCalls;
278 Options.NoZerosInBSS = DontPlaceZerosInBSS;
279 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
280 Options.StackAlignmentOverride = OverrideStackAlignment;
281 Options.StackSymbolOrdering = StackSymbolOrdering;
282 Options.UseInitArray = !UseCtors;
283 Options.RelaxELFRelocations = RelaxELFRelocations;
284 Options.DataSections = DataSections;
285 Options.FunctionSections = FunctionSections;
286 Options.UniqueSectionNames = UniqueSectionNames;
287 Options.EmulatedTLS = EmulatedTLS;
288 Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
289 Options.ExceptionModel = ExceptionModel;
290 Options.EmitStackSizeSection = EnableStackSizeSection;
291
292 Options.MCOptions = InitMCTargetOptionsFromFlags();
293
294 Options.ThreadModel = TMModel;
295 Options.EABIVersion = EABIVersion;
296 Options.DebuggerTuning = DebuggerTuningOpt;
297
298 return Options;
299 }
300
301 LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
302 // If user asked for the 'native' CPU, autodetect here. If autodection fails,
303 // this will set the CPU to an empty string which tells the target to
304 // pick a basic default.
305 if (MCPU == "native")
306 return sys::getHostCPUName();
307
308 return MCPU;
309 }
310
311 LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
312 SubtargetFeatures Features;
313
314 // If user asked for the 'native' CPU, we need to autodetect features.
315 // This is necessary for x86 where the CPU might not support all the
316 // features the autodetected CPU name lists in the target. For example,
317 // not all Sandybridge processors support AVX.
318 if (MCPU == "native") {
319 StringMap HostFeatures;
320 if (sys::getHostCPUFeatures(HostFeatures))
321 for (auto &F : HostFeatures)
322 Features.AddFeature(F.first(), F.second);
323 }
324
325 for (unsigned i = 0; i != MAttrs.size(); ++i)
326 Features.AddFeature(MAttrs[i]);
327
328 return Features.getString();
329 }
330
331 LLVM_ATTRIBUTE_UNUSED static std::vector getFeatureList() {
332 SubtargetFeatures Features;
333
334 // If user asked for the 'native' CPU, we need to autodetect features.
335 // This is necessary for x86 where the CPU might not support all the
336 // features the autodetected CPU name lists in the target. For example,
337 // not all Sandybridge processors support AVX.
338 if (MCPU == "native") {
339 StringMap HostFeatures;
340 if (sys::getHostCPUFeatures(HostFeatures))
341 for (auto &F : HostFeatures)
342 Features.AddFeature(F.first(), F.second);
343 }
344
345 for (unsigned i = 0; i != MAttrs.size(); ++i)
346 Features.AddFeature(MAttrs[i]);
347
348 return Features.getFeatures();
349 }
350
351 /// \brief Set function attributes of functions in Module M based on CPU,
352 /// Features, and command line flags.
353 LLVM_ATTRIBUTE_UNUSED static void
354 setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
355 for (auto &F : M) {
356 auto &Ctx = F.getContext();
357 AttributeList Attrs = F.getAttributes();
358 AttrBuilder NewAttrs;
359
360 if (!CPU.empty())
361 NewAttrs.addAttribute("target-cpu", CPU);
362 if (!Features.empty())
363 NewAttrs.addAttribute("target-features", Features);
364 if (DisableFPElim.getNumOccurrences() > 0)
365 NewAttrs.addAttribute("no-frame-pointer-elim",
366 DisableFPElim ? "true" : "false");
367 if (DisableTailCalls.getNumOccurrences() > 0)
368 NewAttrs.addAttribute("disable-tail-calls",
369 toStringRef(DisableTailCalls));
370 if (StackRealign)
371 NewAttrs.addAttribute("stackrealign");
372
373 if (TrapFuncName.getNumOccurrences() > 0)
374 for (auto &B : F)
375 for (auto &I : B)
376 if (auto *Call = dyn_cast(&I))
377 if (const auto *F = Call->getCalledFunction())
378 if (F->getIntrinsicID() == Intrinsic::debugtrap ||
379 F->getIntrinsicID() == Intrinsic::trap)
380 Call->addAttribute(
381 llvm::AttributeList::FunctionIndex,
382 Attribute::get(Ctx, "trap-func-name", TrapFuncName));
383
384 // Let NewAttrs override Attrs.
385 F.setAttributes(
386 Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
387 }
388 }
0 //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains codegen-specific flags that are shared between different
10 // command line tools. The tools "llc" and "opt" both use this file to prevent
11 // flag duplication.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/ADT/StringExtras.h"
16 #include "llvm/IR/Instructions.h"
17 #include "llvm/IR/Intrinsics.h"
18 #include "llvm/IR/Module.h"
19 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
20 #include "llvm/MC/SubtargetFeature.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Support/CommandLine.h"
23 #include "llvm/Support/Host.h"
24 #include "llvm/Target/TargetMachine.h"
25 #include "llvm/Target/TargetOptions.h"
26 #include
27 using namespace llvm;
28
29 static cl::opt
30 MArch("march",
31 cl::desc("Architecture to generate code for (see --version)"));
32
33 static cl::opt
34 MCPU("mcpu",
35 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
36 cl::value_desc("cpu-name"), cl::init(""));
37
38 static cl::list
39 MAttrs("mattr", cl::CommaSeparated,
40 cl::desc("Target specific attributes (-mattr=help for details)"),
41 cl::value_desc("a1,+a2,-a3,..."));
42
43 static cl::opt RelocModel(
44 "relocation-model", cl::desc("Choose relocation model"),
45 cl::values(
46 clEnumValN(Reloc::Static, "static", "Non-relocatable code"),
47 clEnumValN(Reloc::PIC_, "pic",
48 "Fully relocatable, position independent code"),
49 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
50 "Relocatable external references, non-relocatable code"),
51 clEnumValN(Reloc::ROPI, "ropi",
52 "Code and read-only data relocatable, accessed PC-relative"),
53 clEnumValN(
54 Reloc::RWPI, "rwpi",
55 "Read-write data relocatable, accessed relative to static base"),
56 clEnumValN(Reloc::ROPI_RWPI, "ropi-rwpi",
57 "Combination of ropi and rwpi")));
58
59 LLVM_ATTRIBUTE_UNUSED static Optional getRelocModel() {
60 if (RelocModel.getNumOccurrences()) {
61 Reloc::Model R = RelocModel;
62 return R;
63 }
64 return None;
65 }
66
67 static cl::opt TMModel(
68 "thread-model", cl::desc("Choose threading model"),
69 cl::init(ThreadModel::POSIX),
70 cl::values(clEnumValN(ThreadModel::POSIX, "posix", "POSIX thread model"),
71 clEnumValN(ThreadModel::Single, "single",
72 "Single thread model")));
73
74 static cl::opt CMModel(
75 "code-model", cl::desc("Choose code model"),
76 cl::values(clEnumValN(CodeModel::Small, "small", "Small code model"),
77 clEnumValN(CodeModel::Kernel, "kernel", "Kernel code model"),
78 clEnumValN(CodeModel::Medium, "medium", "Medium code model"),
79 clEnumValN(CodeModel::Large, "large", "Large code model")));
80
81 LLVM_ATTRIBUTE_UNUSED static Optional getCodeModel() {
82 if (CMModel.getNumOccurrences()) {
83 CodeModel::Model M = CMModel;
84 return M;
85 }
86 return None;
87 }
88
89 static cl::opt ExceptionModel(
90 "exception-model", cl::desc("exception model"),
91 cl::init(ExceptionHandling::None),
92 cl::values(
93 clEnumValN(ExceptionHandling::None, "default",
94 "default exception handling model"),
95 clEnumValN(ExceptionHandling::DwarfCFI, "dwarf",
96 "DWARF-like CFI based exception handling"),
97 clEnumValN(ExceptionHandling::SjLj, "sjlj", "SjLj exception handling"),
98 clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
99 clEnumValN(ExceptionHandling::WinEH, "wineh",
100 "Windows exception model"),
101 clEnumValN(ExceptionHandling::Wasm, "wasm",
102 "WebAssembly exception handling")));
103
104 static cl::opt FileType(
105 "filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
106 cl::desc(
107 "Choose a file type (not all types are supported by all targets):"),
108 cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
109 "Emit an assembly ('.s') file"),
110 clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
111 "Emit a native object ('.o') file"),
112 clEnumValN(TargetMachine::CGFT_Null, "null",
113 "Emit nothing, for performance testing")));
114
115 static cl::opt
116 DisableFPElim("disable-fp-elim",
117 cl::desc("Disable frame pointer elimination optimization"),
118 cl::init(false));
119
120 static cl::opt EnableUnsafeFPMath(
121 "enable-unsafe-fp-math",
122 cl::desc("Enable optimizations that may decrease FP precision"),
123 cl::init(false));
124
125 static cl::opt EnableNoInfsFPMath(
126 "enable-no-infs-fp-math",
127 cl::desc("Enable FP math optimizations that assume no +-Infs"),
128 cl::init(false));
129
130 static cl::opt EnableNoNaNsFPMath(
131 "enable-no-nans-fp-math",
132 cl::desc("Enable FP math optimizations that assume no NaNs"),
133 cl::init(false));
134
135 static cl::opt EnableNoSignedZerosFPMath(
136 "enable-no-signed-zeros-fp-math",
137 cl::desc("Enable FP math optimizations that assume "
138 "the sign of 0 is insignificant"),
139 cl::init(false));
140
141 static cl::opt
142 EnableNoTrappingFPMath("enable-no-trapping-fp-math",
143 cl::desc("Enable setting the FP exceptions build "
144 "attribute not to use exceptions"),
145 cl::init(false));
146
147 static cl::opt DenormalMode(
148 "denormal-fp-math",
149 cl::desc("Select which denormal numbers the code is permitted to require"),
150 cl::init(FPDenormal::IEEE),
151 cl::values(clEnumValN(FPDenormal::IEEE, "ieee",
152 "IEEE 754 denormal numbers"),
153 clEnumValN(FPDenormal::PreserveSign, "preserve-sign",
154 "the sign of a flushed-to-zero number is preserved "
155 "in the sign of 0"),
156 clEnumValN(FPDenormal::PositiveZero, "positive-zero",
157 "denormals are flushed to positive zero")));
158
159 static cl::opt EnableHonorSignDependentRoundingFPMath(
160 "enable-sign-dependent-rounding-fp-math", cl::Hidden,
161 cl::desc("Force codegen to assume rounding mode can change dynamically"),
162 cl::init(false));
163
164 static cl::opt FloatABIForCalls(
165 "float-abi", cl::desc("Choose float ABI type"), cl::init(FloatABI::Default),
166 cl::values(clEnumValN(FloatABI::Default, "default",
167 "Target default float ABI type"),
168 clEnumValN(FloatABI::Soft, "soft",
169 "Soft float ABI (implied by -soft-float)"),
170 clEnumValN(FloatABI::Hard, "hard",
171 "Hard float ABI (uses FP registers)")));
172
173 static cl::opt FuseFPOps(
174 "fp-contract", cl::desc("Enable aggressive formation of fused FP ops"),
175 cl::init(FPOpFusion::Standard),
176 cl::values(
177 clEnumValN(FPOpFusion::Fast, "fast", "Fuse FP ops whenever profitable"),
178 clEnumValN(FPOpFusion::Standard, "on", "Only fuse 'blessed' FP ops."),
179 clEnumValN(FPOpFusion::Strict, "off",
180 "Only fuse FP ops when the result won't be affected.")));
181
182 static cl::opt DontPlaceZerosInBSS(
183 "nozero-initialized-in-bss",
184 cl::desc("Don't place zero-initialized symbols into bss section"),
185 cl::init(false));
186
187 static cl::opt EnableGuaranteedTailCallOpt(
188 "tailcallopt",
189 cl::desc(
190 "Turn fastcc calls into tail calls by (potentially) changing ABI."),
191 cl::init(false));
192
193 static cl::opt DisableTailCalls("disable-tail-calls",
194 cl::desc("Never emit tail calls"),
195 cl::init(false));
196
197 static cl::opt StackSymbolOrdering("stack-symbol-ordering",
198 cl::desc("Order local stack symbols."),
199 cl::init(true));
200
201 static cl::opt
202 OverrideStackAlignment("stack-alignment",
203 cl::desc("Override default stack alignment"),
204 cl::init(0));
205
206 static cl::opt
207 StackRealign("stackrealign",
208 cl::desc("Force align the stack to the minimum alignment"),
209 cl::init(false));
210
211 static cl::opt TrapFuncName(
212 "trap-func", cl::Hidden,
213 cl::desc("Emit a call to trap function rather than a trap instruction"),
214 cl::init(""));
215
216 static cl::opt UseCtors("use-ctors",
217 cl::desc("Use .ctors instead of .init_array."),
218 cl::init(false));
219
220 static cl::opt RelaxELFRelocations(
221 "relax-elf-relocations",
222 cl::desc("Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
223 cl::init(false));
224
225 static cl::opt DataSections("data-sections",
226 cl::desc("Emit data into separate sections"),
227 cl::init(false));
228
229 static cl::opt
230 FunctionSections("function-sections",
231 cl::desc("Emit functions into separate sections"),
232 cl::init(false));
233
234 static cl::opt EmulatedTLS("emulated-tls",
235 cl::desc("Use emulated TLS model"),
236 cl::init(false));
237
238 static cl::opt
239 UniqueSectionNames("unique-section-names",
240 cl::desc("Give unique names to every section"),
241 cl::init(true));
242
243 static cl::opt
244 EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"),
245 cl::init(EABI::Default),
246 cl::values(clEnumValN(EABI::Default, "default",
247 "Triple default EABI version"),
248 clEnumValN(EABI::EABI4, "4", "EABI version 4"),
249 clEnumValN(EABI::EABI5, "5", "EABI version 5"),
250 clEnumValN(EABI::GNU, "gnu", "EABI GNU")));
251
252 static cl::opt DebuggerTuningOpt(
253 "debugger-tune", cl::desc("Tune debug info for a particular debugger"),
254 cl::init(DebuggerKind::Default),
255 cl::values(clEnumValN(DebuggerKind::GDB, "gdb", "gdb"),
256 clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
257 clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
258
259 static cl::opt EnableStackSizeSection(
260 "stack-size-section",
261 cl::desc("Emit a section containing stack size metadata"), cl::init(false));
262
263 // Common utility function tightly tied to the options listed here. Initializes
264 // a TargetOptions object with CodeGen flags and returns it.
265 static TargetOptions InitTargetOptionsFromCodeGenFlags() {
266 TargetOptions Options;
267 Options.AllowFPOpFusion = FuseFPOps;
268 Options.UnsafeFPMath = EnableUnsafeFPMath;
269 Options.NoInfsFPMath = EnableNoInfsFPMath;
270 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
271 Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
272 Options.NoTrappingFPMath = EnableNoTrappingFPMath;
273 Options.FPDenormalMode = DenormalMode;
274 Options.HonorSignDependentRoundingFPMathOption =
275 EnableHonorSignDependentRoundingFPMath;
276 if (FloatABIForCalls != FloatABI::Default)
277 Options.FloatABIType = FloatABIForCalls;
278 Options.NoZerosInBSS = DontPlaceZerosInBSS;
279 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
280 Options.StackAlignmentOverride = OverrideStackAlignment;
281 Options.StackSymbolOrdering = StackSymbolOrdering;
282 Options.UseInitArray = !UseCtors;
283 Options.RelaxELFRelocations = RelaxELFRelocations;
284 Options.DataSections = DataSections;
285 Options.FunctionSections = FunctionSections;
286 Options.UniqueSectionNames = UniqueSectionNames;
287 Options.EmulatedTLS = EmulatedTLS;
288 Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
289 Options.ExceptionModel = ExceptionModel;
290 Options.EmitStackSizeSection = EnableStackSizeSection;
291
292 Options.MCOptions = InitMCTargetOptionsFromFlags();
293
294 Options.ThreadModel = TMModel;
295 Options.EABIVersion = EABIVersion;
296 Options.DebuggerTuning = DebuggerTuningOpt;
297
298 return Options;
299 }
300
301 LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
302 // If user asked for the 'native' CPU, autodetect here. If autodection fails,
303 // this will set the CPU to an empty string which tells the target to
304 // pick a basic default.
305 if (MCPU == "native")
306 return sys::getHostCPUName();
307
308 return MCPU;
309 }
310
311 LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
312 SubtargetFeatures Features;
313
314 // If user asked for the 'native' CPU, we need to autodetect features.
315 // This is necessary for x86 where the CPU might not support all the
316 // features the autodetected CPU name lists in the target. For example,
317 // not all Sandybridge processors support AVX.
318 if (MCPU == "native") {
319 StringMap HostFeatures;
320 if (sys::getHostCPUFeatures(HostFeatures))
321 for (auto &F : HostFeatures)
322 Features.AddFeature(F.first(), F.second);
323 }
324
325 for (unsigned i = 0; i != MAttrs.size(); ++i)
326 Features.AddFeature(MAttrs[i]);
327
328 return Features.getString();
329 }
330
331 LLVM_ATTRIBUTE_UNUSED static std::vector getFeatureList() {
332 SubtargetFeatures Features;
333
334 // If user asked for the 'native' CPU, we need to autodetect features.
335 // This is necessary for x86 where the CPU might not support all the
336 // features the autodetected CPU name lists in the target. For example,
337 // not all Sandybridge processors support AVX.
338 if (MCPU == "native") {
339 StringMap HostFeatures;
340 if (sys::getHostCPUFeatures(HostFeatures))
341 for (auto &F : HostFeatures)
342 Features.AddFeature(F.first(), F.second);
343 }
344
345 for (unsigned i = 0; i != MAttrs.size(); ++i)
346 Features.AddFeature(MAttrs[i]);
347
348 return Features.getFeatures();
349 }
350
351 /// \brief Set function attributes of functions in Module M based on CPU,
352 /// Features, and command line flags.
353 LLVM_ATTRIBUTE_UNUSED static void
354 setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
355 for (auto &F : M) {
356 auto &Ctx = F.getContext();
357 AttributeList Attrs = F.getAttributes();
358 AttrBuilder NewAttrs;
359
360 if (!CPU.empty())
361 NewAttrs.addAttribute("target-cpu", CPU);
362 if (!Features.empty())
363 NewAttrs.addAttribute("target-features", Features);
364 if (DisableFPElim.getNumOccurrences() > 0)
365 NewAttrs.addAttribute("no-frame-pointer-elim",
366 DisableFPElim ? "true" : "false");
367 if (DisableTailCalls.getNumOccurrences() > 0)
368 NewAttrs.addAttribute("disable-tail-calls",
369 toStringRef(DisableTailCalls));
370 if (StackRealign)
371 NewAttrs.addAttribute("stackrealign");
372
373 if (TrapFuncName.getNumOccurrences() > 0)
374 for (auto &B : F)
375 for (auto &I : B)
376 if (auto *Call = dyn_cast(&I))
377 if (const auto *F = Call->getCalledFunction())
378 if (F->getIntrinsicID() == Intrinsic::debugtrap ||
379 F->getIntrinsicID() == Intrinsic::trap)
380 Call->addAttribute(
381 llvm::AttributeList::FunctionIndex,
382 Attribute::get(Ctx, "trap-func-name", TrapFuncName));
383
384 // Let NewAttrs override Attrs.
385 F.setAttributes(
386 Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
387 }
388 }
+0
-80
include/llvm/MC/MCTargetOptionsCommandFlags.def less more
None //===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains machine code-specific flags that are shared between
10 // different command line tools.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
15 #define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
16
17 #include "llvm/MC/MCTargetOptions.h"
18 #include "llvm/Support/CommandLine.h"
19 using namespace llvm;
20
21 static cl::opt AsmInstrumentation(
22 "asm-instrumentation", cl::desc("Instrumentation of inline assembly and "
23 "assembly source files"),
24 cl::init(MCTargetOptions::AsmInstrumentationNone),
25 cl::values(clEnumValN(MCTargetOptions::AsmInstrumentationNone, "none",
26 "no instrumentation at all"),
27 clEnumValN(MCTargetOptions::AsmInstrumentationAddress, "address",
28 "instrument instructions with memory arguments")));
29
30 static cl::opt RelaxAll("mc-relax-all",
31 cl::desc("When used with filetype=obj, "
32 "relax all fixups in the emitted object file"));
33
34 static cl::opt IncrementalLinkerCompatible(
35 "incremental-linker-compatible",
36 cl::desc(
37 "When used with filetype=obj, "
38 "emit an object file which can be used with an incremental linker"));
39
40 static cl::opt PIECopyRelocations("pie-copy-relocations", cl::desc("PIE Copy Relocations"));
41
42 static cl::opt DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
43 cl::init(0));
44
45 static cl::opt ShowMCInst("asm-show-inst",
46 cl::desc("Emit internal instruction representation to "
47 "assembly file"));
48
49 static cl::opt FatalWarnings("fatal-warnings",
50 cl::desc("Treat warnings as errors"));
51
52 static cl::opt NoWarn("no-warn", cl::desc("Suppress all warnings"));
53 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn));
54
55 static cl::opt NoDeprecatedWarn("no-deprecated-warn",
56 cl::desc("Suppress all deprecated warnings"));
57
58 static cl::opt
59 ABIName("target-abi", cl::Hidden,
60 cl::desc("The name of the ABI to be targeted from the backend."),
61 cl::init(""));
62
63 static MCTargetOptions InitMCTargetOptionsFromFlags() {
64 MCTargetOptions Options;
65 Options.SanitizeAddress =
66 (AsmInstrumentation == MCTargetOptions::AsmInstrumentationAddress);
67 Options.MCRelaxAll = RelaxAll;
68 Options.MCIncrementalLinkerCompatible = IncrementalLinkerCompatible;
69 Options.MCPIECopyRelocations = PIECopyRelocations;
70 Options.DwarfVersion = DwarfVersion;
71 Options.ShowMCInst = ShowMCInst;
72 Options.ABIName = ABIName;
73 Options.MCFatalWarnings = FatalWarnings;
74 Options.MCNoWarn = NoWarn;
75 Options.MCNoDeprecatedWarn = NoDeprecatedWarn;
76 return Options;
77 }
78
79 #endif
0 //===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains machine code-specific flags that are shared between
10 // different command line tools.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
15 #define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
16
17 #include "llvm/MC/MCTargetOptions.h"
18 #include "llvm/Support/CommandLine.h"
19 using namespace llvm;
20
21 static cl::opt AsmInstrumentation(
22 "asm-instrumentation", cl::desc("Instrumentation of inline assembly and "
23 "assembly source files"),
24 cl::init(MCTargetOptions::AsmInstrumentationNone),
25 cl::values(clEnumValN(MCTargetOptions::AsmInstrumentationNone, "none",
26 "no instrumentation at all"),
27 clEnumValN(MCTargetOptions::AsmInstrumentationAddress, "address",
28 "instrument instructions with memory arguments")));
29
30 static cl::opt RelaxAll("mc-relax-all",
31 cl::desc("When used with filetype=obj, "
32 "relax all fixups in the emitted object file"));
33
34 static cl::opt IncrementalLinkerCompatible(
35 "incremental-linker-compatible",
36 cl::desc(
37 "When used with filetype=obj, "
38 "emit an object file which can be used with an incremental linker"));
39
40 static cl::opt PIECopyRelocations("pie-copy-relocations", cl::desc("PIE Copy Relocations"));
41
42 static cl::opt DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
43 cl::init(0));
44
45 static cl::opt ShowMCInst("asm-show-inst",
46 cl::desc("Emit internal instruction representation to "
47 "assembly file"));
48
49 static cl::opt FatalWarnings("fatal-warnings",
50 cl::desc("Treat warnings as errors"));
51
52 static cl::opt NoWarn("no-warn", cl::desc("Suppress all warnings"));
53 static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn));
54
55 static cl::opt NoDeprecatedWarn("no-deprecated-warn",
56 cl::desc("Suppress all deprecated warnings"));
57
58 static cl::opt
59 ABIName("target-abi", cl::Hidden,
60 cl::desc("The name of the ABI to be targeted from the backend."),
61 cl::init(""));
62
63 static MCTargetOptions InitMCTargetOptionsFromFlags() {
64 MCTargetOptions Options;
65 Options.SanitizeAddress =
66 (AsmInstrumentation == MCTargetOptions::AsmInstrumentationAddress);
67 Options.MCRelaxAll = RelaxAll;
68 Options.MCIncrementalLinkerCompatible = IncrementalLinkerCompatible;
69 Options.MCPIECopyRelocations = PIECopyRelocations;
70 Options.DwarfVersion = DwarfVersion;
71 Options.ShowMCInst = ShowMCInst;
72 Options.ABIName = ABIName;
73 Options.MCFatalWarnings = FatalWarnings;
74 Options.MCNoWarn = NoWarn;
75 Options.MCNoDeprecatedWarn = NoDeprecatedWarn;
76 return Options;
77 }
78
79 #endif
1919
2020 // Exclude these; they're intended to be included into only a single
2121 // translation unit (or none) and aren't part of this module.
22 exclude header "CodeGen/CommandFlags.h"
2322 exclude header "CodeGen/LinkAllAsmWriterComponents.h"
2423 exclude header "CodeGen/LinkAllCodegenComponents.h"
2524
2625 // These are intended for (repeated) textual inclusion.
27 textual header "CodeGen/CommandFlags.def"
26 textual header "CodeGen/CommandFlags.inc"
2827 textual header "CodeGen/DIEValue.def"
2928 textual header "CodeGen/RuntimeLibcalls.def"
3029 }
233232 umbrella "MC"
234233 module * { export * }
235234
236 textual header "MC/MCTargetOptionsCommandFlags.def"
235 textual header "MC/MCTargetOptionsCommandFlags.inc"
237236 }
238237
239238 // Used by llvm-tblgen
5757 #include "llvm/MC/MCStreamer.h"
5858 #include "llvm/MC/MCSubtargetInfo.h"
5959 #include "llvm/MC/MCTargetOptions.h"
60 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
60 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
6161 #include "llvm/Object/MachO.h"
6262 #include "llvm/Object/ObjectFile.h"
6363 #include "llvm/Object/SymbolicFile.h"
1414 #include "llvm/ADT/Statistic.h"
1515 #include "llvm/Bitcode/BitcodeReader.h"
1616 #include "llvm/Bitcode/BitcodeWriter.h"
17 #include "llvm/CodeGen/CommandFlags.def"
17 #include "llvm/CodeGen/CommandFlags.inc"
1818 #include "llvm/Config/config.h" // plugin-api.h requires HAVE_STDINT_H
1919 #include "llvm/IR/Constants.h"
2020 #include "llvm/IR/DiagnosticPrinter.h"
1515 #include "llvm/ADT/STLExtras.h"
1616 #include "llvm/ADT/Triple.h"
1717 #include "llvm/Analysis/TargetLibraryInfo.h"
18 #include "llvm/CodeGen/CommandFlags.def"
18 #include "llvm/CodeGen/CommandFlags.inc"
1919 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
2020 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
2121 #include "llvm/CodeGen/MIRParser/MIRParser.h"
1717 #include "llvm/ADT/StringExtras.h"
1818 #include "llvm/ADT/Triple.h"
1919 #include "llvm/Bitcode/BitcodeReader.h"
20 #include "llvm/CodeGen/CommandFlags.def"
20 #include "llvm/CodeGen/CommandFlags.inc"
2121 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
2222 #include "llvm/ExecutionEngine/GenericValue.h"
2323 #include "llvm/ExecutionEngine/Interpreter.h"
2525 #include "llvm/MC/MCObjectFileInfo.h"
2626 #include "llvm/MC/MCRegisterInfo.h"
2727 #include "llvm/MC/MCStreamer.h"
28 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
28 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
2929 #include "llvm/Object/Decompressor.h"
3030 #include "llvm/Object/ObjectFile.h"
3131 #include "llvm/Support/DataExtractor.h"
1414 #include "llvm/Analysis/TargetLibraryInfo.h"
1515 #include "llvm/Bitcode/BitcodeReader.h"
1616 #include "llvm/Bitcode/BitcodeWriter.h"
17 #include "llvm/CodeGen/CommandFlags.def"
17 #include "llvm/CodeGen/CommandFlags.inc"
1818 #include "llvm/FuzzMutate/FuzzerCLI.h"
1919 #include "llvm/FuzzMutate/IRMutator.h"
2020 #include "llvm/FuzzMutate/Operations.h"
2121 #include "llvm/ADT/Twine.h"
2222 #include "llvm/Bitcode/BitcodeReader.h"
2323 #include "llvm/Bitcode/BitcodeWriter.h"
24 #include "llvm/CodeGen/CommandFlags.def"
24 #include "llvm/CodeGen/CommandFlags.inc"
2525 #include "llvm/IR/DiagnosticInfo.h"
2626 #include "llvm/IR/DiagnosticPrinter.h"
2727 #include "llvm/IR/LLVMContext.h"
1616 //===----------------------------------------------------------------------===//
1717
1818 #include "llvm/Bitcode/BitcodeReader.h"
19 #include "llvm/CodeGen/CommandFlags.def"
19 #include "llvm/CodeGen/CommandFlags.inc"
2020 #include "llvm/IR/DiagnosticPrinter.h"
2121 #include "llvm/LTO/Caching.h"
2222 #include "llvm/LTO/LTO.h"
2424 #include "llvm/MC/MCRegisterInfo.h"
2525 #include "llvm/MC/MCStreamer.h"
2626 #include "llvm/MC/MCSubtargetInfo.h"
27 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
27 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
2828 #include "llvm/Support/CommandLine.h"
2929 #include "llvm/Support/Compression.h"
3030 #include "llvm/Support/FileUtilities.h"
2323 #include "llvm/MC/MCSectionMachO.h"
2424 #include "llvm/MC/MCStreamer.h"
2525 #include "llvm/MC/MCSubtargetInfo.h"
26 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
26 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
2727 #include "llvm/Support/MemoryBuffer.h"
2828 #include "llvm/Support/CommandLine.h"
2929 #include "llvm/Support/FileUtilities.h"
1212
1313 #include "llvm/Bitcode/BitcodeReader.h"
1414 #include "llvm/Bitcode/BitcodeWriter.h"
15 #include "llvm/CodeGen/CommandFlags.def"
15 #include "llvm/CodeGen/CommandFlags.inc"
1616 #include "llvm/FuzzMutate/FuzzerCLI.h"
1717 #include "llvm/FuzzMutate/IRMutator.h"
1818 #include "llvm/IR/Verifier.h"
1414 #include "llvm-c/lto.h"
1515 #include "llvm/ADT/STLExtras.h"
1616 #include "llvm/Bitcode/BitcodeReader.h"
17 #include "llvm/CodeGen/CommandFlags.def"
17 #include "llvm/CodeGen/CommandFlags.inc"
1818 #include "llvm/IR/DiagnosticInfo.h"
1919 #include "llvm/IR/DiagnosticPrinter.h"
2020 #include "llvm/IR/LLVMContext.h"
2222 #include "llvm/Analysis/TargetLibraryInfo.h"
2323 #include "llvm/Analysis/TargetTransformInfo.h"
2424 #include "llvm/Bitcode/BitcodeWriterPass.h"
25 #include "llvm/CodeGen/CommandFlags.def"
25 #include "llvm/CodeGen/CommandFlags.inc"
2626 #include "llvm/CodeGen/TargetPassConfig.h"
2727 #include "llvm/IR/DataLayout.h"
2828 #include "llvm/IR/DebugInfo.h"
2424 #include "llvm/MC/MCRegisterInfo.h"
2525 #include "llvm/MC/MCStreamer.h"
2626 #include "llvm/MC/MCSubtargetInfo.h"
27 #include "llvm/MC/MCTargetOptionsCommandFlags.def"
27 #include "llvm/MC/MCTargetOptionsCommandFlags.inc"
2828 #include "llvm/PassAnalysisSupport.h"
2929 #include "llvm/Support/TargetRegistry.h"
3030 #include "llvm/Support/raw_ostream.h"