OpenASIP  2.0
BinaryEncoding.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 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 BinaryEncoding.hh
26  *
27  * Declaration of BinaryEncoding class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2014
31  * @note rating: red
32  */
33 
34 #ifndef TTA_BINARY_ENCODING_HH
35 #define TTA_BINARY_ENCODING_HH
36 
37 #include "Serializable.hh"
38 #include "InstructionField.hh"
39 #include "TCEString.hh"
40 
41 #include <vector>
42 #include <map>
43 
44 class MoveSlot;
45 class ImmediateSlotField;
46 class SocketCodeTable;
49 class InstructionFormat;
50 
51 /**
52  * BinaryEncoding is the root class in the object model of the binary
53  * encoding map.
54  *
55  * An instance of this class is sufficient to access all the
56  * information pertaining a binary encoding map, so an object can be
57  * passed to clients whenever a full description of the encoding map
58  * is required. BinaryEncoding is mostly a specialized container of
59  * objects of other classes.
60  */
62 public:
63  enum Position {
66  };
67 
69  BinaryEncoding(const ObjectState* state);
70 
71  virtual ~BinaryEncoding();
72 
73  int moveSlotCount() const;
74  MoveSlot& moveSlot(int index) const;
75  bool hasMoveSlot(const std::string& name) const;
76  MoveSlot& moveSlot(const std::string& name) const;
77  void addMoveSlot(MoveSlot& slot);
78  void removeMoveSlot(MoveSlot& slot);
79 
80  int immediateSlotCount() const;
81  ImmediateSlotField& immediateSlot(int index) const;
82  bool hasImmediateSlot(const std::string& name) const;
83  ImmediateSlotField& immediateSlot(const std::string& name) const;
86 
87  bool hasImmediateControlField() const;
91 
92  int longImmDstRegisterFieldCount() const;
95  const std::string& iTemp, const std::string& dstUnit) const;
98 
99  int instructionFormatCount() const;
100  bool hasInstructionFormat(const std::string name) const;
101  InstructionFormat& instructionFormat(int index) const;
104 
105  int socketCodeTableCount() const;
106  SocketCodeTable& socketCodeTable(int index) const;
107  SocketCodeTable& socketCodeTable(const std::string& name) const;
108  void addSocketCodeTable(SocketCodeTable& table);
110  int longestTemplateExtraBits() const;
111 
112  // methods inherited from InstructionField
113  virtual int childFieldCount() const;
114  virtual InstructionField& childField(int position) const;
115  virtual int width(const TCEString& templateName) const;
116  virtual int width() const;
117 
118  void setTemplateExtraBits(const TCEString& templateName, int bitCount);
119  int templateExtraBits(const TCEString& templateName) const;
120 
121  // methods inherited from Serializable interface
122  virtual void loadState(const ObjectState* state);
123  virtual ObjectState* saveState() const;
124 
125  /// ObjectState name for binary encoding.
126  static const std::string OSNAME_BEM;
127  static const std::string OSNAME_FU_OPCODE;
128  static const std::string OSNAME_TEMPLATE_EXTRA_BITS;
129  static const std::string OSNAME_TEMPLATE_EXTRA_BIT_COUNT;
130  static const std::string OSNAME_TEMPLATE_NAME;
131 
132 private:
133  /// Container type for MoveSlots.
134  typedef std::vector<MoveSlot*> MoveSlotContainer;
135  /// Container type for ImmediateSlotFields.
136  typedef std::vector<ImmediateSlotField*> ImmediateSlotContainer;
137  /// Container type for SocketCodeTables.
138  typedef std::vector<SocketCodeTable*> SocketCodeTableContainer;
139  /// Container type for LImmDstRegisterFields.
140  typedef std::vector<LImmDstRegisterField*> LImmDstRegisterFieldContainer;
141  /// Container type for InstructionFormats.
142  typedef std::vector<InstructionFormat*> InstructionFormatContainer;
143  /// Template extra bit count container.
144  typedef std::map<TCEString, int> TemplateExtraBitCountMap;
145 
146  bool hasSocketCodeTable(const std::string& name) const;
147  void deleteMoveSlots();
148  void deleteImmediateSlots();
150  void deleteSocketCodes();
152 
153  /// A container for instruction formats.
155  /// A container for move slots.
157  /// A container for immediate slots.
159  /// A container for socket code tables.
161  /// The immediate control field.
163  /// A container for long immediate register fields.
165  /// Extra (padding) bits per instruction template.
167 };
168 
169 #endif
BinaryEncoding::instructionFormat
InstructionFormat & instructionFormat(int index) const
Definition: BinaryEncoding.cc:521
BinaryEncoding::childFieldCount
virtual int childFieldCount() const
Definition: BinaryEncoding.cc:681
BinaryEncoding::immediateSlot
ImmediateSlotField & immediateSlot(int index) const
Definition: BinaryEncoding.cc:234
BinaryEncoding
Definition: BinaryEncoding.hh:61
BinaryEncoding::hasMoveSlot
bool hasMoveSlot(const std::string &name) const
Definition: BinaryEncoding.cc:138
BinaryEncoding::deleteImmediateSlots
void deleteImmediateSlots()
Definition: BinaryEncoding.cc:961
InstructionField.hh
BinaryEncoding::removeInstructionFormat
void removeInstructionFormat(InstructionFormat &format)
Definition: BinaryEncoding.cc:558
MoveSlot
Definition: MoveSlot.hh:60
BinaryEncoding::removeMoveSlot
void removeMoveSlot(MoveSlot &slot)
Definition: BinaryEncoding.cc:203
BinaryEncoding::instructionFormats_
InstructionFormatContainer instructionFormats_
A container for instruction formats.
Definition: BinaryEncoding.hh:154
BinaryEncoding::longImmDstRegisterFieldCount
int longImmDstRegisterFieldCount() const
Definition: BinaryEncoding.cc:400
BinaryEncoding::LImmDstRegisterFieldContainer
std::vector< LImmDstRegisterField * > LImmDstRegisterFieldContainer
Container type for LImmDstRegisterFields.
Definition: BinaryEncoding.hh:140
BinaryEncoding::MoveSlotContainer
std::vector< MoveSlot * > MoveSlotContainer
Container type for MoveSlots.
Definition: BinaryEncoding.hh:134
BinaryEncoding::moveSlots_
MoveSlotContainer moveSlots_
A container for move slots.
Definition: BinaryEncoding.hh:156
BinaryEncoding::setImmediateControlField
void setImmediateControlField(ImmediateControlField &field)
Definition: BinaryEncoding.cc:367
BinaryEncoding::unsetImmediateControlField
void unsetImmediateControlField()
Definition: BinaryEncoding.cc:385
BinaryEncoding::OSNAME_TEMPLATE_EXTRA_BITS
static const std::string OSNAME_TEMPLATE_EXTRA_BITS
Definition: BinaryEncoding.hh:128
BinaryEncoding::hasImmediateControlField
bool hasImmediateControlField() const
Definition: BinaryEncoding.cc:334
BinaryEncoding::socketCodeTableCount
int socketCodeTableCount() const
Definition: BinaryEncoding.cc:569
BinaryEncoding::TemplateExtraBitCountMap
std::map< TCEString, int > TemplateExtraBitCountMap
Template extra bit count container.
Definition: BinaryEncoding.hh:144
ObjectState
Definition: ObjectState.hh:59
BinaryEncoding::width
virtual int width() const
Definition: BinaryEncoding.cc:751
BinaryEncoding::InstructionFormatContainer
std::vector< InstructionFormat * > InstructionFormatContainer
Container type for InstructionFormats.
Definition: BinaryEncoding.hh:142
BinaryEncoding::hasInstructionFormat
bool hasInstructionFormat(const std::string name) const
Definition: BinaryEncoding.cc:502
BinaryEncoding::socketCodeTable
SocketCodeTable & socketCodeTable(int index) const
Definition: BinaryEncoding.cc:583
ImmediateSlotField
Definition: ImmediateSlotField.hh:44
InstructionField
Definition: InstructionField.hh:43
BinaryEncoding::OSNAME_TEMPLATE_NAME
static const std::string OSNAME_TEMPLATE_NAME
Definition: BinaryEncoding.hh:130
SocketCodeTable
Definition: SocketCodeTable.hh:68
TCEString.hh
BinaryEncoding::templateExtraBits
int templateExtraBits(const TCEString &templateName) const
Definition: BinaryEncoding.cc:1001
ImmediateControlField
Definition: ImmediateControlField.hh:57
BinaryEncoding::Position
Position
Definition: BinaryEncoding.hh:63
BinaryEncoding::saveState
virtual ObjectState * saveState() const
Definition: BinaryEncoding.cc:858
BinaryEncoding::addLongImmDstRegisterField
void addLongImmDstRegisterField(LImmDstRegisterField &field)
Definition: BinaryEncoding.cc:459
BinaryEncoding::immediateField_
ImmediateControlField * immediateField_
The immediate control field.
Definition: BinaryEncoding.hh:162
BinaryEncoding::LEFT
@ LEFT
Definition: BinaryEncoding.hh:64
BinaryEncoding::longestTemplateExtraBits
int longestTemplateExtraBits() const
Definition: BinaryEncoding.cc:657
BinaryEncoding::loadState
virtual void loadState(const ObjectState *state)
Definition: BinaryEncoding.cc:807
BinaryEncoding::longImmDstRegFields_
LImmDstRegisterFieldContainer longImmDstRegFields_
A container for long immediate register fields.
Definition: BinaryEncoding.hh:164
BinaryEncoding::deleteSocketCodes
void deleteSocketCodes()
Definition: BinaryEncoding.cc:980
BinaryEncoding::removeSocketCodeTable
void removeSocketCodeTable(SocketCodeTable &table)
Definition: BinaryEncoding.cc:645
InstructionFormat
Definition: InstructionFormat.hh:46
BinaryEncoding::socketCodes_
SocketCodeTableContainer socketCodes_
A container for socket code tables.
Definition: BinaryEncoding.hh:160
BinaryEncoding::instructionFormatCount
int instructionFormatCount() const
Definition: BinaryEncoding.cc:488
Serializable.hh
BinaryEncoding::removeImmediateSlot
void removeImmediateSlot(ImmediateSlotField &slot)
Definition: BinaryEncoding.cc:320
BinaryEncoding::extraTemplateBits_
TemplateExtraBitCountMap extraTemplateBits_
Extra (padding) bits per instruction template.
Definition: BinaryEncoding.hh:166
BinaryEncoding::immediateSlotCount
int immediateSlotCount() const
Definition: BinaryEncoding.cc:216
BinaryEncoding::OSNAME_TEMPLATE_EXTRA_BIT_COUNT
static const std::string OSNAME_TEMPLATE_EXTRA_BIT_COUNT
Definition: BinaryEncoding.hh:129
BinaryEncoding::hasImmediateSlot
bool hasImmediateSlot(const std::string &name) const
Definition: BinaryEncoding.cc:252
BinaryEncoding::setTemplateExtraBits
void setTemplateExtraBits(const TCEString &templateName, int bitCount)
Definition: BinaryEncoding.cc:995
BinaryEncoding::~BinaryEncoding
virtual ~BinaryEncoding()
Definition: BinaryEncoding.cc:86
BinaryEncoding::addMoveSlot
void addMoveSlot(MoveSlot &slot)
Definition: BinaryEncoding.cc:183
BinaryEncoding::BinaryEncoding
BinaryEncoding()
Definition: BinaryEncoding.cc:65
BinaryEncoding::hasSocketCodeTable
bool hasSocketCodeTable(const std::string &name) const
Definition: BinaryEncoding.cc:935
BinaryEncoding::addInstructionFormat
void addInstructionFormat(InstructionFormat &format)
Definition: BinaryEncoding.cc:538
BinaryEncoding::RIGHT
@ RIGHT
Definition: BinaryEncoding.hh:65
BinaryEncoding::OSNAME_BEM
static const std::string OSNAME_BEM
ObjectState name for binary encoding.
Definition: BinaryEncoding.hh:126
BinaryEncoding::ImmediateSlotContainer
std::vector< ImmediateSlotField * > ImmediateSlotContainer
Container type for ImmediateSlotFields.
Definition: BinaryEncoding.hh:136
TCEString
Definition: TCEString.hh:53
BinaryEncoding::addSocketCodeTable
void addSocketCodeTable(SocketCodeTable &table)
Definition: BinaryEncoding.cc:625
BinaryEncoding::SocketCodeTableContainer
std::vector< SocketCodeTable * > SocketCodeTableContainer
Container type for SocketCodeTables.
Definition: BinaryEncoding.hh:138
LImmDstRegisterField
Definition: LImmDstRegisterField.hh:47
BinaryEncoding::deleteInstructionFormats
void deleteInstructionFormats()
Definition: BinaryEncoding.cc:988
BinaryEncoding::immediateSlots_
ImmediateSlotContainer immediateSlots_
A container for immediate slots.
Definition: BinaryEncoding.hh:158
BinaryEncoding::immediateControlField
ImmediateControlField & immediateControlField() const
Definition: BinaryEncoding.cc:348
BinaryEncoding::removeLongImmDstRegisterField
void removeLongImmDstRegisterField(LImmDstRegisterField &field)
Definition: BinaryEncoding.cc:475
BinaryEncoding::moveSlot
MoveSlot & moveSlot(int index) const
Definition: BinaryEncoding.cc:121
BinaryEncoding::childField
virtual InstructionField & childField(int position) const
Definition: BinaryEncoding.cc:704
BinaryEncoding::deleteMoveSlots
void deleteMoveSlots()
Definition: BinaryEncoding.cc:952
BinaryEncoding::deleteLongImmDstRegisterFields
void deleteLongImmDstRegisterFields()
Definition: BinaryEncoding.cc:971
BinaryEncoding::moveSlotCount
int moveSlotCount() const
Definition: BinaryEncoding.cc:104
BinaryEncoding::addImmediateSlot
void addImmediateSlot(ImmediateSlotField &slot)
Definition: BinaryEncoding.cc:300
BinaryEncoding::longImmDstRegisterField
LImmDstRegisterField & longImmDstRegisterField(int index) const
Definition: BinaryEncoding.cc:415
BinaryEncoding::OSNAME_FU_OPCODE
static const std::string OSNAME_FU_OPCODE
Definition: BinaryEncoding.hh:127