]> git.proxmox.com Git - rustc.git/blob - src/llvm/include/llvm/CodeGen/CommandFlags.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / include / llvm / CodeGen / CommandFlags.h
1 //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains codegen-specific flags that are shared between different
11 // command line tools. The tools "llc" and "opt" both use this file to prevent
12 // flag duplication.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
17 #define LLVM_CODEGEN_COMMANDFLAGS_H
18
19 #include "llvm/MC/MCTargetOptionsCommandFlags.h"
20 #include "llvm/Support/CodeGen.h"
21 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Target/TargetMachine.h"
23 #include "llvm/Target/TargetOptions.h"
24 #include <string>
25 using namespace llvm;
26
27 cl::opt<std::string>
28 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
29
30 cl::opt<std::string>
31 MCPU("mcpu",
32 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
33 cl::value_desc("cpu-name"),
34 cl::init(""));
35
36 cl::list<std::string>
37 MAttrs("mattr",
38 cl::CommaSeparated,
39 cl::desc("Target specific attributes (-mattr=help for details)"),
40 cl::value_desc("a1,+a2,-a3,..."));
41
42 cl::opt<Reloc::Model>
43 RelocModel("relocation-model",
44 cl::desc("Choose relocation model"),
45 cl::init(Reloc::Default),
46 cl::values(
47 clEnumValN(Reloc::Default, "default",
48 "Target default relocation model"),
49 clEnumValN(Reloc::Static, "static",
50 "Non-relocatable code"),
51 clEnumValN(Reloc::PIC_, "pic",
52 "Fully relocatable, position independent code"),
53 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
54 "Relocatable external references, non-relocatable code"),
55 clEnumValEnd));
56
57 cl::opt<ThreadModel::Model>
58 TMModel("thread-model",
59 cl::desc("Choose threading model"),
60 cl::init(ThreadModel::POSIX),
61 cl::values(clEnumValN(ThreadModel::POSIX, "posix",
62 "POSIX thread model"),
63 clEnumValN(ThreadModel::Single, "single",
64 "Single thread model"),
65 clEnumValEnd));
66
67 cl::opt<llvm::CodeModel::Model>
68 CMModel("code-model",
69 cl::desc("Choose code model"),
70 cl::init(CodeModel::Default),
71 cl::values(clEnumValN(CodeModel::Default, "default",
72 "Target default code model"),
73 clEnumValN(CodeModel::Small, "small",
74 "Small code model"),
75 clEnumValN(CodeModel::Kernel, "kernel",
76 "Kernel code model"),
77 clEnumValN(CodeModel::Medium, "medium",
78 "Medium code model"),
79 clEnumValN(CodeModel::Large, "large",
80 "Large code model"),
81 clEnumValEnd));
82
83 cl::opt<TargetMachine::CodeGenFileType>
84 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
85 cl::desc("Choose a file type (not all types are supported by all targets):"),
86 cl::values(
87 clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
88 "Emit an assembly ('.s') file"),
89 clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
90 "Emit a native object ('.o') file"),
91 clEnumValN(TargetMachine::CGFT_Null, "null",
92 "Emit nothing, for performance testing"),
93 clEnumValEnd));
94
95 cl::opt<bool>
96 EnableFPMAD("enable-fp-mad",
97 cl::desc("Enable less precise MAD instructions to be generated"),
98 cl::init(false));
99
100 cl::opt<bool>
101 DisableFPElim("disable-fp-elim",
102 cl::desc("Disable frame pointer elimination optimization"),
103 cl::init(false));
104
105 cl::opt<bool>
106 EnableUnsafeFPMath("enable-unsafe-fp-math",
107 cl::desc("Enable optimizations that may decrease FP precision"),
108 cl::init(false));
109
110 cl::opt<bool>
111 EnableNoInfsFPMath("enable-no-infs-fp-math",
112 cl::desc("Enable FP math optimizations that assume no +-Infs"),
113 cl::init(false));
114
115 cl::opt<bool>
116 EnableNoNaNsFPMath("enable-no-nans-fp-math",
117 cl::desc("Enable FP math optimizations that assume no NaNs"),
118 cl::init(false));
119
120 cl::opt<bool>
121 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
122 cl::Hidden,
123 cl::desc("Force codegen to assume rounding mode can change dynamically"),
124 cl::init(false));
125
126 cl::opt<bool>
127 GenerateSoftFloatCalls("soft-float",
128 cl::desc("Generate software floating point library calls"),
129 cl::init(false));
130
131 cl::opt<llvm::FloatABI::ABIType>
132 FloatABIForCalls("float-abi",
133 cl::desc("Choose float ABI type"),
134 cl::init(FloatABI::Default),
135 cl::values(
136 clEnumValN(FloatABI::Default, "default",
137 "Target default float ABI type"),
138 clEnumValN(FloatABI::Soft, "soft",
139 "Soft float ABI (implied by -soft-float)"),
140 clEnumValN(FloatABI::Hard, "hard",
141 "Hard float ABI (uses FP registers)"),
142 clEnumValEnd));
143
144 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
145 FuseFPOps("fp-contract",
146 cl::desc("Enable aggressive formation of fused FP ops"),
147 cl::init(FPOpFusion::Standard),
148 cl::values(
149 clEnumValN(FPOpFusion::Fast, "fast",
150 "Fuse FP ops whenever profitable"),
151 clEnumValN(FPOpFusion::Standard, "on",
152 "Only fuse 'blessed' FP ops."),
153 clEnumValN(FPOpFusion::Strict, "off",
154 "Only fuse FP ops when the result won't be effected."),
155 clEnumValEnd));
156
157 cl::opt<bool>
158 DontPlaceZerosInBSS("nozero-initialized-in-bss",
159 cl::desc("Don't place zero-initialized symbols into bss section"),
160 cl::init(false));
161
162 cl::opt<bool>
163 EnableGuaranteedTailCallOpt("tailcallopt",
164 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
165 cl::init(false));
166
167 cl::opt<bool>
168 DisableTailCalls("disable-tail-calls",
169 cl::desc("Never emit tail calls"),
170 cl::init(false));
171
172 cl::opt<unsigned>
173 OverrideStackAlignment("stack-alignment",
174 cl::desc("Override default stack alignment"),
175 cl::init(0));
176
177 cl::opt<std::string>
178 TrapFuncName("trap-func", cl::Hidden,
179 cl::desc("Emit a call to trap function rather than a trap instruction"),
180 cl::init(""));
181
182 cl::opt<bool>
183 EnablePIE("enable-pie",
184 cl::desc("Assume the creation of a position independent executable."),
185 cl::init(false));
186
187 cl::opt<bool>
188 UseCtors("use-ctors",
189 cl::desc("Use .ctors instead of .init_array."),
190 cl::init(false));
191
192 cl::opt<std::string> StopAfter("stop-after",
193 cl::desc("Stop compilation after a specific pass"),
194 cl::value_desc("pass-name"),
195 cl::init(""));
196 cl::opt<std::string> StartAfter("start-after",
197 cl::desc("Resume compilation after a specific pass"),
198 cl::value_desc("pass-name"),
199 cl::init(""));
200
201 cl::opt<bool> DataSections("data-sections",
202 cl::desc("Emit data into separate sections"),
203 cl::init(false));
204
205 cl::opt<bool>
206 FunctionSections("function-sections",
207 cl::desc("Emit functions into separate sections"),
208 cl::init(false));
209
210 cl::opt<llvm::JumpTable::JumpTableType>
211 JTableType("jump-table-type",
212 cl::desc("Choose the type of Jump-Instruction Table for jumptable."),
213 cl::init(JumpTable::Single),
214 cl::values(
215 clEnumValN(JumpTable::Single, "single",
216 "Create a single table for all jumptable functions"),
217 clEnumValN(JumpTable::Arity, "arity",
218 "Create one table per number of parameters."),
219 clEnumValN(JumpTable::Simplified, "simplified",
220 "Create one table per simplified function type."),
221 clEnumValN(JumpTable::Full, "full",
222 "Create one table per unique function type."),
223 clEnumValEnd));
224
225 cl::opt<bool>
226 FCFI("fcfi",
227 cl::desc("Apply forward-edge control-flow integrity"),
228 cl::init(false));
229
230 cl::opt<llvm::CFIntegrity>
231 CFIType("cfi-type",
232 cl::desc("Choose the type of Control-Flow Integrity check to add"),
233 cl::init(CFIntegrity::Sub),
234 cl::values(
235 clEnumValN(CFIntegrity::Sub, "sub",
236 "Subtract the pointer from the table base, then mask."),
237 clEnumValN(CFIntegrity::Ror, "ror",
238 "Use rotate to check the offset from a table base."),
239 clEnumValN(CFIntegrity::Add, "add",
240 "Mask out the high bits and add to an aligned base."),
241 clEnumValEnd));
242
243 cl::opt<bool>
244 CFIEnforcing("cfi-enforcing",
245 cl::desc("Enforce CFI or pass the violation to a function."),
246 cl::init(false));
247
248 // Note that this option is linked to the cfi-enforcing option above: if
249 // cfi-enforcing is set, then the cfi-func-name option is entirely ignored. If
250 // cfi-enforcing is false and no cfi-func-name is set, then a default function
251 // will be generated that ignores all CFI violations. The expected signature for
252 // functions called with CFI violations is
253 //
254 // void (i8*, i8*)
255 //
256 // The first pointer is a C string containing the name of the function in which
257 // the violation occurs, and the second pointer is the pointer that violated
258 // CFI.
259 cl::opt<std::string>
260 CFIFuncName("cfi-func-name", cl::desc("The name of the CFI function to call"),
261 cl::init(""));
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 inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
266 TargetOptions Options;
267 Options.LessPreciseFPMADOption = EnableFPMAD;
268 Options.NoFramePointerElim = DisableFPElim;
269 Options.AllowFPOpFusion = FuseFPOps;
270 Options.UnsafeFPMath = EnableUnsafeFPMath;
271 Options.NoInfsFPMath = EnableNoInfsFPMath;
272 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
273 Options.HonorSignDependentRoundingFPMathOption =
274 EnableHonorSignDependentRoundingFPMath;
275 Options.UseSoftFloat = GenerateSoftFloatCalls;
276 if (FloatABIForCalls != FloatABI::Default)
277 Options.FloatABIType = FloatABIForCalls;
278 Options.NoZerosInBSS = DontPlaceZerosInBSS;
279 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
280 Options.DisableTailCalls = DisableTailCalls;
281 Options.StackAlignmentOverride = OverrideStackAlignment;
282 Options.TrapFuncName = TrapFuncName;
283 Options.PositionIndependentExecutable = EnablePIE;
284 Options.UseInitArray = !UseCtors;
285 Options.DataSections = DataSections;
286 Options.FunctionSections = FunctionSections;
287
288 Options.MCOptions = InitMCTargetOptionsFromFlags();
289 Options.JTType = JTableType;
290 Options.FCFI = FCFI;
291 Options.CFIType = CFIType;
292 Options.CFIEnforcing = CFIEnforcing;
293 Options.CFIFuncName = CFIFuncName;
294
295 Options.ThreadModel = TMModel;
296
297 return Options;
298 }
299
300 #endif