1 //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
17 #define LLVM_CODEGEN_COMMANDFLAGS_H
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"
28 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
32 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
33 cl::value_desc("cpu-name"),
39 cl::desc("Target specific attributes (-mattr=help for details)"),
40 cl::value_desc("a1,+a2,-a3,..."));
43 RelocModel("relocation-model",
44 cl::desc("Choose relocation model"),
45 cl::init(Reloc::Default),
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"),
57 cl::opt<llvm::CodeModel::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",
65 clEnumValN(CodeModel::Kernel, "kernel",
67 clEnumValN(CodeModel::Medium, "medium",
69 clEnumValN(CodeModel::Large, "large",
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):"),
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"),
86 DisableRedZone("disable-red-zone",
87 cl::desc("Do not emit code that uses the red zone."),
91 EnableFPMAD("enable-fp-mad",
92 cl::desc("Enable less precise MAD instructions to be generated"),
96 DisableFPElim("disable-fp-elim",
97 cl::desc("Disable frame pointer elimination optimization"),
101 EnableUnsafeFPMath("enable-unsafe-fp-math",
102 cl::desc("Enable optimizations that may decrease FP precision"),
106 EnableNoInfsFPMath("enable-no-infs-fp-math",
107 cl::desc("Enable FP math optimizations that assume no +-Infs"),
111 EnableNoNaNsFPMath("enable-no-nans-fp-math",
112 cl::desc("Enable FP math optimizations that assume no NaNs"),
116 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
118 cl::desc("Force codegen to assume rounding mode can change dynamically"),
122 GenerateSoftFloatCalls("soft-float",
123 cl::desc("Generate software floating point library calls"),
126 cl::opt<llvm::FloatABI::ABIType>
127 FloatABIForCalls("float-abi",
128 cl::desc("Choose float ABI type"),
129 cl::init(FloatABI::Default),
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)"),
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),
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."),
153 DontPlaceZerosInBSS("nozero-initialized-in-bss",
154 cl::desc("Don't place zero-initialized symbols into bss section"),
158 EnableGuaranteedTailCallOpt("tailcallopt",
159 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
163 DisableTailCalls("disable-tail-calls",
164 cl::desc("Never emit tail calls"),
168 OverrideStackAlignment("stack-alignment",
169 cl::desc("Override default stack alignment"),
173 TrapFuncName("trap-func", cl::Hidden,
174 cl::desc("Emit a call to trap function rather than a trap instruction"),
178 EnablePIE("enable-pie",
179 cl::desc("Assume the creation of a position independent executable."),
183 UseInitArray("use-init-array",
184 cl::desc("Use .init_array instead of .ctors."),
187 cl::opt<std::string> StopAfter("stop-after",
188 cl::desc("Stop compilation after a specific pass"),
189 cl::value_desc("pass-name"),
191 cl::opt<std::string> StartAfter("start-after",
192 cl::desc("Resume compilation after a specific pass"),
193 cl::value_desc("pass-name"),
196 cl::opt<bool> DataSections("data-sections",
197 cl::desc("Emit data into separate sections"),
201 FunctionSections("function-sections",
202 cl::desc("Emit functions into separate sections"),
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),
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."),
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;
245 Options.MCOptions = InitMCTargetOptionsFromFlags();
246 Options.JTType = JTableType;