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