BranchIslandFactory.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
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 16namespace mcld 17{ 18 19class Fragment; 20class Module; 21 22/** \class BranchIslandFactory 23 * \brief 24 * 25 */ 26class BranchIslandFactory : public GCFactory<BranchIsland, 0> 27{ 28public: 29 /// ctor 30 /// @param pMaxBranchRange - the max branch range of the target backend 31 /// @param pMaxIslandSize - a predifned value (64KB here) to decide the max 32 /// size of the island 33 BranchIslandFactory(uint64_t pMaxBranchRange, 34 uint64_t pMaxIslandSize = 65536U); 35 36 ~BranchIslandFactory(); 37 38 /// group - group fragments and create islands when needed 39 /// @param pSectionData - the SectionData holds fragments need to be grouped 40 void group(Module& pModule); 41 42 /// produce - produce a island for the given fragment 43 /// @param pFragment - the fragment needs a branch island 44 BranchIsland* produce(Fragment& pFragment); 45 46 /// find - find a island for the given fragment 47 /// @param pFragment - the fragment needs a branch isladn 48 BranchIsland* find(const Fragment& pFragment); 49 50private: 51 uint64_t m_MaxBranchRange; 52 uint64_t m_MaxIslandSize; 53}; 54 55} // namespace of mcld 56 57#endif 58 59