122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===- MCLinker.h ---------------------------------------------------------===//
222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//                     The MCLinker Project
422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// This file is distributed under the University of Illinois Open Source
622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// License. See LICENSE.TXT for details.
722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===----------------------------------------------------------------------===//
922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
1022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// MCLinker is a base class inherited by target specific linker.
1122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// This class primarily handles common functionality used by all linkers.
1222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
1322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===----------------------------------------------------------------------===//
1422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#ifndef MCLD_CODEGEN_MCLINKER_H
1522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#define MCLD_CODEGEN_MCLINKER_H
1622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#include <llvm/CodeGen/MachineFunctionPass.h>
1722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
1822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace llvm {
1922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass Module;
2122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass MachineFunction;
2222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao} // namespace of llvm
2422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace mcld {
2622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass Module;
2822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass IRBuilder;
2922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass LinkerConfig;
3022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass Linker;
3187f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass FileHandle;
3222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
3322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao/** \class MCLinker
3422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  \brief MCLinker provides a linking pass for standard compilation flow
3522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*
3622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  MCLinker is responded for
3722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  - provide an interface for target-specific linker
3822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  - set up environment for ObjectLinker
3922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  - perform linking
4022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*
4122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*  @see MachineFunctionPass ObjectLinker
4222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao*/
4322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass MCLinker : public llvm::MachineFunctionPass
4422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao{
4522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoprotected:
4622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // Constructor. Although MCLinker has only two arguments,
4722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // TargetMCLinker should handle
4822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // - enabled attributes
4922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // - the default attribute
5022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // - the default link script
5122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  // - the standard symbols
5222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  MCLinker(LinkerConfig& pConfig,
5322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao           mcld::Module& pModule,
5487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines           FileHandle& pFileHandle);
5522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
5622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaopublic:
5722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  virtual ~MCLinker();
5822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
5922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  virtual bool doInitialization(llvm::Module &pM);
6022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  virtual bool doFinalization(llvm::Module &pM);
6222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  virtual bool runOnMachineFunction(llvm::MachineFunction& pMFn);
6422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoprotected:
6622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  void initializeInputTree(IRBuilder& pBuilder);
6722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoprotected:
6922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  LinkerConfig& m_Config;
7022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  mcld::Module& m_Module;
7187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  FileHandle& m_FileHandle;
7222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  IRBuilder* m_pBuilder;
7322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  Linker* m_pLinker;
7422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
7522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoprivate:
7622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  static char m_ID;
7722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao};
7822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
7922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao} // namespace of MC Linker
8022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
8122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao#endif
8222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
83