LLVM API Documentation

CommandFlags.h
Go to the documentation of this file.
00001 //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains codegen-specific flags that are shared between different
00011 // command line tools. The tools "llc" and "opt" both use this file to prevent
00012 // flag duplication.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
00017 #define LLVM_CODEGEN_COMMANDFLAGS_H
00018 
00019 #include "llvm/MC/MCTargetOptionsCommandFlags.h"
00020 #include "llvm/Support/CodeGen.h"
00021 #include "llvm/Support/CommandLine.h"
00022 #include "llvm/Target/TargetMachine.h"
00023 #include "llvm/Target/TargetOptions.h"
00024 #include <string>
00025 using namespace llvm;
00026 
00027 cl::opt<std::string>
00028 MArch("march", cl::desc("Architecture to generate code for (see --version)"));
00029 
00030 cl::opt<std::string>
00031 MCPU("mcpu",
00032      cl::desc("Target a specific cpu type (-mcpu=help for details)"),
00033      cl::value_desc("cpu-name"),
00034      cl::init(""));
00035 
00036 cl::list<std::string>
00037 MAttrs("mattr",
00038        cl::CommaSeparated,
00039        cl::desc("Target specific attributes (-mattr=help for details)"),
00040        cl::value_desc("a1,+a2,-a3,..."));
00041 
00042 cl::opt<Reloc::Model>
00043 RelocModel("relocation-model",
00044            cl::desc("Choose relocation model"),
00045            cl::init(Reloc::Default),
00046            cl::values(
00047               clEnumValN(Reloc::Default, "default",
00048                       "Target default relocation model"),
00049               clEnumValN(Reloc::Static, "static",
00050                       "Non-relocatable code"),
00051               clEnumValN(Reloc::PIC_, "pic",
00052                       "Fully relocatable, position independent code"),
00053               clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
00054                       "Relocatable external references, non-relocatable code"),
00055               clEnumValEnd));
00056 
00057 cl::opt<ThreadModel::Model>
00058 TMModel("thread-model",
00059         cl::desc("Choose threading model"),
00060         cl::init(ThreadModel::POSIX),
00061         cl::values(clEnumValN(ThreadModel::POSIX, "posix",
00062                               "POSIX thread model"),
00063                    clEnumValN(ThreadModel::Single, "single",
00064                               "Single thread model"),
00065                    clEnumValEnd));
00066 
00067 cl::opt<llvm::CodeModel::Model>
00068 CMModel("code-model",
00069         cl::desc("Choose code model"),
00070         cl::init(CodeModel::Default),
00071         cl::values(clEnumValN(CodeModel::Default, "default",
00072                               "Target default code model"),
00073                    clEnumValN(CodeModel::Small, "small",
00074                               "Small code model"),
00075                    clEnumValN(CodeModel::Kernel, "kernel",
00076                               "Kernel code model"),
00077                    clEnumValN(CodeModel::Medium, "medium",
00078                               "Medium code model"),
00079                    clEnumValN(CodeModel::Large, "large",
00080                               "Large code model"),
00081                    clEnumValEnd));
00082 
00083 cl::opt<TargetMachine::CodeGenFileType>
00084 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
00085   cl::desc("Choose a file type (not all types are supported by all targets):"),
00086   cl::values(
00087              clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
00088                         "Emit an assembly ('.s') file"),
00089              clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
00090                         "Emit a native object ('.o') file"),
00091              clEnumValN(TargetMachine::CGFT_Null, "null",
00092                         "Emit nothing, for performance testing"),
00093              clEnumValEnd));
00094 
00095 cl::opt<bool>
00096 DisableRedZone("disable-red-zone",
00097                cl::desc("Do not emit code that uses the red zone."),
00098                cl::init(false));
00099 
00100 cl::opt<bool>
00101 EnableFPMAD("enable-fp-mad",
00102             cl::desc("Enable less precise MAD instructions to be generated"),
00103             cl::init(false));
00104 
00105 cl::opt<bool>
00106 DisableFPElim("disable-fp-elim",
00107               cl::desc("Disable frame pointer elimination optimization"),
00108               cl::init(false));
00109 
00110 cl::opt<bool>
00111 EnableUnsafeFPMath("enable-unsafe-fp-math",
00112                 cl::desc("Enable optimizations that may decrease FP precision"),
00113                 cl::init(false));
00114 
00115 cl::opt<bool>
00116 EnableNoInfsFPMath("enable-no-infs-fp-math",
00117                 cl::desc("Enable FP math optimizations that assume no +-Infs"),
00118                 cl::init(false));
00119 
00120 cl::opt<bool>
00121 EnableNoNaNsFPMath("enable-no-nans-fp-math",
00122                    cl::desc("Enable FP math optimizations that assume no NaNs"),
00123                    cl::init(false));
00124 
00125 cl::opt<bool>
00126 EnableHonorSignDependentRoundingFPMath("enable-sign-dependent-rounding-fp-math",
00127       cl::Hidden,
00128       cl::desc("Force codegen to assume rounding mode can change dynamically"),
00129       cl::init(false));
00130 
00131 cl::opt<bool>
00132 GenerateSoftFloatCalls("soft-float",
00133                     cl::desc("Generate software floating point library calls"),
00134                     cl::init(false));
00135 
00136 cl::opt<llvm::FloatABI::ABIType>
00137 FloatABIForCalls("float-abi",
00138                  cl::desc("Choose float ABI type"),
00139                  cl::init(FloatABI::Default),
00140                  cl::values(
00141                      clEnumValN(FloatABI::Default, "default",
00142                                 "Target default float ABI type"),
00143                      clEnumValN(FloatABI::Soft, "soft",
00144                                 "Soft float ABI (implied by -soft-float)"),
00145                      clEnumValN(FloatABI::Hard, "hard",
00146                                 "Hard float ABI (uses FP registers)"),
00147                      clEnumValEnd));
00148 
00149 cl::opt<llvm::FPOpFusion::FPOpFusionMode>
00150 FuseFPOps("fp-contract",
00151           cl::desc("Enable aggressive formation of fused FP ops"),
00152           cl::init(FPOpFusion::Standard),
00153           cl::values(
00154               clEnumValN(FPOpFusion::Fast, "fast",
00155                          "Fuse FP ops whenever profitable"),
00156               clEnumValN(FPOpFusion::Standard, "on",
00157                          "Only fuse 'blessed' FP ops."),
00158               clEnumValN(FPOpFusion::Strict, "off",
00159                          "Only fuse FP ops when the result won't be effected."),
00160               clEnumValEnd));
00161 
00162 cl::opt<bool>
00163 DontPlaceZerosInBSS("nozero-initialized-in-bss",
00164               cl::desc("Don't place zero-initialized symbols into bss section"),
00165               cl::init(false));
00166 
00167 cl::opt<bool>
00168 EnableGuaranteedTailCallOpt("tailcallopt",
00169   cl::desc("Turn fastcc calls into tail calls by (potentially) changing ABI."),
00170   cl::init(false));
00171 
00172 cl::opt<bool>
00173 DisableTailCalls("disable-tail-calls",
00174                  cl::desc("Never emit tail calls"),
00175                  cl::init(false));
00176 
00177 cl::opt<unsigned>
00178 OverrideStackAlignment("stack-alignment",
00179                        cl::desc("Override default stack alignment"),
00180                        cl::init(0));
00181 
00182 cl::opt<std::string>
00183 TrapFuncName("trap-func", cl::Hidden,
00184         cl::desc("Emit a call to trap function rather than a trap instruction"),
00185         cl::init(""));
00186 
00187 cl::opt<bool>
00188 EnablePIE("enable-pie",
00189           cl::desc("Assume the creation of a position independent executable."),
00190           cl::init(false));
00191 
00192 cl::opt<bool>
00193 UseCtors("use-ctors",
00194              cl::desc("Use .ctors instead of .init_array."),
00195              cl::init(false));
00196 
00197 cl::opt<std::string> StopAfter("stop-after",
00198                             cl::desc("Stop compilation after a specific pass"),
00199                             cl::value_desc("pass-name"),
00200                                       cl::init(""));
00201 cl::opt<std::string> StartAfter("start-after",
00202                           cl::desc("Resume compilation after a specific pass"),
00203                           cl::value_desc("pass-name"),
00204                           cl::init(""));
00205 
00206 cl::opt<bool> DataSections("data-sections",
00207                            cl::desc("Emit data into separate sections"),
00208                            cl::init(false));
00209 
00210 cl::opt<bool>
00211 FunctionSections("function-sections",
00212                  cl::desc("Emit functions into separate sections"),
00213                  cl::init(false));
00214 
00215 cl::opt<llvm::JumpTable::JumpTableType>
00216 JTableType("jump-table-type",
00217           cl::desc("Choose the type of Jump-Instruction Table for jumptable."),
00218           cl::init(JumpTable::Single),
00219           cl::values(
00220               clEnumValN(JumpTable::Single, "single",
00221                          "Create a single table for all jumptable functions"),
00222               clEnumValN(JumpTable::Arity, "arity",
00223                          "Create one table per number of parameters."),
00224               clEnumValN(JumpTable::Simplified, "simplified",
00225                          "Create one table per simplified function type."),
00226               clEnumValN(JumpTable::Full, "full",
00227                          "Create one table per unique function type."),
00228               clEnumValEnd));
00229 
00230 // Common utility function tightly tied to the options listed here. Initializes
00231 // a TargetOptions object with CodeGen flags and returns it.
00232 static inline TargetOptions InitTargetOptionsFromCodeGenFlags() {
00233   TargetOptions Options;
00234   Options.LessPreciseFPMADOption = EnableFPMAD;
00235   Options.NoFramePointerElim = DisableFPElim;
00236   Options.AllowFPOpFusion = FuseFPOps;
00237   Options.UnsafeFPMath = EnableUnsafeFPMath;
00238   Options.NoInfsFPMath = EnableNoInfsFPMath;
00239   Options.NoNaNsFPMath = EnableNoNaNsFPMath;
00240   Options.HonorSignDependentRoundingFPMathOption =
00241       EnableHonorSignDependentRoundingFPMath;
00242   Options.UseSoftFloat = GenerateSoftFloatCalls;
00243   if (FloatABIForCalls != FloatABI::Default)
00244     Options.FloatABIType = FloatABIForCalls;
00245   Options.NoZerosInBSS = DontPlaceZerosInBSS;
00246   Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
00247   Options.DisableTailCalls = DisableTailCalls;
00248   Options.StackAlignmentOverride = OverrideStackAlignment;
00249   Options.TrapFuncName = TrapFuncName;
00250   Options.PositionIndependentExecutable = EnablePIE;
00251   Options.UseInitArray = !UseCtors;
00252   Options.DataSections = DataSections;
00253   Options.FunctionSections = FunctionSections;
00254 
00255   Options.MCOptions = InitMCTargetOptionsFromFlags();
00256   Options.JTType = JTableType;
00257 
00258   Options.ThreadModel = TMModel;
00259 
00260   return Options;
00261 }
00262 
00263 #endif