Home | History | Annotate | Download | only in CodeGen
      1 //===- MCLinker.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 //
     10 // MCLinker is a base class inherited by target specific linker.
     11 // This class primarily handles common functionality used by all linkers.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 #ifndef MCLD_CODEGEN_MCLINKER_H
     15 #define MCLD_CODEGEN_MCLINKER_H
     16 #include <llvm/CodeGen/MachineFunctionPass.h>
     17 
     18 namespace llvm {
     19 
     20 class Module;
     21 class MachineFunction;
     22 
     23 } // namespace of llvm
     24 
     25 namespace mcld {
     26 
     27 class Module;
     28 class IRBuilder;
     29 class LinkerConfig;
     30 class Linker;
     31 class FileHandle;
     32 
     33 /** \class MCLinker
     34 *  \brief MCLinker provides a linking pass for standard compilation flow
     35 *
     36 *  MCLinker is responded for
     37 *  - provide an interface for target-specific linker
     38 *  - set up environment for ObjectLinker
     39 *  - perform linking
     40 *
     41 *  @see MachineFunctionPass ObjectLinker
     42 */
     43 class MCLinker : public llvm::MachineFunctionPass
     44 {
     45 protected:
     46   // Constructor. Although MCLinker has only two arguments,
     47   // TargetMCLinker should handle
     48   // - enabled attributes
     49   // - the default attribute
     50   // - the default link script
     51   // - the standard symbols
     52   MCLinker(LinkerConfig& pConfig,
     53            mcld::Module& pModule,
     54            FileHandle& pFileHandle);
     55 
     56 public:
     57   virtual ~MCLinker();
     58 
     59   virtual bool doInitialization(llvm::Module &pM);
     60 
     61   virtual bool doFinalization(llvm::Module &pM);
     62 
     63   virtual bool runOnMachineFunction(llvm::MachineFunction& pMFn);
     64 
     65 protected:
     66   void initializeInputTree(IRBuilder& pBuilder);
     67 
     68 protected:
     69   LinkerConfig& m_Config;
     70   mcld::Module& m_Module;
     71   FileHandle& m_FileHandle;
     72   IRBuilder* m_pBuilder;
     73   Linker* m_pLinker;
     74 
     75 private:
     76   static char m_ID;
     77 };
     78 
     79 } // namespace of MC Linker
     80 
     81 #endif
     82 
     83