1 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines command line option flags that are shared across various 11 // targets. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_TARGET_TARGETOPTIONS_H 16 #define LLVM_TARGET_TARGETOPTIONS_H 17 18 #include <string> 19 20 namespace llvm { 21 class MachineFunction; 22 class StringRef; 23 24 // Possible float ABI settings. Used with FloatABIType in TargetOptions.h. 25 namespace FloatABI { 26 enum ABIType { 27 Default, // Target-specific (either soft or hard depending on triple, etc). 28 Soft, // Soft float. 29 Hard // Hard float. 30 }; 31 } 32 33 class TargetOptions { 34 public: TargetOptions()35 TargetOptions() 36 : PrintMachineCode(false), NoFramePointerElim(false), 37 NoFramePointerElimNonLeaf(false), LessPreciseFPMADOption(false), 38 NoExcessFPPrecision(false), UnsafeFPMath(false), NoInfsFPMath(false), 39 NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false), 40 UseSoftFloat(false), NoZerosInBSS(false), JITExceptionHandling(false), 41 JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false), 42 GuaranteedTailCallOpt(false), DisableTailCalls(false), 43 StackAlignmentOverride(0), RealignStack(true), 44 DisableJumpTables(false), EnableFastISel(false), 45 PositionIndependentExecutable(false), EnableSegmentedStacks(false), 46 TrapFuncName(""), FloatABIType(FloatABI::Default) 47 {} 48 49 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs 50 /// option is specified on the command line, and should enable debugging 51 /// output from the code generator. 52 unsigned PrintMachineCode : 1; 53 54 /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is 55 /// specified on the command line. If the target supports the frame pointer 56 /// elimination optimization, this option should disable it. 57 unsigned NoFramePointerElim : 1; 58 59 /// NoFramePointerElimNonLeaf - This flag is enabled when the 60 /// -disable-non-leaf-fp-elim is specified on the command line. If the 61 /// target supports the frame pointer elimination optimization, this option 62 /// should disable it for non-leaf functions. 63 unsigned NoFramePointerElimNonLeaf : 1; 64 65 /// DisableFramePointerElim - This returns true if frame pointer elimination 66 /// optimization should be disabled for the given machine function. 67 bool DisableFramePointerElim(const MachineFunction &MF) const; 68 69 /// LessPreciseFPMAD - This flag is enabled when the 70 /// -enable-fp-mad is specified on the command line. When this flag is off 71 /// (the default), the code generator is not allowed to generate mad 72 /// (multiply add) if the result is "less precise" than doing those 73 /// operations individually. 74 unsigned LessPreciseFPMADOption : 1; 75 bool LessPreciseFPMAD() const; 76 77 /// NoExcessFPPrecision - This flag is enabled when the 78 /// -disable-excess-fp-precision flag is specified on the command line. 79 /// When this flag is off (the default), the code generator is allowed to 80 /// produce results that are "more precise" than IEEE allows. This includes 81 /// use of FMA-like operations and use of the X86 FP registers without 82 /// rounding all over the place. 83 unsigned NoExcessFPPrecision : 1; 84 85 /// UnsafeFPMath - This flag is enabled when the 86 /// -enable-unsafe-fp-math flag is specified on the command line. When 87 /// this flag is off (the default), the code generator is not allowed to 88 /// produce results that are "less precise" than IEEE allows. This includes 89 /// use of X86 instructions like FSIN and FCOS instead of libcalls. 90 /// UnsafeFPMath implies LessPreciseFPMAD. 91 unsigned UnsafeFPMath : 1; 92 93 /// NoInfsFPMath - This flag is enabled when the 94 /// -enable-no-infs-fp-math flag is specified on the command line. When 95 /// this flag is off (the default), the code generator is not allowed to 96 /// assume the FP arithmetic arguments and results are never +-Infs. 97 unsigned NoInfsFPMath : 1; 98 99 /// NoNaNsFPMath - This flag is enabled when the 100 /// -enable-no-nans-fp-math flag is specified on the command line. When 101 /// this flag is off (the default), the code generator is not allowed to 102 /// assume the FP arithmetic arguments and results are never NaNs. 103 unsigned NoNaNsFPMath : 1; 104 105 /// HonorSignDependentRoundingFPMath - This returns true when the 106 /// -enable-sign-dependent-rounding-fp-math is specified. If this returns 107 /// false (the default), the code generator is allowed to assume that the 108 /// rounding behavior is the default (round-to-zero for all floating point 109 /// to integer conversions, and round-to-nearest for all other arithmetic 110 /// truncations). If this is enabled (set to true), the code generator must 111 /// assume that the rounding mode may dynamically change. 112 unsigned HonorSignDependentRoundingFPMathOption : 1; 113 bool HonorSignDependentRoundingFPMath() const; 114 115 /// UseSoftFloat - This flag is enabled when the -soft-float flag is 116 /// specified on the command line. When this flag is on, the code generator 117 /// will generate libcalls to the software floating point library instead of 118 /// target FP instructions. 119 unsigned UseSoftFloat : 1; 120 121 /// NoZerosInBSS - By default some codegens place zero-initialized data to 122 /// .bss section. This flag disables such behaviour (necessary, e.g. for 123 /// crt*.o compiling). 124 unsigned NoZerosInBSS : 1; 125 126 /// JITExceptionHandling - This flag indicates that the JIT should emit 127 /// exception handling information. 128 unsigned JITExceptionHandling : 1; 129 130 /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit 131 /// debug information and notify a debugger about it. 132 unsigned JITEmitDebugInfo : 1; 133 134 /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write 135 /// the object files generated by the JITEmitDebugInfo flag to disk. This 136 /// flag is hidden and is only for debugging the debug info. 137 unsigned JITEmitDebugInfoToDisk : 1; 138 139 /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is 140 /// specified on the commandline. When the flag is on, participating targets 141 /// will perform tail call optimization on all calls which use the fastcc 142 /// calling convention and which satisfy certain target-independent 143 /// criteria (being at the end of a function, having the same return type 144 /// as their parent function, etc.), using an alternate ABI if necessary. 145 unsigned GuaranteedTailCallOpt : 1; 146 147 /// DisableTailCalls - This flag controls whether we will use tail calls. 148 /// Disabling them may be useful to maintain a correct call stack. 149 unsigned DisableTailCalls : 1; 150 151 /// StackAlignmentOverride - Override default stack alignment for target. 152 unsigned StackAlignmentOverride; 153 154 /// RealignStack - This flag indicates whether the stack should be 155 /// automatically realigned, if needed. 156 unsigned RealignStack : 1; 157 158 /// DisableJumpTables - This flag indicates jump tables should not be 159 /// generated. 160 unsigned DisableJumpTables : 1; 161 162 /// EnableFastISel - This flag enables fast-path instruction selection 163 /// which trades away generated code quality in favor of reducing 164 /// compile time. 165 unsigned EnableFastISel : 1; 166 167 /// PositionIndependentExecutable - This flag indicates whether the code 168 /// will eventually be linked into a single executable, despite the PIC 169 /// relocation model being in use. It's value is undefined (and irrelevant) 170 /// if the relocation model is anything other than PIC. 171 unsigned PositionIndependentExecutable : 1; 172 173 unsigned EnableSegmentedStacks : 1; 174 175 /// getTrapFunctionName - If this returns a non-empty string, this means 176 /// isel should lower Intrinsic::trap to a call to the specified function 177 /// name instead of an ISD::TRAP node. 178 std::string TrapFuncName; 179 StringRef getTrapFunctionName() const; 180 181 /// FloatABIType - This setting is set by -float-abi=xxx option is specfied 182 /// on the command line. This setting may either be Default, Soft, or Hard. 183 /// Default selects the target's default behavior. Soft selects the ABI for 184 /// UseSoftFloat, but does not indicate that FP hardware may not be used. 185 /// Such a combination is unfortunately popular (e.g. arm-apple-darwin). 186 /// Hard presumes that the normal FP ABI is used. 187 FloatABI::ABIType FloatABIType; 188 }; 189 } // End llvm namespace 190 191 #endif 192