Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 9 | #ifndef MCLD_SUPPORT_TARGET_H_ |
| 10 | #define MCLD_SUPPORT_TARGET_H_ |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 11 | #include <string> |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 12 | |
| 13 | namespace llvm { |
| 14 | class Target; |
| 15 | class Triple; |
| 16 | class TargetMachine; |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 17 | } // namespace llvm |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 18 | |
| 19 | namespace mcld { |
| 20 | |
| 21 | class MCLDTargetMachine; |
| 22 | class TargetRegistry; |
| 23 | class MCLinker; |
| 24 | class LinkerScript; |
| 25 | class LinkerConfig; |
| 26 | class Module; |
| 27 | class FileHandle; |
| 28 | class DiagnosticLineInfo; |
| 29 | class TargetLDBackend; |
| 30 | |
| 31 | /** \class Target |
| 32 | * \brief Target collects target specific information |
| 33 | */ |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 34 | class Target { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 35 | friend class mcld::MCLDTargetMachine; |
| 36 | friend class mcld::TargetRegistry; |
| 37 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 38 | public: |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 39 | typedef unsigned int (*TripleMatchQualityFnTy)(const llvm::Triple& pTriple); |
| 40 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 41 | typedef MCLDTargetMachine* (*TargetMachineCtorTy)(const llvm::Target&, |
| 42 | const mcld::Target&, |
| 43 | llvm::TargetMachine&, |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 44 | const std::string&); |
| 45 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 46 | typedef MCLinker* (*MCLinkerCtorTy)(const std::string& pTriple, |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 47 | LinkerConfig&, |
| 48 | Module&, |
| 49 | FileHandle& pFileHandle); |
| 50 | |
| 51 | typedef bool (*EmulationFnTy)(LinkerScript&, LinkerConfig&); |
| 52 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 53 | typedef TargetLDBackend* (*TargetLDBackendCtorTy)(const LinkerConfig&); |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 54 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 55 | typedef DiagnosticLineInfo* (*DiagnosticLineInfoCtorTy)(const mcld::Target&, |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 56 | const std::string&); |
| 57 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 58 | public: |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 59 | Target(); |
| 60 | |
| 61 | /// getName - get the target name |
| 62 | const char* name() const { return Name; } |
| 63 | |
| 64 | unsigned int getTripleQuality(const llvm::Triple& pTriple) const; |
| 65 | |
| 66 | /// createTargetMachine - create target-specific TargetMachine |
| 67 | MCLDTargetMachine* createTargetMachine(const std::string& pTriple, |
| 68 | const llvm::Target& pTarget, |
| 69 | llvm::TargetMachine& pTM) const; |
| 70 | |
| 71 | /// createMCLinker - create target-specific MCLinker |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 72 | MCLinker* createMCLinker(const std::string& pTriple, |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 73 | LinkerConfig& pConfig, |
| 74 | Module& pModule, |
| 75 | FileHandle& pFileHandle) const; |
| 76 | |
| 77 | /// emulate - given MCLinker default values for the other aspects of the |
| 78 | /// target system. |
| 79 | bool emulate(LinkerScript& pScript, LinkerConfig& pConfig) const; |
| 80 | |
| 81 | /// createLDBackend - create target-specific LDBackend |
| 82 | TargetLDBackend* createLDBackend(const LinkerConfig& pConfig) const; |
| 83 | |
| 84 | /// createDiagnosticLineInfo - create target-specific DiagnosticLineInfo |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 85 | DiagnosticLineInfo* createDiagnosticLineInfo( |
| 86 | const mcld::Target& pTarget, |
| 87 | const std::string& pTriple) const; |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 88 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 89 | private: |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 90 | /// Name - The target name |
| 91 | const char* Name; |
| 92 | |
| 93 | TripleMatchQualityFnTy TripleMatchQualityFn; |
| 94 | TargetMachineCtorTy TargetMachineCtorFn; |
| 95 | MCLinkerCtorTy MCLinkerCtorFn; |
| 96 | EmulationFnTy EmulationFn; |
| 97 | TargetLDBackendCtorTy TargetLDBackendCtorFn; |
| 98 | DiagnosticLineInfoCtorTy DiagnosticLineInfoCtorFn; |
| 99 | }; |
| 100 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 101 | } // namespace mcld |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 102 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 103 | #endif // MCLD_SUPPORT_TARGET_H_ |