1 //===- BranchIslandFactory.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_LD_BRANCHISLANDFACTORY_H 10 #define MCLD_LD_BRANCHISLANDFACTORY_H 11 12 #include <llvm/Support/DataTypes.h> 13 #include <mcld/Support/GCFactory.h> 14 #include <mcld/LD/BranchIsland.h> 15 16 namespace mcld 17 { 18 19 class Fragment; 20 class Module; 21 22 /** \class BranchIslandFactory 23 * \brief 24 * 25 */ 26 class BranchIslandFactory : public GCFactory<BranchIsland, 0> 27 { 28 public: 29 /// ctor 30 /// @param pMaxFwdBranchRange - the max forward branch range of the target 31 /// @param pMaxBwdBranchRange - the max backward branch range of the target 32 /// @param pMaxIslandSize - a predifned value (64KB here) to decide the max 33 /// size of the island 34 BranchIslandFactory(int64_t pMaxFwdBranchRange, 35 int64_t pMaxBwdBranchRange, 36 size_t pMaxIslandSize = 65536U); 37 38 ~BranchIslandFactory(); 39 40 /// group - group fragments and create islands when needed 41 /// @param pSectionData - the SectionData holds fragments need to be grouped 42 void group(Module& pModule); 43 44 /// produce - produce a island for the given fragment 45 /// @param pFragment - the fragment needs a branch island 46 BranchIsland* produce(Fragment& pFragment); 47 48 /// getIsland - find fwd and bwd islands for the fragment 49 /// @param pFragment - the fragment needs a branch island 50 /// @return - return the pair of <fwd island, bwd island> 51 std::pair<BranchIsland*, BranchIsland*> getIslands(const Fragment& pFragment); 52 53 private: 54 int64_t m_MaxFwdBranchRange; 55 int64_t m_MaxBwdBranchRange; 56 size_t m_MaxIslandSize; 57 }; 58 59 } // namespace of mcld 60 61 #endif 62 63