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