OpenASIP 2.2
Loading...
Searching...
No Matches
DisassemblyInstruction.cc
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 DisassemblyInstruction.cc
26 *
27 * Implementation of DisassemblyInstruction class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
34#include "SequenceTools.hh"
35
36/**
37 * Constructor.
38 */
41
42
43/**
44 * Destructor.
45 */
47 // Delete all moves of the instruction.
49}
50
51
52/**
53 * Adds a move to the instruction.
54 *
55 * @param move Move to be added.
56 */
57void
61
62
63/**
64 * Returns number of moves in the instruction.
65 *
66 * @return Instruction move count.
67 */
68Word
70 return moves_.size();
71}
72
73
74/**
75 * Returns the isntruction move at a given index.
76 *
77 * @param index Index of the move.
78 * @return The move at the index.
79 * @exception OutOfRange If the give index is out of range.
80 */
83 if (index >= moveCount()) {
84 std::string procName = "DisassemblyInstruction::move";
85 throw OutOfRange(__FILE__, __LINE__, procName);
86 }
87 return *moves_[index];
88}
89
90/**
91 * Adds a long immediate to the instruction.
92 *
93 * @param longImm Immediate to be added.
94 */
95void
101
102
103/**
104 * Returns number of long immediates in the instruction.
105 *
106 * @return Instruction's long immediate count.
107 */
108Word
112
113
114/**
115 * Returns the long immediate at a given index.
116 *
117 * @param index Index of the long immediate.
118 * @return The long immediate at the index.
119 * @exception OutOfRange If the give index is out of range.
120 */
123 if (index >= longImmediateCount()) {
124 throw OutOfRange(__FILE__, __LINE__, __func__);
125 }
126 return *longImmediates_[index];
127}
128
129/**
130 * Returns disassembly of the instruction.
131 *
132 * @return Disassembly of the instruction as a string.
133 */
134std::string
136 std::string disassembly;
137 for (Word i = 0; i < moveCount(); i++) {
138 if (i > 0) {
139 disassembly = disassembly + ", ";
140 }
141 disassembly = disassembly + move(i).toString();
142 }
143
144 for (Word i = 0; i < longImmediateCount(); i++) {
145
146 disassembly = disassembly + " " + longImmediate(i).toString();
147 }
148
149 for (int i = 0; i < annotationCount(); i++) {
150 disassembly += annotation(i).toString();
151 }
152
153 disassembly = disassembly + " ;";
154 return disassembly;
155}
156
157
158/**
159 * Returns annotation of requested index.
160 *
161 * @param index Index of annotation to return.
162 * @return Annotation of requested index.
163 */
166 return *(annotations_.at(index));
167}
168
169/**
170 * Adds an annotation to instruction.
171 *
172 * @param annotation Annotation to add.
173 */
174void
178
179/**
180 * Returns the number of annotationes stored for the instruction.
181 *
182 * @return The number of annotationes stored for the instruction.
183 */
184int
186 return static_cast<int>(annotations_.size());
187}
#define __func__
virtual std::string toString() const
virtual std::string toString() const =0
void addAnnotation(DisassemblyAnnotation *annotation)
MoveTable moves_
List of instruction moves.
DisassemblyInstructionSlot & move(Word index) const
std::vector< DisassemblyAnnotation * > annotations_
Annotationes of instruction itself.
void addLongImmediate(DisassemblyImmediateAssignment *longImm)
void addMove(DisassemblyInstructionSlot *move)
DisassemblyImmediateAssignment & longImmediate(Word index) const
DisassemblyAnnotation & annotation(int index) const
LongImmediateTable longImmediates_
List of instruction long immediates.
static void deleteAllItems(SequenceType &aSequence)