CodeGenOptions.h revision ff971d7973aaa00c286b788d30f6919c7b1f4de2
12811ccf48d6d898c42cc4cfad37abedb36236d20Chandler Carruth//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===// 270f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// 370f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// The LLVM Compiler Infrastructure 470f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// 570f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// This file is distributed under the University of Illinois Open Source 670f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// License. See LICENSE.TXT for details. 770f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// 870f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar//===----------------------------------------------------------------------===// 970f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// 102811ccf48d6d898c42cc4cfad37abedb36236d20Chandler Carruth// This file defines the CodeGenOptions interface. 1170f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar// 1270f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar//===----------------------------------------------------------------------===// 1370f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 1406057cef0bcd7804e80f3ce2bbe352178396c715Chandler Carruth#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H 1506057cef0bcd7804e80f3ce2bbe352178396c715Chandler Carruth#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H 1670f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 17e062533e298f72d970b2aa99cd0e3818b20d73dfChris Lattner#include <string> 183c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar#include <vector> 19e062533e298f72d970b2aa99cd0e3818b20d73dfChris Lattner 2070f92436f5828c11ef108463da4473d44e114c28Daniel Dunbarnamespace clang { 2170f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 224cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor/// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure 234cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor/// that this large collection of bitfields is a trivial class type. 244cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregorclass CodeGenOptionsBase { 254cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregorpublic: 264cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits; 274cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) 284cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 294cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor 304cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregorprotected: 314cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) 324cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits; 334cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 344cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor}; 354cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor 362811ccf48d6d898c42cc4cfad37abedb36236d20Chandler Carruth/// CodeGenOptions - Track various options which control how the code 3770f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar/// is optimized and passed to the backend. 384cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregorclass CodeGenOptions : public CodeGenOptionsBase { 39e062533e298f72d970b2aa99cd0e3818b20d73dfChris Lattnerpublic: 40877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar enum InliningMethod { 41877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar NoInlining, // Perform no inlining whatsoever. 42877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar NormalInlining, // Use the standard function inlining pass. 43877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar OnlyAlwaysInlining // Only run the always inlining pass. 44877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar }; 45877db3852e29c5b5a2dc25b3fe4a3b78619aa904Daniel Dunbar 46f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar enum ObjCDispatchMethodKind { 47f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar Legacy = 0, 48f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar NonLegacy = 1, 49f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar Mixed = 2 50f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar }; 51f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar 523a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov enum DebugInfoKind { 533a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov NoDebugInfo, // Don't generate debug info. 54fd00eecad6fa5400cf37269d84361a0551d0e6d3Alexey Samsonov DebugLineTablesOnly, // Emit only debug info necessary for generating 55fd00eecad6fa5400cf37269d84361a0551d0e6d3Alexey Samsonov // line number tables (-gline-tables-only). 563a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov LimitedDebugInfo, // Limit generated debug info to reduce size 573a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov // (-flimit-debug-info). 583a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov FullDebugInfo // Generate complete debug info. 593a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov }; 603a70cd6e1cc414856e41ce5509aa61c89bf472dcAlexey Samsonov 61de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg enum TLSModel { 62de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg GeneralDynamicTLSModel, 63de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg LocalDynamicTLSModel, 64de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg InitialExecTLSModel, 65de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg LocalExecTLSModel 66de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg }; 67de981f3ff163bc9ec69e4c5e7316e94276412993Hans Wennborg 68931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames enum FPContractModeKind { 69931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames FPC_Off, // Form fused FP ops only where result will not be affected. 70931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames FPC_On, // Form fused FP ops according to FP_CONTRACT rules. 71931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames FPC_Fast // Aggressively fuse FP ops (E.g. FMA). 72931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames }; 73931c0833811c030884fa50b2ccbd3c34f0f4c4eeLang Hames 74f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The code model to use (-mcmodel). 75f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string CodeModel; 76f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 773dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky /// The filename with path we use for coverage files. The extension will be 783dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky /// replaced. 793dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky std::string CoverageFile; 805ea4f44e34449a78d6b38aa47c14b527839d7aacNick Lewycky 813b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar /// Enable additional debugging information. 82f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string DebugPass; 83f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 847c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky /// The string to embed in debug information as the current working directory. 857c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky std::string DebugCompilationDir; 867c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky 87f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar /// The string to embed in the debug information for the compile unit, if 88f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar /// non-empty. 89f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar std::string DwarfDebugFlags; 90f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar 913b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar /// The ABI to use for passing floating point arguments. 923b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar std::string FloatABI; 933b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar 94f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The float precision limit to use, if non-empty. 95f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string LimitFloatPrecision; 96f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 9722a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne /// The name of the bitcode file to link before optzns. 9822a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne std::string LinkBitcodeFile; 9922a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne 1007d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// The user provided name for the "main file", if non-empty. This is useful 1017d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// in situations where the input file name does not match the original input 1027d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// file, for example with -save-temps. 1037d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar std::string MainFileName; 1047d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar 105ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher /// The name for the split debug info file that we'll break out. This is used 106ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher /// in the backend for setting the name in the skeleton cu. 107ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher std::string SplitDwarfFile; 108ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher 109f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The name of the relocation model to use. 110f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string RelocationModel; 111f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 11291ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov /// Path to blacklist file for sanitizers. 11391ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov std::string SanitizerBlacklistFile; 11491ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov 11571fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson /// If not an empty string, trap intrinsics are lowered to calls to this 11671fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson /// function instead of to trap instructions. 11771fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson std::string TrapFuncName; 11871fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson 1193c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar /// A list of command-line options to forward to the LLVM backend. 1203c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar std::vector<std::string> BackendOptions; 1213c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar 12270f92436f5828c11ef108463da4473d44e114c28Daniel Dunbarpublic: 1234cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor // Define accessors/mutators for code generation options of enumeration type. 1244cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) 1254cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 1264cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor Type get##Name() const { return static_cast<Type>(Name); } \ 1274cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 1284cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 1294cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor 1302811ccf48d6d898c42cc4cfad37abedb36236d20Chandler Carruth CodeGenOptions() { 1314cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) Name = Default; 1324cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 1334cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor set##Name(Default); 1344cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 135f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 136f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar RelocationModel = "pic"; 137f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar } 13870f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar}; 13970f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 14070f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar} // end namespace clang 14170f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 14270f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar#endif 143