TargetOptions.h revision 263508
17055Sdg//===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===// 221830Sjoerg// 321830Sjoerg// The LLVM Compiler Infrastructure 47055Sdg// 57055Sdg// This file is distributed under the University of Illinois Open Source 67055Sdg// License. See LICENSE.TXT for details. 77055Sdg// 87055Sdg//===----------------------------------------------------------------------===// 97055Sdg// 107055Sdg// This file defines command line option flags that are shared across various 117055Sdg// targets. 127055Sdg// 137055Sdg//===----------------------------------------------------------------------===// 147055Sdg 157055Sdg#ifndef LLVM_TARGET_TARGETOPTIONS_H 167055Sdg#define LLVM_TARGET_TARGETOPTIONS_H 177055Sdg 187055Sdg#include <string> 197055Sdg 207055Sdgnamespace llvm { 217055Sdg class MachineFunction; 227055Sdg class StringRef; 237055Sdg 247055Sdg // Possible float ABI settings. Used with FloatABIType in TargetOptions.h. 257055Sdg namespace FloatABI { 267055Sdg enum ABIType { 277055Sdg Default, // Target-specific (either soft or hard depending on triple,etc). 287055Sdg Soft, // Soft float. 297055Sdg Hard // Hard float. 307055Sdg }; 317055Sdg } 327055Sdg 337055Sdg namespace FPOpFusion { 347055Sdg enum FPOpFusionMode { 357061Sdg Fast, // Enable fusion of FP ops wherever it's profitable. 3650477Speter Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd). 377055Sdg Strict // Never fuse FP-ops. 387055Sdg }; 3932356Seivind } 4032350Seivind 4154263Sshin class TargetOptions { 4231742Seivind public: 43105577Srwatson TargetOptions() 4431742Seivind : PrintMachineCode(false), NoFramePointerElim(false), 457055Sdg LessPreciseFPMADOption(false), 467055Sdg UnsafeFPMath(false), NoInfsFPMath(false), 4793375Smdodd NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false), 48105577Srwatson UseSoftFloat(false), NoZerosInBSS(false), 4993375Smdodd JITEmitDebugInfo(false), JITEmitDebugInfoToDisk(false), 507055Sdg GuaranteedTailCallOpt(false), DisableTailCalls(false), 5193375Smdodd StackAlignmentOverride(0), 527055Sdg EnableFastISel(false), PositionIndependentExecutable(false), 5393375Smdodd EnableSegmentedStacks(false), UseInitArray(false), TrapFuncName(""), 547055Sdg FloatABIType(FloatABI::Default), AllowFPOpFusion(FPOpFusion::Standard) 557055Sdg {} 567055Sdg 577055Sdg /// PrintMachineCode - This flag is enabled when the -print-machineinstrs 587055Sdg /// option is specified on the command line, and should enable debugging 5993375Smdodd /// output from the code generator. 6093375Smdodd unsigned PrintMachineCode : 1; 6193375Smdodd 6293373Smdodd /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is 637055Sdg /// specified on the command line. If the target supports the frame pointer 6454263Sshin /// elimination optimization, this option should disable it. 657055Sdg unsigned NoFramePointerElim : 1; 667055Sdg 6732350Seivind /// DisableFramePointerElim - This returns true if frame pointer elimination 687055Sdg /// optimization should be disabled for the given machine function. 6954263Sshin bool DisableFramePointerElim(const MachineFunction &MF) const; 7054263Sshin 7154263Sshin /// LessPreciseFPMAD - This flag is enabled when the 727055Sdg /// -enable-fp-mad is specified on the command line. When this flag is off 7311819Sjulian /// (the default), the code generator is not allowed to generate mad 7421830Sjoerg /// (multiply add) if the result is "less precise" than doing those 7511819Sjulian /// operations individually. 7611819Sjulian unsigned LessPreciseFPMADOption : 1; 7711819Sjulian bool LessPreciseFPMAD() const; 787055Sdg 797055Sdg /// UnsafeFPMath - This flag is enabled when the 807055Sdg /// -enable-unsafe-fp-math flag is specified on the command line. When 817055Sdg /// this flag is off (the default), the code generator is not allowed to 827055Sdg /// produce results that are "less precise" than IEEE allows. This includes 837055Sdg /// use of X86 instructions like FSIN and FCOS instead of libcalls. 847055Sdg /// UnsafeFPMath implies LessPreciseFPMAD. 857055Sdg unsigned UnsafeFPMath : 1; 867055Sdg 8721830Sjoerg /// NoInfsFPMath - This flag is enabled when the 8821830Sjoerg /// -enable-no-infs-fp-math flag is specified on the command line. When 8921830Sjoerg /// this flag is off (the default), the code generator is not allowed to 9021830Sjoerg /// assume the FP arithmetic arguments and results are never +-Infs. 9121830Sjoerg unsigned NoInfsFPMath : 1; 9221830Sjoerg 9321830Sjoerg /// NoNaNsFPMath - This flag is enabled when the 9421830Sjoerg /// -enable-no-nans-fp-math flag is specified on the command line. When 9521830Sjoerg /// this flag is off (the default), the code generator is not allowed to 9693382Smdodd /// assume the FP arithmetic arguments and results are never NaNs. 9793382Smdodd unsigned NoNaNsFPMath : 1; 9893382Smdodd 9993383Smdodd /// HonorSignDependentRoundingFPMath - This returns true when the 10093084Sbde /// -enable-sign-dependent-rounding-fp-math is specified. If this returns 10193383Smdodd /// false (the default), the code generator is allowed to assume that the 10293383Smdodd /// rounding behavior is the default (round-to-zero for all floating point 103106939Ssam /// to integer conversions, and round-to-nearest for all other arithmetic 10468180Sume /// truncations). If this is enabled (set to true), the code generator must 10593383Smdodd /// assume that the rounding mode may dynamically change. 10693369Smdodd unsigned HonorSignDependentRoundingFPMathOption : 1; 10793369Smdodd bool HonorSignDependentRoundingFPMath() const; 10893369Smdodd 1097055Sdg /// UseSoftFloat - This flag is enabled when the -soft-float flag is 1107055Sdg /// specified on the command line. When this flag is on, the code generator 1117055Sdg /// will generate libcalls to the software floating point library instead of 1127055Sdg /// target FP instructions. 1137055Sdg unsigned UseSoftFloat : 1; 1147055Sdg 1157055Sdg /// NoZerosInBSS - By default some codegens place zero-initialized data to 11693383Smdodd /// .bss section. This flag disables such behaviour (necessary, e.g. for 11754799Sgreen /// crt*.o compiling). 11893367Smdodd unsigned NoZerosInBSS : 1; 11954799Sgreen 1207055Sdg /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit 1217055Sdg /// debug information and notify a debugger about it. 1227055Sdg unsigned JITEmitDebugInfo : 1; 12321830Sjoerg 12469152Sjlemon /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write 12593373Smdodd /// the object files generated by the JITEmitDebugInfo flag to disk. This 12693367Smdodd /// flag is hidden and is only for debugging the debug info. 12793367Smdodd unsigned JITEmitDebugInfoToDisk : 1; 12893369Smdodd 1297055Sdg /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is 130105577Srwatson /// specified on the commandline. When the flag is on, participating targets 131105577Srwatson /// will perform tail call optimization on all calls which use the fastcc 132105577Srwatson /// calling convention and which satisfy certain target-independent 133105577Srwatson /// criteria (being at the end of a function, having the same return type 134105577Srwatson /// as their parent function, etc.), using an alternate ABI if necessary. 135105577Srwatson unsigned GuaranteedTailCallOpt : 1; 1367055Sdg 1377055Sdg /// DisableTailCalls - This flag controls whether we will use tail calls. 13834961Sphk /// Disabling them may be useful to maintain a correct call stack. 139111767Smdodd unsigned DisableTailCalls : 1; 140111767Smdodd 141111767Smdodd /// StackAlignmentOverride - Override default stack alignment for target. 142111767Smdodd unsigned StackAlignmentOverride; 143111767Smdodd 1447055Sdg /// EnableFastISel - This flag enables fast-path instruction selection 1457055Sdg /// which trades away generated code quality in favor of reducing 1467055Sdg /// compile time. 14721830Sjoerg unsigned EnableFastISel : 1; 14893369Smdodd 1497055Sdg /// PositionIndependentExecutable - This flag indicates whether the code 15021830Sjoerg /// will eventually be linked into a single executable, despite the PIC 1517055Sdg /// relocation model being in use. It's value is undefined (and irrelevant) 15221830Sjoerg /// if the relocation model is anything other than PIC. 1537055Sdg unsigned PositionIndependentExecutable : 1; 15454263Sshin 15554263Sshin unsigned EnableSegmentedStacks : 1; 15693375Smdodd 15774093Sbmilekic /// UseInitArray - Use .init_array instead of .ctors for static 15893369Smdodd /// constructors. 15954263Sshin unsigned UseInitArray : 1; 16054263Sshin 16154263Sshin /// getTrapFunctionName - If this returns a non-empty string, this means 16254263Sshin /// isel should lower Intrinsic::trap to a call to the specified function 16311819Sjulian /// name instead of an ISD::TRAP node. 16411819Sjulian std::string TrapFuncName; 16521830Sjoerg StringRef getTrapFunctionName() const; 16611819Sjulian 16793373Smdodd /// FloatABIType - This setting is set by -float-abi=xxx option is specfied 16811819Sjulian /// on the command line. This setting may either be Default, Soft, or Hard. 16911819Sjulian /// Default selects the target's default behavior. Soft selects the ABI for 17021830Sjoerg /// UseSoftFloat, but does not indicate that FP hardware may not be used. 17121830Sjoerg /// Such a combination is unfortunately popular (e.g. arm-apple-darwin). 17221830Sjoerg /// Hard presumes that the normal FP ABI is used. 17336908Sjulian FloatABI::ABIType FloatABIType; 17421830Sjoerg 17521830Sjoerg /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option. 17621830Sjoerg /// This controls the creation of fused FP ops that store intermediate 17721830Sjoerg /// results in higher precision than IEEE allows (E.g. FMAs). 17830834Sjulian /// 17921830Sjoerg /// Fast mode - allows formation of fused FP ops whenever they're 18021830Sjoerg /// profitable. 18121830Sjoerg /// Standard mode - allow fusion only for 'blessed' FP ops. At present the 18221830Sjoerg /// only blessed op is the fmuladd intrinsic. In the future more blessed ops 18321830Sjoerg /// may be added. 18421830Sjoerg /// Strict mode - allow fusion only if/when it can be proven that the excess 18521830Sjoerg /// precision won't effect the result. 18621830Sjoerg /// 18721830Sjoerg /// Note: This option only controls formation of fused ops by the 18821830Sjoerg /// optimizers. Fused operations that are explicitly specified (e.g. FMA 189111119Simp /// via the llvm.fma.* intrinsic) will always be honored, regardless of 19021830Sjoerg /// the value of this option. 19121830Sjoerg FPOpFusion::FPOpFusionMode AllowFPOpFusion; 19221830Sjoerg }; 19321830Sjoerg 19493371Smdodd// Comparison operators: 19593371Smdodd 19693373Smdodd 19721830Sjoerginline bool operator==(const TargetOptions &LHS, 19821830Sjoerg const TargetOptions &RHS) { 19921830Sjoerg#define ARE_EQUAL(X) LHS.X == RHS.X 20021830Sjoerg return 20121830Sjoerg ARE_EQUAL(UnsafeFPMath) && 20221830Sjoerg ARE_EQUAL(NoInfsFPMath) && 20321830Sjoerg ARE_EQUAL(NoNaNsFPMath) && 2047055Sdg ARE_EQUAL(HonorSignDependentRoundingFPMathOption) && 2057055Sdg ARE_EQUAL(UseSoftFloat) && 20621830Sjoerg ARE_EQUAL(NoZerosInBSS) && 2077055Sdg ARE_EQUAL(JITEmitDebugInfo) && 20893373Smdodd ARE_EQUAL(JITEmitDebugInfoToDisk) && 2097055Sdg ARE_EQUAL(GuaranteedTailCallOpt) && 2107055Sdg ARE_EQUAL(DisableTailCalls) && 2117055Sdg ARE_EQUAL(StackAlignmentOverride) && 21252248Smsmith ARE_EQUAL(EnableFastISel) && 21352248Smsmith ARE_EQUAL(PositionIndependentExecutable) && 21493376Smdodd ARE_EQUAL(EnableSegmentedStacks) && 21552248Smsmith ARE_EQUAL(UseInitArray) && 21693376Smdodd ARE_EQUAL(TrapFuncName) && 21793376Smdodd ARE_EQUAL(FloatABIType) && 21852248Smsmith ARE_EQUAL(AllowFPOpFusion); 21952248Smsmith#undef ARE_EQUAL 22052248Smsmith} 2217055Sdg 2227055Sdginline bool operator!=(const TargetOptions &LHS, 2237055Sdg const TargetOptions &RHS) { 22436992Sjulian return !(LHS == RHS); 2257055Sdg} 22693375Smdodd 2277055Sdg} // End llvm namespace 2287055Sdg 2297055Sdg#endif 2307055Sdg