• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- MCBitcodeInterceptor.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_BITCODE_INTERCEPTOR_H
10 #define MCLD_BITCODE_INTERCEPTOR_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 #include <llvm/MC/MCObjectWriter.h>
15 
16 
17 namespace llvm
18 {
19   class MCStreamer;
20   class MCObjectStreamer;
21   class MCAsmLayout;
22   class MCAssembler;
23   class MCFixup;
24   class MCFragment;
25   class MCSymbol;
26   class MCSymbolData;
27   class MCSymbolRefExpr;
28   class MCValue;
29   class raw_ostream;
30 } // namespace of llvm
31 
32 namespace mcld
33 {
34 
35 class MCLDInfo;
36 class TargetLDBackend;
37 
38 /** \class MCBitcodeInterceptor
39  *  \brief MCBitcodeInterceptor converts bitcode into LDContext
40  *
41  *  @see LDContext
42  *  @see MCObjectWriter
43  */
44 class MCBitcodeInterceptor : public llvm::MCObjectWriter
45 {
46 public:
47   MCBitcodeInterceptor(llvm::MCObjectStreamer&, TargetLDBackend&, MCLDInfo&);
48   ~MCBitcodeInterceptor();
49 
50   void ExecutePostLayoutBinding(llvm::MCAssembler &Asm,
51                                 const llvm::MCAsmLayout &Layout);
52 
53   /// RecordRelocation - record relocations
54   //  make a LDRelocation and recordds in the LDContext.
55   void RecordRelocation(const llvm::MCAssembler &Asm,
56                         const llvm::MCAsmLayout &Layout,
57                         const llvm::MCFragment *Fragment,
58                         const llvm::MCFixup &Fixup,
59                         llvm::MCValue Target,
60                         uint64_t &FixedValue);
61 
62   /// WriteObject - not really write out a object. Instead, load data to
63   /// LDContext
64   void WriteObject(llvm::MCAssembler &Asm, const llvm::MCAsmLayout &Layout);
65 
66 private:
67   TargetLDBackend& m_Backend;
68   MCLDInfo& m_LDInfo;
69 
70 };
71 
72 } // namespace of mcld
73 
74 #endif
75 
76