2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
25 * @file InstructionElement.icc
27 * Inline definitions of InstructionElement and InstructionAnnotation classes.
29 * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
31 * @note rating: yellow
34 //////////////////////////////////////////////////////////////////////////////
35 // InstructionAnnotation definition.
36 //////////////////////////////////////////////////////////////////////////////
41 * Returns the code that identifies this annotation.
43 * This numeric code is used by applications to recognize annotations that
46 * @return Unique identification code.
49 InstructionAnnotation::id() const {
50 assert (id_ < 0xFFFFFF); // only 16 million id's
55 * Gets requested byte of data from annotation.
57 * @param index Index of requested byte.
58 * @return Value of requested index.
61 InstructionAnnotation::byte(Byte index) const {
62 assert(index < size());
63 return payLoad_[index];
67 * Returns a const reference to the payload byte bector.
69 * @returns A const reference to the payload byte vector.
71 inline const std::vector<Byte>&
72 InstructionAnnotation::payload() const {
77 * Adds a byte to annotation.
79 * @praram aByte Byte to add.
82 InstructionAnnotation::addByte(Byte aByte) {
83 assert(size() <= MAX_ANNOTATION_BYTES);
84 payLoad_.push_back(aByte);
88 * Returns size of data.
90 * @return Size of data.
93 InstructionAnnotation::size() const {
94 return payLoad_.size();
98 //////////////////////////////////////////////////////////////////////////////
99 // InstructionElement definition.
100 //////////////////////////////////////////////////////////////////////////////
103 * Returns true, if instruction element is the first element of instruction.
105 * @return True if instruction element is the first element of instruction.
108 InstructionElement::begin() const {
113 * Sets beginning status of instruction element.
115 * @param isBegin Value that is set to beginning status.
118 InstructionElement::setBegin(bool isBegin) {
123 * Returns true, if instruction element is move.
125 * @return True, if instruction element is move.
128 InstructionElement::isMove() const {
133 * Returns true, if instruction element is immediate.
135 * @return True, if instruction element is immediate.
138 InstructionElement::isImmediate() const {
143 * Returns requested annotation.
145 * Returned reference to annotation may be edited.
147 * @param index Index of annotation to return.
148 * @return Pointer to requested annotation.
150 inline InstructionAnnotation*
151 InstructionElement::annotation(Word index) const {
152 assert(index < annotationCount());
153 return annotations_[index];
158 * Adds an annotation to instruction.
160 * @param anAnnotation Annotation to add.
163 InstructionElement::addAnnotation(InstructionAnnotation *anAnnotation) {
164 annotations_.push_back(anAnnotation);
168 * Returns number of annotations that are stored to instruction element.
170 * @return Number of annotations.
173 InstructionElement::annotationCount() const {
174 return annotations_.size();