OpenASIP  2.0
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 
40 namespace 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  */
50 public:
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 
67 private:
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  */
78 public:
79  virtual ~InstructionElement();
80 
81  bool isMove() const;
82  bool isImmediate() const;
83 
84  bool begin() const;
85  void setBegin(bool isBegin);
86 
87  InstructionAnnotation* annotation(Word index) const;
88  void addAnnotation(InstructionAnnotation *anAnnotation);
89  Word annotationCount() const;
90 
91 protected:
93 
94 private:
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
TPEF::InstructionElement::isMove
bool isMove() const
BaseType.hh
TPEF::InstructionElement::addAnnotation
void addAnnotation(InstructionAnnotation *anAnnotation)
TPEF::InstructionElement
Definition: InstructionElement.hh:77
TPEF::InstructionAnnotation::MAX_ANNOTATION_BYTES
static const size_t MAX_ANNOTATION_BYTES
Maximum number of bytes that annotation may contain.
Definition: InstructionElement.hh:65
TPEF::InstructionElement::annotation
InstructionAnnotation * annotation(Word index) const
TPEF::InstructionElement::isImmediate
bool isImmediate() const
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::InstructionAnnotation::addByte
void addByte(Byte aByte)
TPEF::InstructionElement::~InstructionElement
virtual ~InstructionElement()
Definition: InstructionElement.cc:83
TPEF::InstructionAnnotation::payload
const std::vector< Byte > & payload() const
TPEF::InstructionElement::annotations_
std::vector< InstructionAnnotation * > annotations_
All annotations.
Definition: InstructionElement.hh:101
TPEF::InstructionElement::begin_
bool begin_
Is the first element of whole instruction.
Definition: InstructionElement.hh:96
TPEF::SectionElement
Definition: SectionElement.hh:44
TPEF::InstructionElement::annotationCount
Word annotationCount() const
TPEF::InstructionAnnotation::id
Word id() const
TPEF::InstructionElement::begin
bool begin() const
TPEF::InstructionElement::isMove_
bool isMove_
Is move or immediate.
Definition: InstructionElement.hh:98
TPEF::InstructionAnnotation::id_
Word id_
Identifcation code of annotation.
Definition: InstructionElement.hh:69
TPEF::InstructionElement::setBegin
void setBegin(bool isBegin)
TPEF::InstructionAnnotation::payLoad_
std::vector< Byte > payLoad_
Data of annotation.
Definition: InstructionElement.hh:71
TPEF::InstructionAnnotation::~InstructionAnnotation
~InstructionAnnotation()
Definition: InstructionElement.cc:66
SectionElement.hh
TPEF::InstructionAnnotation
Definition: InstructionElement.hh:49
TPEF::InstructionAnnotation::size
Byte size() const
TPEF::InstructionAnnotation::byte
Byte byte(Byte index) const
TPEF::InstructionAnnotation::InstructionAnnotation
InstructionAnnotation(Word anId, const std::vector< Byte > &payload)
Definition: InstructionElement.cc:51
InstructionElement.icc
TPEF::InstructionElement::InstructionElement
InstructionElement(bool isMove)
Definition: InstructionElement.cc:76
TPEF
Definition: Assembler.hh:43