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
13#include "clang/Driver/Action.h"
14#include "clang/Driver/ToolChain.h"
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/Support/Compiler.h"
18
19#include "Tools.h"
20
21namespace clang {
22namespace driver {
23namespace toolchains {
24
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.
28class VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
29protected:
30 mutable llvm::DenseMap<unsigned, Tool*> Tools;
31
32public:
33 Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
34 ~Generic_GCC();
35
36 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
37
38 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
39
40 virtual bool IsMathErrnoDefault() const;
41 virtual bool IsUnwindTablesDefault() const;
42 virtual const char *GetDefaultRelocationModel() const;
43 virtual const char *GetForcedPicModel() const;
44};
45
46 /// 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
50 /// 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
59 /// The default macosx-version-min of this tool chain; empty until
60 /// initialized.
61 mutable std::string MacosxVersionMin;
62
63 const char *getMacosxVersionMin() const;
64
65public:
66 Darwin_X86(const HostInfo &Host, const llvm::Triple& Triple,
67 const unsigned (&DarwinVersion)[3],
68 const unsigned (&GCCVersion)[3]);
69 ~Darwin_X86();
70
71 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
91 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
92
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 llvm::Triple& Triple)
105 : Generic_GCC(Host, Triple) {}
106
107 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
108};
109
110class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
111public:
112 OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
113
114 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
115};
116
117class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
118public:
119 FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
120
121 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
122};
123
124class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
125public:
126 DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
127
128 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
129};
130
131class VISIBILITY_HIDDEN Linux : public Generic_GCC {
132public:
133 Linux(const HostInfo &Host, const llvm::Triple& Triple);
134};
135
136
137} // end namespace toolchains
138} // end namespace driver
139} // end namespace clang
140
141#endif
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
13#include "clang/Driver/Action.h"
14#include "clang/Driver/ToolChain.h"
15
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/Support/Compiler.h"
18
19#include "Tools.h"
20
21namespace clang {
22namespace driver {
23namespace toolchains {
24
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.
28class VISIBILITY_HIDDEN Generic_GCC : public ToolChain {
29protected:
30 mutable llvm::DenseMap<unsigned, Tool*> Tools;
31
32public:
33 Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
34 ~Generic_GCC();
35
36 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
37
38 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
39
40 virtual bool IsMathErrnoDefault() const;
41 virtual bool IsUnwindTablesDefault() const;
42 virtual const char *GetDefaultRelocationModel() const;
43 virtual const char *GetForcedPicModel() const;
44};
45
46 /// 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
50 /// 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
59 /// The default macosx-version-min of this tool chain; empty until
60 /// initialized.
61 mutable std::string MacosxVersionMin;
62
63 const char *getMacosxVersionMin() const;
64
65public:
66 Darwin_X86(const HostInfo &Host, const llvm::Triple& Triple,
67 const unsigned (&DarwinVersion)[3],
68 const unsigned (&GCCVersion)[3]);
69 ~Darwin_X86();
70
71 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
91 virtual DerivedArgList *TranslateArgs(InputArgList &Args) const;
92
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 llvm::Triple& Triple)
105 : Generic_GCC(Host, Triple) {}
106
107 virtual const char *GetDefaultRelocationModel() const { return "pic"; }
108};
109
110class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
111public:
112 OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
113
114 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
115};
116
117class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
118public:
119 FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);
120
121 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
122};
123
124class VISIBILITY_HIDDEN DragonFly : public Generic_GCC {
125public:
126 DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
127
128 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
129};
130
131class VISIBILITY_HIDDEN Linux : public Generic_GCC {
132public:
133 Linux(const HostInfo &Host, const llvm::Triple& Triple);
134};
135
136
137} // end namespace toolchains
138} // end namespace driver
139} // end namespace clang
140
141#endif