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> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
91 cl::desc("Use .file directives with an explicit directory."));
94 DisableRedZone("disable-red-zone",
95 cl::desc("Do not emit code that uses the red zone."),
99 EnableFPMAD("enable-fp-mad",
100 cl::desc("Enable less precise MAD instructions to be generated"),
104 DisableFPElim("disable-fp-elim",
105 cl::desc("Disable frame pointer elimination optimization"),
109 EnableUnsafeFPMath("enable-unsafe-fp-math",
110 cl::desc("Enable optimizations that may decrease FP precision"),
114 EnableNoInfsFPMath("enable-no-infs-fp-math",
115 cl::desc("Enable FP math optimizations that assume no +-Infs"),
119 EnableNoNaNsFPMath("enable-no-nans-fp-math",
120 cl::desc("Enable FP math optimizations that assume no NaNs"),
124 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
126 cl::desc("Force codegen to assume rounding mode can change dynamically"),
130 GenerateSoftFloatCalls("soft-float",
131 cl::desc("Generate software floating point library calls"),
134 cl::opt<llvm::FloatABI::ABIType>
135 FloatABIForCalls("float-abi",
136 cl::desc("Choose float ABI type"),
137 cl::init(FloatABI::Default),
139 clEnumValN(FloatABI::Default, "default",
140 "Target default float ABI type"),
141 clEnumValN(FloatABI::Soft, "soft",
142 "Soft float ABI (implied by -soft-float)"),
143 clEnumValN(FloatABI::Hard, "hard",
144 "Hard float ABI (uses FP registers)"),
147 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
148 FuseFPOps("fp-contract",
149 cl::desc("Enable aggressive formation of fused FP ops"),
150 cl::init(FPOpFusion::Standard),
152 clEnumValN(FPOpFusion::Fast, "fast",
153 "Fuse FP ops whenever profitable"),
154 clEnumValN(FPOpFusion::Standard, "on",
155 "Only fuse 'blessed' FP ops."),
156 clEnumValN(FPOpFusion::Strict, "off",
157 "Only fuse FP ops when the result won't be effected."),
161 DontPlaceZerosInBSS("nozero-initialized-in-bss",
162 cl::desc("Don't place zero-initialized symbols into bss section"),
166 EnableGuaranteedTailCallOpt("tailcallopt",
167 cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
171 DisableTailCalls("disable-tail-calls",
172 cl::desc("Never emit tail calls"),
176 OverrideStackAlignment("stack-alignment",
177 cl::desc("Override default stack alignment"),
181 TrapFuncName("trap-func", cl::Hidden,
182 cl::desc("Emit a call to trap function rather than a trap instruction"),
186 EnablePIE("enable-pie",
187 cl::desc("Assume the creation of a position independent executable."),
191 UseInitArray("use-init-array",
192 cl::desc("Use .init_array instead of .ctors."),
195 cl::opt<std::string> StopAfter("stop-after",
196 cl::desc("Stop compilation after a specific pass"),
197 cl::value_desc("pass-name"),
199 cl::opt<std::string> StartAfter("start-after",
200 cl::desc("Resume compilation after a specific pass"),
201 cl::value_desc("pass-name"),
204 // Common utility function tightly tied to the options listed here. Initializes
205 // a TargetOptions object with CodeGen flags and returns it.
206 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
207 TargetOptions Options;
208 Options.LessPreciseFPMADOption = EnableFPMAD;
209 Options.NoFramePointerElim = DisableFPElim;
210 Options.AllowFPOpFusion = FuseFPOps;
211 Options.UnsafeFPMath = EnableUnsafeFPMath;
212 Options.NoInfsFPMath = EnableNoInfsFPMath;
213 Options.NoNaNsFPMath = EnableNoNaNsFPMath;
214 Options.HonorSignDependentRoundingFPMathOption =
215 EnableHonorSignDependentRoundingFPMath;
216 Options.UseSoftFloat = GenerateSoftFloatCalls;
217 if (FloatABIForCalls != FloatABI::Default)
218 Options.FloatABIType = FloatABIForCalls;
219 Options.NoZerosInBSS = DontPlaceZerosInBSS;
220 Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
221 Options.DisableTailCalls = DisableTailCalls;
222 Options.StackAlignmentOverride = OverrideStackAlignment;
223 Options.TrapFuncName = TrapFuncName;
224 Options.PositionIndependentExecutable = EnablePIE;
225 Options.UseInitArray = UseInitArray;
227 Options.MCOptions = InitMCTargetOptionsFromFlags();