1 //===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_TOOLCHAIN_H_
11 #define CLANG_DRIVER_TOOLCHAIN_H_
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/System/Path.h"
28 /// ToolChain - Access to tools for a single platform.
31 typedef llvm::SmallVector<std::string, 4> path_list;
35 const llvm::Triple Triple;
37 /// The list of toolchain specific path prefixes to search for
41 /// The list of toolchain specific path prefixes to search for
43 path_list ProgramPaths;
46 ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
53 const Driver &getDriver() const;
54 const llvm::Triple &getTriple() const { return Triple; }
56 llvm::StringRef getArchName() const { return Triple.getArchName(); }
57 llvm::StringRef getPlatform() const { return Triple.getVendorName(); }
58 llvm::StringRef getOS() const { return Triple.getOSName(); }
60 std::string getTripleString() const {
61 return Triple.getTriple();
64 path_list &getFilePaths() { return FilePaths; }
65 const path_list &getFilePaths() const { return FilePaths; }
67 path_list &getProgramPaths() { return ProgramPaths; }
68 const path_list &getProgramPaths() const { return ProgramPaths; }
72 /// TranslateArgs - Create a new derived argument list for any argument
73 /// translations this ToolChain may wish to perform.
75 /// \param BoundArch - The bound architecture name, or 0.
76 virtual DerivedArgList *TranslateArgs(InputArgList &Args,
77 const char *BoundArch) const = 0;
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;
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;
88 // Platform defaults information
90 /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
91 virtual bool IsBlocksDefault() const { return false; }
93 /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
95 virtual bool IsIntegratedAssemblerDefault() const { return false; }
97 /// IsObjCNonFragileABIDefault - Does this tool chain set
98 /// -fobjc-nonfragile-abi by default.
99 virtual bool IsObjCNonFragileABIDefault() const { return false; }
101 /// IsObjCLegacyDispatchDefault - Does this tool chain set
102 /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
104 virtual bool IsObjCLegacyDispatchDefault() const { return false; }
106 /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
107 /// mixed dispatch method be used?
108 virtual bool UseObjCMixedDispatch() const { return false; }
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; }
114 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
116 virtual bool IsUnwindTablesDefault() const = 0;
118 /// GetDefaultRelocationModel - Return the LLVM name of the default
119 /// relocation model for this tool chain.
120 virtual const char *GetDefaultRelocationModel() const = 0;
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;
127 /// Does this tool chain support Objective-C garbage collection.
128 virtual bool SupportsObjCGC() const { return false; }
130 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
131 /// compile unit information.
132 virtual bool UseDwarfDebugFlags() const { return false; }
134 /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
135 virtual bool UseSjLjExceptions() const { return false; }
138 } // end namespace driver
139 } // end namespace clang