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 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame^] | 56 | /// Whether this is this an iPhone toolchain. |
| 57 | bool IsIPhone; |
| 58 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 59 | /// The directory suffix for this tool chain. |
| 60 | std::string ToolChainDir; |
| 61 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 62 | /// The default macosx-version-min of this tool chain; empty until |
| 63 | /// initialized. |
| 64 | mutable std::string MacosxVersionMin; |
| 65 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame^] | 66 | /// The default iphoneos-version-min of this tool chain. |
| 67 | std::string IPhoneOSVersionMin; |
| 68 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 69 | const char *getMacosxVersionMin() const; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 70 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 71 | public: |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 72 | Darwin(const HostInfo &Host, const llvm::Triple& Triple, |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame^] | 73 | const unsigned (&DarwinVersion)[3], |
| 74 | const unsigned (&GCCVersion)[3], |
| 75 | bool IsIPhone); |
Daniel Dunbar | f395528 | 2009-09-04 18:34:51 +0000 | [diff] [blame] | 76 | ~Darwin(); |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 77 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 78 | void getDarwinVersion(unsigned (&Res)[3]) const { |
| 79 | Res[0] = DarwinVersion[0]; |
| 80 | Res[1] = DarwinVersion[1]; |
| 81 | Res[2] = DarwinVersion[2]; |
| 82 | } |
| 83 | |
| 84 | void getMacosxVersion(unsigned (&Res)[3]) const { |
| 85 | Res[0] = 10; |
| 86 | Res[1] = DarwinVersion[0] - 4; |
| 87 | Res[2] = DarwinVersion[1]; |
| 88 | } |
| 89 | |
| 90 | const char *getMacosxVersionStr() const { |
| 91 | return MacosxVersionMin.c_str(); |
| 92 | } |
| 93 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame^] | 94 | const char *getIPhoneOSVersionStr() const { |
| 95 | return IPhoneOSVersionMin.c_str(); |
| 96 | } |
| 97 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 98 | const std::string &getToolChainDir() const { |
| 99 | return ToolChainDir; |
| 100 | } |
| 101 | |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame^] | 102 | bool isIPhone() const { return IsIPhone; } |
| 103 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 104 | virtual DerivedArgList *TranslateArgs(InputArgList &Args) const; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 105 | |
| 106 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 107 | |
| 108 | virtual bool IsMathErrnoDefault() const; |
| 109 | virtual bool IsUnwindTablesDefault() const; |
| 110 | virtual const char *GetDefaultRelocationModel() const; |
| 111 | virtual const char *GetForcedPicModel() const; |
| 112 | }; |
| 113 | |
| 114 | /// Darwin_GCC - Generic Darwin tool chain using gcc. |
| 115 | class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC { |
| 116 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 117 | Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple) |
| 118 | : Generic_GCC(Host, Triple) {} |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 119 | |
| 120 | virtual const char *GetDefaultRelocationModel() const { return "pic"; } |
| 121 | }; |
| 122 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 123 | class VISIBILITY_HIDDEN AuroraUX : public Generic_GCC { |
| 124 | public: |
| 125 | AuroraUX(const HostInfo &Host, const llvm::Triple& Triple); |
| 126 | |
| 127 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 128 | }; |
| 129 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 130 | class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC { |
| 131 | public: |
| 132 | OpenBSD(const HostInfo &Host, const llvm::Triple& Triple); |
| 133 | |
| 134 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 135 | }; |
| 136 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 137 | class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC { |
| 138 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 139 | FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32); |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 140 | |
| 141 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 142 | }; |
| 143 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 144 | class VISIBILITY_HIDDEN DragonFly : public Generic_GCC { |
| 145 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 146 | DragonFly(const HostInfo &Host, const llvm::Triple& Triple); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 147 | |
| 148 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 149 | }; |
| 150 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 151 | class VISIBILITY_HIDDEN Linux : public Generic_GCC { |
| 152 | public: |
| 153 | Linux(const HostInfo &Host, const llvm::Triple& Triple); |
| 154 | }; |
| 155 | |
| 156 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 157 | } // end namespace toolchains |
| 158 | } // end namespace driver |
| 159 | } // end namespace clang |
| 160 | |
| 161 | #endif |