From d1d820ed51074053b9eb22af1bb2ebe49f9dfb4b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 13 Jul 2009 20:29:08 +0000 Subject: [PATCH] add netbsd support, patch by Krister Kalfridsson! llvm-svn: 75492 --- clang/lib/Basic/Targets.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 0ff881231472..65c5264eb114 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -321,6 +321,24 @@ public: } }; +// NetBSD Target +template +class NetBSDTargetInfo : public OSTargetInfo { +protected: + virtual void getOSDefines(const LangOptions &Opts, const char *Triple, + std::vector &Defs) const { + // NetBSD defines; list based off of gcc output + Define(Defs, "__NetBSD__", "1"); + Define(Defs, "__unix__", "1"); + Define(Defs, "__ELF__", "1"); + } +public: + NetBSDTargetInfo(const std::string &triple) + : OSTargetInfo(triple) { + this->UserLabelPrefix = ""; + } +}; + // OpenBSD Target template class OpenBSDTargetInfo : public OSTargetInfo { @@ -1372,6 +1390,7 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { // Additions and corrections are welcome. bool isDarwin = T.find("-darwin") != std::string::npos; bool isDragonFly = T.find("-dragonfly") != std::string::npos; + bool isNetBSD = T.find("-netbsd") != std::string::npos; bool isOpenBSD = T.find("-openbsd") != std::string::npos; bool isFreeBSD = T.find("-freebsd") != std::string::npos; bool isSolaris = T.find("-solaris") != std::string::npos; @@ -1411,6 +1430,8 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { return new DarwinX86_64TargetInfo(T); if (isLinux) return new LinuxTargetInfo(T); + if (isNetBSD) + return new NetBSDTargetInfo(T); if (isOpenBSD) return new OpenBSDX86_64TargetInfo(T); if (isFreeBSD) @@ -1433,6 +1454,8 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) { return new LinuxTargetInfo(T); if (isDragonFly) return new DragonFlyBSDTargetInfo(T); + if (isNetBSD) + return new NetBSDTargetInfo(T); if (isOpenBSD) return new OpenBSDI386TargetInfo(T); if (isFreeBSD)