619826cf622e206da89d1c72bc36c8bf66def7ba
[oota-llvm.git] / 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<llvm::CodeModel::Model>
58 CMModel("code-model",
59         cl::desc("Choose code model"),
60         cl::init(CodeModel::Default),
61         cl::values(clEnumValN(CodeModel::Default, "default",
62                               "Target default code model"),
63                    clEnumValN(CodeModel::Small, "small",
64                               "Small code model"),
65                    clEnumValN(CodeModel::Kernel, "kernel",
66                               "Kernel code model"),
67                    clEnumValN(CodeModel::Medium, "medium",
68                               "Medium code model"),
69                    clEnumValN(CodeModel::Large, "large",
70                               "Large code model"),
71                    clEnumValEnd));
72
73 cl::opt<bool>
74 RelaxAll("mc-relax-all",
75          cl::desc("When used with filetype=obj, "
76                   "relax all fixups in the emitted object file"));
77
78 cl::opt<TargetMachine::CodeGenFileType>
79 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
80   cl::desc("Choose a file type (not all types are supported by all targets):"),
81   cl::values(
82              clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
83                         "Emit an assembly ('.s') file"),
84              clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
85                         "Emit a native object ('.o') file"),
86              clEnumValN(TargetMachine::CGFT_Null, "null",
87                         "Emit nothing, for performance testing"),
88              clEnumValEnd));
89
90 cl::opt<bool> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
91                   cl::desc("Use .file directives with an explicit directory."));
92
93 cl::opt<bool>
94 DisableRedZone("disable-red-zone",
95                cl::desc("Do not emit code that uses the red zone."),
96                cl::init(false));
97
98 cl::opt<bool>
99 EnableFPMAD("enable-fp-mad",
100             cl::desc("Enable less precise MAD instructions to be generated"),
101             cl::init(false));
102
103 cl::opt<bool>
104 DisableFPElim("disable-fp-elim",
105               cl::desc("Disable frame pointer elimination optimization"),
106               cl::init(false));
107
108 cl::opt<bool>
109 EnableUnsafeFPMath("enable-unsafe-fp-math",
110                 cl::desc("Enable optimizations that may decrease FP precision"),
111                 cl::init(false));
112
113 cl::opt<bool>
114 EnableNoInfsFPMath("enable-no-infs-fp-math",
115                 cl::desc("Enable FP math optimizations that assume no +-Infs"),
116                 cl::init(false));
117
118 cl::opt<bool>
119 EnableNoNaNsFPMath("enable-no-nans-fp-math",
120                    cl::desc("Enable FP math optimizations that assume no NaNs"),
121                    cl::init(false));
122
123 cl::opt<bool>
124 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
125       cl::Hidden,
126       cl::desc("Force codegen to assume rounding mode can change dynamically"),
127       cl::init(false));
128
129 cl::opt<bool>
130 GenerateSoftFloatCalls("soft-float",
131                     cl::desc("Generate software floating point library calls"),
132                     cl::init(false));
133
134 cl::opt<llvm::FloatABI::ABIType>
135 FloatABIForCalls("float-abi",
136                  cl::desc("Choose float ABI type"),
137                  cl::init(FloatABI::Default),
138                  cl::values(
139                      clEnumValN(FloatABI::Default, "default",
140                                 "Target default float ABI type"),
141                      clEnumValN(FloatABI::Soft, "soft",
142                                 "Soft float ABI (implied by -soft-float)"),
143                      clEnumValN(FloatABI::Hard, "hard",
144                                 "Hard float ABI (uses FP registers)"),
145                      clEnumValEnd));
146
147 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
148 FuseFPOps("fp-contract",
149           cl::desc("Enable aggressive formation of fused FP ops"),
150           cl::init(FPOpFusion::Standard),
151           cl::values(
152               clEnumValN(FPOpFusion::Fast, "fast",
153                          "Fuse FP ops whenever profitable"),
154               clEnumValN(FPOpFusion::Standard, "on",
155                          "Only fuse 'blessed' FP ops."),
156               clEnumValN(FPOpFusion::Strict, "off",
157                          "Only fuse FP ops when the result won't be effected."),
158               clEnumValEnd));
159
160 cl::opt<bool>
161 DontPlaceZerosInBSS("nozero-initialized-in-bss",
162               cl::desc("Don't place zero-initialized symbols into bss section"),
163               cl::init(false));
164
165 cl::opt<bool>
166 EnableGuaranteedTailCallOpt("tailcallopt",
167   cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
168   cl::init(false));
169
170 cl::opt<bool>
171 DisableTailCalls("disable-tail-calls",
172                  cl::desc("Never emit tail calls"),
173                  cl::init(false));
174
175 cl::opt<unsigned>
176 OverrideStackAlignment("stack-alignment",
177                        cl::desc("Override default stack alignment"),
178                        cl::init(0));
179
180 cl::opt<std::string>
181 TrapFuncName("trap-func", cl::Hidden,
182         cl::desc("Emit a call to trap function rather than a trap instruction"),
183         cl::init(""));
184
185 cl::opt<bool>
186 EnablePIE("enable-pie",
187           cl::desc("Assume the creation of a position independent executable."),
188           cl::init(false));
189
190 cl::opt<bool>
191 UseInitArray("use-init-array",
192              cl::desc("Use .init_array instead of .ctors."),
193              cl::init(false));
194
195 cl::opt<std::string> StopAfter("stop-after",
196                             cl::desc("Stop compilation after a specific pass"),
197                             cl::value_desc("pass-name"),
198                                       cl::init(""));
199 cl::opt<std::string> StartAfter("start-after",
200                           cl::desc("Resume compilation after a specific pass"),
201                           cl::value_desc("pass-name"),
202                           cl::init(""));
203
204 // Common utility function tightly tied to the options listed here. Initializes
205 // a TargetOptions object with CodeGen flags and returns it.
206 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
207   TargetOptions Options;
208   Options.LessPreciseFPMADOption = EnableFPMAD;
209   Options.NoFramePointerElim = DisableFPElim;
210   Options.AllowFPOpFusion = FuseFPOps;
211   Options.UnsafeFPMath = EnableUnsafeFPMath;
212   Options.NoInfsFPMath = EnableNoInfsFPMath;
213   Options.NoNaNsFPMath = EnableNoNaNsFPMath;
214   Options.HonorSignDependentRoundingFPMathOption =
215       EnableHonorSignDependentRoundingFPMath;
216   Options.UseSoftFloat = GenerateSoftFloatCalls;
217   if (FloatABIForCalls != FloatABI::Default)
218     Options.FloatABIType = FloatABIForCalls;
219   Options.NoZerosInBSS = DontPlaceZerosInBSS;
220   Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
221   Options.DisableTailCalls = DisableTailCalls;
222   Options.StackAlignmentOverride = OverrideStackAlignment;
223   Options.TrapFuncName = TrapFuncName;
224   Options.PositionIndependentExecutable = EnablePIE;
225   Options.UseInitArray = UseInitArray;
226
227   Options.MCOptions = InitMCTargetOptionsFromFlags();
228
229   return Options;
230 }
231
232 #endif