LLVM API Documentation

TargetMachine.cpp

Go to the documentation of this file.
00001 //===-- TargetMachine.cpp - General Target Information ---------------------==//
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 describes the general parts of a Target machine.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/Target/TargetAsmInfo.h"
00015 #include "llvm/Target/TargetMachine.h"
00016 #include "llvm/Target/TargetOptions.h"
00017 #include "llvm/Support/CommandLine.h"
00018 using namespace llvm;
00019 
00020 //---------------------------------------------------------------------------
00021 // Command-line options that tend to be useful on more than one back-end.
00022 //
00023 
00024 namespace llvm {
00025   bool PrintMachineCode;
00026   bool NoFramePointerElim;
00027   bool NoExcessFPPrecision;
00028   bool UnsafeFPMath;
00029   bool FiniteOnlyFPMathOption;
00030   bool HonorSignDependentRoundingFPMathOption;
00031   bool UseSoftFloat;
00032   bool NoZerosInBSS;
00033   bool ExceptionHandling;
00034   bool UnwindTablesMandatory;
00035   Reloc::Model RelocationModel;
00036   CodeModel::Model CMModel;
00037   bool PerformTailCallOpt;
00038   unsigned StackAlignment;
00039   bool RealignStack;
00040   bool VerboseAsm;
00041   bool DisableJumpTables;
00042   bool StrongPHIElim;
00043 }
00044 
00045 static cl::opt<bool, true> PrintCode("print-machineinstrs",
00046   cl::desc("Print generated machine code"),
00047   cl::location(PrintMachineCode), cl::init(false));
00048 
00049 static cl::opt<bool, true>
00050 DisableFPElim("disable-fp-elim",
00051               cl::desc("Disable frame pointer elimination optimization"),
00052               cl::location(NoFramePointerElim),
00053               cl::init(false));
00054 static cl::opt<bool, true>
00055 DisableExcessPrecision("disable-excess-fp-precision",
00056              cl::desc("Disable optimizations that may increase FP precision"),
00057              cl::location(NoExcessFPPrecision),
00058              cl::init(false));
00059 static cl::opt<bool, true>
00060 EnableUnsafeFPMath("enable-unsafe-fp-math",
00061              cl::desc("Enable optimizations that may decrease FP precision"),
00062              cl::location(UnsafeFPMath),
00063              cl::init(false));
00064 static cl::opt<bool, true>
00065 EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
00066              cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
00067              cl::location(FiniteOnlyFPMathOption),
00068              cl::init(false));
00069 static cl::opt<bool, true>
00070 EnableHonorSignDependentRoundingFPMath(cl::Hidden,
00071              "enable-sign-dependent-rounding-fp-math",
00072      cl::desc("Force codegen to assume rounding mode can change dynamically"),
00073              cl::location(HonorSignDependentRoundingFPMathOption),
00074              cl::init(false));
00075 
00076 static cl::opt<bool, true>
00077 GenerateSoftFloatCalls("soft-float",
00078              cl::desc("Generate software floating point library calls"),
00079              cl::location(UseSoftFloat),
00080              cl::init(false));
00081 static cl::opt<bool, true>
00082 DontPlaceZerosInBSS("nozero-initialized-in-bss",
00083             cl::desc("Don't place zero-initialized symbols into bss section"),
00084             cl::location(NoZerosInBSS),
00085             cl::init(false));
00086 static cl::opt<bool, true>
00087 EnableExceptionHandling("enable-eh",
00088              cl::desc("Emit DWARF exception handling (default if target supports)"),
00089              cl::location(ExceptionHandling),
00090              cl::init(false));
00091 static cl::opt<bool, true>
00092 EnableUnwindTables("unwind-tables",
00093              cl::desc("Generate unwinding tables for all functions"),
00094              cl::location(UnwindTablesMandatory),
00095              cl::init(false));
00096 
00097 static cl::opt<llvm::Reloc::Model, true>
00098 DefRelocationModel(
00099   "relocation-model",
00100   cl::desc("Choose relocation model"),
00101   cl::location(RelocationModel),
00102   cl::init(Reloc::Default),
00103   cl::values(
00104     clEnumValN(Reloc::Default, "default",
00105                "Target default relocation model"),
00106     clEnumValN(Reloc::Static, "static",
00107                "Non-relocatable code"),
00108     clEnumValN(Reloc::PIC_, "pic",
00109                "Fully relocatable, position independent code"),
00110     clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
00111                "Relocatable external references, non-relocatable code"),
00112     clEnumValEnd));
00113 static cl::opt<llvm::CodeModel::Model, true>
00114 DefCodeModel(
00115   "code-model",
00116   cl::desc("Choose code model"),
00117   cl::location(CMModel),
00118   cl::init(CodeModel::Default),
00119   cl::values(
00120     clEnumValN(CodeModel::Default, "default",
00121                "Target default code model"),
00122     clEnumValN(CodeModel::Small, "small",
00123                "Small code model"),
00124     clEnumValN(CodeModel::Kernel, "kernel",
00125                "Kernel code model"),
00126     clEnumValN(CodeModel::Medium, "medium",
00127                "Medium code model"),
00128     clEnumValN(CodeModel::Large, "large",
00129                "Large code model"),
00130     clEnumValEnd));
00131 
00132 static cl::opt<bool, true>
00133 EnablePerformTailCallOpt("tailcallopt",
00134                          cl::desc("Turn on tail call optimization."),
00135                          cl::location(PerformTailCallOpt),
00136                          cl::init(false));
00137 
00138 static cl::opt<unsigned, true>
00139 OverrideStackAlignment("stack-alignment",
00140                        cl::desc("Override default stack alignment"),
00141                        cl::location(StackAlignment),
00142                        cl::init(0));
00143 
00144 static cl::opt<bool, true>
00145 EnableRealignStack("realign-stack",
00146                    cl::desc("Realign stack if needed"),
00147                    cl::location(RealignStack),
00148                    cl::init(true));
00149 
00150 static cl::opt<bool, true>
00151 AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
00152            cl::location(VerboseAsm),
00153            cl::init(false));
00154 
00155 static cl::opt<bool, true>
00156 DisableSwitchTables(cl::Hidden, "disable-jump-tables", 
00157            cl::desc("Do not generate jump tables."),
00158            cl::location(DisableJumpTables),
00159            cl::init(false));
00160 
00161 static cl::opt<bool, true>
00162 EnableStrongPHIElim(cl::Hidden, "strong-phi-elim",
00163            cl::desc("Use strong PHI elimination."),
00164            cl::location(StrongPHIElim),
00165            cl::init(false));
00166 
00167 //---------------------------------------------------------------------------
00168 // TargetMachine Class
00169 //
00170 
00171 TargetMachine::~TargetMachine() {
00172   delete AsmInfo;
00173 }
00174 
00175 /// getRelocationModel - Returns the code generation relocation model. The
00176 /// choices are static, PIC, and dynamic-no-pic, and target default.
00177 Reloc::Model TargetMachine::getRelocationModel() {
00178   return RelocationModel;
00179 }
00180 
00181 /// setRelocationModel - Sets the code generation relocation model.
00182 void TargetMachine::setRelocationModel(Reloc::Model Model) {
00183   RelocationModel = Model;
00184 }
00185 
00186 /// getCodeModel - Returns the code model. The choices are small, kernel,
00187 /// medium, large, and target default.
00188 CodeModel::Model TargetMachine::getCodeModel() {
00189   return CMModel;
00190 }
00191 
00192 /// setCodeModel - Sets the code model.
00193 void TargetMachine::setCodeModel(CodeModel::Model Model) {
00194   CMModel = Model;
00195 }
00196 
00197 namespace llvm {
00198   /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
00199   /// option is specified on the command line. If this returns false (default),
00200   /// the code generator is not allowed to assume that FP arithmetic arguments
00201   /// and results are never NaNs or +-Infs.
00202   bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
00203   
00204   /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
00205   /// that the rounding mode of the FPU can change from its default.
00206   bool HonorSignDependentRoundingFPMath() {
00207     return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
00208   }
00209 }
00210 



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.