StubFactory.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
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//===----------------------------------------------------------------------===//
9#ifndef MCLD_LD_STUBFACTORY_H
10#define MCLD_LD_STUBFACTORY_H
11
12#include <llvm/Support/DataTypes.h>
13#include <vector>
14
15namespace mcld {
16
17class Stub;
18class Relocation;
19class BranchIslandFactory;
20class IRBuilder;
21
22/** \class StubFactory
23 *  \brief the clone factory of Stub
24 *
25 */
26class StubFactory
27{
28public:
29  ~StubFactory();
30
31  /// addPrototype - register a stub prototype
32  void addPrototype(Stub* pPrototype);
33
34  /// create - create a stub if needed, otherwise return NULL
35  Stub* create(Relocation& pReloc,
36               uint64_t pTargetSymValue,
37               IRBuilder& pBuilder,
38               BranchIslandFactory& pBRIslandFactory);
39
40private:
41  /// findPrototype - find if there is a registered stub prototype for the given
42  ///                 relocation
43  Stub* findPrototype(const Relocation& pReloc,
44                      const uint64_t pSource,
45                      uint64_t pTargetSymValue);
46
47private:
48 typedef std::vector<Stub*> StubPoolType;
49
50private:
51  StubPoolType m_StubPool; // stub pool
52};
53
54} // namespace of mcld
55
56#endif
57