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 "clang/Driver/Types.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/System/Path.h"
30 /// ToolChain - Access to tools for a single platform.
33 typedef llvm::SmallVector<std::string, 4> path_list;
37 const llvm::Triple Triple;
39 /// The list of toolchain specific path prefixes to search for
43 /// The list of toolchain specific path prefixes to search for
45 path_list ProgramPaths;
48 ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
55 const Driver &getDriver() const;
56 const llvm::Triple &getTriple() const { return Triple; }
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(); }
63 std::string getTripleString() const {
64 return Triple.getTriple();
67 path_list &getFilePaths() { return FilePaths; }
68 const path_list &getFilePaths() const { return FilePaths; }
70 path_list &getProgramPaths() { return ProgramPaths; }
71 const path_list &getProgramPaths() const { return ProgramPaths; }
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.
79 /// \param BoundArch - The bound architecture name, or 0.
80 virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
81 const char *BoundArch) const {
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;
90 std::string GetFilePath(const char *Name) const;
91 std::string GetProgramPath(const char *Name, bool WantFile = false) const;
93 // Platform defaults information
95 /// LookupTypeForExtension - Return the default language type to use for the
97 virtual types::ID LookupTypeForExtension(const char *Ext) const;
99 /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
100 virtual bool IsBlocksDefault() const { return false; }
102 /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
104 virtual bool IsIntegratedAssemblerDefault() const { return false; }
106 /// IsObjCNonFragileABIDefault - Does this tool chain set
107 /// -fobjc-nonfragile-abi by default.
108 virtual bool IsObjCNonFragileABIDefault() const { return false; }
110 /// IsObjCLegacyDispatchDefault - Does this tool chain set
111 /// -fobjc-legacy-dispatch by default (this is only used with the non-fragile
113 virtual bool IsObjCLegacyDispatchDefault() const { return false; }
115 /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
116 /// mixed dispatch method be used?
117 virtual bool UseObjCMixedDispatch() const { return false; }
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; }
123 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
125 virtual bool IsUnwindTablesDefault() const = 0;
127 /// GetDefaultRelocationModel - Return the LLVM name of the default
128 /// relocation model for this tool chain.
129 virtual const char *GetDefaultRelocationModel() const = 0;
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;
136 /// Does this tool chain support Objective-C garbage collection.
137 virtual bool SupportsObjCGC() const { return false; }
139 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
140 /// compile unit information.
141 virtual bool UseDwarfDebugFlags() const { return false; }
143 /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
144 virtual bool UseSjLjExceptions() const { return false; }
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;
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
155 virtual std::string ComputeEffectiveClangTriple(const ArgList &Args) const;
158 } // end namespace driver
159 } // end namespace clang