Target.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- Target.h -----------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_SUPPORT_TARGET_H 10#define MCLD_SUPPORT_TARGET_H 11#include <string> 12#include <list> 13 14namespace llvm { 15class Target; 16class Triple; 17class TargetMachine; 18} // namespace of llvm 19 20namespace mcld { 21 22class MCLDTargetMachine; 23class TargetRegistry; 24class MCLinker; 25class LinkerScript; 26class LinkerConfig; 27class Module; 28class FileHandle; 29class DiagnosticLineInfo; 30class TargetLDBackend; 31 32/** \class Target 33 * \brief Target collects target specific information 34 */ 35class Target 36{ 37 friend class mcld::MCLDTargetMachine; 38 friend class mcld::TargetRegistry; 39 40public: 41 typedef unsigned int (*TripleMatchQualityFnTy)(const llvm::Triple& pTriple); 42 43 typedef MCLDTargetMachine *(*TargetMachineCtorTy)(const llvm::Target &, 44 const mcld::Target &, 45 llvm::TargetMachine &, 46 const std::string&); 47 48 typedef MCLinker *(*MCLinkerCtorTy)(const std::string& pTriple, 49 LinkerConfig&, 50 Module&, 51 FileHandle& pFileHandle); 52 53 typedef bool (*EmulationFnTy)(LinkerScript&, LinkerConfig&); 54 55 typedef TargetLDBackend *(*TargetLDBackendCtorTy)(const LinkerConfig&); 56 57 typedef DiagnosticLineInfo *(*DiagnosticLineInfoCtorTy)(const mcld::Target&, 58 const std::string&); 59 60public: 61 Target(); 62 63 /// getName - get the target name 64 const char* name() const { return Name; } 65 66 unsigned int getTripleQuality(const llvm::Triple& pTriple) const; 67 68 /// createTargetMachine - create target-specific TargetMachine 69 MCLDTargetMachine* createTargetMachine(const std::string& pTriple, 70 const llvm::Target& pTarget, 71 llvm::TargetMachine& pTM) const; 72 73 /// createMCLinker - create target-specific MCLinker 74 MCLinker *createMCLinker(const std::string &pTriple, 75 LinkerConfig& pConfig, 76 Module& pModule, 77 FileHandle& pFileHandle) const; 78 79 /// emulate - given MCLinker default values for the other aspects of the 80 /// target system. 81 bool emulate(LinkerScript& pScript, LinkerConfig& pConfig) const; 82 83 /// createLDBackend - create target-specific LDBackend 84 TargetLDBackend* createLDBackend(const LinkerConfig& pConfig) const; 85 86 /// createDiagnosticLineInfo - create target-specific DiagnosticLineInfo 87 DiagnosticLineInfo* createDiagnosticLineInfo(const mcld::Target& pTarget, 88 const std::string& pTriple) const; 89 90private: 91 /// Name - The target name 92 const char* Name; 93 94 TripleMatchQualityFnTy TripleMatchQualityFn; 95 TargetMachineCtorTy TargetMachineCtorFn; 96 MCLinkerCtorTy MCLinkerCtorFn; 97 EmulationFnTy EmulationFn; 98 TargetLDBackendCtorTy TargetLDBackendCtorFn; 99 DiagnosticLineInfoCtorTy DiagnosticLineInfoCtorFn; 100}; 101 102} //end namespace mcld 103 104#endif 105 106