blob: 5e7bdb5f7b43fcba3b9363f6ace36af27a549769 [file] [log] [blame]
Daniel Dunbar83b08eb2009-03-17 21:38:00 +00001//===--- 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 Dunbar670b7f42009-03-17 22:07:31 +000013#include "clang/Driver/Action.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000014#include "clang/Driver/ToolChain.h"
15
Daniel Dunbar670b7f42009-03-17 22:07:31 +000016#include "llvm/ADT/DenseMap.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000017#include "llvm/Support/Compiler.h"
18
Daniel Dunbar670b7f42009-03-17 22:07:31 +000019#include "Tools.h"
20
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000021namespace clang {
22namespace driver {
Daniel Dunbar985b8252009-03-17 22:18:43 +000023namespace toolchains {
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000024
Daniel Dunbar670b7f42009-03-17 22:07:31 +000025 /// 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 Dunbar985b8252009-03-17 22:18:43 +000028class VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
Daniel Dunbar670b7f42009-03-17 22:07:31 +000029 mutable llvm::DenseMap<unsigned, Tool*> Tools;
30
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000031public:
32 Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000033 const char *OS);
Daniel Dunbar39176082009-03-20 00:20:03 +000034 ~Generic_GCC();
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000035
Daniel Dunbarf3cad362009-03-25 04:13:45 +000036 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000037
Daniel Dunbar39176082009-03-20 00:20:03 +000038 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
Daniel Dunbar670b7f42009-03-17 22:07:31 +000039
Daniel Dunbar39176082009-03-20 00:20:03 +000040 virtual bool IsMathErrnoDefault() const;
41 virtual bool IsUnwindTablesDefault() const;
42 virtual const char *GetDefaultRelocationModel() const;
43 virtual const char *GetForcedPicModel() const;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000044};
45
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000046 /// Darwin_X86 - Darwin tool chain for i386 an x86_64.
47class VISIBILITY_HIDDEN Darwin_X86 : public ToolChain {
48 mutable llvm::DenseMap<unsigned, Tool*> Tools;
49
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000050 /// Darwin version of tool chain.
51 unsigned DarwinVersion[3];
52
53 /// GCC version to use.
54 unsigned GCCVersion[3];
55
56 /// The directory suffix for this tool chain.
57 std::string ToolChainDir;
58
Daniel Dunbar02633b52009-03-26 16:23:12 +000059 /// The default macosx-version-min of this tool chain; empty until
60 /// initialized.
61 mutable std::string MacosxVersionMin;
62
63 const char *getMacosxVersionMin() const;
Daniel Dunbarec069ed2009-03-25 06:58:31 +000064
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000065public:
66 Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform,
Daniel Dunbarc50b00d2009-03-23 16:15:50 +000067 const char *OS, const unsigned (&DarwinVersion)[3],
68 const unsigned (&GCCVersion)[3]);
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000069 ~Darwin_X86();
70
Daniel Dunbar02633b52009-03-26 16:23:12 +000071 void getDarwinVersion(unsigned (&Res)[3]) const {
72 Res[0] = DarwinVersion[0];
73 Res[1] = DarwinVersion[1];
74 Res[2] = DarwinVersion[2];
75 }
76
77 void getMacosxVersion(unsigned (&Res)[3]) const {
78 Res[0] = 10;
79 Res[1] = DarwinVersion[0] - 4;
80 Res[2] = DarwinVersion[1];
81 }
82
83 const char *getMacosxVersionStr() const {
84 return MacosxVersionMin.c_str();
85 }
86
87 const std::string &getToolChainDir() const {
88 return ToolChainDir;
89 }
90
Daniel Dunbarf3cad362009-03-25 04:13:45 +000091 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
Daniel Dunbar8eddb3f2009-03-20 00:57:52 +000092
93 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
94
95 virtual bool IsMathErrnoDefault() const;
96 virtual bool IsUnwindTablesDefault() const;
97 virtual const char *GetDefaultRelocationModel() const;
98 virtual const char *GetForcedPicModel() const;
99};
100
101 /// Darwin_GCC - Generic Darwin tool chain using gcc.
102class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
103public:
104 Darwin_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
105 const char *OS) : Generic_GCC(Host, Arch, Platform, OS) {}
106
107 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
108};
109
Daniel Dunbar83b08eb2009-03-17 21:38:00 +0000110} // end namespace toolchains
111} // end namespace driver
112} // end namespace clang
113
114#endif