1//===- MCLDInfo.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_LDINFO_H
10#define MCLD_LDINFO_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <llvm/ADT/Triple.h>
16
17#include <mcld/Support/FileSystem.h>
18#include <mcld/MC/MCLDOutput.h>
19#include <mcld/MC/MCLDOptions.h>
20#include <mcld/MC/InputTree.h>
21#include <mcld/MC/AttributeFactory.h>
22#include <mcld/MC/ContextFactory.h>
23#include <mcld/LD/NamePool.h>
24
25#include <string>
26#include <cassert>
27
28namespace mcld
29{
30class Resolver;
31
32/** \class MCLDInfo
33 *  \brief MCLDInfo is composed of argumments of MCLinker.
34 *   options()        - the general options
35 *   scripts()        - the script options
36 *   inputs()         - the tree of inputs
37 *   bitcode()        - the bitcode being linked
38 *   output()         - the output file
39 *   inputFactory()   - the list of all inputs
40 *   attrFactory()    - the list of all attributes
41 *   contextFactory() - the list of all contexts.
42 *   memAreaFactory() - the list of all MemoryAreas.
43 */
44class MCLDInfo
45{
46public:
47  explicit MCLDInfo(const std::string &pTripleString,
48                    size_t pAttrNum,
49                    size_t InputSize);
50
51  virtual ~MCLDInfo();
52
53  GeneralOptions& options()
54  { return m_Options; }
55
56  const GeneralOptions& options() const
57  { return m_Options; }
58
59  ScriptOptions& scripts()
60  { return m_Scripts; }
61
62  const ScriptOptions& scripts() const
63  { return m_Scripts; }
64
65  void setBitcode(const Input& pInput);
66  Input& bitcode();
67  const Input& bitcode() const;
68
69  Output& output()
70  { return *m_pOutput; }
71
72  const Output& output() const
73  { return *m_pOutput; }
74
75  InputTree& inputs()
76  { return *m_pInputTree; }
77
78  const InputTree& inputs() const
79  { return *m_pInputTree; }
80
81  InputFactory& inputFactory()
82  { return *m_pInputFactory; }
83
84  const InputFactory& inputFactory() const
85  { return *m_pInputFactory; }
86
87  AttributeFactory& attrFactory()
88  { return *m_pAttrFactory; }
89
90
91  const AttributeFactory& attrFactory() const
92  { return *m_pAttrFactory; }
93
94  ContextFactory& contextFactory()
95  { return *m_pCntxtFactory; }
96
97  const ContextFactory& contextFactory() const
98  { return *m_pCntxtFactory; }
99
100  const llvm::Triple& triple() const
101  { return m_Triple; }
102
103  static const char* version();
104
105  NamePool& getNamePool() {
106    assert(NULL != m_pNamePool);
107    return *m_pNamePool;
108  }
109
110  const NamePool& getNamePool() const {
111    assert(NULL != m_pNamePool);
112    return *m_pNamePool;
113  }
114
115private:
116  // -----  General Options  ----- //
117  GeneralOptions m_Options;
118  ScriptOptions m_Scripts;
119  InputTree *m_pInputTree;
120  Input* m_pBitcode;
121  Output* m_pOutput;
122  llvm::Triple m_Triple;
123
124  // -----  factories  ----- //
125  InputFactory *m_pInputFactory;
126  AttributeFactory *m_pAttrFactory;
127  ContextFactory *m_pCntxtFactory;
128
129  // -----  string and symbols  ----- //
130  Resolver* m_pResolver;
131  NamePool* m_pNamePool;
132};
133
134} // namespace of mcld
135
136#endif
137
138