]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Driver/ToolChain.h
Update clang to r84119.
[FreeBSD/FreeBSD.git] / include / clang / Driver / ToolChain.h
1 //===--- ToolChain.h - Collections of tools for one platform ----*- 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_DRIVER_TOOLCHAIN_H_
11 #define CLANG_DRIVER_TOOLCHAIN_H_
12
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/System/Path.h"
16 #include <string>
17
18 namespace clang {
19 namespace driver {
20   class Compilation;
21   class DerivedArgList;
22   class HostInfo;
23   class InputArgList;
24   class JobAction;
25   class Tool;
26
27 /// ToolChain - Access to tools for a single platform.
28 class ToolChain {
29 public:
30   typedef llvm::SmallVector<std::string, 4> path_list;
31
32 private:
33   const HostInfo &Host;
34   const llvm::Triple Triple;
35
36   /// The list of toolchain specific path prefixes to search for
37   /// files.
38   path_list FilePaths;
39
40   /// The list of toolchain specific path prefixes to search for
41   /// programs.
42   path_list ProgramPaths;
43
44 protected:
45   ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
46
47 public:
48   virtual ~ToolChain();
49
50   // Accessors
51
52   const HostInfo &getHost() const { return Host; }
53   const llvm::Triple &getTriple() const { return Triple; }
54
55   std::string getArchName() const { return Triple.getArchName(); }
56   std::string getPlatform() const { return Triple.getVendorName(); }
57   std::string getOS() const { return Triple.getOSName(); }
58
59   std::string getTripleString() const {
60     return Triple.getTriple();
61   }
62
63   path_list &getFilePaths() { return FilePaths; }
64   const path_list &getFilePaths() const { return FilePaths; }
65
66   path_list &getProgramPaths() { return ProgramPaths; }
67   const path_list &getProgramPaths() const { return ProgramPaths; }
68
69   // Tool access.
70
71   /// TranslateArgs - Create a new derived argument list for any argument
72   /// translations this ToolChain may wish to perform.
73   ///
74   /// \param BoundArch - The bound architecture name, or 0.
75   virtual DerivedArgList *TranslateArgs(InputArgList &Args,
76                                         const char *BoundArch) const = 0;
77
78   /// SelectTool - Choose a tool to use to handle the action \arg JA.
79   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
80
81   // Helper methods
82
83   std::string GetFilePath(const Compilation &C, const char *Name) const;
84   std::string GetProgramPath(const Compilation &C, const char *Name,
85                              bool WantFile = false) const;
86
87   // Platform defaults information
88
89   /// IsMathErrnoDefault - Does this tool chain set -fmath-errno by
90   /// default.
91   virtual bool IsMathErrnoDefault() const = 0;
92
93   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
94   /// by default.
95   virtual bool IsUnwindTablesDefault() const = 0;
96
97   /// GetDefaultRelocationModel - Return the LLVM name of the default
98   /// relocation model for this tool chain.
99   virtual const char *GetDefaultRelocationModel() const = 0;
100
101   /// GetForcedPicModel - Return the LLVM name of the forced PIC model
102   /// for this tool chain, or 0 if this tool chain does not force a
103   /// particular PIC mode.
104   virtual const char *GetForcedPicModel() const = 0;
105 };
106
107 } // end namespace driver
108 } // end namespace clang
109
110 #endif