ToolChain.h revision 8767cbc475ed96397b6f08617814eeb9cab121bd
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 18namespace clang { 19namespace 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. 29class ToolChain { 30public: 31 typedef llvm::SmallVector<std::string, 4> path_list; 32 33private: 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 45protected: 46 ToolChain(const HostInfo &Host, const llvm::Triple &_Triple); 47 48public: 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 /// GetDefaultStackProtectorLevel - Get the default stack protector level for 107 /// this tool chain (0=off, 1=on, 2=all). 108 virtual unsigned GetDefaultStackProtectorLevel() const { return 0; } 109 110 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables 111 /// by default. 112 virtual bool IsUnwindTablesDefault() const = 0; 113 114 /// GetDefaultRelocationModel - Return the LLVM name of the default 115 /// relocation model for this tool chain. 116 virtual const char *GetDefaultRelocationModel() const = 0; 117 118 /// GetForcedPicModel - Return the LLVM name of the forced PIC model 119 /// for this tool chain, or 0 if this tool chain does not force a 120 /// particular PIC mode. 121 virtual const char *GetForcedPicModel() const = 0; 122 123 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf 124 /// compile unit information. 125 virtual bool UseDwarfDebugFlags() const { return false; } 126}; 127 128} // end namespace driver 129} // end namespace clang 130 131#endif 132