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