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 { |
| 23 | namespace toolchains VISIBILITY_HIDDEN { |
| 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 | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 28 | class Generic_GCC : public ToolChain { |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame^] | 29 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 30 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 31 | public: |
| 32 | Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame^] | 33 | const char *OS) : ToolChain(Host, Arch, Platform, OS) {} |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 34 | |
| 35 | virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; } |
| 36 | |
| 37 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const { |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame^] | 38 | Action::ActionClass Key; |
| 39 | if (ShouldUseClangCompiler(C, JA)) |
| 40 | Key = Action::AnalyzeJobClass; |
| 41 | else |
| 42 | Key = JA.getKind(); |
| 43 | |
| 44 | Tool *&T = Tools[Key]; |
| 45 | if (!T) { |
| 46 | switch (Key) { |
| 47 | default: |
| 48 | assert(0 && "Invalid tool kind."); |
| 49 | case Action::PreprocessJobClass: |
| 50 | T = new tools::GCC_Preprocess(*this); break; |
| 51 | case Action::PrecompileJobClass: |
| 52 | T = new tools::GCC_Precompile(*this); break; |
| 53 | case Action::AnalyzeJobClass: |
| 54 | T = new tools::Clang(*this); break; |
| 55 | case Action::CompileJobClass: |
| 56 | T = new tools::GCC_Compile(*this); break; |
| 57 | case Action::AssembleJobClass: |
| 58 | T = new tools::GCC_Assemble(*this); break; |
| 59 | case Action::LinkJobClass: |
| 60 | T = new tools::GCC_Assemble(*this); break; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return *T; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | virtual bool IsMathErrnoDefault() const { return true; } |
| 68 | |
| 69 | virtual bool IsUnwindTablesDefault() const { |
| 70 | // FIXME: Gross; we should probably have some separate target definition, |
| 71 | // possibly even reusing the one in clang. |
| 72 | return getArchName() == "x86_64"; |
| 73 | } |
| 74 | |
| 75 | virtual const char *GetDefaultRelocationModel() const { |
| 76 | return "static"; |
| 77 | } |
| 78 | |
| 79 | virtual const char *GetForcedPicModel() const { |
| 80 | return 0; |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | } // end namespace toolchains |
| 85 | } // end namespace driver |
| 86 | } // end namespace clang |
| 87 | |
| 88 | #endif |