ToolChains.h revision c50b00dbd843cd929b5f220d4a8699852249f64c
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 {
29  mutable llvm::DenseMap<unsigned, Tool*> Tools;
30
31public:
32  Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
33              const char *OS);
34  ~Generic_GCC();
35
36  virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }
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
59public:
60  Darwin_X86(const HostInfo &Host, const char *Arch, const char *Platform,
61             const char *OS, const unsigned (&DarwinVersion)[3],
62             const unsigned (&GCCVersion)[3]);
63  ~Darwin_X86();
64
65  virtual ArgList *TranslateArgs(ArgList &Args) const;
66
67  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
68
69  virtual bool IsMathErrnoDefault() const;
70  virtual bool IsUnwindTablesDefault() const;
71  virtual const char *GetDefaultRelocationModel() const;
72  virtual const char *GetForcedPicModel() const;
73
74private:
75  const std::string &getToolChainDir() const { return ToolChainDir; }
76};
77
78  /// Darwin_GCC - Generic Darwin tool chain using gcc.
79class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
80public:
81  Darwin_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
82             const char *OS) : Generic_GCC(Host, Arch, Platform, OS) {}
83
84  virtual const char *GetDefaultRelocationModel() const { return "pic"; }
85};
86
87} // end namespace toolchains
88} // end namespace driver
89} // end namespace clang
90
91#endif
92