1635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===//
234695381d626485a560594f162701088079589dfMisha Brukman//
3635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//                     The LLVM Compiler Infrastructure
4635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
734695381d626485a560594f162701088079589dfMisha Brukman//
8635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//===----------------------------------------------------------------------===//
9635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//
10635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner// This file defines command line option flags that are shared across various
11635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner// targets.
12635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//
13635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner//===----------------------------------------------------------------------===//
14635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner
15635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner#ifndef LLVM_TARGET_TARGETOPTIONS_H
16635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner#define LLVM_TARGET_TARGETOPTIONS_H
17635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner
18dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines#include "llvm/MC/MCTargetOptions.h"
198a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky#include <string>
208a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
21635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattnernamespace llvm {
22e566763b1915c7a4821ce95937b763724d271fecEvan Cheng  class MachineFunction;
2384a61269370138b68ae2bcd6711a9ae8004fd77aEli Friedman  class StringRef;
24e566763b1915c7a4821ce95937b763724d271fecEvan Cheng
2505e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner  // Possible float ABI settings. Used with FloatABIType in TargetOptions.h.
2605e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner  namespace FloatABI {
2705e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner    enum ABIType {
28a04d6c948cd6f273f6146fdb95a76e3bc587b9d4Chad Rosier      Default, // Target-specific (either soft or hard depending on triple,etc).
2905e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner      Soft, // Soft float.
3005e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner      Hard  // Hard float.
3105e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner    };
3205e5fcab0910b7e0ebdd03cb4c1960ae8ba219fdChris Lattner  }
338a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
34e0231413225cf47aaf3238bf21afd0d59025028dLang Hames  namespace FPOpFusion {
35e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    enum FPOpFusionMode {
36e0231413225cf47aaf3238bf21afd0d59025028dLang Hames      Fast,     // Enable fusion of FP ops wherever it's profitable.
37e0231413225cf47aaf3238bf21afd0d59025028dLang Hames      Standard, // Only allow fusion of 'blessed' ops (currently just fmuladd).
38e0231413225cf47aaf3238bf21afd0d59025028dLang Hames      Strict    // Never fuse FP-ops.
39e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    };
40e0231413225cf47aaf3238bf21afd0d59025028dLang Hames  }
41e0231413225cf47aaf3238bf21afd0d59025028dLang Hames
42c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines  namespace JumpTable {
43c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines    enum JumpTableType {
44c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines      Single,          // Use a single table for all indirect jumptable calls.
45c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines      Arity,           // Use one table per number of function parameters.
46c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines      Simplified,      // Use one table per function type, with types projected
47c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines                       // into 4 types: pointer to non-function, struct,
48c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines                       // primitive, and function pointer.
49c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines      Full             // Use one table per unique function type
50c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines    };
51c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines  }
52c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines
5337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  namespace ThreadModel {
5437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    enum Model {
5537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines      POSIX,  // POSIX Threads
5637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines      Single  // Single Threaded Environment
5737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    };
5837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  }
5937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
6037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  enum class CFIntegrity {
6137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    Sub,             // Use subtraction-based checks.
6237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    Ror,             // Use rotation-based checks.
6337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    Add              // Use addition-based checks. This depends on having
6437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                     // sufficient alignment in the code and is usually not
6537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines                     // feasible.
6637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines  };
6737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
688a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky  class TargetOptions {
698a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky  public:
708a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    TargetOptions()
718a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky        : PrintMachineCode(false), NoFramePointerElim(false),
7236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          LessPreciseFPMADOption(false), UnsafeFPMath(false),
7336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          NoInfsFPMath(false), NoNaNsFPMath(false),
7436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          HonorSignDependentRoundingFPMathOption(false), UseSoftFloat(false),
7536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          NoZerosInBSS(false), JITEmitDebugInfo(false),
7636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          JITEmitDebugInfoToDisk(false), GuaranteedTailCallOpt(false),
7736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines          DisableTailCalls(false), StackAlignmentOverride(0),
78b09350d9a5639f55c46659b30be12a0c938378abChad Rosier          EnableFastISel(false), PositionIndependentExecutable(false),
79dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines          UseInitArray(false), DisableIntegratedAS(false),
80dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines          CompressDebugSections(false), FunctionSections(false),
81ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines          DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
82ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines          TrapFuncName(), FloatABIType(FloatABI::Default),
8337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines          AllowFPOpFusion(FPOpFusion::Standard), JTType(JumpTable::Single),
8437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines          FCFI(false), ThreadModel(ThreadModel::POSIX),
8537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines          CFIType(CFIntegrity::Sub), CFIEnforcing(false), CFIFuncName() {}
860de283dfa2686e30b44a3f6d7ce081588bf4910fTodd Fiala
878a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
888a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// option is specified on the command line, and should enable debugging
898a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// output from the code generator.
908a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned PrintMachineCode : 1;
918a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
928a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is
938a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// specified on the command line.  If the target supports the frame pointer
948a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// elimination optimization, this option should disable it.
958a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned NoFramePointerElim : 1;
968a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
978a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// DisableFramePointerElim - This returns true if frame pointer elimination
988a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// optimization should be disabled for the given machine function.
998a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    bool DisableFramePointerElim(const MachineFunction &MF) const;
1008a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1018a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// LessPreciseFPMAD - This flag is enabled when the
1028a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// -enable-fp-mad is specified on the command line.  When this flag is off
1038a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// (the default), the code generator is not allowed to generate mad
1048a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// (multiply add) if the result is "less precise" than doing those
1058a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// operations individually.
1068a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned LessPreciseFPMADOption : 1;
1078a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    bool LessPreciseFPMAD() const;
1088a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1098a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// UnsafeFPMath - This flag is enabled when the
1108a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// -enable-unsafe-fp-math flag is specified on the command line.  When
1118a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// this flag is off (the default), the code generator is not allowed to
1128a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// produce results that are "less precise" than IEEE allows.  This includes
1138a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// use of X86 instructions like FSIN and FCOS instead of libcalls.
1148a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// UnsafeFPMath implies LessPreciseFPMAD.
1158a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned UnsafeFPMath : 1;
1168a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1178a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// NoInfsFPMath - This flag is enabled when the
1188a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// -enable-no-infs-fp-math flag is specified on the command line. When
1198a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// this flag is off (the default), the code generator is not allowed to
1208a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// assume the FP arithmetic arguments and results are never +-Infs.
1218a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned NoInfsFPMath : 1;
1228a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1238a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// NoNaNsFPMath - This flag is enabled when the
1248a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// -enable-no-nans-fp-math flag is specified on the command line. When
1258a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// this flag is off (the default), the code generator is not allowed to
1268a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// assume the FP arithmetic arguments and results are never NaNs.
1278a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned NoNaNsFPMath : 1;
1288a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1298a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// HonorSignDependentRoundingFPMath - This returns true when the
1308a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// -enable-sign-dependent-rounding-fp-math is specified.  If this returns
1318a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// false (the default), the code generator is allowed to assume that the
1328a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// rounding behavior is the default (round-to-zero for all floating point
1338a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// to integer conversions, and round-to-nearest for all other arithmetic
1348a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// truncations).  If this is enabled (set to true), the code generator must
1358a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// assume that the rounding mode may dynamically change.
1368a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned HonorSignDependentRoundingFPMathOption : 1;
1378a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    bool HonorSignDependentRoundingFPMath() const;
138b3fe88f8379c4c4193d5d84267ae1a304437f8faAndrew Trick
1398a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// UseSoftFloat - This flag is enabled when the -soft-float flag is
1408a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// specified on the command line.  When this flag is on, the code generator
1418a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// will generate libcalls to the software floating point library instead of
1428a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// target FP instructions.
1438a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned UseSoftFloat : 1;
1448a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1458a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// NoZerosInBSS - By default some codegens place zero-initialized data to
1468a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// .bss section. This flag disables such behaviour (necessary, e.g. for
1478a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// crt*.o compiling).
1488a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned NoZerosInBSS : 1;
1498a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1508a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// JITEmitDebugInfo - This flag indicates that the JIT should try to emit
1518a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// debug information and notify a debugger about it.
1528a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned JITEmitDebugInfo : 1;
1538a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1548a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// JITEmitDebugInfoToDisk - This flag indicates that the JIT should write
1558a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// the object files generated by the JITEmitDebugInfo flag to disk.  This
1568a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// flag is hidden and is only for debugging the debug info.
1578a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned JITEmitDebugInfoToDisk : 1;
1588a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1598a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is
1608a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// specified on the commandline. When the flag is on, participating targets
1618a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// will perform tail call optimization on all calls which use the fastcc
1628a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// calling convention and which satisfy certain target-independent
1638a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// criteria (being at the end of a function, having the same return type
1648a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// as their parent function, etc.), using an alternate ABI if necessary.
1658a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned GuaranteedTailCallOpt : 1;
1668a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
16722de16dc7582dac43429ce0dcb374604020c01f5Nick Lewycky    /// DisableTailCalls - This flag controls whether we will use tail calls.
16822de16dc7582dac43429ce0dcb374604020c01f5Nick Lewycky    /// Disabling them may be useful to maintain a correct call stack.
16922de16dc7582dac43429ce0dcb374604020c01f5Nick Lewycky    unsigned DisableTailCalls : 1;
17022de16dc7582dac43429ce0dcb374604020c01f5Nick Lewycky
1718a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// StackAlignmentOverride - Override default stack alignment for target.
1728a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned StackAlignmentOverride;
1738a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
1748a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// EnableFastISel - This flag enables fast-path instruction selection
1758a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// which trades away generated code quality in favor of reducing
1768a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// compile time.
1778a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    unsigned EnableFastISel : 1;
178b3fe88f8379c4c4193d5d84267ae1a304437f8faAndrew Trick
179253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth    /// PositionIndependentExecutable - This flag indicates whether the code
180253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth    /// will eventually be linked into a single executable, despite the PIC
181253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth    /// relocation model being in use. It's value is undefined (and irrelevant)
182253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth    /// if the relocation model is anything other than PIC.
183253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth    unsigned PositionIndependentExecutable : 1;
184253933ee9ef2c413ecd782efeacc5d7b9bcda09aChandler Carruth
185d6b43a317e71246380db55a50b799b062b53cdceRafael Espindola    /// UseInitArray - Use .init_array instead of .ctors for static
186d6b43a317e71246380db55a50b799b062b53cdceRafael Espindola    /// constructors.
187d6b43a317e71246380db55a50b799b062b53cdceRafael Espindola    unsigned UseInitArray : 1;
188d6b43a317e71246380db55a50b799b062b53cdceRafael Espindola
18936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    /// Disable the integrated assembler.
19036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    unsigned DisableIntegratedAS : 1;
19136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
19236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    /// Compress DWARF debug sections.
19336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines    unsigned CompressDebugSections : 1;
19436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
195dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    /// Emit functions into separate sections.
196dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    unsigned FunctionSections : 1;
197dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
198dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    /// Emit data into separate sections.
199dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    unsigned DataSections : 1;
200dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
201ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    unsigned UniqueSectionNames : 1;
202ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines
203dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    /// Emit target-specific trap instruction for 'unreachable' IR instructions.
204dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    unsigned TrapUnreachable : 1;
205dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
2068a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// getTrapFunctionName - If this returns a non-empty string, this means
2078a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// isel should lower Intrinsic::trap to a call to the specified function
2088a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// name instead of an ISD::TRAP node.
2098a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    std::string TrapFuncName;
2108a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    StringRef getTrapFunctionName() const;
2118a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky
2128a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// FloatABIType - This setting is set by -float-abi=xxx option is specfied
2138a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// on the command line. This setting may either be Default, Soft, or Hard.
2148a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    /// Default selects the target's default behavior. Soft selects the ABI for
2152c3e0051c31c3f5b2328b447eadf1cf9c4427442Pirama Arumuga Nainar    /// software floating point, but does not indicate that FP hardware may not
2162c3e0051c31c3f5b2328b447eadf1cf9c4427442Pirama Arumuga Nainar    /// be used. Such a combination is unfortunately popular (e.g.
2172c3e0051c31c3f5b2328b447eadf1cf9c4427442Pirama Arumuga Nainar    /// arm-apple-darwin). Hard presumes that the normal FP ABI is used.
2188a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky    FloatABI::ABIType FloatABIType;
219e0231413225cf47aaf3238bf21afd0d59025028dLang Hames
220e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
221e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// This controls the creation of fused FP ops that store intermediate
222e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// results in higher precision than IEEE allows (E.g. FMAs).
223e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    ///
224e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// Fast mode - allows formation of fused FP ops whenever they're
225e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// profitable.
226e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// Standard mode - allow fusion only for 'blessed' FP ops. At present the
227e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// only blessed op is the fmuladd intrinsic. In the future more blessed ops
228e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// may be added.
229e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// Strict mode - allow fusion only if/when it can be proven that the excess
230e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    /// precision won't effect the result.
231e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    ///
232a04d6c948cd6f273f6146fdb95a76e3bc587b9d4Chad Rosier    /// Note: This option only controls formation of fused ops by the
233a04d6c948cd6f273f6146fdb95a76e3bc587b9d4Chad Rosier    /// optimizers.  Fused operations that are explicitly specified (e.g. FMA
234a04d6c948cd6f273f6146fdb95a76e3bc587b9d4Chad Rosier    /// via the llvm.fma.* intrinsic) will always be honored, regardless of
23533634833aa651cab5ea92b87822c038fb6e71778Chad Rosier    /// the value of this option.
236e0231413225cf47aaf3238bf21afd0d59025028dLang Hames    FPOpFusion::FPOpFusionMode AllowFPOpFusion;
237dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
238c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines    /// JTType - This flag specifies the type of jump-instruction table to
239c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines    /// create for functions that have the jumptable attribute.
240c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines    JumpTable::JumpTableType JTType;
241c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines
24237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// FCFI - This flags controls whether or not forward-edge control-flow
24337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// integrity is applied.
24437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    bool FCFI;
24537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
24637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// ThreadModel - This flag specifies the type of threading model to assume
24737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// for things like atomics
24837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    ThreadModel::Model ThreadModel;
24937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
25037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// CFIType - This flag specifies the type of control-flow integrity check
25137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// to add as a preamble to indirect calls.
25237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    CFIntegrity CFIType;
25337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
25437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// CFIEnforcing - This flags controls whether or not CFI violations cause
25537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// the program to halt.
25637ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    bool CFIEnforcing;
25737ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
25837ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// getCFIFuncName - If this returns a non-empty string, then this is the
25937ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// name of the function that will be called for each CFI violation in
26037ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    /// non-enforcing mode.
26137ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    std::string CFIFuncName;
26237ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines    StringRef getCFIFuncName() const;
26337ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines
264dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    /// Machine level options.
265dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    MCTargetOptions MCOptions;
2668a8d479214745c82ef00f08d4e4f1c173b5f9ce2Nick Lewycky  };
26759aa54073848645cd20c828dfb1088127c541b36Bill Wendling
26859aa54073848645cd20c828dfb1088127c541b36Bill Wendling// Comparison operators:
26959aa54073848645cd20c828dfb1088127c541b36Bill Wendling
27059aa54073848645cd20c828dfb1088127c541b36Bill Wendling
271face8d901ebc2f3ac26e303603aae1b9304c4728Bill Wendlinginline bool operator==(const TargetOptions &LHS,
272face8d901ebc2f3ac26e303603aae1b9304c4728Bill Wendling                       const TargetOptions &RHS) {
2733b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling#define ARE_EQUAL(X) LHS.X == RHS.X
2743b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling  return
2753b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(UnsafeFPMath) &&
2763b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(NoInfsFPMath) &&
2773b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(NoNaNsFPMath) &&
2783b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
2793b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(UseSoftFloat) &&
2803b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(NoZerosInBSS) &&
2813b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(JITEmitDebugInfo) &&
2823b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(JITEmitDebugInfoToDisk) &&
2833b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(GuaranteedTailCallOpt) &&
2843b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(DisableTailCalls) &&
2853b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(StackAlignmentOverride) &&
2863b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(EnableFastISel) &&
2873b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(PositionIndependentExecutable) &&
2883b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(UseInitArray) &&
289dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    ARE_EQUAL(TrapUnreachable) &&
2903b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(TrapFuncName) &&
2913b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling    ARE_EQUAL(FloatABIType) &&
292dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    ARE_EQUAL(AllowFPOpFusion) &&
293ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(JTType) &&
294ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(FCFI) &&
295ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(ThreadModel) &&
296ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(CFIType) &&
297ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(CFIEnforcing) &&
298ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines    ARE_EQUAL(CFIFuncName) &&
299dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines    ARE_EQUAL(MCOptions);
3003b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling#undef ARE_EQUAL
3013b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling}
3023b6e067f56db88509d9254ecc70951d77d51a2d7Bill Wendling
303face8d901ebc2f3ac26e303603aae1b9304c4728Bill Wendlinginline bool operator!=(const TargetOptions &LHS,
304face8d901ebc2f3ac26e303603aae1b9304c4728Bill Wendling                       const TargetOptions &RHS) {
30559aa54073848645cd20c828dfb1088127c541b36Bill Wendling  return !(LHS == RHS);
30659aa54073848645cd20c828dfb1088127c541b36Bill Wendling}
30759aa54073848645cd20c828dfb1088127c541b36Bill Wendling
308635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner} // End llvm namespace
309635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner
310635ffcdf58f9bdc35c4ad4969fb35dc3659cf384Chris Lattner#endif
311