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 74b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall enum StructReturnConventionKind { 75b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall SRCK_Default, // No special option was passed. 76b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). 77b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall SRCK_InRegs // Small structs in registers (-freg-struct-return). 78b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall }; 79b8b52972c72b2ba6fe171c522e5d3d7d69503021John McCall 80f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The code model to use (-mcmodel). 81f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string CodeModel; 82f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 833dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky /// The filename with path we use for coverage files. The extension will be 843dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky /// replaced. 853dc05418538c719fea48b906bfa4febe5296e126Nick Lewycky std::string CoverageFile; 865ea4f44e34449a78d6b38aa47c14b527839d7aacNick Lewycky 870f815f1f91e5cf0726fd8296445038fec3bed80bNick Lewycky /// The version string to put into coverage files. 880f815f1f91e5cf0726fd8296445038fec3bed80bNick Lewycky char CoverageVersion[4]; 890f815f1f91e5cf0726fd8296445038fec3bed80bNick Lewycky 903b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar /// Enable additional debugging information. 91f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string DebugPass; 92f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 937c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky /// The string to embed in debug information as the current working directory. 947c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky std::string DebugCompilationDir; 957c4fd9121f5885096fd3258d20a984e3f08f8603Nick Lewycky 96f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar /// The string to embed in the debug information for the compile unit, if 97f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar /// non-empty. 98f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar std::string DwarfDebugFlags; 99f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar 1003b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar /// The ABI to use for passing floating point arguments. 1013b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar std::string FloatABI; 1023b315264d1a6fa303e20fe0caec306ccafc090deDaniel Dunbar 103f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The float precision limit to use, if non-empty. 104f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string LimitFloatPrecision; 105f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 10622a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne /// The name of the bitcode file to link before optzns. 10722a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne std::string LinkBitcodeFile; 10822a7dfea585703d6755db69b83e29a0e6ee10369Peter Collingbourne 1097d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// The user provided name for the "main file", if non-empty. This is useful 1107d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// in situations where the input file name does not match the original input 1117d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar /// file, for example with -save-temps. 1127d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar std::string MainFileName; 1137d065d0f21b35f445cee13730398bc2bec6edff2Daniel Dunbar 114ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher /// The name for the split debug info file that we'll break out. This is used 115ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher /// in the backend for setting the name in the skeleton cu. 116ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher std::string SplitDwarfFile; 117ff971d7973aaa00c286b788d30f6919c7b1f4de2Eric Christopher 118f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar /// The name of the relocation model to use. 119f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar std::string RelocationModel; 120f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 12191ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov /// Path to blacklist file for sanitizers. 12291ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov std::string SanitizerBlacklistFile; 12391ecfa6af51836d3ccc90beddab1193b0c060739Alexey Samsonov 12471fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson /// If not an empty string, trap intrinsics are lowered to calls to this 12571fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson /// function instead of to trap instructions. 12671fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson std::string TrapFuncName; 12771fd6cc843719cab528a5df0899ad3d15cb9297fBob Wilson 1283c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar /// A list of command-line options to forward to the LLVM backend. 1293c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar std::vector<std::string> BackendOptions; 1303c66d30d513106bb794990c5e4ba36a31ac19f15Daniel Dunbar 13170f92436f5828c11ef108463da4473d44e114c28Daniel Dunbarpublic: 1324cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor // Define accessors/mutators for code generation options of enumeration type. 1334cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) 1344cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 1354cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor Type get##Name() const { return static_cast<Type>(Name); } \ 1364cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 1374cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 1384cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor 1392811ccf48d6d898c42cc4cfad37abedb36236d20Chandler Carruth CodeGenOptions() { 1404cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define CODEGENOPT(Name, Bits, Default) Name = Default; 1414cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \ 1424cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor set##Name(Default); 1434cdad3151bfb2075c6bdbfe89fbb08f31a90a45bDouglas Gregor#include "clang/Frontend/CodeGenOptions.def" 144f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar 145f219e7c1529fac29e34483667f740b452e5ef9ccDaniel Dunbar RelocationModel = "pic"; 146493fe6d504a436c0639e641ef7c3c3982cf5fecaBill Wendling memcpy(CoverageVersion, "402*", 4); 147f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar } 14870f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar}; 14970f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 15070f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar} // end namespace clang 15170f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar 15270f92436f5828c11ef108463da4473d44e114c28Daniel Dunbar#endif 153