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