Nick Lewycky | bb3f995 | 2010-12-01 04:33:27 +0000 | [diff] [blame] | 1 | //===--- HostInfo.cpp - Host specific information -------------------------===// |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 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 | #include "clang/Driver/HostInfo.h" |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 11 | |
| 12 | #include "clang/Driver/Arg.h" |
| 13 | #include "clang/Driver/ArgList.h" |
Daniel Dunbar | fc6a899 | 2009-03-20 18:21:51 +0000 | [diff] [blame] | 14 | #include "clang/Driver/Driver.h" |
| 15 | #include "clang/Driver/DriverDiagnostic.h" |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 16 | #include "clang/Driver/Option.h" |
| 17 | #include "clang/Driver/Options.h" |
| 18 | |
| 19 | #include "llvm/ADT/StringMap.h" |
| 20 | #include "llvm/Support/Compiler.h" |
| 21 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 22 | #include "ToolChains.h" |
| 23 | |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 24 | #include <cassert> |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 25 | |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 26 | using namespace clang::driver; |
| 27 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 28 | HostInfo::HostInfo(const Driver &D, const llvm::Triple &_Triple) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 29 | : TheDriver(D), Triple(_Triple) { |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | HostInfo::~HostInfo() { |
| 33 | } |
| 34 | |
Chris Lattner | aae82f1 | 2009-03-17 22:24:01 +0000 | [diff] [blame] | 35 | namespace { |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 36 | |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 37 | // Darwin Host Info |
| 38 | |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 39 | /// DarwinHostInfo - Darwin host information implementation. |
| 40 | class DarwinHostInfo : public HostInfo { |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 41 | /// Cache of tool chains we have created. |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 42 | mutable llvm::DenseMap<unsigned, ToolChain*> ToolChains; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 43 | |
| 44 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 45 | DarwinHostInfo(const Driver &D, const llvm::Triple &Triple); |
Daniel Dunbar | 7e4534d | 2009-03-18 01:09:40 +0000 | [diff] [blame] | 46 | ~DarwinHostInfo(); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 47 | |
| 48 | virtual bool useDriverDriver() const; |
| 49 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 50 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 51 | const char *ArchName) const; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 54 | DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 55 | : HostInfo(D, Triple) { |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Daniel Dunbar | 7e4534d | 2009-03-18 01:09:40 +0000 | [diff] [blame] | 58 | DarwinHostInfo::~DarwinHostInfo() { |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 59 | for (llvm::DenseMap<unsigned, ToolChain*>::iterator |
Daniel Dunbar | 7e4534d | 2009-03-18 01:09:40 +0000 | [diff] [blame] | 60 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 61 | delete it->second; |
| 62 | } |
| 63 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 64 | bool DarwinHostInfo::useDriverDriver() const { |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 65 | return true; |
| 66 | } |
| 67 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 68 | ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args, |
| 69 | const char *ArchName) const { |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 70 | llvm::Triple::ArchType Arch; |
| 71 | |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 72 | if (!ArchName) { |
Daniel Dunbar | f2edbf3 | 2009-06-16 21:39:33 +0000 | [diff] [blame] | 73 | // If we aren't looking for a specific arch, infer the default architecture |
| 74 | // based on -arch and -m32/-m64 command line options. |
| 75 | if (Arg *A = Args.getLastArg(options::OPT_arch)) { |
| 76 | // The gcc driver behavior with multiple -arch flags wasn't consistent for |
| 77 | // things which rely on a default architecture. We just use the last -arch |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 78 | // to find the default tool chain (assuming it is valid). |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 79 | Arch = llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args)); |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 80 | |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 81 | // If it was invalid just use the host, we will reject this command line |
| 82 | // later. |
| 83 | if (Arch == llvm::Triple::UnknownArch) |
| 84 | Arch = getTriple().getArch(); |
Daniel Dunbar | f2edbf3 | 2009-06-16 21:39:33 +0000 | [diff] [blame] | 85 | } else { |
| 86 | // Otherwise default to the arch of the host. |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 87 | Arch = getTriple().getArch(); |
Daniel Dunbar | f2edbf3 | 2009-06-16 21:39:33 +0000 | [diff] [blame] | 88 | } |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 89 | |
Daniel Dunbar | f2edbf3 | 2009-06-16 21:39:33 +0000 | [diff] [blame] | 90 | // Honor -m32 and -m64 when finding the default tool chain. |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 91 | // |
| 92 | // FIXME: Should this information be in llvm::Triple? |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 93 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 94 | if (A->getOption().matches(options::OPT_m32)) { |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 95 | if (Arch == llvm::Triple::x86_64) |
| 96 | Arch = llvm::Triple::x86; |
| 97 | if (Arch == llvm::Triple::ppc64) |
| 98 | Arch = llvm::Triple::ppc; |
| 99 | } else { |
| 100 | if (Arch == llvm::Triple::x86) |
| 101 | Arch = llvm::Triple::x86_64; |
| 102 | if (Arch == llvm::Triple::ppc) |
| 103 | Arch = llvm::Triple::ppc64; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 104 | } |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 105 | } |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 106 | } else |
| 107 | Arch = llvm::Triple::getArchTypeForDarwinArchName(ArchName); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 108 | |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 109 | assert(Arch != llvm::Triple::UnknownArch && "Unexpected arch!"); |
| 110 | ToolChain *&TC = ToolChains[Arch]; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 111 | if (!TC) { |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 112 | llvm::Triple TCTriple(getTriple()); |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 113 | TCTriple.setArch(Arch); |
Daniel Dunbar | 30392de | 2009-09-04 18:35:21 +0000 | [diff] [blame] | 114 | |
Daniel Dunbar | 7ef7f13 | 2009-09-08 23:37:36 +0000 | [diff] [blame] | 115 | // If we recognized the arch, match it to the toolchains we support. |
Daniel Dunbar | 79be940 | 2011-03-18 19:25:10 +0000 | [diff] [blame] | 116 | if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 || |
Daniel Dunbar | 2dc70ad | 2010-08-26 01:41:44 +0000 | [diff] [blame] | 117 | Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) { |
Daniel Dunbar | 5edbd23 | 2010-08-26 00:55:55 +0000 | [diff] [blame] | 118 | TC = new toolchains::DarwinClang(*this, TCTriple); |
Daniel Dunbar | 3bc96eb | 2010-03-26 22:41:03 +0000 | [diff] [blame] | 119 | } else |
Daniel Dunbar | 1d4612b | 2009-09-18 08:15:13 +0000 | [diff] [blame] | 120 | TC = new toolchains::Darwin_Generic_GCC(*this, TCTriple); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | return TC; |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 126 | // TCE Host Info |
| 127 | |
| 128 | /// TCEHostInfo - TCE host information implementation (see http://tce.cs.tut.fi) |
| 129 | class TCEHostInfo : public HostInfo { |
| 130 | |
| 131 | public: |
| 132 | TCEHostInfo(const Driver &D, const llvm::Triple &Triple); |
Douglas Gregor | da79149 | 2010-03-08 02:49:35 +0000 | [diff] [blame] | 133 | ~TCEHostInfo() {} |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 134 | |
| 135 | virtual bool useDriverDriver() const; |
| 136 | |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 137 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 138 | const char *ArchName) const; |
| 139 | }; |
| 140 | |
| 141 | TCEHostInfo::TCEHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 142 | : HostInfo(D, Triple) { |
| 143 | } |
| 144 | |
| 145 | bool TCEHostInfo::useDriverDriver() const { |
| 146 | return false; |
| 147 | } |
| 148 | |
| 149 | ToolChain *TCEHostInfo::CreateToolChain(const ArgList &Args, |
| 150 | const char *ArchName) const { |
| 151 | llvm::Triple TCTriple(getTriple()); |
| 152 | // TCTriple.setArchName(ArchName); |
| 153 | return new toolchains::TCEToolChain(*this, TCTriple); |
| 154 | } |
| 155 | |
| 156 | |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 157 | // Unknown Host Info |
| 158 | |
Daniel Dunbar | 2603137 | 2010-01-27 00:56:25 +0000 | [diff] [blame] | 159 | /// UnknownHostInfo - Generic host information to use for unknown hosts. |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 160 | class UnknownHostInfo : public HostInfo { |
| 161 | /// Cache of tool chains we have created. |
| 162 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 163 | |
| 164 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 165 | UnknownHostInfo(const Driver &D, const llvm::Triple& Triple); |
Daniel Dunbar | 7e4534d | 2009-03-18 01:09:40 +0000 | [diff] [blame] | 166 | ~UnknownHostInfo(); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 167 | |
| 168 | virtual bool useDriverDriver() const; |
| 169 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 170 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 171 | const char *ArchName) const; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 172 | }; |
| 173 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 174 | UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple) |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 175 | : HostInfo(D, Triple) { |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Daniel Dunbar | 7e4534d | 2009-03-18 01:09:40 +0000 | [diff] [blame] | 178 | UnknownHostInfo::~UnknownHostInfo() { |
| 179 | for (llvm::StringMap<ToolChain*>::iterator |
| 180 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 181 | delete it->second; |
| 182 | } |
| 183 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 184 | bool UnknownHostInfo::useDriverDriver() const { |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 185 | return false; |
| 186 | } |
| 187 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 188 | ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args, |
| 189 | const char *ArchName) const { |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 190 | assert(!ArchName && |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 191 | "Unexpected arch name on platform without driver driver support."); |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 192 | |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 193 | // Automatically handle some instances of -m32/-m64 we know about. |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 194 | std::string Arch = getArchName(); |
| 195 | ArchName = Arch.c_str(); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 196 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 197 | if (Triple.getArch() == llvm::Triple::x86 || |
| 198 | Triple.getArch() == llvm::Triple::x86_64) { |
| 199 | ArchName = |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 200 | (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 201 | } else if (Triple.getArch() == llvm::Triple::ppc || |
| 202 | Triple.getArch() == llvm::Triple::ppc64) { |
| 203 | ArchName = |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 204 | (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64"; |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 205 | } |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 208 | ToolChain *&TC = ToolChains[ArchName]; |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 209 | if (!TC) { |
| 210 | llvm::Triple TCTriple(getTriple()); |
| 211 | TCTriple.setArchName(ArchName); |
| 212 | |
| 213 | TC = new toolchains::Generic_GCC(*this, TCTriple); |
| 214 | } |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 215 | |
Daniel Dunbar | b25c7c1 | 2009-03-18 01:39:08 +0000 | [diff] [blame] | 216 | return TC; |
Daniel Dunbar | e399564 | 2009-03-10 23:50:49 +0000 | [diff] [blame] | 217 | } |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 218 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 219 | // OpenBSD Host Info |
| 220 | |
| 221 | /// OpenBSDHostInfo - OpenBSD host information implementation. |
| 222 | class OpenBSDHostInfo : public HostInfo { |
| 223 | /// Cache of tool chains we have created. |
| 224 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 225 | |
| 226 | public: |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 227 | OpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple) |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 228 | : HostInfo(D, Triple) {} |
| 229 | ~OpenBSDHostInfo(); |
| 230 | |
| 231 | virtual bool useDriverDriver() const; |
| 232 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 233 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 234 | const char *ArchName) const; |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | OpenBSDHostInfo::~OpenBSDHostInfo() { |
| 238 | for (llvm::StringMap<ToolChain*>::iterator |
| 239 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 240 | delete it->second; |
| 241 | } |
| 242 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 243 | bool OpenBSDHostInfo::useDriverDriver() const { |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 244 | return false; |
| 245 | } |
| 246 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 247 | ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args, |
| 248 | const char *ArchName) const { |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 249 | assert(!ArchName && |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 250 | "Unexpected arch name on platform without driver driver support."); |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 251 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 252 | std::string Arch = getArchName(); |
| 253 | ArchName = Arch.c_str(); |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 254 | |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 255 | ToolChain *&TC = ToolChains[ArchName]; |
| 256 | if (!TC) { |
| 257 | llvm::Triple TCTriple(getTriple()); |
| 258 | TCTriple.setArchName(ArchName); |
| 259 | |
| 260 | TC = new toolchains::OpenBSD(*this, TCTriple); |
| 261 | } |
| 262 | |
| 263 | return TC; |
| 264 | } |
| 265 | |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 266 | // AuroraUX Host Info |
| 267 | |
| 268 | /// AuroraUXHostInfo - AuroraUX host information implementation. |
| 269 | class AuroraUXHostInfo : public HostInfo { |
| 270 | /// Cache of tool chains we have created. |
| 271 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 272 | |
| 273 | public: |
| 274 | AuroraUXHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 275 | : HostInfo(D, Triple) {} |
| 276 | ~AuroraUXHostInfo(); |
| 277 | |
| 278 | virtual bool useDriverDriver() const; |
| 279 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 280 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 281 | const char *ArchName) const; |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | AuroraUXHostInfo::~AuroraUXHostInfo() { |
| 285 | for (llvm::StringMap<ToolChain*>::iterator |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 286 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 287 | delete it->second; |
| 288 | } |
| 289 | |
| 290 | bool AuroraUXHostInfo::useDriverDriver() const { |
| 291 | return false; |
| 292 | } |
| 293 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 294 | ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args, |
| 295 | const char *ArchName) const { |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 296 | assert(!ArchName && |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 297 | "Unexpected arch name on platform without driver driver support."); |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 298 | |
| 299 | ToolChain *&TC = ToolChains[getArchName()]; |
| 300 | |
| 301 | if (!TC) { |
| 302 | llvm::Triple TCTriple(getTriple()); |
| 303 | TCTriple.setArchName(getArchName()); |
| 304 | |
| 305 | TC = new toolchains::AuroraUX(*this, TCTriple); |
| 306 | } |
| 307 | |
| 308 | return TC; |
| 309 | } |
| 310 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 311 | // FreeBSD Host Info |
| 312 | |
Daniel Dunbar | b85f59d | 2009-03-30 22:11:38 +0000 | [diff] [blame] | 313 | /// FreeBSDHostInfo - FreeBSD host information implementation. |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 314 | class FreeBSDHostInfo : public HostInfo { |
| 315 | /// Cache of tool chains we have created. |
| 316 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 317 | |
| 318 | public: |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 319 | FreeBSDHostInfo(const Driver &D, const llvm::Triple& Triple) |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 320 | : HostInfo(D, Triple) {} |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 321 | ~FreeBSDHostInfo(); |
| 322 | |
| 323 | virtual bool useDriverDriver() const; |
| 324 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 325 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 326 | const char *ArchName) const; |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 327 | }; |
| 328 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 329 | FreeBSDHostInfo::~FreeBSDHostInfo() { |
| 330 | for (llvm::StringMap<ToolChain*>::iterator |
| 331 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 332 | delete it->second; |
| 333 | } |
| 334 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 335 | bool FreeBSDHostInfo::useDriverDriver() const { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 336 | return false; |
| 337 | } |
| 338 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 339 | ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args, |
| 340 | const char *ArchName) const { |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 341 | assert(!ArchName && |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 342 | "Unexpected arch name on platform without driver driver support."); |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 343 | |
Daniel Dunbar | 9d5600a | 2010-08-10 17:39:05 +0000 | [diff] [blame] | 344 | // Automatically handle some instances of -m32/-m64 we know about. |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 345 | std::string Arch = getArchName(); |
| 346 | ArchName = Arch.c_str(); |
Daniel Dunbar | 9d5600a | 2010-08-10 17:39:05 +0000 | [diff] [blame] | 347 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
| 348 | if (Triple.getArch() == llvm::Triple::x86 || |
| 349 | Triple.getArch() == llvm::Triple::x86_64) { |
| 350 | ArchName = |
| 351 | (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; |
| 352 | } else if (Triple.getArch() == llvm::Triple::ppc || |
| 353 | Triple.getArch() == llvm::Triple::ppc64) { |
| 354 | ArchName = |
| 355 | (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64"; |
| 356 | } |
| 357 | } |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 358 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 359 | ToolChain *&TC = ToolChains[ArchName]; |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 360 | if (!TC) { |
| 361 | llvm::Triple TCTriple(getTriple()); |
| 362 | TCTriple.setArchName(ArchName); |
| 363 | |
Daniel Dunbar | 214afe9 | 2010-08-02 05:43:59 +0000 | [diff] [blame] | 364 | TC = new toolchains::FreeBSD(*this, TCTriple); |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 365 | } |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 366 | |
| 367 | return TC; |
| 368 | } |
| 369 | |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 370 | // NetBSD Host Info |
| 371 | |
| 372 | /// NetBSDHostInfo - NetBSD host information implementation. |
| 373 | class NetBSDHostInfo : public HostInfo { |
| 374 | /// Cache of tool chains we have created. |
| 375 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 376 | |
| 377 | public: |
| 378 | NetBSDHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 379 | : HostInfo(D, Triple) {} |
| 380 | ~NetBSDHostInfo(); |
| 381 | |
| 382 | virtual bool useDriverDriver() const; |
| 383 | |
| 384 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 385 | const char *ArchName) const; |
| 386 | }; |
| 387 | |
| 388 | NetBSDHostInfo::~NetBSDHostInfo() { |
| 389 | for (llvm::StringMap<ToolChain*>::iterator |
| 390 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 391 | delete it->second; |
| 392 | } |
| 393 | |
| 394 | bool NetBSDHostInfo::useDriverDriver() const { |
| 395 | return false; |
| 396 | } |
| 397 | |
| 398 | ToolChain *NetBSDHostInfo::CreateToolChain(const ArgList &Args, |
| 399 | const char *ArchName) const { |
| 400 | assert(!ArchName && |
| 401 | "Unexpected arch name on platform without driver driver support."); |
| 402 | |
| 403 | // Automatically handle some instances of -m32/-m64 we know about. |
| 404 | std::string Arch = getArchName(); |
| 405 | ArchName = Arch.c_str(); |
| 406 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
| 407 | if (Triple.getArch() == llvm::Triple::x86 || |
| 408 | Triple.getArch() == llvm::Triple::x86_64) { |
| 409 | ArchName = |
| 410 | (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; |
| 411 | } else if (Triple.getArch() == llvm::Triple::ppc || |
| 412 | Triple.getArch() == llvm::Triple::ppc64) { |
| 413 | ArchName = |
| 414 | (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64"; |
| 415 | } |
| 416 | } |
Joerg Sonnenberger | 182564c | 2011-05-16 13:35:02 +0000 | [diff] [blame] | 417 | llvm::Triple TargetTriple(getTriple()); |
| 418 | TargetTriple.setArchName(ArchName); |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 419 | |
Joerg Sonnenberger | 182564c | 2011-05-16 13:35:02 +0000 | [diff] [blame] | 420 | ToolChain *TC; |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 421 | |
Joerg Sonnenberger | 182564c | 2011-05-16 13:35:02 +0000 | [diff] [blame] | 422 | // XXX Cache toolchain even if -m32 is used |
| 423 | if (Arch == ArchName) { |
| 424 | TC = ToolChains[ArchName]; |
| 425 | if (TC) |
| 426 | return TC; |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 427 | } |
| 428 | |
Joerg Sonnenberger | 182564c | 2011-05-16 13:35:02 +0000 | [diff] [blame] | 429 | TC = new toolchains::NetBSD(*this, TargetTriple, getTriple()); |
| 430 | |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 431 | return TC; |
| 432 | } |
| 433 | |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 434 | // Minix Host Info |
| 435 | |
| 436 | /// MinixHostInfo - Minix host information implementation. |
| 437 | class MinixHostInfo : public HostInfo { |
| 438 | /// Cache of tool chains we have created. |
| 439 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 440 | |
| 441 | public: |
| 442 | MinixHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 443 | : HostInfo(D, Triple) {} |
| 444 | ~MinixHostInfo(); |
| 445 | |
| 446 | virtual bool useDriverDriver() const; |
| 447 | |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 448 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 449 | const char *ArchName) const; |
| 450 | }; |
| 451 | |
| 452 | MinixHostInfo::~MinixHostInfo() { |
| 453 | for (llvm::StringMap<ToolChain*>::iterator |
| 454 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it){ |
| 455 | delete it->second; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | bool MinixHostInfo::useDriverDriver() const { |
| 460 | return false; |
| 461 | } |
| 462 | |
| 463 | ToolChain *MinixHostInfo::CreateToolChain(const ArgList &Args, |
| 464 | const char *ArchName) const { |
| 465 | assert(!ArchName && |
| 466 | "Unexpected arch name on platform without driver driver support."); |
| 467 | |
| 468 | std::string Arch = getArchName(); |
| 469 | ArchName = Arch.c_str(); |
| 470 | |
| 471 | ToolChain *&TC = ToolChains[ArchName]; |
| 472 | if (!TC) { |
| 473 | llvm::Triple TCTriple(getTriple()); |
| 474 | TCTriple.setArchName(ArchName); |
| 475 | |
| 476 | TC = new toolchains::Minix(*this, TCTriple); |
| 477 | } |
| 478 | |
| 479 | return TC; |
| 480 | } |
| 481 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 482 | // DragonFly Host Info |
| 483 | |
| 484 | /// DragonFlyHostInfo - DragonFly host information implementation. |
| 485 | class DragonFlyHostInfo : public HostInfo { |
| 486 | /// Cache of tool chains we have created. |
| 487 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 488 | |
| 489 | public: |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 490 | DragonFlyHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 491 | : HostInfo(D, Triple) {} |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 492 | ~DragonFlyHostInfo(); |
| 493 | |
| 494 | virtual bool useDriverDriver() const; |
| 495 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 496 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 497 | const char *ArchName) const; |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 498 | }; |
| 499 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 500 | DragonFlyHostInfo::~DragonFlyHostInfo() { |
| 501 | for (llvm::StringMap<ToolChain*>::iterator |
| 502 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 503 | delete it->second; |
| 504 | } |
| 505 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 506 | bool DragonFlyHostInfo::useDriverDriver() const { |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 507 | return false; |
| 508 | } |
| 509 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 510 | ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args, |
| 511 | const char *ArchName) const { |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 512 | assert(!ArchName && |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 513 | "Unexpected arch name on platform without driver driver support."); |
| 514 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 515 | ToolChain *&TC = ToolChains[getArchName()]; |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 516 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 517 | if (!TC) { |
| 518 | llvm::Triple TCTriple(getTriple()); |
| 519 | TCTriple.setArchName(getArchName()); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 520 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 521 | TC = new toolchains::DragonFly(*this, TCTriple); |
| 522 | } |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 523 | |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 524 | return TC; |
| 525 | } |
| 526 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 527 | // Linux Host Info |
| 528 | |
| 529 | /// LinuxHostInfo - Linux host information implementation. |
| 530 | class LinuxHostInfo : public HostInfo { |
| 531 | /// Cache of tool chains we have created. |
| 532 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 533 | |
| 534 | public: |
| 535 | LinuxHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 536 | : HostInfo(D, Triple) {} |
| 537 | ~LinuxHostInfo(); |
| 538 | |
| 539 | virtual bool useDriverDriver() const; |
| 540 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 541 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 542 | const char *ArchName) const; |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 543 | }; |
| 544 | |
| 545 | LinuxHostInfo::~LinuxHostInfo() { |
| 546 | for (llvm::StringMap<ToolChain*>::iterator |
| 547 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 548 | delete it->second; |
| 549 | } |
| 550 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 551 | bool LinuxHostInfo::useDriverDriver() const { |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 552 | return false; |
| 553 | } |
| 554 | |
Daniel Dunbar | d7502d0 | 2009-09-08 23:37:19 +0000 | [diff] [blame] | 555 | ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args, |
| 556 | const char *ArchName) const { |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 557 | |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 558 | assert(!ArchName && |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 559 | "Unexpected arch name on platform without driver driver support."); |
| 560 | |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 561 | // Automatically handle some instances of -m32/-m64 we know about. |
| 562 | std::string Arch = getArchName(); |
| 563 | ArchName = Arch.c_str(); |
| 564 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
| 565 | if (Triple.getArch() == llvm::Triple::x86 || |
| 566 | Triple.getArch() == llvm::Triple::x86_64) { |
| 567 | ArchName = |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 568 | (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 569 | } else if (Triple.getArch() == llvm::Triple::ppc || |
| 570 | Triple.getArch() == llvm::Triple::ppc64) { |
| 571 | ArchName = |
Daniel Dunbar | b827a05 | 2009-11-19 03:26:40 +0000 | [diff] [blame] | 572 | (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64"; |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 573 | } |
| 574 | } |
| 575 | |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 576 | ToolChain *&TC = ToolChains[ArchName]; |
| 577 | |
| 578 | if (!TC) { |
| 579 | llvm::Triple TCTriple(getTriple()); |
Eli Friedman | 4e2567d | 2009-06-03 18:59:56 +0000 | [diff] [blame] | 580 | TCTriple.setArchName(ArchName); |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 581 | |
| 582 | TC = new toolchains::Linux(*this, TCTriple); |
| 583 | } |
| 584 | |
| 585 | return TC; |
| 586 | } |
| 587 | |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 588 | // Windows Host Info |
| 589 | |
| 590 | /// WindowsHostInfo - Host information to use on Microsoft Windows. |
| 591 | class WindowsHostInfo : public HostInfo { |
| 592 | /// Cache of tool chains we have created. |
| 593 | mutable llvm::StringMap<ToolChain*> ToolChains; |
| 594 | |
| 595 | public: |
| 596 | WindowsHostInfo(const Driver &D, const llvm::Triple& Triple); |
| 597 | ~WindowsHostInfo(); |
| 598 | |
| 599 | virtual bool useDriverDriver() const; |
| 600 | |
| 601 | virtual types::ID lookupTypeForExtension(const char *Ext) const { |
| 602 | return types::lookupTypeForExtension(Ext); |
| 603 | } |
| 604 | |
| 605 | virtual ToolChain *CreateToolChain(const ArgList &Args, |
| 606 | const char *ArchName) const; |
| 607 | }; |
| 608 | |
| 609 | WindowsHostInfo::WindowsHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 610 | : HostInfo(D, Triple) { |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 611 | } |
| 612 | |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 613 | WindowsHostInfo::~WindowsHostInfo() { |
| 614 | for (llvm::StringMap<ToolChain*>::iterator |
| 615 | it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) |
| 616 | delete it->second; |
| 617 | } |
| 618 | |
| 619 | bool WindowsHostInfo::useDriverDriver() const { |
| 620 | return false; |
| 621 | } |
| 622 | |
| 623 | ToolChain *WindowsHostInfo::CreateToolChain(const ArgList &Args, |
| 624 | const char *ArchName) const { |
| 625 | assert(!ArchName && |
| 626 | "Unexpected arch name on platform without driver driver support."); |
| 627 | |
| 628 | // Automatically handle some instances of -m32/-m64 we know about. |
| 629 | std::string Arch = getArchName(); |
| 630 | ArchName = Arch.c_str(); |
| 631 | if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { |
| 632 | if (Triple.getArch() == llvm::Triple::x86 || |
| 633 | Triple.getArch() == llvm::Triple::x86_64) { |
| 634 | ArchName = |
| 635 | (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | ToolChain *&TC = ToolChains[ArchName]; |
| 640 | if (!TC) { |
| 641 | llvm::Triple TCTriple(getTriple()); |
| 642 | TCTriple.setArchName(ArchName); |
| 643 | |
| 644 | TC = new toolchains::Windows(*this, TCTriple); |
| 645 | } |
| 646 | |
| 647 | return TC; |
| 648 | } |
| 649 | |
| 650 | // FIXME: This is a placeholder. |
| 651 | class MinGWHostInfo : public UnknownHostInfo { |
| 652 | public: |
| 653 | MinGWHostInfo(const Driver &D, const llvm::Triple& Triple); |
| 654 | }; |
| 655 | |
| 656 | MinGWHostInfo::MinGWHostInfo(const Driver &D, const llvm::Triple& Triple) |
| 657 | : UnknownHostInfo(D, Triple) {} |
| 658 | |
| 659 | } // end anon namespace |
| 660 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 661 | const HostInfo * |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 662 | clang::driver::createAuroraUXHostInfo(const Driver &D, |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 663 | const llvm::Triple& Triple){ |
Edward O'Callaghan | e7925a0 | 2009-08-22 01:06:46 +0000 | [diff] [blame] | 664 | return new AuroraUXHostInfo(D, Triple); |
| 665 | } |
| 666 | |
| 667 | const HostInfo * |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 668 | clang::driver::createDarwinHostInfo(const Driver &D, |
| 669 | const llvm::Triple& Triple){ |
| 670 | return new DarwinHostInfo(D, Triple); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 673 | const HostInfo * |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 674 | clang::driver::createOpenBSDHostInfo(const Driver &D, |
Daniel Dunbar | f7b8eec | 2009-06-29 20:52:51 +0000 | [diff] [blame] | 675 | const llvm::Triple& Triple) { |
| 676 | return new OpenBSDHostInfo(D, Triple); |
| 677 | } |
| 678 | |
| 679 | const HostInfo * |
Daniel Dunbar | fe8aa47 | 2009-09-08 23:37:08 +0000 | [diff] [blame] | 680 | clang::driver::createFreeBSDHostInfo(const Driver &D, |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 681 | const llvm::Triple& Triple) { |
| 682 | return new FreeBSDHostInfo(D, Triple); |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 683 | } |
| 684 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 685 | const HostInfo * |
Benjamin Kramer | 8e50a96 | 2011-02-02 18:59:27 +0000 | [diff] [blame] | 686 | clang::driver::createNetBSDHostInfo(const Driver &D, |
| 687 | const llvm::Triple& Triple) { |
| 688 | return new NetBSDHostInfo(D, Triple); |
| 689 | } |
| 690 | |
| 691 | const HostInfo * |
Chris Lattner | 38e317d | 2010-07-07 16:01:42 +0000 | [diff] [blame] | 692 | clang::driver::createMinixHostInfo(const Driver &D, |
| 693 | const llvm::Triple& Triple) { |
| 694 | return new MinixHostInfo(D, Triple); |
| 695 | } |
| 696 | |
| 697 | const HostInfo * |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 698 | clang::driver::createDragonFlyHostInfo(const Driver &D, |
| 699 | const llvm::Triple& Triple) { |
| 700 | return new DragonFlyHostInfo(D, Triple); |
Daniel Dunbar | 11e1b40 | 2009-05-02 18:28:39 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 703 | const HostInfo * |
Eli Friedman | 6b3454a | 2009-05-26 07:52:18 +0000 | [diff] [blame] | 704 | clang::driver::createLinuxHostInfo(const Driver &D, |
| 705 | const llvm::Triple& Triple) { |
| 706 | return new LinuxHostInfo(D, Triple); |
| 707 | } |
| 708 | |
| 709 | const HostInfo * |
Chris Lattner | 3a47c4e | 2010-03-04 21:07:38 +0000 | [diff] [blame] | 710 | clang::driver::createTCEHostInfo(const Driver &D, |
| 711 | const llvm::Triple& Triple) { |
| 712 | return new TCEHostInfo(D, Triple); |
| 713 | } |
| 714 | |
| 715 | const HostInfo * |
Michael J. Spencer | ff58e36 | 2010-08-21 21:55:07 +0000 | [diff] [blame] | 716 | clang::driver::createWindowsHostInfo(const Driver &D, |
| 717 | const llvm::Triple& Triple) { |
| 718 | return new WindowsHostInfo(D, Triple); |
| 719 | } |
| 720 | |
| 721 | const HostInfo * |
| 722 | clang::driver::createMinGWHostInfo(const Driver &D, |
| 723 | const llvm::Triple& Triple) { |
| 724 | return new MinGWHostInfo(D, Triple); |
| 725 | } |
| 726 | |
| 727 | const HostInfo * |
Daniel Dunbar | cb8ab23 | 2009-05-22 02:53:45 +0000 | [diff] [blame] | 728 | clang::driver::createUnknownHostInfo(const Driver &D, |
| 729 | const llvm::Triple& Triple) { |
| 730 | return new UnknownHostInfo(D, Triple); |
Daniel Dunbar | 1fd6c4b | 2009-03-17 19:00:50 +0000 | [diff] [blame] | 731 | } |