Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 1 | //===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_ |
| 11 | #define CLANG_LIB_DRIVER_TOOLCHAINS_H_ |
| 12 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 13 | #include "clang/Driver/Action.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 14 | #include "clang/Driver/ToolChain.h" |
| 15 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/DenseMap.h" |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Compiler.h" |
| 18 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 19 | #include "Tools.h" |
| 20 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 21 | namespace clang { |
| 22 | namespace driver { |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 23 | namespace toolchains { |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 24 | |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 25 | /// Generic_GCC - A tool chain using the 'gcc' command to perform |
| 26 | /// all subcommands; this relies on gcc translating the majority of |
| 27 | /// command line options. |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 28 | class VISIBILITY_HIDDEN Generic_GCC : public ToolChain { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 29 | protected: |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 30 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 31 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 32 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 33 | Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple); |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 34 | ~Generic_GCC(); |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 35 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 36 | virtual DerivedArgList *TranslateArgs(InputArgList &Args) const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 37 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 38 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 39 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 40 | virtual bool IsMathErrnoDefault() const; |
| 41 | virtual bool IsUnwindTablesDefault() const; |
| 42 | virtual const char *GetDefaultRelocationModel() const; |
| 43 | virtual const char *GetForcedPicModel() const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 46 | /// Darwin - Darwin tool chain. |
| 47 | class VISIBILITY_HIDDEN Darwin : public ToolChain { |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 48 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 49 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 50 | /// Darwin version of tool chain. |
| 51 | unsigned DarwinVersion[3]; |
| 52 | |
| 53 | /// GCC version to use. |
| 54 | unsigned GCCVersion[3]; |
| 55 | |
| 56 | /// The directory suffix for this tool chain. |
| 57 | std::string ToolChainDir; |
| 58 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 59 | /// The default macosx-version-min of this tool chain; empty until |
| 60 | /// initialized. |
| 61 | mutable std::string MacosxVersionMin; |
| 62 | |
| 63 | const char *getMacosxVersionMin() const; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 64 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 65 | public: |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 66 | Darwin(const HostInfo &Host, const llvm::Triple& Triple, |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 67 | const unsigned (&DarwinVersion)[3], |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 68 | const unsigned (&GCCVersion)[3]); |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 69 | ~Darwin(); |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 70 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 71 | void getDarwinVersion(unsigned (&Res)[3]) const { |
| 72 | Res[0] = DarwinVersion[0]; |
| 73 | Res[1] = DarwinVersion[1]; |
| 74 | Res[2] = DarwinVersion[2]; |
| 75 | } |
| 76 | |
| 77 | void getMacosxVersion(unsigned (&Res)[3]) const { |
| 78 | Res[0] = 10; |
| 79 | Res[1] = DarwinVersion[0] - 4; |
| 80 | Res[2] = DarwinVersion[1]; |
| 81 | } |
| 82 | |
| 83 | const char *getMacosxVersionStr() const { |
| 84 | return MacosxVersionMin.c_str(); |
| 85 | } |
| 86 | |
| 87 | const std::string &getToolChainDir() const { |
| 88 | return ToolChainDir; |
| 89 | } |
| 90 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 91 | virtual DerivedArgList *TranslateArgs(InputArgList &Args) const; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 92 | |
| 93 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 94 | |
| 95 | virtual bool IsMathErrnoDefault() const; |
| 96 | virtual bool IsUnwindTablesDefault() const; |
| 97 | virtual const char *GetDefaultRelocationModel() const; |
| 98 | virtual const char *GetForcedPicModel() const; |
| 99 | }; |
| 100 | |
| 101 | /// Darwin_GCC - Generic Darwin tool chain using gcc. |
| 102 | class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC { |
| 103 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 104 | Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
| 105 | : Generic_GCC(Host, Triple) {} |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 106 | |
| 107 | virtual const char *GetDefaultRelocationModel() const { return "pic"; } |
| 108 | }; |
| 109 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 110 | class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC { |
| 111 | public: |
| 112 | AuroraUX(const HostInfo &Host, const llvm::Triple& Triple); |
| 113 | |
| 114 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 115 | }; |
| 116 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 117 | class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC { |
| 118 | public: |
| 119 | OpenBSD(const HostInfo &Host, const llvm::Triple& Triple); |
| 120 | |
| 121 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 122 | }; |
| 123 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 124 | class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC { |
| 125 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 126 | FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32); |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 127 | |
| 128 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 129 | }; |
| 130 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 131 | class VISIBILITY_HIDDEN DragonFly : public Generic_GCC { |
| 132 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 133 | DragonFly(const HostInfo &Host, const llvm::Triple& Triple); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 134 | |
| 135 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 136 | }; |
| 137 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 138 | class VISIBILITY_HIDDEN Linux : public Generic_GCC { |
| 139 | public: |
| 140 | Linux(const HostInfo &Host, const llvm::Triple& Triple); |
| 141 | }; |
| 142 | |
| 143 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 144 | } // end namespace toolchains |
| 145 | } // end namespace driver |
| 146 | } // end namespace clang |
| 147 | |
| 148 | #endif |