]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Driver/ToolChain.h
Update Clang sources to r73879.
[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
72   /// argument translations this ToolChain may wish to perform.
73   virtual DerivedArgList *TranslateArgs(InputArgList &Args) const = 0;
74
75   /// SelectTool - Choose a tool to use to handle the action \arg JA.
76   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
77
78   // Helper methods
79
80   llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const;
81   llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name,
82                                  bool WantFile = false) const;
83
84   // Platform defaults information
85
86   /// IsMathErrnoDefault - Does this tool chain set -fmath-errno by
87   /// default.
88   virtual bool IsMathErrnoDefault() const = 0;
89
90   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
91   /// by default.
92   virtual bool IsUnwindTablesDefault() const = 0;
93
94   /// GetDefaultRelocationModel - Return the LLVM name of the default
95   /// relocation model for this tool chain.
96   virtual const char *GetDefaultRelocationModel() const = 0;
97
98   /// GetForcedPicModel - Return the LLVM name of the forced PIC model
99   /// for this tool chain, or 0 if this tool chain does not force a
100   /// particular PIC mode.
101   virtual const char *GetForcedPicModel() const = 0;
102 };
103
104 } // end namespace driver
105 } // end namespace clang
106
107 #endif