1 //===- FGNode.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_FGNODE_H 10 #define MCLD_FGNODE_H 11 #ifdef ENABLE_UNITTEST 12 #include <gtest.h> 13 #endif 14 15 #include <llvm/Support/DataTypes.h> 16 17 #include <vector> 18 19 namespace mcld 20 { 21 22 class Relocation; 23 class ResolveInfo; 24 class Fragment; 25 26 /** \class FGNode 27 * \brief FGNode is a node for FragmentGraph 28 */ 29 class FGNode 30 { 31 public: 32 typedef ResolveInfo* Slot; 33 typedef Relocation* Signal; 34 35 typedef std::vector<Fragment*> FragmentListType; 36 typedef FragmentListType::iterator frag_iterator; 37 typedef FragmentListType::const_iterator const_frag_iterator; 38 39 typedef std::vector<Slot> SlotListType; 40 typedef SlotListType::iterator slot_iterator; 41 typedef SlotListType::const_iterator const_slot_iterator; 42 43 typedef std::vector<Signal> SignalListType; 44 typedef SignalListType::iterator signal_iterator; 45 typedef SignalListType::const_iterator const_signal_iterator; 46 47 public: 48 FGNode(); 49 explicit FGNode(uint32_t pIndex); 50 51 void addFragment(Fragment* pFrag); 52 void addSignal(Signal pSignal); 53 void addSlot(Slot pSlot); 54 55 /// ----- observers ----- /// 56 uint32_t getIndex() const 57 { return m_Index; } 58 59 slot_iterator slot_begin () { return m_Slots.begin(); } 60 const_slot_iterator slot_begin () const { return m_Slots.begin(); } 61 slot_iterator slot_end () { return m_Slots.end(); } 62 const_slot_iterator slot_end () const { return m_Slots.end(); } 63 64 signal_iterator signal_begin () { return m_Signals.begin(); } 65 const_signal_iterator signal_begin () const { return m_Signals.begin(); } 66 signal_iterator signal_end () { return m_Signals.end(); } 67 const_signal_iterator signal_end () const { return m_Signals.end(); } 68 69 frag_iterator frag_begin () { return m_Fragments.begin(); } 70 const_frag_iterator frag_begin () const { return m_Fragments.begin(); } 71 frag_iterator frag_end () { return m_Fragments.end(); } 72 const_frag_iterator frag_end () const { return m_Fragments.end(); } 73 74 private: 75 FragmentListType m_Fragments; 76 77 /// m_Signals - a list of relocations describes the possible fan-out of this 78 /// node 79 SignalListType m_Signals; 80 81 /// m_Slots - a list of symbols describes the possible fan-in of this node 82 SlotListType m_Slots; 83 84 /// m_Index - the index in the reachability matrix 85 uint32_t m_Index; 86 }; 87 88 } // namespace of mcld 89 90 #endif 91 92