ToolChain.h revision f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26e
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 HostInfo; 23 class InputArgList; 24 class JobAction; 25 class Tool; 26 27/// ToolChain - Access to tools for a single platform. 28class ToolChain { 29public: 30 typedef llvm::SmallVector<std::string, 4> path_list; 31 32private: 33 const HostInfo &Host; 34 const llvm::Triple Triple; 35 36 /// The list of toolchain specific path prefixes to search for 37 /// files. 38 path_list FilePaths; 39 40 /// The list of toolchain specific path prefixes to search for 41 /// programs. 42 path_list ProgramPaths; 43 44protected: 45 ToolChain(const HostInfo &Host, const llvm::Triple &_Triple); 46 47public: 48 virtual ~ToolChain(); 49 50 // Accessors 51 52 const HostInfo &getHost() const { return Host; } 53 const llvm::Triple &getTriple() const { return Triple; } 54 55 std::string getArchName() const { return Triple.getArchName(); } 56 std::string getPlatform() const { return Triple.getVendorName(); } 57 std::string getOS() const { return Triple.getOSName(); } 58 59 std::string getTripleString() const { 60 return Triple.getTriple(); 61 } 62 63 path_list &getFilePaths() { return FilePaths; } 64 const path_list &getFilePaths() const { return FilePaths; } 65 66 path_list &getProgramPaths() { return ProgramPaths; } 67 const path_list &getProgramPaths() const { return ProgramPaths; } 68 69 // Tool access. 70 71 /// TranslateArgs - Create a new derived argument list for any argument 72 /// translations this ToolChain may wish to perform. 73 /// 74 /// \param BoundArch - The bound architecture name, or 0. 75 virtual DerivedArgList *TranslateArgs(InputArgList &Args, 76 const char *BoundArch) const = 0; 77 78 /// SelectTool - Choose a tool to use to handle the action \arg JA. 79 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0; 80 81 // Helper methods 82 83 std::string GetFilePath(const Compilation &C, const char *Name) const; 84 std::string GetProgramPath(const Compilation &C, const char *Name, 85 bool WantFile = false) const; 86 87 // Platform defaults information 88 89 /// IsMathErrnoDefault - Does this tool chain set -fmath-errno by 90 /// default. 91 virtual bool IsMathErrnoDefault() const = 0; 92 93 /// IsBlocksDefault - Does this tool chain enable -fblocks by default. 94 virtual bool IsBlocksDefault() const { return false; } 95 96 /// IsObjCNonFragileABIDefault - Does this tool chain set 97 /// -fobjc-nonfragile-abi by default. 98 virtual bool IsObjCNonFragileABIDefault() const { return false; } 99 100 /// GetDefaultStackProtectorLevel - Get the default stack protector level for 101 /// this tool chain (0=off, 1=on, 2=all). 102 virtual unsigned GetDefaultStackProtectorLevel() const { return 0; } 103 104 /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables 105 /// by default. 106 virtual bool IsUnwindTablesDefault() const = 0; 107 108 /// GetDefaultRelocationModel - Return the LLVM name of the default 109 /// relocation model for this tool chain. 110 virtual const char *GetDefaultRelocationModel() const = 0; 111 112 /// GetForcedPicModel - Return the LLVM name of the forced PIC model 113 /// for this tool chain, or 0 if this tool chain does not force a 114 /// particular PIC mode. 115 virtual const char *GetForcedPicModel() const = 0; 116 117 /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf 118 /// compile unit information. 119 virtual bool UseDwarfDebugFlags() const { return false; } 120}; 121 122} // end namespace driver 123} // end namespace clang 124 125#endif 126