TargetOptions.h revision e4496548155ba6606f107fbdc10ea17e58fd3401
11e230224d412d763b98472a8cd92a8349afba99bLiming Gao//===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===// 21e230224d412d763b98472a8cd92a8349afba99bLiming Gao// 31e230224d412d763b98472a8cd92a8349afba99bLiming Gao// The LLVM Compiler Infrastructure 41e230224d412d763b98472a8cd92a8349afba99bLiming Gao// 51e230224d412d763b98472a8cd92a8349afba99bLiming Gao// This file is distributed under the University of Illinois Open Source 61e230224d412d763b98472a8cd92a8349afba99bLiming Gao// License. See LICENSE.TXT for details. 71e230224d412d763b98472a8cd92a8349afba99bLiming Gao// 81e230224d412d763b98472a8cd92a8349afba99bLiming Gao//===----------------------------------------------------------------------===// 91e230224d412d763b98472a8cd92a8349afba99bLiming Gao// 101e230224d412d763b98472a8cd92a8349afba99bLiming Gao// This file defines command line option flags that are shared across various 111e230224d412d763b98472a8cd92a8349afba99bLiming Gao// targets. 121e230224d412d763b98472a8cd92a8349afba99bLiming Gao// 131e230224d412d763b98472a8cd92a8349afba99bLiming Gao//===----------------------------------------------------------------------===// 141e230224d412d763b98472a8cd92a8349afba99bLiming Gao 151e230224d412d763b98472a8cd92a8349afba99bLiming Gao#ifndef LLVM_TARGET_TARGETOPTIONS_H 161e230224d412d763b98472a8cd92a8349afba99bLiming Gao#define LLVM_TARGET_TARGETOPTIONS_H 171e230224d412d763b98472a8cd92a8349afba99bLiming Gao 181e230224d412d763b98472a8cd92a8349afba99bLiming Gao#include <string> 191e230224d412d763b98472a8cd92a8349afba99bLiming Gao 201e230224d412d763b98472a8cd92a8349afba99bLiming Gaonamespace llvm { 211e230224d412d763b98472a8cd92a8349afba99bLiming Gao class MachineFunction; 221e230224d412d763b98472a8cd92a8349afba99bLiming Gao class StringRef; 231e230224d412d763b98472a8cd92a8349afba99bLiming Gao 241e230224d412d763b98472a8cd92a8349afba99bLiming Gao // Possible float ABI settings. Used with FloatABIType in TargetOptions.h. 251e230224d412d763b98472a8cd92a8349afba99bLiming Gao namespace FloatABI { 261e230224d412d763b98472a8cd92a8349afba99bLiming Gao enum ABIType { 271e230224d412d763b98472a8cd92a8349afba99bLiming Gao Default, // Target-specific (either soft or hard depending on triple,etc). 281e230224d412d763b98472a8cd92a8349afba99bLiming Gao Soft, // Soft float. 291e230224d412d763b98472a8cd92a8349afba99bLiming Gao Hard // Hard float. 301e230224d412d763b98472a8cd92a8349afba99bLiming Gao }; 311e230224d412d763b98472a8cd92a8349afba99bLiming Gao } 321e230224d412d763b98472a8cd92a8349afba99bLiming Gao 331e230224d412d763b98472a8cd92a8349afba99bLiming Gao namespace FPOpFusion { 341e230224d412d763b98472a8cd92a8349afba99bLiming Gao enum FPOpFusionMode { 351e230224d412d763b98472a8cd92a8349afba99bLiming Gao Fast, // Enable fusion of FP ops wherever it's profitable. 361e230224d412d763b98472a8cd92a8349afba99bLiming Gao Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd). 371e230224d412d763b98472a8cd92a8349afba99bLiming Gao Strict // Never fuse FP-ops. 381e230224d412d763b98472a8cd92a8349afba99bLiming Gao }; 391e230224d412d763b98472a8cd92a8349afba99bLiming Gao } 401e230224d412d763b98472a8cd92a8349afba99bLiming Gao 411e230224d412d763b98472a8cd92a8349afba99bLiming Gao class TargetOptions { 421e230224d412d763b98472a8cd92a8349afba99bLiming Gao public: 431e230224d412d763b98472a8cd92a8349afba99bLiming Gao TargetOptions() 441e230224d412d763b98472a8cd92a8349afba99bLiming Gao : PrintMachineCode(false), NoFramePointerElim(false), 451e230224d412d763b98472a8cd92a8349afba99bLiming Gao NoFramePointerElimNonLeaf(false), LessPreciseFPMADOption(false), 461e230224d412d763b98472a8cd92a8349afba99bLiming Gao UnsafeFPMath(false), NoInfsFPMath(false), 471e230224d412d763b98472a8cd92a8349afba99bLiming Gao NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false), 481e230224d412d763b98472a8cd92a8349afba99bLiming Gao UseSoftFloat(false), NoZerosInBSS(false), 491e230224d412d763b98472a8cd92a8349afba99bLiming Gao JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false), 501e230224d412d763b98472a8cd92a8349afba99bLiming Gao GuaranteedTailCallOpt(false), DisableTailCalls(false), 511e230224d412d763b98472a8cd92a8349afba99bLiming Gao StackAlignmentOverride(0), RealignStack(true), SSPBufferSize(0), 521e230224d412d763b98472a8cd92a8349afba99bLiming Gao EnableFastISel(false), PositionIndependentExecutable(false), 531e230224d412d763b98472a8cd92a8349afba99bLiming Gao EnableSegmentedStacks(false), UseInitArray(false), TrapFuncName(""), 541e230224d412d763b98472a8cd92a8349afba99bLiming Gao FloatABIType(FloatABI::Default), AllowFPOpFusion(FPOpFusion::Standard) 551e230224d412d763b98472a8cd92a8349afba99bLiming Gao {} 561e230224d412d763b98472a8cd92a8349afba99bLiming Gao 571e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// PrintMachineCode - This flag is enabled when the -print-machineinstrs 581e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// option is specified on the command line, and should enable debugging 591e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// output from the code generator. 601e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned PrintMachineCode : 1; 611e230224d412d763b98472a8cd92a8349afba99bLiming Gao 621e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is 631e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// specified on the command line. If the target supports the frame pointer 641e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// elimination optimization, this option should disable it. 651e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned NoFramePointerElim : 1; 661e230224d412d763b98472a8cd92a8349afba99bLiming Gao 671e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// NoFramePointerElimNonLeaf - This flag is enabled when the 681e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -disable-non-leaf-fp-elim is specified on the command line. If the 691e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// target supports the frame pointer elimination optimization, this option 701e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// should disable it for non-leaf functions. 711e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned NoFramePointerElimNonLeaf : 1; 721e230224d412d763b98472a8cd92a8349afba99bLiming Gao 731e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// DisableFramePointerElim - This returns true if frame pointer elimination 741e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// optimization should be disabled for the given machine function. 751e230224d412d763b98472a8cd92a8349afba99bLiming Gao bool DisableFramePointerElim(const MachineFunction &MF) const; 761e230224d412d763b98472a8cd92a8349afba99bLiming Gao 771e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// LessPreciseFPMAD - This flag is enabled when the 781e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -enable-fp-mad is specified on the command line. When this flag is off 791e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// (the default), the code generator is not allowed to generate mad 801e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// (multiply add) if the result is "less precise" than doing those 811e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// operations individually. 821e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned LessPreciseFPMADOption : 1; 831e230224d412d763b98472a8cd92a8349afba99bLiming Gao bool LessPreciseFPMAD() const; 841e230224d412d763b98472a8cd92a8349afba99bLiming Gao 851e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// UnsafeFPMath - This flag is enabled when the 861e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -enable-unsafe-fp-math flag is specified on the command line. When 871e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// this flag is off (the default), the code generator is not allowed to 881e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// produce results that are "less precise" than IEEE allows. This includes 891e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// use of X86 instructions like FSIN and FCOS instead of libcalls. 901e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// UnsafeFPMath implies LessPreciseFPMAD. 911e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned UnsafeFPMath : 1; 921e230224d412d763b98472a8cd92a8349afba99bLiming Gao 931e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// NoInfsFPMath - This flag is enabled when the 941e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -enable-no-infs-fp-math flag is specified on the command line. When 951e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// this flag is off (the default), the code generator is not allowed to 961e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// assume the FP arithmetic arguments and results are never +-Infs. 971e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned NoInfsFPMath : 1; 981e230224d412d763b98472a8cd92a8349afba99bLiming Gao 991e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// NoNaNsFPMath - This flag is enabled when the 1001e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -enable-no-nans-fp-math flag is specified on the command line. When 1011e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// this flag is off (the default), the code generator is not allowed to 1021e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// assume the FP arithmetic arguments and results are never NaNs. 1031e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned NoNaNsFPMath : 1; 1041e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1051e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// HonorSignDependentRoundingFPMath - This returns true when the 1061e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// -enable-sign-dependent-rounding-fp-math is specified. If this returns 1071e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// false (the default), the code generator is allowed to assume that the 1081e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// rounding behavior is the default (round-to-zero for all floating point 1091e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// to integer conversions, and round-to-nearest for all other arithmetic 1101e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// truncations). If this is enabled (set to true), the code generator must 1111e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// assume that the rounding mode may dynamically change. 1121e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned HonorSignDependentRoundingFPMathOption : 1; 1131e230224d412d763b98472a8cd92a8349afba99bLiming Gao bool HonorSignDependentRoundingFPMath() const; 1141e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1151e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// UseSoftFloat - This flag is enabled when the -soft-float flag is 1161e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// specified on the command line. When this flag is on, the code generator 1171e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// will generate libcalls to the software floating point library instead of 1181e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// target FP instructions. 1191e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned UseSoftFloat : 1; 1201e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1211e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// NoZerosInBSS - By default some codegens place zero-initialized data to 1221e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// .bss section. This flag disables such behaviour (necessary, e.g. for 1231e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// crt*.o compiling). 1241e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned NoZerosInBSS : 1; 1251e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1261e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit 1271e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// debug information and notify a debugger about it. 1281e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned JITEmitDebugInfo : 1; 1291e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1301e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write 1311e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// the object files generated by the JITEmitDebugInfo flag to disk. This 1321e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// flag is hidden and is only for debugging the debug info. 1331e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned JITEmitDebugInfoToDisk : 1; 1341e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1351e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is 1361e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// specified on the commandline. When the flag is on, participating targets 1371e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// will perform tail call optimization on all calls which use the fastcc 1381e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// calling convention and which satisfy certain target-independent 1391e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// criteria (being at the end of a function, having the same return type 1401e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// as their parent function, etc.), using an alternate ABI if necessary. 1411e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned GuaranteedTailCallOpt : 1; 1421e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1431e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// DisableTailCalls - This flag controls whether we will use tail calls. 1441e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Disabling them may be useful to maintain a correct call stack. 1451e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned DisableTailCalls : 1; 1461e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1471e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// StackAlignmentOverride - Override default stack alignment for target. 1481e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned StackAlignmentOverride; 1491e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1501e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// RealignStack - This flag indicates whether the stack should be 1511e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// automatically realigned, if needed. 1521e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned RealignStack : 1; 1531e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1541e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// SSPBufferSize - The minimum size of buffers that will receive stack 1551e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// smashing protection when -fstack-protection is used. 1561e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned SSPBufferSize; 1571e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1581e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// EnableFastISel - This flag enables fast-path instruction selection 1591e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// which trades away generated code quality in favor of reducing 1601e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// compile time. 1611e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned EnableFastISel : 1; 1621e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1631e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// PositionIndependentExecutable - This flag indicates whether the code 1641e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// will eventually be linked into a single executable, despite the PIC 1651e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// relocation model being in use. It's value is undefined (and irrelevant) 1661e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// if the relocation model is anything other than PIC. 1671e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned PositionIndependentExecutable : 1; 1681e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1691e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned EnableSegmentedStacks : 1; 1701e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1711e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// UseInitArray - Use .init_array instead of .ctors for static 1721e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// constructors. 1731e230224d412d763b98472a8cd92a8349afba99bLiming Gao unsigned UseInitArray : 1; 1741e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1751e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// getTrapFunctionName - If this returns a non-empty string, this means 1761e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// isel should lower Intrinsic::trap to a call to the specified function 1771e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// name instead of an ISD::TRAP node. 1781e230224d412d763b98472a8cd92a8349afba99bLiming Gao std::string TrapFuncName; 1791e230224d412d763b98472a8cd92a8349afba99bLiming Gao StringRef getTrapFunctionName() const; 1801e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1811e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// FloatABIType - This setting is set by -float-abi=xxx option is specfied 1821e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// on the command line. This setting may either be Default, Soft, or Hard. 1831e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Default selects the target's default behavior. Soft selects the ABI for 1841e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// UseSoftFloat, but does not indicate that FP hardware may not be used. 1851e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Such a combination is unfortunately popular (e.g. arm-apple-darwin). 1861e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Hard presumes that the normal FP ABI is used. 1871e230224d412d763b98472a8cd92a8349afba99bLiming Gao FloatABI::ABIType FloatABIType; 1881e230224d412d763b98472a8cd92a8349afba99bLiming Gao 1891e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option. 1901e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// This controls the creation of fused FP ops that store intermediate 1911e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// results in higher precision than IEEE allows (E.g. FMAs). 1921e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// 1931e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Fast mode - allows formation of fused FP ops whenever they're 1941e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// profitable. 1951e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Standard mode - allow fusion only for 'blessed' FP ops. At present the 1961e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// only blessed op is the fmuladd intrinsic. In the future more blessed ops 1971e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// may be added. 1981e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Strict mode - allow fusion only if/when it can be proven that the excess 1991e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// precision won't effect the result. 2001e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// 2011e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// Note: This option only controls formation of fused ops by the 2021e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// optimizers. Fused operations that are explicitly specified (e.g. FMA 2031e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// via the llvm.fma.* intrinsic) will always be honored, regardless of 2041e230224d412d763b98472a8cd92a8349afba99bLiming Gao /// the value of this option. 2051e230224d412d763b98472a8cd92a8349afba99bLiming Gao FPOpFusion::FPOpFusionMode AllowFPOpFusion; 2061e230224d412d763b98472a8cd92a8349afba99bLiming Gao 2071e230224d412d763b98472a8cd92a8349afba99bLiming Gao bool operator==(const TargetOptions &); 2081e230224d412d763b98472a8cd92a8349afba99bLiming Gao }; 2091e230224d412d763b98472a8cd92a8349afba99bLiming Gao} // End llvm namespace 2101e230224d412d763b98472a8cd92a8349afba99bLiming Gao 2111e230224d412d763b98472a8cd92a8349afba99bLiming Gao#endif 2121e230224d412d763b98472a8cd92a8349afba99bLiming Gao