]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Driver/ToolChain.h
Update clang to r108243.
[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 Driver;
23   class HostInfo;
24   class InputArgList;
25   class JobAction;
26   class Tool;
27
28 /// ToolChain - Access to tools for a single platform.
29 class ToolChain {
30 public:
31   typedef llvm::SmallVector<std::string, 4> path_list;
32
33 private:
34   const HostInfo &Host;
35   const llvm::Triple Triple;
36
37   /// The list of toolchain specific path prefixes to search for
38   /// files.
39   path_list FilePaths;
40
41   /// The list of toolchain specific path prefixes to search for
42   /// programs.
43   path_list ProgramPaths;
44
45 protected:
46   ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
47
48 public:
49   virtual ~ToolChain();
50
51   // Accessors
52
53   const Driver &getDriver() const;
54   const llvm::Triple &getTriple() const { return Triple; }
55
56   llvm::StringRef getArchName() const { return Triple.getArchName(); }
57   llvm::StringRef getPlatform() const { return Triple.getVendorName(); }
58   llvm::StringRef getOS() const { return Triple.getOSName(); }
59
60   std::string getTripleString() const {
61     return Triple.getTriple();
62   }
63
64   path_list &getFilePaths() { return FilePaths; }
65   const path_list &getFilePaths() const { return FilePaths; }
66
67   path_list &getProgramPaths() { return ProgramPaths; }
68   const path_list &getProgramPaths() const { return ProgramPaths; }
69
70   // Tool access.
71
72   /// TranslateArgs - Create a new derived argument list for any argument
73   /// translations this ToolChain may wish to perform, or 0 if no tool chain
74   /// specific translations are needed.
75   ///
76   /// \param BoundArch - The bound architecture name, or 0.
77   virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
78                                         const char *BoundArch) const {
79     return 0;
80   }
81
82   /// SelectTool - Choose a tool to use to handle the action \arg JA.
83   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
84
85   // Helper methods
86
87   std::string GetFilePath(const Compilation &C, const char *Name) const;
88   std::string GetProgramPath(const Compilation &C, const char *Name,
89                              bool WantFile = false) const;
90
91   // Platform defaults information
92
93   /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
94   virtual bool IsBlocksDefault() const { return false; }
95
96   /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
97   /// by default.
98   virtual bool IsIntegratedAssemblerDefault() const { return false; }
99
100   /// IsObjCNonFragileABIDefault - Does this tool chain set
101   /// -fobjc-nonfragile-abi by default.
102   virtual bool IsObjCNonFragileABIDefault() const { return false; }
103
104   /// IsObjCLegacyDispatchDefault - Does this tool chain set
105   /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
106   /// ABI).
107   virtual bool IsObjCLegacyDispatchDefault() const { return false; }
108
109   /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
110   /// mixed dispatch method be used?
111   virtual bool UseObjCMixedDispatch() const { return false; }
112
113   /// GetDefaultStackProtectorLevel - Get the default stack protector level for
114   /// this tool chain (0=off, 1=on, 2=all).
115   virtual unsigned GetDefaultStackProtectorLevel() const { return 0; }
116
117   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
118   /// by default.
119   virtual bool IsUnwindTablesDefault() const = 0;
120
121   /// GetDefaultRelocationModel - Return the LLVM name of the default
122   /// relocation model for this tool chain.
123   virtual const char *GetDefaultRelocationModel() const = 0;
124
125   /// GetForcedPicModel - Return the LLVM name of the forced PIC model
126   /// for this tool chain, or 0 if this tool chain does not force a
127   /// particular PIC mode.
128   virtual const char *GetForcedPicModel() const = 0;
129
130   /// Does this tool chain support Objective-C garbage collection.
131   virtual bool SupportsObjCGC() const { return false; }
132
133   /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
134   /// compile unit information.
135   virtual bool UseDwarfDebugFlags() const { return false; }
136
137   /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
138   virtual bool UseSjLjExceptions() const { return false; }
139 };
140
141 } // end namespace driver
142 } // end namespace clang
143
144 #endif