Home | History | Annotate | Download | only in Support
      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 
     14 namespace llvm {
     15 class Target;
     16 class Triple;
     17 class TargetMachine;
     18 } // namespace of llvm
     19 
     20 namespace mcld {
     21 
     22 class MCLDTargetMachine;
     23 class TargetRegistry;
     24 class MCLinker;
     25 class LinkerScript;
     26 class LinkerConfig;
     27 class Module;
     28 class FileHandle;
     29 class DiagnosticLineInfo;
     30 class TargetLDBackend;
     31 
     32 /** \class Target
     33  *  \brief Target collects target specific information
     34  */
     35 class Target
     36 {
     37   friend class mcld::MCLDTargetMachine;
     38   friend class mcld::TargetRegistry;
     39 
     40 public:
     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 
     60 public:
     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 
     90 private:
     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