[cfe-commits] r67356 - in /cfe/trunk/lib/Driver: HostInfo.cpp ToolChains.cpp ToolChains.h
Daniel Dunbar
daniel at zuster.org
Thu Mar 19 17:57:53 PDT 2009
Author: ddunbar
Date: Thu Mar 19 19:57:52 2009
New Revision: 67356
URL: http://llvm.org/viewvc/llvm-project?rev=67356&view=rev
Log:
Driver: Sketch Darwin tool chains.
Modified:
cfe/trunk/lib/Driver/HostInfo.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=67356&r1=67355&r2=67356&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Thu Mar 19 19:57:52 2009
@@ -106,13 +106,13 @@
ToolChain *&TC = ToolChains[ArchName];
if (!TC) {
if (strcmp(ArchName, "i386") == 0 || strcmp(ArchName, "x86_64") == 0)
- TC = new toolchains::Generic_GCC(*this, ArchName,
- getPlatformName().c_str(),
- getOSName().c_str());
+ TC = new toolchains::Darwin_X86(*this, ArchName,
+ getPlatformName().c_str(),
+ getOSName().c_str());
else
- TC = new toolchains::Generic_GCC(*this, ArchName,
- getPlatformName().c_str(),
- getOSName().c_str());
+ TC = new toolchains::Darwin_GCC(*this, ArchName,
+ getPlatformName().c_str(),
+ getOSName().c_str());
}
return TC;
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=67356&r1=67355&r2=67356&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Mar 19 19:57:52 2009
@@ -12,6 +12,74 @@
using namespace clang::driver;
using namespace clang::driver::toolchains;
+/// Darwin_X86 - Darwin tool chain for i386 and x86_64.
+
+Darwin_X86::~Darwin_X86() {
+ // Free tool implementations.
+ for (llvm::DenseMap<unsigned, Tool*>::iterator
+ it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
+ delete it->second;
+}
+
+Tool &Darwin_X86::SelectTool(const Compilation &C,
+ const JobAction &JA) const {
+ Action::ActionClass Key;
+ if (ShouldUseClangCompiler(C, JA))
+ Key = Action::AnalyzeJobClass;
+ else
+ Key = JA.getKind();
+
+ Tool *&T = Tools[Key];
+ if (!T) {
+ switch (Key) {
+ case Action::InputClass:
+ case Action::BindArchClass:
+ assert(0 && "Invalid tool kind.");
+ case Action::PreprocessJobClass:
+ T = new tools::gcc::Preprocess(*this); break;
+ case Action::PrecompileJobClass:
+ T = new tools::gcc::Precompile(*this); break;
+ case Action::AnalyzeJobClass:
+ T = new tools::Clang(*this); break;
+ case Action::CompileJobClass:
+ T = new tools::gcc::Compile(*this); break;
+ case Action::AssembleJobClass:
+ T = new tools::gcc::Assemble(*this); break;
+ case Action::LinkJobClass:
+ T = new tools::gcc::Link(*this); break;
+ case Action::LipoJobClass:
+ T = new tools::darwin::Lipo(*this); break;
+ }
+ }
+
+ return *T;
+}
+
+ArgList *Darwin_X86::TranslateArgs(ArgList &Args) const {
+ // FIXME: Implement!
+ return &Args;
+}
+
+bool Darwin_X86::IsMathErrnoDefault() const {
+ return false;
+}
+
+bool Darwin_X86::IsUnwindTablesDefault() const {
+ // FIXME: Gross; we should probably have some separate target
+ // definition, possibly even reusing the one in clang.
+ return getArchName() == "x86_64";
+}
+
+const char *Darwin_X86::GetDefaultRelocationModel() const {
+ return "pic";
+}
+
+const char *Darwin_X86::GetForcedPicModel() const {
+ if (getArchName() == "x86_64")
+ return "pic";
+ return 0;
+}
+
/// Generic_GCC - A tool chain using the 'gcc' command to perform
/// all subcommands; this relies on gcc translating the majority of
/// command line options.
@@ -34,7 +102,8 @@
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
- default:
+ case Action::InputClass:
+ case Action::BindArchClass:
assert(0 && "Invalid tool kind.");
case Action::PreprocessJobClass:
T = new tools::gcc::Preprocess(*this); break;
@@ -48,6 +117,11 @@
T = new tools::gcc::Assemble(*this); break;
case Action::LinkJobClass:
T = new tools::gcc::Link(*this); break;
+
+ // This is a bit ungeneric, but the only platform using a driver
+ // driver is Darwin.
+ case Action::LipoJobClass:
+ T = new tools::darwin::Lipo(*this); break;
}
}
@@ -59,8 +133,8 @@
}
bool Generic_GCC::IsUnwindTablesDefault() const {
- // FIXME: Gross; we should probably have some separate target definition,
- // possibly even reusing the one in clang.
+ // FIXME: Gross; we should probably have some separate target
+ // definition, possibly even reusing the one in clang.
return getArchName() == "x86_64";
}
@@ -71,5 +145,3 @@
const char *Generic_GCC::GetForcedPicModel() const {
return 0;
}
-
-
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=67356&r1=67355&r2=67356&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Mar 19 19:57:52 2009
@@ -43,6 +43,34 @@
virtual const char *GetForcedPicModel() const;
};
+ /// Darwin_X86 - Darwin tool chain for i386 an x86_64.
+class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain {
+ mutable llvm::DenseMap<unsigned, Tool*> Tools;
+
+public:
+ Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform,
+ const char *OS) : ToolChain(Host, Arch, Platform, OS) {}
+ ~Darwin_X86();
+
+ virtual ArgList *TranslateArgs(ArgList &Args) const;
+
+ virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
+
+ virtual bool IsMathErrnoDefault() const;
+ virtual bool IsUnwindTablesDefault() const;
+ virtual const char *GetDefaultRelocationModel() const;
+ virtual const char *GetForcedPicModel() const;
+};
+
+ /// Darwin_GCC - Generic Darwin tool chain using gcc.
+class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
+public:
+ Darwin_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
+ const char *OS) : Generic_GCC(Host, Arch, Platform, OS) {}
+
+ virtual const char *GetDefaultRelocationModel() const { return "pic"; }
+};
+
} // end namespace toolchains
} // end namespace driver
} // end namespace clang
More information about the cfe-commits
mailing list