OpenASIP  2.0
DataSectionCreator.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DataSectionCreator.hh
26  *
27  * Declaration of DataSectionCreator class.
28  *
29  * @author Mikael Lepistö 2005 (tmlepist-no.spam-cs.tut.fi)
30  * @note rating: yellow
31  */
32 
33 #ifndef TCEASM_DATA_SECTION_CREATOR_HH
34 #define TCEASM_DATA_SECTION_CREATOR_HH
35 
36 #include "Exception.hh"
37 #include "ParserStructs.hh"
38 
39 namespace TPEF {
40  class Binary;
41  class Section;
42  class DataSection;
43 }
44 
46 class LabelManager;
48 
49 /**
50  * Collects data area information and parses data to tpef data sections.
51  */
53 public:
55  MachineResourceManager &resourceManager,
56  AssemblyParserDiagnostic* parent);
57 
59 
60  void setAreaStartAddress(UValue address);
61 
62  void addDataLine(const DataLine& origLine);
63 
64  void finalize(TPEF::Binary& tpef, LabelManager& labels, bool littleEndian);
65 
66  void cleanup();
67 
68 private:
69  /**
70  * Internal representation of data section.
71  */
72  struct InternalSection {
73  /// Address space of the section.
74  std::string addressSpace;
75 
76  /// If section contains initialization data.
78  /// Is start address of the section fixed.
80 
81  /// The start address of the section.
83  /// Number of MAUs stored in section.
85 
86  /// Initialization data of the section. (or uninitialization data;)
87  std::vector<DataLine*> lines;
88  };
89 
91  std::map<std::string, UValue>& addressSpaceUsedMAUs,
92  std::vector<std::string>& addedLabels, LabelManager& labels);
93 
95  DataLine* line, TPEF::DataSection* dataSection, LabelManager& labels,
96  UValue currentMAUIndex);
97 
98  int sizeInWords(UValue value, int MAUWidth, bool isSigned) const;
99 
100  /// TPEF Resources and strings.
102 
103  /// Start address of next line (if fixed address).
105  /// Is next data line address fixed.
107 
108  /// Internal data sections.
109  std::vector<InternalSection> sections_;
110 };
111 
112 
113 
114 #endif
DataSectionCreator::InternalSection
Definition: DataSectionCreator.hh:72
Exception.hh
TPEF::Binary
Definition: Binary.hh:49
DataSectionCreator::InternalSection::isInitialized
bool isInitialized
If section contains initialization data.
Definition: DataSectionCreator.hh:77
ParserStructs.hh
DataSectionCreator::sections_
std::vector< InternalSection > sections_
Internal data sections.
Definition: DataSectionCreator.hh:109
DataSectionCreator::resources_
MachineResourceManager & resources_
TPEF Resources and strings.
Definition: DataSectionCreator.hh:101
TPEF::DataSection
Definition: DataSection.hh:52
DataSectionCreator::cleanup
void cleanup()
Definition: DataSectionCreator.cc:156
AssemblyParserDiagnostic
Definition: AssemblyParserDiagnostic.hh:68
LabelManager
Definition: LabelManager.hh:64
DataSectionCreator::sizeInWords
int sizeInWords(UValue value, int MAUWidth, bool isSigned) const
Definition: DataSectionCreator.cc:544
DataSectionCreator::InternalSection::fixedStartAddress
bool fixedStartAddress
Is start address of the section fixed.
Definition: DataSectionCreator.hh:79
DataSectionCreator::currentStartAddress_
UValue currentStartAddress_
Start address of next line (if fixed address).
Definition: DataSectionCreator.hh:104
UValue
unsigned long UValue
Definition: ParserStructs.hh:44
DataSectionCreator::DataSectionCreator
DataSectionCreator(MachineResourceManager &resourceManager, AssemblyParserDiagnostic *parent)
Definition: DataSectionCreator.cc:55
MachineResourceManager
Definition: MachineResourceManager.hh:76
DataSectionCreator::InternalSection::startAddress
UValue startAddress
The start address of the section.
Definition: DataSectionCreator.hh:82
DataSectionCreator::finalize
void finalize(TPEF::Binary &tpef, LabelManager &labels, bool littleEndian)
Definition: DataSectionCreator.cc:190
DataSectionCreator::InternalSection::length
UValue length
Number of MAUs stored in section.
Definition: DataSectionCreator.hh:84
DataSectionCreator::~DataSectionCreator
~DataSectionCreator()
Definition: DataSectionCreator.cc:64
DataLine
Definition: ParserStructs.hh:477
DataSectionCreator::InternalSection::addressSpace
std::string addressSpace
Address space of the section.
Definition: DataSectionCreator.hh:74
DataSectionCreator::writeDataLineToTPEF
UValue writeDataLineToTPEF(DataLine *line, TPEF::DataSection *dataSection, LabelManager &labels, UValue currentMAUIndex)
Definition: DataSectionCreator.cc:439
DataSectionCreator::setAreaStartAddress
void setAreaStartAddress(UValue address)
Definition: DataSectionCreator.cc:73
DataSectionCreator
Definition: DataSectionCreator.hh:52
DataSectionCreator::isStartAddressDefined_
bool isStartAddressDefined_
Is next data line address fixed.
Definition: DataSectionCreator.hh:106
DataSectionCreator::InternalSection::lines
std::vector< DataLine * > lines
Initialization data of the section. (or uninitialization data;)
Definition: DataSectionCreator.hh:87
DataSectionCreator::addDataLine
void addDataLine(const DataLine &origLine)
Definition: DataSectionCreator.cc:84
DataSectionCreator::resolveDataAreaSizesAndLabelAddresses
void resolveDataAreaSizesAndLabelAddresses(std::map< std::string, UValue > &addressSpaceUsedMAUs, std::vector< std::string > &addedLabels, LabelManager &labels)
Definition: DataSectionCreator.cc:324
TPEF
Definition: Assembler.hh:43