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",
74 RelaxAll("mc-relax-all",
75 cl::desc("When used with filetype=obj, "
76 "relax all fixups in the emitted object file"));
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):"),
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"),
90 cl::opt<bool> DisableCFI("disable-cfi", cl::Hidden,
91 cl::desc("Do not use .cfi_* directives"));
93 cl::opt<bool> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
94 cl::desc("Use .file directives with an explicit directory."));
97 DisableRedZone("disable-red-zone",
98 cl::desc("Do not emit code that uses the red zone."),
102 EnableFPMAD("enable-fp-mad",
103 cl::desc("Enable less precise MAD instructions to be generated"),
107 DisableFPElim("disable-fp-elim",
108 cl::desc("Disable frame pointer elimination optimization"),
112 EnableUnsafeFPMath("enable-unsafe-fp-math",
113 cl::desc("Enable optimizations that may decrease FP precision"),
117 EnableNoInfsFPMath("enable-no-infs-fp-math",
118 cl::desc("Enable FP math optimizations that assume no +-Infs"),
122 EnableNoNaNsFPMath("enable-no-nans-fp-math",
123 cl::desc("Enable FP math optimizations that assume no NaNs"),
127 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
129 cl::desc("Force codegen to assume rounding mode can change dynamically"),
133 GenerateSoftFloatCalls("soft-float",
134 cl::desc("Generate software floating point library calls"),
137 cl::opt<llvm::FloatABI::ABIType>
138 FloatABIForCalls("float-abi",
139 cl::desc("Choose float ABI type"),
140 cl::init(FloatABI::Default),
142 clEnumValN(FloatABI::Default, "default",
143 "Target default float ABI type"),
144 clEnumValN(FloatABI::Soft, "soft",
145 "Soft float ABI (implied by -soft-float)"),
146 clEnumValN(FloatABI::Hard, "hard",
147 "Hard float ABI (uses FP registers)"),
150 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
151 FuseFPOps("fp-contract",
152 cl::desc("Enable aggressive formation of fused FP ops"),
153 cl::init(FPOpFusion::Standard),
155 clEnumValN(FPOpFusion::Fast, "fast",
156 "Fuse FP ops whenever profitable"),
157 clEnumValN(FPOpFusion::Standard, "on",
158 "Only fuse 'blessed' FP ops."),
159 clEnumValN(FPOpFusion::Strict, "off",
160 "Only fuse FP ops when the result won't be effected."),
164 DontPlaceZerosInBSS("nozero-initialized-in-bss",
165 cl::desc("Don't place zero-initialized symbols into bss section"),
169 EnableGuaranteedTailCallOpt("tailcallopt",
170 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
174 DisableTailCalls("disable-tail-calls",
175 cl::desc("Never emit tail calls"),
179 OverrideStackAlignment("stack-alignment",
180 cl::desc("Override default stack alignment"),
184 TrapFuncName("trap-func", cl::Hidden,
185 cl::desc("Emit a call to trap function rather than a trap instruction"),
189 EnablePIE("enable-pie",
190 cl::desc("Assume the creation of a position independent executable."),
194 UseInitArray("use-init-array",
195 cl::desc("Use .init_array instead of .ctors."),
198 cl::opt<std::string> StopAfter("stop-after",
199 cl::desc("Stop compilation after a specific pass"),
200 cl::value_desc("pass-name"),
202 cl::opt<std::string> StartAfter("start-after",
203 cl::desc("Resume compilation after a specific pass"),
204 cl::value_desc("pass-name"),
207 // Common utility function tightly tied to the options listed here. Initializes
208 // a TargetOptions object with CodeGen flags and returns it.
209 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
210 TargetOptions Options;
211 Options.LessPreciseFPMADOption = EnableFPMAD;
212 Options.NoFramePointerElim = DisableFPElim;
213 Options.AllowFPOpFusion = FuseFPOps;
214 Options.UnsafeFPMath = EnableUnsafeFPMath;
215 Options.NoInfsFPMath = EnableNoInfsFPMath;
216 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
217 Options.HonorSignDependentRoundingFPMathOption =
218 EnableHonorSignDependentRoundingFPMath;
219 Options.UseSoftFloat = GenerateSoftFloatCalls;
220 if (FloatABIForCalls != FloatABI::Default)
221 Options.FloatABIType = FloatABIForCalls;
222 Options.NoZerosInBSS = DontPlaceZerosInBSS;
223 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
224 Options.DisableTailCalls = DisableTailCalls;
225 Options.StackAlignmentOverride = OverrideStackAlignment;
226 Options.TrapFuncName = TrapFuncName;
227 Options.PositionIndependentExecutable = EnablePIE;
228 Options.UseInitArray = UseInitArray;
230 Options.MCOptions = InitMCTargetOptionsFromFlags();