Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 1 | //===- StubFactory.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_STUBFACTORY_H_ |
| 10 | #define MCLD_LD_STUBFACTORY_H_ |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 11 | |
| 12 | #include <llvm/Support/DataTypes.h> |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 13 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame] | 16 | namespace mcld { |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 17 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 18 | class BranchIslandFactory; |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 19 | class IRBuilder; |
Stephen Hines | cfcb224 | 2016-03-08 00:18:09 -0800 | [diff] [blame^] | 20 | class FragmentRef; |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 21 | class Relocation; |
| 22 | class Stub; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 23 | |
| 24 | /** \class StubFactory |
| 25 | * \brief the clone factory of Stub |
| 26 | * |
| 27 | */ |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 28 | class StubFactory { |
| 29 | public: |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 30 | ~StubFactory(); |
| 31 | |
| 32 | /// addPrototype - register a stub prototype |
| 33 | void addPrototype(Stub* pPrototype); |
| 34 | |
| 35 | /// create - create a stub if needed, otherwise return NULL |
| 36 | Stub* create(Relocation& pReloc, |
| 37 | uint64_t pTargetSymValue, |
Stephen Hines | 6f75755 | 2013-03-04 19:51:03 -0800 | [diff] [blame] | 38 | IRBuilder& pBuilder, |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 39 | BranchIslandFactory& pBRIslandFactory); |
| 40 | |
Stephen Hines | cfcb224 | 2016-03-08 00:18:09 -0800 | [diff] [blame^] | 41 | Stub* create(FragmentRef& pFragRef, |
| 42 | IRBuilder& pBuilder, |
| 43 | BranchIslandFactory& pBRIslandFactory); |
| 44 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 45 | private: |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 46 | /// findPrototype - find if there is a registered stub prototype for the given |
| 47 | /// relocation |
| 48 | Stub* findPrototype(const Relocation& pReloc, |
| 49 | const uint64_t pSource, |
Stephen Hines | cfcb224 | 2016-03-08 00:18:09 -0800 | [diff] [blame^] | 50 | uint64_t pTargetSymValue) const; |
| 51 | |
| 52 | Stub* findPrototype(const FragmentRef& pFragRef) const; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 53 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 54 | private: |
| 55 | typedef std::vector<Stub*> StubPoolType; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 56 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 57 | private: |
| 58 | StubPoolType m_StubPool; // stub pool |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 61 | } // namespace mcld |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 62 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 63 | #endif // MCLD_LD_STUBFACTORY_H_ |