SectionData.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera//===- SectionData.h ------------------------------------------------------===// 2fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// 3fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// The MCLinker Project 4fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// 5fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// This file is distributed under the University of Illinois Open Source 6fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// License. See LICENSE.TXT for details. 7fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera// 8fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera//===----------------------------------------------------------------------===// 9fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifndef MCLD_LD_SECTIONDATA_H 10fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#define MCLD_LD_SECTIONDATA_H 11fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#ifdef ENABLE_UNITTEST 12fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <gtest.h> 13fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 14fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 15fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <llvm/ADT/ilist.h> 16fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <llvm/ADT/ilist_node.h> 179c78e8681dafcdf265bc733875bad436ef9ec220James Dong#include <llvm/Support/DataTypes.h> 18fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 19fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <mcld/Config/Config.h> 20fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <mcld/Support/Allocators.h> 21fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#include <mcld/Fragment/Fragment.h> 22fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 23fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheranamespace mcld { 24fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 25fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraclass LDSection; 26fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 27fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera/** \class SectionData 28fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera * \brief SectionData provides a container for all Fragments. 29fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera */ 30fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraclass SectionData 31fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera{ 32fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraprivate: 33fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera friend class Chunk<SectionData, MCLD_SECTIONS_PER_INPUT>; 34fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 35fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera SectionData(); 36fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera explicit SectionData(LDSection &pSection); 37fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 38fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera SectionData(const SectionData &); // DO NOT IMPLEMENT 39fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera SectionData& operator=(const SectionData &); // DO NOT IMPLEMENT 40fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 41fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherapublic: 42fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef llvm::iplist<Fragment> FragmentListType; 43fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 44fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::reference reference; 45fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::const_reference const_reference; 46fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 47fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::iterator iterator; 48fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::const_iterator const_iterator; 49fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 50fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::reverse_iterator reverse_iterator; 51fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera typedef FragmentListType::const_reverse_iterator const_reverse_iterator; 52fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 53fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeherapublic: 54fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera static SectionData* Create(LDSection& pSection); 55fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 56fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera static void Destroy(SectionData*& pSection); 57fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 58fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera static void Clear(); 59fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 60fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const LDSection& getSection() const { return *m_pSection; } 61fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera LDSection& getSection() { return *m_pSection; } 62fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 63fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera FragmentListType &getFragmentList() { return m_Fragments; } 64fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const FragmentListType &getFragmentList() const { return m_Fragments; } 65fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 66fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera size_t size() const { return m_Fragments.size(); } 67fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 68fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera bool empty() const { return m_Fragments.empty(); } 69fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 70fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera reference front () { return m_Fragments.front(); } 71fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_reference front () const { return m_Fragments.front(); } 72fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera reference back () { return m_Fragments.back(); } 73fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_reference back () const { return m_Fragments.back(); } 74fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 75fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_iterator begin () const { return m_Fragments.begin(); } 76fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera iterator begin () { return m_Fragments.begin(); } 77fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_iterator end () const { return m_Fragments.end(); } 78fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera iterator end () { return m_Fragments.end(); } 79fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_reverse_iterator rbegin() const { return m_Fragments.rbegin(); } 80fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera reverse_iterator rbegin() { return m_Fragments.rbegin(); } 81fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera const_reverse_iterator rend () const { return m_Fragments.rend(); } 82fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera reverse_iterator rend () { return m_Fragments.rend(); } 83fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 84fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbeheraprivate: 85fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera FragmentListType m_Fragments; 86fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera LDSection* m_pSection; 87fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 88fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera}; 89fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 90fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera} // namespace of mcld 91fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 92fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera#endif 93fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera 94fdd65a0fc7df2c878cc601e4c0f4021cb264f051Pravat Dalbehera