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 { |
Daniel Dunbar | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 23 | namespace toolchains { |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 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 | 985b825 | 2009-03-17 22:18:43 +0000 | [diff] [blame] | 28 | class VISIBILITY_HIDDEN Generic_GCC : public ToolChain { |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 29 | protected: |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 30 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 31 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 32 | public: |
| 33 | Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 34 | const char *OS); |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 35 | ~Generic_GCC(); |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 36 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 37 | virtual DerivedArgList *TranslateArgs(InputArgList &Args) const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 38 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 39 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
Daniel Dunbar | 670b7f4 | 2009-03-17 22:07:31 +0000 | [diff] [blame] | 40 | |
Daniel Dunbar | 3917608 | 2009-03-20 00:20:03 +0000 | [diff] [blame] | 41 | virtual bool IsMathErrnoDefault() const; |
| 42 | virtual bool IsUnwindTablesDefault() const; |
| 43 | virtual const char *GetDefaultRelocationModel() const; |
| 44 | virtual const char *GetForcedPicModel() const; |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 47 | /// Darwin_X86 - Darwin tool chain for i386 an x86_64. |
| 48 | class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain { |
| 49 | mutable llvm::DenseMap<unsigned, Tool*> Tools; |
| 50 | |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 51 | /// Darwin version of tool chain. |
| 52 | unsigned DarwinVersion[3]; |
| 53 | |
| 54 | /// GCC version to use. |
| 55 | unsigned GCCVersion[3]; |
| 56 | |
| 57 | /// The directory suffix for this tool chain. |
| 58 | std::string ToolChainDir; |
| 59 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 60 | /// The default macosx-version-min of this tool chain; empty until |
| 61 | /// initialized. |
| 62 | mutable std::string MacosxVersionMin; |
| 63 | |
| 64 | const char *getMacosxVersionMin() const; |
Daniel Dunbar | ec069ed | 2009-03-25 06:58:31 +0000 | [diff] [blame] | 65 | |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 66 | public: |
| 67 | Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform, |
Daniel Dunbar | c50b00d | 2009-03-23 16:15:50 +0000 | [diff] [blame] | 68 | const char *OS, const unsigned (&DarwinVersion)[3], |
| 69 | const unsigned (&GCCVersion)[3]); |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 70 | ~Darwin_X86(); |
| 71 | |
Daniel Dunbar | 02633b5 | 2009-03-26 16:23:12 +0000 | [diff] [blame] | 72 | void getDarwinVersion(unsigned (&Res)[3]) const { |
| 73 | Res[0] = DarwinVersion[0]; |
| 74 | Res[1] = DarwinVersion[1]; |
| 75 | Res[2] = DarwinVersion[2]; |
| 76 | } |
| 77 | |
| 78 | void getMacosxVersion(unsigned (&Res)[3]) const { |
| 79 | Res[0] = 10; |
| 80 | Res[1] = DarwinVersion[0] - 4; |
| 81 | Res[2] = DarwinVersion[1]; |
| 82 | } |
| 83 | |
| 84 | const char *getMacosxVersionStr() const { |
| 85 | return MacosxVersionMin.c_str(); |
| 86 | } |
| 87 | |
| 88 | const std::string &getToolChainDir() const { |
| 89 | return ToolChainDir; |
| 90 | } |
| 91 | |
Daniel Dunbar | f3cad36 | 2009-03-25 04:13:45 +0000 | [diff] [blame] | 92 | virtual DerivedArgList *TranslateArgs(InputArgList &Args) const; |
Daniel Dunbar | 8eddb3f | 2009-03-20 00:57:52 +0000 | [diff] [blame] | 93 | |
| 94 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 95 | |
| 96 | virtual bool IsMathErrnoDefault() const; |
| 97 | virtual bool IsUnwindTablesDefault() const; |
| 98 | virtual const char *GetDefaultRelocationModel() const; |
| 99 | virtual const char *GetForcedPicModel() const; |
| 100 | }; |
| 101 | |
| 102 | /// Darwin_GCC - Generic Darwin tool chain using gcc. |
| 103 | class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC { |
| 104 | public: |
| 105 | Darwin_GCC(const HostInfo &Host, const char *Arch, const char *Platform, |
| 106 | const char *OS) : Generic_GCC(Host, Arch, Platform, OS) {} |
| 107 | |
| 108 | virtual const char *GetDefaultRelocationModel() const { return "pic"; } |
| 109 | }; |
| 110 | |
Daniel Dunbar | 75358d2 | 2009-03-30 21:06:03 +0000 | [diff] [blame] | 111 | class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC { |
| 112 | public: |
| 113 | FreeBSD(const HostInfo &Host, const char *Arch, const char *Platform, |
| 114 | const char *OS, bool Lib32); |
| 115 | |
| 116 | virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const; |
| 117 | }; |
| 118 | |
Daniel Dunbar | 83b08eb | 2009-03-17 21:38:00 +0000 | [diff] [blame] | 119 | } // end namespace toolchains |
| 120 | } // end namespace driver |
| 121 | } // end namespace clang |
| 122 | |
| 123 | #endif |