Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 9 | #ifndef MCLD_LD_BRANCHISLANDFACTORY_H_ |
| 10 | #define MCLD_LD_BRANCHISLANDFACTORY_H_ |
| 11 | |
| 12 | #include "mcld/LD/BranchIsland.h" |
| 13 | #include "mcld/Support/GCFactory.h" |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 14 | |
| 15 | #include <llvm/Support/DataTypes.h> |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 16 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 17 | namespace mcld { |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 18 | |
| 19 | class Fragment; |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 20 | class Module; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 21 | |
| 22 | /** \class BranchIslandFactory |
| 23 | * \brief |
| 24 | * |
| 25 | */ |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 26 | class BranchIslandFactory : public GCFactory<BranchIsland, 0> { |
| 27 | public: |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 28 | /// ctor |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 29 | /// @param pMaxFwdBranchRange - the max forward branch range of the target |
| 30 | /// @param pMaxBwdBranchRange - the max backward branch range of the target |
Stephen Hines | cfcb224 | 2016-03-08 00:18:09 -0800 | [diff] [blame^] | 31 | /// @param pMaxIslandSize - the group size to place stubs between sections |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 32 | BranchIslandFactory(int64_t pMaxFwdBranchRange, |
| 33 | int64_t pMaxBwdBranchRange, |
Stephen Hines | cfcb224 | 2016-03-08 00:18:09 -0800 | [diff] [blame^] | 34 | size_t pMaxIslandSize); |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 35 | |
| 36 | ~BranchIslandFactory(); |
| 37 | |
Stephen Hines | 87f3465 | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 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 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 42 | /// produce - produce a island for the given fragment |
| 43 | /// @param pFragment - the fragment needs a branch island |
| 44 | BranchIsland* produce(Fragment& pFragment); |
| 45 | |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 46 | /// getIsland - find fwd and bwd islands for the fragment |
| 47 | /// @param pFragment - the fragment needs a branch island |
| 48 | /// @return - return the pair of <fwd island, bwd island> |
| 49 | std::pair<BranchIsland*, BranchIsland*> getIslands(const Fragment& pFragment); |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 50 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 51 | private: |
Stephen Hines | 0dea6bc | 2014-07-15 18:33:32 -0700 | [diff] [blame] | 52 | int64_t m_MaxFwdBranchRange; |
| 53 | int64_t m_MaxBwdBranchRange; |
| 54 | size_t m_MaxIslandSize; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 57 | } // namespace mcld |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 58 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 59 | #endif // MCLD_LD_BRANCHISLANDFACTORY_H_ |