]> git.proxmox.com Git - rustc.git/blame - src/llvm/include/llvm/CodeGen/CommandFlags.h
Imported Upstream version 1.0.0~0alpha
[rustc.git] / src / llvm / include / llvm / CodeGen / CommandFlags.h
CommitLineData
970d7e83
LB
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
1a4d82fc 19#include "llvm/MC/MCTargetOptionsCommandFlags.h"
970d7e83
LB
20#include "llvm/Support/CodeGen.h"
21#include "llvm/Support/CommandLine.h"
22#include "llvm/Target/TargetMachine.h"
1a4d82fc 23#include "llvm/Target/TargetOptions.h"
970d7e83
LB
24#include <string>
25using namespace llvm;
26
27cl::opt<std::string>
28MArch("march", cl::desc("Architecture to generate code for (see --version)"));
29
30cl::opt<std::string>
31MCPU("mcpu",
32 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
33 cl::value_desc("cpu-name"),
34 cl::init(""));
35
36cl::list<std::string>
37MAttrs("mattr",
38 cl::CommaSeparated,
39 cl::desc("Target specific attributes (-mattr=help for details)"),
40 cl::value_desc("a1,+a2,-a3,..."));
41
42cl::opt<Reloc::Model>
43RelocModel("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
1a4d82fc
JJ
57cl::opt<ThreadModel::Model>
58TMModel("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
970d7e83
LB
67cl::opt<llvm::CodeModel::Model>
68CMModel("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
970d7e83
LB
83cl::opt<TargetMachine::CodeGenFileType>
84FileType("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
970d7e83
LB
95cl::opt<bool>
96DisableRedZone("disable-red-zone",
97 cl::desc("Do not emit code that uses the red zone."),
98 cl::init(false));
99
100cl::opt<bool>
101EnableFPMAD("enable-fp-mad",
102 cl::desc("Enable less precise MAD instructions to be generated"),
103 cl::init(false));
104
105cl::opt<bool>
106DisableFPElim("disable-fp-elim",
107 cl::desc("Disable frame pointer elimination optimization"),
108 cl::init(false));
109
970d7e83
LB
110cl::opt<bool>
111EnableUnsafeFPMath("enable-unsafe-fp-math",
112 cl::desc("Enable optimizations that may decrease FP precision"),
113 cl::init(false));
114
115cl::opt<bool>
116EnableNoInfsFPMath("enable-no-infs-fp-math",
117 cl::desc("Enable FP math optimizations that assume no +-Infs"),
118 cl::init(false));
119
120cl::opt<bool>
121EnableNoNaNsFPMath("enable-no-nans-fp-math",
122 cl::desc("Enable FP math optimizations that assume no NaNs"),
123 cl::init(false));
124
125cl::opt<bool>
126EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
127 cl::Hidden,
128 cl::desc("Force codegen to assume rounding mode can change dynamically"),
129 cl::init(false));
130
131cl::opt<bool>
132GenerateSoftFloatCalls("soft-float",
133 cl::desc("Generate software floating point library calls"),
134 cl::init(false));
135
136cl::opt<llvm::FloatABI::ABIType>
137FloatABIForCalls("float-abi",
138 cl::desc("Choose float ABI type"),
139 cl::init(FloatABI::Default),
140 cl::values(
141 clEnumValN(FloatABI::Default, "default",
142 "Target default float ABI type"),
143 clEnumValN(FloatABI::Soft, "soft",
144 "Soft float ABI (implied by -soft-float)"),
145 clEnumValN(FloatABI::Hard, "hard",
146 "Hard float ABI (uses FP registers)"),
147 clEnumValEnd));
148
149cl::opt<llvm::FPOpFusion::FPOpFusionMode>
150FuseFPOps("fp-contract",
1a4d82fc 151 cl::desc("Enable aggressive formation of fused FP ops"),
970d7e83
LB
152 cl::init(FPOpFusion::Standard),
153 cl::values(
154 clEnumValN(FPOpFusion::Fast, "fast",
155 "Fuse FP ops whenever profitable"),
156 clEnumValN(FPOpFusion::Standard, "on",
157 "Only fuse 'blessed' FP ops."),
158 clEnumValN(FPOpFusion::Strict, "off",
159 "Only fuse FP ops when the result won't be effected."),
160 clEnumValEnd));
161
162cl::opt<bool>
163DontPlaceZerosInBSS("nozero-initialized-in-bss",
164 cl::desc("Don't place zero-initialized symbols into bss section"),
165 cl::init(false));
166
167cl::opt<bool>
168EnableGuaranteedTailCallOpt("tailcallopt",
169 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
170 cl::init(false));
171
172cl::opt<bool>
173DisableTailCalls("disable-tail-calls",
174 cl::desc("Never emit tail calls"),
175 cl::init(false));
176
177cl::opt<unsigned>
178OverrideStackAlignment("stack-alignment",
179 cl::desc("Override default stack alignment"),
180 cl::init(0));
181
970d7e83
LB
182cl::opt<std::string>
183TrapFuncName("trap-func", cl::Hidden,
184 cl::desc("Emit a call to trap function rather than a trap instruction"),
185 cl::init(""));
186
187cl::opt<bool>
188EnablePIE("enable-pie",
189 cl::desc("Assume the creation of a position independent executable."),
190 cl::init(false));
191
192cl::opt<bool>
1a4d82fc
JJ
193UseCtors("use-ctors",
194 cl::desc("Use .ctors instead of .init_array."),
970d7e83
LB
195 cl::init(false));
196
197cl::opt<std::string> StopAfter("stop-after",
198 cl::desc("Stop compilation after a specific pass"),
199 cl::value_desc("pass-name"),
200 cl::init(""));
201cl::opt<std::string> StartAfter("start-after",
202 cl::desc("Resume compilation after a specific pass"),
203 cl::value_desc("pass-name"),
204 cl::init(""));
205
1a4d82fc
JJ
206cl::opt<bool> DataSections("data-sections",
207 cl::desc("Emit data into separate sections"),
208 cl::init(false));
209
210cl::opt<bool>
211FunctionSections("function-sections",
212 cl::desc("Emit functions into separate sections"),
213 cl::init(false));
214
215cl::opt<llvm::JumpTable::JumpTableType>
216JTableType("jump-table-type",
217 cl::desc("Choose the type of Jump-Instruction Table for jumptable."),
218 cl::init(JumpTable::Single),
219 cl::values(
220 clEnumValN(JumpTable::Single, "single",
221 "Create a single table for all jumptable functions"),
222 clEnumValN(JumpTable::Arity, "arity",
223 "Create one table per number of parameters."),
224 clEnumValN(JumpTable::Simplified, "simplified",
225 "Create one table per simplified function type."),
226 clEnumValN(JumpTable::Full, "full",
227 "Create one table per unique function type."),
228 clEnumValEnd));
229
230// Common utility function tightly tied to the options listed here. Initializes
231// a TargetOptions object with CodeGen flags and returns it.
232static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
233 TargetOptions Options;
234 Options.LessPreciseFPMADOption = EnableFPMAD;
235 Options.NoFramePointerElim = DisableFPElim;
236 Options.AllowFPOpFusion = FuseFPOps;
237 Options.UnsafeFPMath = EnableUnsafeFPMath;
238 Options.NoInfsFPMath = EnableNoInfsFPMath;
239 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
240 Options.HonorSignDependentRoundingFPMathOption =
241 EnableHonorSignDependentRoundingFPMath;
242 Options.UseSoftFloat = GenerateSoftFloatCalls;
243 if (FloatABIForCalls != FloatABI::Default)
244 Options.FloatABIType = FloatABIForCalls;
245 Options.NoZerosInBSS = DontPlaceZerosInBSS;
246 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
247 Options.DisableTailCalls = DisableTailCalls;
248 Options.StackAlignmentOverride = OverrideStackAlignment;
249 Options.TrapFuncName = TrapFuncName;
250 Options.PositionIndependentExecutable = EnablePIE;
251 Options.UseInitArray = !UseCtors;
252 Options.DataSections = DataSections;
253 Options.FunctionSections = FunctionSections;
254
255 Options.MCOptions = InitMCTargetOptionsFromFlags();
256 Options.JTType = JTableType;
257
258 Options.ThreadModel = TMModel;
259
260 return Options;
261}
262
970d7e83 263#endif