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_BRANCH_ISLAND_FACTORY_H 10#define MCLD_LD_BRANCH_ISLAND_FACTORY_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; 23 24/** \class BranchIslandFactory 25 * \brief 26 * 27 */ 28class BranchIslandFactory : public GCFactory<BranchIsland, 0> 29{ 30public: 31 /// ctor 32 /// @param pMaxBranchRange - the max branch range of the target backend 33 /// @param pMaxIslandSize - a predifned value (64KB here) to decide the max 34 /// size of the island 35 BranchIslandFactory(uint64_t pMaxBranchRange, 36 uint64_t pMaxIslandSize = 65536U); 37 38 ~BranchIslandFactory(); 39 40 /// produce - produce a island for the given fragment 41 /// @param pFragment - the fragment needs a branch island 42 BranchIsland* produce(Fragment& pFragment); 43 44 /// find - find a island for the given fragment 45 /// @param pFragment - the fragment needs a branch isladn 46 BranchIsland* find(const Fragment& pFragment); 47 48private: 49 uint64_t m_MaxBranchRange; 50 uint64_t m_MaxIslandSize; 51}; 52 53} // namespace of mcld 54 55#endif 56 57