Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
9.6 KiB

  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. #ifndef LLVM_TARGET_TARGETOPTIONS_H
  15. #define LLVM_TARGET_TARGETOPTIONS_H
  16. #include <string>
  17. namespace llvm {
  18. class MachineFunction;
  19. class StringRef;
  20. // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
  21. namespace FloatABI {
  22. enum ABIType {
  23. Default, // Target-specific (either soft or hard depending on triple,etc).
  24. Soft, // Soft float.
  25. Hard // Hard float.
  26. };
  27. }
  28. namespace FPOpFusion {
  29. enum FPOpFusionMode {
  30. Fast, // Enable fusion of FP ops wherever it's profitable.
  31. Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
  32. Strict // Never fuse FP-ops.
  33. };
  34. }
  35. class TargetOptions {
  36. public:
  37. TargetOptions()
  38. : PrintMachineCode(false), NoFramePointerElim(false),
  39. NoFramePointerElimNonLeaf(false), LessPreciseFPMADOption(false),
  40. UnsafeFPMath(false), NoInfsFPMath(false),
  41. NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false),
  42. UseSoftFloat(false), NoZerosInBSS(false), JITExceptionHandling(false),
  43. JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false),
  44. GuaranteedTailCallOpt(false), DisableTailCalls(false),
  45. StackAlignmentOverride(0), RealignStack(true), SSPBufferSize(0),
  46. EnableFastISel(false), PositionIndependentExecutable(false),
  47. EnableSegmentedStacks(false), UseInitArray(false), TrapFuncName(""),
  48. FloatABIType(FloatABI::Default), AllowFPOpFusion(FPOpFusion::Standard)
  49. {}
  50. /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
  51. /// option is specified on the command line, and should enable debugging
  52. /// output from the code generator.
  53. unsigned PrintMachineCode : 1;
  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. /// NoFramePointerElimNonLeaf - This flag is enabled when the
  59. /// -disable-non-leaf-fp-elim is specified on the command line. If the
  60. /// target supports the frame pointer elimination optimization, this option
  61. /// should disable it for non-leaf functions.
  62. unsigned NoFramePointerElimNonLeaf : 1;
  63. /// DisableFramePointerElim - This returns true if frame pointer elimination
  64. /// optimization should be disabled for the given machine function.
  65. bool DisableFramePointerElim(const MachineFunction &MF) const;
  66. /// LessPreciseFPMAD - This flag is enabled when the
  67. /// -enable-fp-mad is specified on the command line. When this flag is off
  68. /// (the default), the code generator is not allowed to generate mad
  69. /// (multiply add) if the result is "less precise" than doing those
  70. /// operations individually.
  71. unsigned LessPreciseFPMADOption : 1;
  72. bool LessPreciseFPMAD() const;
  73. /// UnsafeFPMath - This flag is enabled when the
  74. /// -enable-unsafe-fp-math flag is specified on the command line. When
  75. /// this flag is off (the default), the code generator is not allowed to
  76. /// produce results that are "less precise" than IEEE allows. This includes
  77. /// use of X86 instructions like FSIN and FCOS instead of libcalls.
  78. /// UnsafeFPMath implies LessPreciseFPMAD.
  79. unsigned UnsafeFPMath : 1;
  80. /// NoInfsFPMath - This flag is enabled when the
  81. /// -enable-no-infs-fp-math flag is specified on the command line. When
  82. /// this flag is off (the default), the code generator is not allowed to
  83. /// assume the FP arithmetic arguments and results are never +-Infs.
  84. unsigned NoInfsFPMath : 1;
  85. /// NoNaNsFPMath - This flag is enabled when the
  86. /// -enable-no-nans-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. /// assume the FP arithmetic arguments and results are never NaNs.
  89. unsigned NoNaNsFPMath : 1;
  90. /// HonorSignDependentRoundingFPMath - This returns true when the
  91. /// -enable-sign-dependent-rounding-fp-math is specified. If this returns
  92. /// false (the default), the code generator is allowed to assume that the
  93. /// rounding behavior is the default (round-to-zero for all floating point
  94. /// to integer conversions, and round-to-nearest for all other arithmetic
  95. /// truncations). If this is enabled (set to true), the code generator must
  96. /// assume that the rounding mode may dynamically change.
  97. unsigned HonorSignDependentRoundingFPMathOption : 1;
  98. bool HonorSignDependentRoundingFPMath() const;
  99. /// UseSoftFloat - This flag is enabled when the -soft-float flag is
  100. /// specified on the command line. When this flag is on, the code generator
  101. /// will generate libcalls to the software floating point library instead of
  102. /// target FP instructions.
  103. unsigned UseSoftFloat : 1;
  104. /// NoZerosInBSS - By default some codegens place zero-initialized data to
  105. /// .bss section. This flag disables such behaviour (necessary, e.g. for
  106. /// crt*.o compiling).
  107. unsigned NoZerosInBSS : 1;
  108. /// JITExceptionHandling - This flag indicates that the JIT should emit
  109. /// exception handling information.
  110. unsigned JITExceptionHandling : 1;
  111. /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
  112. /// debug information and notify a debugger about it.
  113. unsigned JITEmitDebugInfo : 1;
  114. /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
  115. /// the object files generated by the JITEmitDebugInfo flag to disk. This
  116. /// flag is hidden and is only for debugging the debug info.
  117. unsigned JITEmitDebugInfoToDisk : 1;
  118. /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
  119. /// specified on the commandline. When the flag is on, participating targets
  120. /// will perform tail call optimization on all calls which use the fastcc
  121. /// calling convention and which satisfy certain target-independent
  122. /// criteria (being at the end of a function, having the same return type
  123. /// as their parent function, etc.), using an alternate ABI if necessary.
  124. unsigned GuaranteedTailCallOpt : 1;
  125. /// DisableTailCalls - This flag controls whether we will use tail calls.
  126. /// Disabling them may be useful to maintain a correct call stack.
  127. unsigned DisableTailCalls : 1;
  128. /// StackAlignmentOverride - Override default stack alignment for target.
  129. unsigned StackAlignmentOverride;
  130. /// RealignStack - This flag indicates whether the stack should be
  131. /// automatically realigned, if needed.
  132. unsigned RealignStack : 1;
  133. /// SSPBufferSize - The minimum size of buffers that will receive stack
  134. /// smashing protection when -fstack-protection is used.
  135. unsigned SSPBufferSize;
  136. /// EnableFastISel - This flag enables fast-path instruction selection
  137. /// which trades away generated code quality in favor of reducing
  138. /// compile time.
  139. unsigned EnableFastISel : 1;
  140. /// PositionIndependentExecutable - This flag indicates whether the code
  141. /// will eventually be linked into a single executable, despite the PIC
  142. /// relocation model being in use. It's value is undefined (and irrelevant)
  143. /// if the relocation model is anything other than PIC.
  144. unsigned PositionIndependentExecutable : 1;
  145. unsigned EnableSegmentedStacks : 1;
  146. /// UseInitArray - Use .init_array instead of .ctors for static
  147. /// constructors.
  148. unsigned UseInitArray : 1;
  149. /// getTrapFunctionName - If this returns a non-empty string, this means
  150. /// isel should lower Intrinsic::trap to a call to the specified function
  151. /// name instead of an ISD::TRAP node.
  152. std::string TrapFuncName;
  153. StringRef getTrapFunctionName() const;
  154. /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
  155. /// on the command line. This setting may either be Default, Soft, or Hard.
  156. /// Default selects the target's default behavior. Soft selects the ABI for
  157. /// UseSoftFloat, but does not indicate that FP hardware may not be used.
  158. /// Such a combination is unfortunately popular (e.g. arm-apple-darwin).
  159. /// Hard presumes that the normal FP ABI is used.
  160. FloatABI::ABIType FloatABIType;
  161. /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
  162. /// This controls the creation of fused FP ops that store intermediate
  163. /// results in higher precision than IEEE allows (E.g. FMAs).
  164. ///
  165. /// Fast mode - allows formation of fused FP ops whenever they're
  166. /// profitable.
  167. /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
  168. /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
  169. /// may be added.
  170. /// Strict mode - allow fusion only if/when it can be proven that the excess
  171. /// precision won't effect the result.
  172. ///
  173. /// Note: This option only controls formation of fused ops by the
  174. /// optimizers. Fused operations that are explicitly specified (e.g. FMA
  175. /// via the llvm.fma.* intrinsic) will always be honored, regardless of
  176. /// the value of this option.
  177. FPOpFusion::FPOpFusionMode AllowFPOpFusion;
  178. bool operator==(const TargetOptions &);
  179. };
  180. } // End llvm namespace
  181. #endif