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/Support/CodeGen.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetOptions.h"
27 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
31 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
32 cl::value_desc("cpu-name"),
38 cl::desc("Target specific attributes (-mattr=help for details)"),
39 cl::value_desc("a1,+a2,-a3,..."));
42 RelocModel("relocation-model",
43 cl::desc("Choose relocation model"),
44 cl::init(Reloc::Default),
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"),
56 cl::opt<llvm::CodeModel::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",
64 clEnumValN(CodeModel::Kernel, "kernel",
66 clEnumValN(CodeModel::Medium, "medium",
68 clEnumValN(CodeModel::Large, "large",
73 RelaxAll("mc-relax-all",
74 cl::desc("When used with filetype=obj, "
75 "relax all fixups in the emitted object file"));
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):"),
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"),
89 cl::opt<bool> DisableCFI("disable-cfi", cl::Hidden,
90 cl::desc("Do not use .cfi_* directives"));
92 cl::opt<bool> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
93 cl::desc("Use .file directives with an explicit directory."));
96 DisableRedZone("disable-red-zone",
97 cl::desc("Do not emit code that uses the red zone."),
101 EnableFPMAD("enable-fp-mad",
102 cl::desc("Enable less precise MAD instructions to be generated"),
106 DisableFPElim("disable-fp-elim",
107 cl::desc("Disable frame pointer elimination optimization"),
111 EnableUnsafeFPMath("enable-unsafe-fp-math",
112 cl::desc("Enable optimizations that may decrease FP precision"),
116 EnableNoInfsFPMath("enable-no-infs-fp-math",
117 cl::desc("Enable FP math optimizations that assume no +-Infs"),
121 EnableNoNaNsFPMath("enable-no-nans-fp-math",
122 cl::desc("Enable FP math optimizations that assume no NaNs"),
126 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
128 cl::desc("Force codegen to assume rounding mode can change dynamically"),
132 GenerateSoftFloatCalls("soft-float",
133 cl::desc("Generate software floating point library calls"),
136 cl::opt<llvm::FloatABI::ABIType>
137 FloatABIForCalls("float-abi",
138 cl::desc("Choose float ABI type"),
139 cl::init(FloatABI::Default),
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)"),
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),
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."),
163 DontPlaceZerosInBSS("nozero-initialized-in-bss",
164 cl::desc("Don't place zero-initialized symbols into bss section"),
168 EnableGuaranteedTailCallOpt("tailcallopt",
169 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
173 DisableTailCalls("disable-tail-calls",
174 cl::desc("Never emit tail calls"),
178 OverrideStackAlignment("stack-alignment",
179 cl::desc("Override default stack alignment"),
183 TrapFuncName("trap-func", cl::Hidden,
184 cl::desc("Emit a call to trap function rather than a trap instruction"),
188 EnablePIE("enable-pie",
189 cl::desc("Assume the creation of a position independent executable."),
193 SegmentedStacks("segmented-stacks",
194 cl::desc("Use segmented stacks if possible."),
198 UseInitArray("use-init-array",
199 cl::desc("Use .init_array instead of .ctors."),
202 cl::opt<std::string> StopAfter("stop-after",
203 cl::desc("Stop compilation after a specific pass"),
204 cl::value_desc("pass-name"),
206 cl::opt<std::string> StartAfter("start-after",
207 cl::desc("Resume compilation after a specific pass"),
208 cl::value_desc("pass-name"),
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;