OpenASIP 2.2
Loading...
Searching...
No Matches
InstructionElement.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 InstructionElement.hh
26 *
27 * Declaration of InstructionElement and InstructionAnnotation classes.
28 *
29 * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30 *
31 * @note rating: yellow
32 */
33
34#ifndef TTA_INSTRUCTION_ELEMENT_HH
35#define TTA_INSTRUCTION_ELEMENT_HH
36
37#include "BaseType.hh"
38#include "SectionElement.hh"
39
40namespace TPEF {
41
42/**
43 * Instruction annotation.
44 *
45 * Inline annotations allow to argument an instruction element
46 * with additional application-dependent information without
47 * disrupting the normal work of application.
48 */
50public:
51 InstructionAnnotation(Word anId, const std::vector<Byte>& payload);
52 InstructionAnnotation(Word anId);
54
55 Word id() const;
56
57 Byte byte(Byte index) const;
58 const std::vector<Byte>& payload() const;
59
60 void addByte(Byte aByte);
61
62 Byte size() const;
63
64 /// Maximum number of bytes that annotation may contain.
65 static const size_t MAX_ANNOTATION_BYTES;
66
67private:
68 /// Identifcation code of annotation.
69 Word id_;
70 /// Data of annotation.
71 std::vector<Byte> payLoad_;
72};
73
74/**
75 * Abstract base class for all instructions of CodeSection.
76 */
78public:
79 virtual ~InstructionElement();
80
81 bool isMove() const;
82 bool isImmediate() const;
83
84 bool begin() const;
85 void setBegin(bool isBegin);
86
89 Word annotationCount() const;
90
91protected:
93
94private:
95 /// Is the first element of whole instruction.
96 bool begin_;
97 /// Is move or immediate.
98 bool isMove_;
99
100 /// All annotations.
101 std::vector<InstructionAnnotation*> annotations_;
102};
103}
104
105#include "InstructionElement.icc"
106
107#endif
unsigned char Byte
Definition BaseType.hh:116
std::vector< Byte > payLoad_
Data of annotation.
void addByte(Byte aByte)
static const size_t MAX_ANNOTATION_BYTES
Maximum number of bytes that annotation may contain.
Byte byte(Byte index) const
const std::vector< Byte > & payload() const
Word id_
Identifcation code of annotation.
bool begin_
Is the first element of whole instruction.
bool isMove_
Is move or immediate.
Word annotationCount() const
InstructionAnnotation * annotation(Word index) const
void setBegin(bool isBegin)
void addAnnotation(InstructionAnnotation *anAnnotation)
std::vector< InstructionAnnotation * > annotations_
All annotations.