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, or 0 if no tool chain
74 /// specific translations are needed.
76 /// \param BoundArch - The bound architecture name, or 0.
77 virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
78 const char *BoundArch) const {
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;
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;
91 // Platform defaults information
93 /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
94 virtual bool IsBlocksDefault() const { return false; }
96 /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
98 virtual bool IsIntegratedAssemblerDefault() const { return false; }
100 /// IsObjCNonFragileABIDefault - Does this tool chain set
101 /// -fobjc-nonfragile-abi by default.
102 virtual bool IsObjCNonFragileABIDefault() const { return false; }
104 /// IsObjCLegacyDispatchDefault - Does this tool chain set
105 /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
107 virtual bool IsObjCLegacyDispatchDefault() const { return false; }
109 /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
110 /// mixed dispatch method be used?
111 virtual bool UseObjCMixedDispatch() const { return false; }
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; }
117 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
119 virtual bool IsUnwindTablesDefault() const = 0;
121 /// GetDefaultRelocationModel - Return the LLVM name of the default
122 /// relocation model for this tool chain.
123 virtual const char *GetDefaultRelocationModel() const = 0;
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;
130 /// Does this tool chain support Objective-C garbage collection.
131 virtual bool SupportsObjCGC() const { return false; }
133 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
134 /// compile unit information.
135 virtual bool UseDwarfDebugFlags() const { return false; }
137 /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
138 virtual bool UseSjLjExceptions() const { return false; }
141 } // end namespace driver
142 } // end namespace clang