OSDN Git Service

Merge "Don't try to use Clang on Windows yet."
[android-x86/external-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/Support/CodeGen.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetOptions.h"
23 #include <string>
24 using namespace llvm;
25
26 cl::opt<std::string>
27 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
28
29 cl::opt<std::string>
30 MCPU("mcpu",
31      cl::desc("Target a specific cpu type (-mcpu=help for details)"),
32      cl::value_desc("cpu-name"),
33      cl::init(""));
34
35 cl::list<std::string>
36 MAttrs("mattr",
37        cl::CommaSeparated,
38        cl::desc("Target specific attributes (-mattr=help for details)"),
39        cl::value_desc("a1,+a2,-a3,..."));
40
41 cl::opt<Reloc::Model>
42 RelocModel("relocation-model",
43            cl::desc("Choose relocation model"),
44            cl::init(Reloc::Default),
45            cl::values(
46               clEnumValN(Reloc::Default, "default",
47                       "Target default relocation model"),
48               clEnumValN(Reloc::Static, "static",
49                       "Non-relocatable code"),
50               clEnumValN(Reloc::PIC_, "pic",
51                       "Fully relocatable, position independent code"),
52               clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
53                       "Relocatable external references, non-relocatable code"),
54               clEnumValEnd));
55
56 cl::opt<llvm::CodeModel::Model>
57 CMModel("code-model",
58         cl::desc("Choose code model"),
59         cl::init(CodeModel::Default),
60         cl::values(clEnumValN(CodeModel::Default, "default",
61                               "Target default code model"),
62                    clEnumValN(CodeModel::Small, "small",
63                               "Small code model"),
64                    clEnumValN(CodeModel::Kernel, "kernel",
65                               "Kernel code model"),
66                    clEnumValN(CodeModel::Medium, "medium",
67                               "Medium code model"),
68                    clEnumValN(CodeModel::Large, "large",
69                               "Large code model"),
70                    clEnumValEnd));
71
72 cl::opt<bool>
73 RelaxAll("mc-relax-all",
74          cl::desc("When used with filetype=obj, "
75                   "relax all fixups in the emitted object file"));
76
77 cl::opt<TargetMachine::CodeGenFileType>
78 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
79   cl::desc("Choose a file type (not all types are supported by all targets):"),
80   cl::values(
81              clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
82                         "Emit an assembly ('.s') file"),
83              clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
84                         "Emit a native object ('.o') file"),
85              clEnumValN(TargetMachine::CGFT_Null, "null",
86                         "Emit nothing, for performance testing"),
87              clEnumValEnd));
88
89 cl::opt<bool> DisableCFI("disable-cfi", cl::Hidden,
90                          cl::desc("Do not use .cfi_* directives"));
91
92 cl::opt<bool> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
93                   cl::desc("Use .file directives with an explicit directory."));
94
95 cl::opt<bool>
96 DisableRedZone("disable-red-zone",
97                cl::desc("Do not emit code that uses the red zone."),
98                cl::init(false));
99
100 cl::opt<bool>
101 EnableFPMAD("enable-fp-mad",
102             cl::desc("Enable less precise MAD instructions to be generated"),
103             cl::init(false));
104
105 cl::opt<bool>
106 DisableFPElim("disable-fp-elim",
107               cl::desc("Disable frame pointer elimination optimization"),
108               cl::init(false));
109
110 cl::opt<bool>
111 EnableUnsafeFPMath("enable-unsafe-fp-math",
112                 cl::desc("Enable optimizations that may decrease FP precision"),
113                 cl::init(false));
114
115 cl::opt<bool>
116 EnableNoInfsFPMath("enable-no-infs-fp-math",
117                 cl::desc("Enable FP math optimizations that assume no +-Infs"),
118                 cl::init(false));
119
120 cl::opt<bool>
121 EnableNoNaNsFPMath("enable-no-nans-fp-math",
122                    cl::desc("Enable FP math optimizations that assume no NaNs"),
123                    cl::init(false));
124
125 cl::opt<bool>
126 EnableHonorSignDependentRoundingFPMath("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
131 cl::opt<bool>
132 GenerateSoftFloatCalls("soft-float",
133                     cl::desc("Generate software floating point library calls"),
134                     cl::init(false));
135
136 cl::opt<llvm::FloatABI::ABIType>
137 FloatABIForCalls("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
149 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
150 FuseFPOps("fp-contract",
151           cl::desc("Enable aggressive formation of fused FP ops"),
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
162 cl::opt<bool>
163 DontPlaceZerosInBSS("nozero-initialized-in-bss",
164               cl::desc("Don't place zero-initialized symbols into bss section"),
165               cl::init(false));
166
167 cl::opt<bool>
168 EnableGuaranteedTailCallOpt("tailcallopt",
169   cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
170   cl::init(false));
171
172 cl::opt<bool>
173 DisableTailCalls("disable-tail-calls",
174                  cl::desc("Never emit tail calls"),
175                  cl::init(false));
176
177 cl::opt<unsigned>
178 OverrideStackAlignment("stack-alignment",
179                        cl::desc("Override default stack alignment"),
180                        cl::init(0));
181
182 cl::opt<std::string>
183 TrapFuncName("trap-func", cl::Hidden,
184         cl::desc("Emit a call to trap function rather than a trap instruction"),
185         cl::init(""));
186
187 cl::opt<bool>
188 EnablePIE("enable-pie",
189           cl::desc("Assume the creation of a position independent executable."),
190           cl::init(false));
191
192 cl::opt<bool>
193 SegmentedStacks("segmented-stacks",
194                 cl::desc("Use segmented stacks if possible."),
195                 cl::init(false));
196
197 cl::opt<bool>
198 UseInitArray("use-init-array",
199              cl::desc("Use .init_array instead of .ctors."),
200              cl::init(false));
201
202 cl::opt<std::string> StopAfter("stop-after",
203                             cl::desc("Stop compilation after a specific pass"),
204                             cl::value_desc("pass-name"),
205                                       cl::init(""));
206 cl::opt<std::string> StartAfter("start-after",
207                           cl::desc("Resume compilation after a specific pass"),
208                           cl::value_desc("pass-name"),
209                           cl::init(""));
210
211 // Common utility function tightly tied to the options listed here. Initializes
212 // a TargetOptions object with CodeGen flags and returns it.
213 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
214   TargetOptions Options;
215   Options.LessPreciseFPMADOption = EnableFPMAD;
216   Options.NoFramePointerElim = DisableFPElim;
217   Options.AllowFPOpFusion = FuseFPOps;
218   Options.UnsafeFPMath = EnableUnsafeFPMath;
219   Options.NoInfsFPMath = EnableNoInfsFPMath;
220   Options.NoNaNsFPMath = EnableNoNaNsFPMath;
221   Options.HonorSignDependentRoundingFPMathOption =
222       EnableHonorSignDependentRoundingFPMath;
223   Options.UseSoftFloat = GenerateSoftFloatCalls;
224   if (FloatABIForCalls != FloatABI::Default)
225     Options.FloatABIType = FloatABIForCalls;
226   Options.NoZerosInBSS = DontPlaceZerosInBSS;
227   Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
228   Options.DisableTailCalls = DisableTailCalls;
229   Options.StackAlignmentOverride = OverrideStackAlignment;
230   Options.TrapFuncName = TrapFuncName;
231   Options.PositionIndependentExecutable = EnablePIE;
232   Options.EnableSegmentedStacks = SegmentedStacks;
233   Options.UseInitArray = UseInitArray;
234   return Options;
235 }
236
237 #endif