]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Driver/ToolChain.h
Update clang to r103004.
[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.
74   ///
75   /// \param BoundArch - The bound architecture name, or 0.
76   virtual DerivedArgList *TranslateArgs(InputArgList &Args,
77                                         const char *BoundArch) const = 0;
78
79   /// SelectTool - Choose a tool to use to handle the action \arg JA.
80   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
81
82   // Helper methods
83
84   std::string GetFilePath(const Compilation &C, const char *Name) const;
85   std::string GetProgramPath(const Compilation &C, const char *Name,
86                              bool WantFile = false) const;
87
88   // Platform defaults information
89
90   /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
91   virtual bool IsBlocksDefault() const { return false; }
92
93   /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
94   /// by default.
95   virtual bool IsIntegratedAssemblerDefault() const { return false; }
96
97   /// IsObjCNonFragileABIDefault - Does this tool chain set
98   /// -fobjc-nonfragile-abi by default.
99   virtual bool IsObjCNonFragileABIDefault() const { return false; }
100
101   /// IsObjCLegacyDispatchDefault - Does this tool chain set
102   /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
103   /// ABI).
104   virtual bool IsObjCLegacyDispatchDefault() const { return false; }
105
106   /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
107   /// mixed dispatch method be used?
108   virtual bool UseObjCMixedDispatch() const { return false; }
109
110   /// GetDefaultStackProtectorLevel - Get the default stack protector level for
111   /// this tool chain (0=off, 1=on, 2=all).
112   virtual unsigned GetDefaultStackProtectorLevel() const { return 0; }
113
114   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
115   /// by default.
116   virtual bool IsUnwindTablesDefault() const = 0;
117
118   /// GetDefaultRelocationModel - Return the LLVM name of the default
119   /// relocation model for this tool chain.
120   virtual const char *GetDefaultRelocationModel() const = 0;
121
122   /// GetForcedPicModel - Return the LLVM name of the forced PIC model
123   /// for this tool chain, or 0 if this tool chain does not force a
124   /// particular PIC mode.
125   virtual const char *GetForcedPicModel() const = 0;
126
127   /// Does this tool chain support Objective-C garbage collection.
128   virtual bool SupportsObjCGC() const { return false; }
129
130   /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
131   /// compile unit information.
132   virtual bool UseDwarfDebugFlags() const { return false; }
133
134   /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
135   virtual bool UseSjLjExceptions() const { return false; }
136 };
137
138 } // end namespace driver
139 } // end namespace clang
140
141 #endif