OpenASIP  2.0
InstructionBitVector.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 InstructionBitVector.hh
26  *
27  * Declaration of InstructionBitVector class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_INSTRUCTION_BIT_VECTOR_HH
34 #define TTA_INSTRUCTION_BIT_VECTOR_HH
35 
36 #include <set>
37 #include <map>
38 
39 #include "BitVector.hh"
40 #include "Exception.hh"
41 #include "IndexBound.hh"
42 
43 namespace TTAProgram {
44  class Instruction;
45 }
46 
47 /**
48  * A bit vector class that provides instruction relocation capabilities.
49  */
51 public:
54  virtual ~InstructionBitVector();
55 
56  void pushBack(const InstructionBitVector& bits);
57  void pushBack(const BitVector& bits);
59  unsigned int firstIndex, unsigned int lastIndex) const;
60 
62  const TTAProgram::Instruction& instruction);
64 
66  const TTAProgram::Instruction& instruction, unsigned int address);
67 
68  void markInstructionStartingPoint(unsigned int position);
69  unsigned int instructionCount() const;
70  unsigned int instructionStartingPoint(unsigned int index) const;
71 
72 private:
73  /// A vector type that stores index bounds.
74  typedef std::vector<IndexBound> IndexBoundTable;
75  /// A set type that stores IndexBoundTables.
76  typedef std::set<IndexBoundTable*> IndexBoundSet;
77  /// A map type that maps Instructions to IndexBoundSets.
78  typedef std::map<const TTAProgram::Instruction*, IndexBoundSet*>
80  /// A vector type that stores instruction boundaries.
81  typedef std::vector<unsigned int> BoundaryTable;
82  /// A map type for instruction addresses.
83  typedef std::map<const TTAProgram::Instruction*, unsigned int>
85 
87  const TTAProgram::Instruction& instruction);
88  void addIndexBoundTables(const IndexBoundSet& from, IndexBoundSet& to);
89  void fixBits(const IndexBoundTable& indexes, unsigned int value);
90  static unsigned int availableSize(const IndexBoundTable& indexes);
91 
92  /// Contains information of the parts of the bit vector that refer to
93  /// an instruction address.
95  /// IndexBoundTable being under construction.
97  /// Stores the instruction boundaries.
99  /// Addresses of the instructions.
101 };
102 
103 #endif
104 
105 
TTAProgram
Definition: Estimator.hh:65
InstructionBitVector::addIndexBoundsForReference
void addIndexBoundsForReference(IndexBound bounds)
Definition: InstructionBitVector.cc:179
Exception.hh
BitVector
Definition: BitVector.hh:44
TTAProgram::Instruction
Definition: Instruction.hh:57
InstructionBitVector::startSettingInstructionReference
void startSettingInstructionReference(const TTAProgram::Instruction &instruction)
Definition: InstructionBitVector.cc:160
BitVector.hh
InstructionBitVector::instructionAddresses_
InstructionAddressTable instructionAddresses_
Addresses of the instructions.
Definition: InstructionBitVector.hh:100
InstructionBitVector::IndexBoundTable
std::vector< IndexBound > IndexBoundTable
A vector type that stores index bounds.
Definition: InstructionBitVector.hh:74
IndexBound
Definition: IndexBound.hh:40
InstructionBitVector::instructionStartingPoint
unsigned int instructionStartingPoint(unsigned int index) const
Definition: InstructionBitVector.cc:269
InstructionBitVector::references_
ReferenceMap references_
Contains information of the parts of the bit vector that refer to an instruction address.
Definition: InstructionBitVector.hh:94
InstructionBitVector::ReferenceMap
std::map< const TTAProgram::Instruction *, IndexBoundSet * > ReferenceMap
A map type that maps Instructions to IndexBoundSets.
Definition: InstructionBitVector.hh:79
InstructionBitVector::instructionCount
unsigned int instructionCount() const
Definition: InstructionBitVector.cc:254
InstructionBitVector::indexBounds
IndexBoundSet & indexBounds(const TTAProgram::Instruction &instruction)
Definition: InstructionBitVector.cc:284
InstructionBitVector::InstructionAddressTable
std::map< const TTAProgram::Instruction *, unsigned int > InstructionAddressTable
A map type for instruction addresses.
Definition: InstructionBitVector.hh:84
InstructionBitVector::InstructionBitVector
InstructionBitVector()
Definition: InstructionBitVector.cc:46
InstructionBitVector::fixInstructionAddress
void fixInstructionAddress(const TTAProgram::Instruction &instruction, unsigned int address)
Definition: InstructionBitVector.cc:199
InstructionBitVector::availableSize
static unsigned int availableSize(const IndexBoundTable &indexes)
Definition: InstructionBitVector.cc:387
InstructionBitVector::addIndexBoundTables
void addIndexBoundTables(const IndexBoundSet &from, IndexBoundSet &to)
Definition: InstructionBitVector.cc:308
InstructionBitVector::subVector
InstructionBitVector * subVector(unsigned int firstIndex, unsigned int lastIndex) const
InstructionBitVector::currentTable_
IndexBoundTable * currentTable_
IndexBoundTable being under construction.
Definition: InstructionBitVector.hh:96
IndexBound.hh
InstructionBitVector::~InstructionBitVector
virtual ~InstructionBitVector()
Definition: InstructionBitVector.cc:87
InstructionBitVector::markInstructionStartingPoint
void markInstructionStartingPoint(unsigned int position)
Definition: InstructionBitVector.cc:224
InstructionBitVector::IndexBoundSet
std::set< IndexBoundTable * > IndexBoundSet
A set type that stores IndexBoundTables.
Definition: InstructionBitVector.hh:76
InstructionBitVector::instructionBoundaries_
BoundaryTable instructionBoundaries_
Stores the instruction boundaries.
Definition: InstructionBitVector.hh:98
InstructionBitVector::pushBack
void pushBack(const InstructionBitVector &bits)
Definition: InstructionBitVector.cc:102
InstructionBitVector::BoundaryTable
std::vector< unsigned int > BoundaryTable
A vector type that stores instruction boundaries.
Definition: InstructionBitVector.hh:81
InstructionBitVector::fixBits
void fixBits(const IndexBoundTable &indexes, unsigned int value)
Definition: InstructionBitVector.cc:338
InstructionBitVector
Definition: InstructionBitVector.hh:50