LLVM API Documentation

TargetOptions.h
Go to the documentation of this file.
00001 //===-- llvm/Target/TargetOptions.h - Target Options ------------*- 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 defines command line option flags that are shared across various
00011 // targets.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_TARGET_TARGETOPTIONS_H
00016 #define LLVM_TARGET_TARGETOPTIONS_H
00017 
00018 #include "llvm/MC/MCTargetOptions.h"
00019 #include <string>
00020 
00021 namespace llvm {
00022   class MachineFunction;
00023   class StringRef;
00024 
00025   // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
00026   namespace FloatABI {
00027     enum ABIType {
00028       Default, // Target-specific (either soft or hard depending on triple,etc).
00029       Soft, // Soft float.
00030       Hard  // Hard float.
00031     };
00032   }
00033 
00034   namespace FPOpFusion {
00035     enum FPOpFusionMode {
00036       Fast,     // Enable fusion of FP ops wherever it's profitable.
00037       Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
00038       Strict    // Never fuse FP-ops.
00039     };
00040   }
00041 
00042   class TargetOptions {
00043   public:
00044     TargetOptions()
00045         : PrintMachineCode(false), NoFramePointerElim(false),
00046           LessPreciseFPMADOption(false), UnsafeFPMath(false),
00047           NoInfsFPMath(false), NoNaNsFPMath(false),
00048           HonorSignDependentRoundingFPMathOption(false), UseSoftFloat(false),
00049           NoZerosInBSS(false), JITEmitDebugInfo(false),
00050           JITEmitDebugInfoToDisk(false), GuaranteedTailCallOpt(false),
00051           DisableTailCalls(false), StackAlignmentOverride(0),
00052           EnableFastISel(false), PositionIndependentExecutable(false),
00053           UseInitArray(false),
00054           DisableIntegratedAS(false), CompressDebugSections(false),
00055           TrapUnreachable(false),
00056           TrapFuncName(""), FloatABIType(FloatABI::Default),
00057           AllowFPOpFusion(FPOpFusion::Standard) {}
00058 
00059     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
00060     /// option is specified on the command line, and should enable debugging
00061     /// output from the code generator.
00062     unsigned PrintMachineCode : 1;
00063 
00064     /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
00065     /// specified on the command line.  If the target supports the frame pointer
00066     /// elimination optimization, this option should disable it.
00067     unsigned NoFramePointerElim : 1;
00068 
00069     /// DisableFramePointerElim - This returns true if frame pointer elimination
00070     /// optimization should be disabled for the given machine function.
00071     bool DisableFramePointerElim(const MachineFunction &MF) const;
00072 
00073     /// LessPreciseFPMAD - This flag is enabled when the
00074     /// -enable-fp-mad is specified on the command line.  When this flag is off
00075     /// (the default), the code generator is not allowed to generate mad
00076     /// (multiply add) if the result is "less precise" than doing those
00077     /// operations individually.
00078     unsigned LessPreciseFPMADOption : 1;
00079     bool LessPreciseFPMAD() const;
00080 
00081     /// UnsafeFPMath - This flag is enabled when the
00082     /// -enable-unsafe-fp-math flag is specified on the command line.  When
00083     /// this flag is off (the default), the code generator is not allowed to
00084     /// produce results that are "less precise" than IEEE allows.  This includes
00085     /// use of X86 instructions like FSIN and FCOS instead of libcalls.
00086     /// UnsafeFPMath implies LessPreciseFPMAD.
00087     unsigned UnsafeFPMath : 1;
00088 
00089     /// NoInfsFPMath - This flag is enabled when the
00090     /// -enable-no-infs-fp-math flag is specified on the command line. When
00091     /// this flag is off (the default), the code generator is not allowed to
00092     /// assume the FP arithmetic arguments and results are never +-Infs.
00093     unsigned NoInfsFPMath : 1;
00094 
00095     /// NoNaNsFPMath - This flag is enabled when the
00096     /// -enable-no-nans-fp-math flag is specified on the command line. When
00097     /// this flag is off (the default), the code generator is not allowed to
00098     /// assume the FP arithmetic arguments and results are never NaNs.
00099     unsigned NoNaNsFPMath : 1;
00100 
00101     /// HonorSignDependentRoundingFPMath - This returns true when the
00102     /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
00103     /// false (the default), the code generator is allowed to assume that the
00104     /// rounding behavior is the default (round-to-zero for all floating point
00105     /// to integer conversions, and round-to-nearest for all other arithmetic
00106     /// truncations).  If this is enabled (set to true), the code generator must
00107     /// assume that the rounding mode may dynamically change.
00108     unsigned HonorSignDependentRoundingFPMathOption : 1;
00109     bool HonorSignDependentRoundingFPMath() const;
00110 
00111     /// UseSoftFloat - This flag is enabled when the -soft-float flag is
00112     /// specified on the command line.  When this flag is on, the code generator
00113     /// will generate libcalls to the software floating point library instead of
00114     /// target FP instructions.
00115     unsigned UseSoftFloat : 1;
00116 
00117     /// NoZerosInBSS - By default some codegens place zero-initialized data to
00118     /// .bss section. This flag disables such behaviour (necessary, e.g. for
00119     /// crt*.o compiling).
00120     unsigned NoZerosInBSS : 1;
00121 
00122     /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
00123     /// debug information and notify a debugger about it.
00124     unsigned JITEmitDebugInfo : 1;
00125 
00126     /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
00127     /// the object files generated by the JITEmitDebugInfo flag to disk.  This
00128     /// flag is hidden and is only for debugging the debug info.
00129     unsigned JITEmitDebugInfoToDisk : 1;
00130 
00131     /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
00132     /// specified on the commandline. When the flag is on, participating targets
00133     /// will perform tail call optimization on all calls which use the fastcc
00134     /// calling convention and which satisfy certain target-independent
00135     /// criteria (being at the end of a function, having the same return type
00136     /// as their parent function, etc.), using an alternate ABI if necessary.
00137     unsigned GuaranteedTailCallOpt : 1;
00138 
00139     /// DisableTailCalls - This flag controls whether we will use tail calls.
00140     /// Disabling them may be useful to maintain a correct call stack.
00141     unsigned DisableTailCalls : 1;
00142 
00143     /// StackAlignmentOverride - Override default stack alignment for target.
00144     unsigned StackAlignmentOverride;
00145 
00146     /// EnableFastISel - This flag enables fast-path instruction selection
00147     /// which trades away generated code quality in favor of reducing
00148     /// compile time.
00149     unsigned EnableFastISel : 1;
00150 
00151     /// PositionIndependentExecutable - This flag indicates whether the code
00152     /// will eventually be linked into a single executable, despite the PIC
00153     /// relocation model being in use. It's value is undefined (and irrelevant)
00154     /// if the relocation model is anything other than PIC.
00155     unsigned PositionIndependentExecutable : 1;
00156 
00157     /// UseInitArray - Use .init_array instead of .ctors for static
00158     /// constructors.
00159     unsigned UseInitArray : 1;
00160 
00161     /// Disable the integrated assembler.
00162     unsigned DisableIntegratedAS : 1;
00163 
00164     /// Compress DWARF debug sections.
00165     unsigned CompressDebugSections : 1;
00166 
00167     /// Emit target-specific trap instruction for 'unreachable' IR instructions.
00168     unsigned TrapUnreachable : 1;
00169 
00170     /// getTrapFunctionName - If this returns a non-empty string, this means
00171     /// isel should lower Intrinsic::trap to a call to the specified function
00172     /// name instead of an ISD::TRAP node.
00173     std::string TrapFuncName;
00174     StringRef getTrapFunctionName() const;
00175 
00176     /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
00177     /// on the command line. This setting may either be Default, Soft, or Hard.
00178     /// Default selects the target's default behavior. Soft selects the ABI for
00179     /// UseSoftFloat, but does not indicate that FP hardware may not be used.
00180     /// Such a combination is unfortunately popular (e.g. arm-apple-darwin).
00181     /// Hard presumes that the normal FP ABI is used.
00182     FloatABI::ABIType FloatABIType;
00183 
00184     /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
00185     /// This controls the creation of fused FP ops that store intermediate
00186     /// results in higher precision than IEEE allows (E.g. FMAs).
00187     ///
00188     /// Fast mode - allows formation of fused FP ops whenever they're
00189     /// profitable.
00190     /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
00191     /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
00192     /// may be added.
00193     /// Strict mode - allow fusion only if/when it can be proven that the excess
00194     /// precision won't effect the result.
00195     ///
00196     /// Note: This option only controls formation of fused ops by the
00197     /// optimizers.  Fused operations that are explicitly specified (e.g. FMA
00198     /// via the llvm.fma.* intrinsic) will always be honored, regardless of
00199     /// the value of this option.
00200     FPOpFusion::FPOpFusionMode AllowFPOpFusion;
00201 
00202     /// Machine level options.
00203     MCTargetOptions MCOptions;
00204   };
00205 
00206 // Comparison operators:
00207 
00208 
00209 inline bool operator==(const TargetOptions &LHS,
00210                        const TargetOptions &RHS) {
00211 #define ARE_EQUAL(X) LHS.X == RHS.X
00212   return
00213     ARE_EQUAL(UnsafeFPMath) &&
00214     ARE_EQUAL(NoInfsFPMath) &&
00215     ARE_EQUAL(NoNaNsFPMath) &&
00216     ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
00217     ARE_EQUAL(UseSoftFloat) &&
00218     ARE_EQUAL(NoZerosInBSS) &&
00219     ARE_EQUAL(JITEmitDebugInfo) &&
00220     ARE_EQUAL(JITEmitDebugInfoToDisk) &&
00221     ARE_EQUAL(GuaranteedTailCallOpt) &&
00222     ARE_EQUAL(DisableTailCalls) &&
00223     ARE_EQUAL(StackAlignmentOverride) &&
00224     ARE_EQUAL(EnableFastISel) &&
00225     ARE_EQUAL(PositionIndependentExecutable) &&
00226     ARE_EQUAL(UseInitArray) &&
00227     ARE_EQUAL(TrapUnreachable) &&
00228     ARE_EQUAL(TrapFuncName) &&
00229     ARE_EQUAL(FloatABIType) &&
00230     ARE_EQUAL(AllowFPOpFusion) &&
00231     ARE_EQUAL(MCOptions);
00232 #undef ARE_EQUAL
00233 }
00234 
00235 inline bool operator!=(const TargetOptions &LHS,
00236                        const TargetOptions &RHS) {
00237   return !(LHS == RHS);
00238 }
00239 
00240 } // End llvm namespace
00241 
00242 #endif