OpenASIP 2.2
Loading...
Searching...
No Matches
CodeSectionCreator.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 CodeSectionCreator.hh
26 *
27 * Declaration of CodeSectionCreator class.
28 *
29 * @author Mikael Lepistö 2005 (tmlepist-no.spam-cs.tut.fi)
30 * @author Pekka Jääskeläinen 2006 (pekka.jaaskelainen-no.spam-tut.fi)
31 *
32 * @note rating: yellow
33 */
34
35#ifndef TCEASM_CODE_SECTION_CREATOR_HH
36#define TCEASM_CODE_SECTION_CREATOR_HH
37
38#include "ParserStructs.hh"
39#include "MoveElement.hh"
40#include "Exception.hh"
41
42namespace TPEF {
43 class CodeSection;
44 class Binary;
45 class InstructionElement;
46}
47
49class LabelManager;
51namespace TTAMachine {
52 class Machine;
53}
54
55/**
56 * Read moves and creates TPEF code section out of them.
57 */
59public:
60
62 MachineResourceManager &resourceManager,
63 const TTAMachine::Machine& targetMachine,
65
66 void newSection(UValue startAddress);
67
68 void addMove(const ParserMove& move);
69
70 void finalize(TPEF::Binary& tpef, LabelManager& labels);
71
72 void cleanup();
73
74
75private:
76
77 /**
78 * Type of move element.
79 */
81 EMPTY, ///< Empty move.
82 MOVE, ///< Data transport.
83 IMMEDIATE ///< Long immediate assignment.
84 };
85
86 /**
87 * Internal representation of one move.
88 *
89 * Element can define normal move, empty move or long immediate
90 * assignment. This format is written as TPEF in finalize pahse.
91 */
93 /// Type of move.
95 /// Bus slot number.
97
98 /// Is first move of an instruction.
99 bool isBegin;
100
101 /// Is guarded move.
103 /// Is guard inverted.
105 /// Guard type.
107 /// TPEF Resource section unit id of guard register or port.
109 /// TPEF Resource section operand id or register number.
111
112 /// Source type.
114 /// TPEF Resource section unit id of register or port.
116 /// TPEF Resource section operand id or register number.
118
119 /// Destination type.
121 /// TPEF Resource section unit id of register or port.
123 /// TPEF Resource section operand id or register number.
125
126 /// If source is immediate, the value.
128
129 /// Line number where in source code this move is located.
131
132 /// Annotations for the element.
133 std::vector<Annotation> annotationes;
134 };
135
136 /**
137 * Internal representation of code section.
138 */
140 /// Start address of the section.
142 /// Elements of the section.
143 std::vector<InternalElement> elements;
144 };
145
146 void startNewInstruction();
147
149
151
152 bool isDestinationAlreadyWritten(const InternalElement& elem) const;
153
155 InternalElement& elem, LabelManager& lables) const;
156
158
159 /// Internal representation of code section.
161
162 /// TPEF Resources and strings.
164
165 /// Place to add warnings during compilation.
167
168 /// Next element is starting element of instruction.
170
171 /// Slot number of current move.
173
174 /// Immediate index.
176
177 /// Bitwidth of immediate value containing address to relocate.
179};
180
181#endif
unsigned long UValue
AssemblyParserDiagnostic * parent_
Place to add warnings during compilation.
UValue immediateIndex_
Immediate index.
void addAnnotationes(TPEF::InstructionElement &instrElem, InternalElement &elem, LabelManager &lables) const
@ IMMEDIATE
Long immediate assignment.
@ MOVE
Data transport.
UValue slotNumber_
Slot number of current move.
void newSection(UValue startAddress)
void addMove(const ParserMove &move)
bool isNextBegin_
Next element is starting element of instruction.
bool isDestinationAlreadyWritten(const InternalElement &elem) const
const TTAMachine::Machine & mach_
MachineResourceManager & resources_
TPEF Resources and strings.
static const UValue CODE_RELOC_SIZE
Bitwidth of immediate value containing address to relocate.
InternalSection internalSection_
Internal representation of code section.
void finalize(TPEF::Binary &tpef, LabelManager &labels)
UValue guardUnit
TPEF Resource section unit id of guard register or port.
UValue srcUnit
TPEF Resource section unit id of register or port.
UValue srcIndex
TPEF Resource section operand id or register number.
TPEF::MoveElement::FieldType guardType
Guard type.
TPEF::MoveElement::FieldType srcType
Source type.
std::vector< Annotation > annotationes
Annotations for the element.
UValue asmLineNumber
Line number where in source code this move is located.
TPEF::MoveElement::FieldType dstType
Destination type.
LiteralOrExpression immValue
If source is immediate, the value.
UValue dstIndex
TPEF Resource section operand id or register number.
UValue dstUnit
TPEF Resource section unit id of register or port.
UValue guardIndex
TPEF Resource section operand id or register number.
bool isBegin
Is first move of an instruction.
std::vector< InternalElement > elements
Elements of the section.
UValue startAddress
Start address of the section.