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