diff options
Diffstat (limited to 'lib/Driver/HostInfo.cpp')
| -rw-r--r-- | lib/Driver/HostInfo.cpp | 68 | 
1 files changed, 67 insertions, 1 deletions
diff --git a/lib/Driver/HostInfo.cpp b/lib/Driver/HostInfo.cpp index 7c5e430bb7d5..cd413180f77b 100644 --- a/lib/Driver/HostInfo.cpp +++ b/lib/Driver/HostInfo.cpp @@ -1,4 +1,4 @@ -//===--- HostInfo.cpp - Host specific information -----------------------*-===// +//===--- HostInfo.cpp - Host specific information -------------------------===//  //  //                     The LLVM Compiler Infrastructure  // @@ -115,6 +115,7 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,      // If we recognized the arch, match it to the toolchains we support.      const char *UseNewToolChain = ::getenv("CCC_ENABLE_NEW_DARWIN_TOOLCHAIN");      if (UseNewToolChain ||  +        Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 ||          Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {        TC = new toolchains::DarwinClang(*this, TCTriple);      } else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) { @@ -371,6 +372,65 @@ ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args,    return TC;  } +// NetBSD Host Info + +/// NetBSDHostInfo -  NetBSD host information implementation. +class NetBSDHostInfo : public HostInfo { +  /// Cache of tool chains we have created. +  mutable llvm::StringMap<ToolChain*> ToolChains; + +public: +  NetBSDHostInfo(const Driver &D, const llvm::Triple& Triple) +    : HostInfo(D, Triple) {} +  ~NetBSDHostInfo(); + +  virtual bool useDriverDriver() const; + +  virtual ToolChain *CreateToolChain(const ArgList &Args, +                                     const char *ArchName) const; +}; + +NetBSDHostInfo::~NetBSDHostInfo() { +  for (llvm::StringMap<ToolChain*>::iterator +         it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) +    delete it->second; +} + +bool NetBSDHostInfo::useDriverDriver() const { +  return false; +} + +ToolChain *NetBSDHostInfo::CreateToolChain(const ArgList &Args, +                                            const char *ArchName) const { +  assert(!ArchName && +         "Unexpected arch name on platform without driver driver support."); + +  // Automatically handle some instances of -m32/-m64 we know about. +  std::string Arch = getArchName(); +  ArchName = Arch.c_str(); +  if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) { +    if (Triple.getArch() == llvm::Triple::x86 || +        Triple.getArch() == llvm::Triple::x86_64) { +      ArchName = +        (A->getOption().matches(options::OPT_m32)) ? "i386" : "x86_64"; +    } else if (Triple.getArch() == llvm::Triple::ppc || +               Triple.getArch() == llvm::Triple::ppc64) { +      ArchName = +        (A->getOption().matches(options::OPT_m32)) ? "powerpc" : "powerpc64"; +    } +  } + +  ToolChain *&TC = ToolChains[ArchName]; +  if (!TC) { +    llvm::Triple TCTriple(getTriple()); +    TCTriple.setArchName(ArchName); + +    TC = new toolchains::NetBSD(*this, TCTriple); +  } + +  return TC; +} +  // Minix Host Info  /// MinixHostInfo -  Minix host information implementation. @@ -623,6 +683,12 @@ clang::driver::createFreeBSDHostInfo(const Driver &D,  }  const HostInfo * +clang::driver::createNetBSDHostInfo(const Driver &D, +                                     const llvm::Triple& Triple) { +  return new NetBSDHostInfo(D, Triple); +} + +const HostInfo *  clang::driver::createMinixHostInfo(const Driver &D,                                       const llvm::Triple& Triple) {    return new MinixHostInfo(D, Triple);  | 
