OpenASIP  2.0
BasicBlock.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 BasicBlock.hh
26  *
27  * Declaration of the BasicBlock class.
28  *
29  * @author Pekka Jääskeläinen 2007-2010
30  * @note rating: red
31  */
32 
33 #ifndef TTA_BASIC_BLOCK_HH
34 #define TTA_BASIC_BLOCK_HH
35 
36 
37 #include <vector>
38 #include <set>
39 #include <map>
40 
41 
42 #include "Exception.hh"
43 #include "CodeSnippet.hh"
44 
45 struct LiveRangeData;
46 
47 namespace TTAProgram {
48 
49 class Instruction;
50 class CodeSnippet;
51 
52 /**
53  * Represents statistics about single basic block.
54  */
56 public:
58  virtual ~BasicBlockStatistics();
59  virtual int moveCount() const;
60  virtual int immediateCount() const;
61  virtual int instructionCount() const;
62  virtual int bypassedCount() const;
63  virtual void setMoveCount(int);
64  virtual void setImmediateCount(int);
65  virtual void setInstructionCount(int);
66  virtual void setBypassedCount(int);
67 private:
72 };
73 
74 /**
75  * Represents contents and information of one basic block.
76  *
77  * A basic block is defined as an ordered sequence of adjacent instructions
78  * in which only the first can be target of jump and only the last one (save
79  * jump delay slots) can contain jumps.
80  *
81  * @note Instructions that contain function calls are control flow barriers
82  * also. For now they split basic blocks into two, with special type of edge
83  * connecting them.
84  */
86 public:
87 
88  BasicBlock(int startAddress=0);
89  virtual ~BasicBlock();
90 
91  BasicBlock* copy() const;
92  virtual void clear();
93 
94  int skippedFirstInstructions() const;
95  void skipFirstInstructions(int count);
97 
98  bool isEmpty() {
100  }
101 
102  /// returns true in case the BB is *known* to be inside an inner loop
103  bool isInInnerLoop() const { return innerLoop_; }
104  void setInInnerLoop(bool inner = true) { innerLoop_ = inner; }
105 
106  /// in case the BB is inside a loop and trip count is known,
107  /// returns it, otherwise returns 0
108  unsigned tripCount() const { return tripCount_; }
109  void setTripCount(unsigned count) { tripCount_ = count; }
110 
112 
113 private:
114 
118 
120  unsigned tripCount_;
121 };
122 
123 }
124 
125 #endif
126 
TTAProgram::BasicBlockStatistics::bypassedCount_
int bypassedCount_
Definition: BasicBlock.hh:71
TTAProgram::BasicBlockStatistics::setInstructionCount
virtual void setInstructionCount(int)
Definition: BasicBlock.cc:230
TTAProgram
Definition: Estimator.hh:65
TTAProgram::BasicBlock::statistics
const BasicBlockStatistics & statistics()
Definition: BasicBlock.cc:111
TTAProgram::BasicBlockStatistics::moveCount
virtual int moveCount() const
Definition: BasicBlock.cc:177
Exception.hh
TTAProgram::BasicBlockStatistics::moveCount_
int moveCount_
Definition: BasicBlock.hh:68
TTAProgram::BasicBlockStatistics::setImmediateCount
virtual void setImmediateCount(int)
Definition: BasicBlock.cc:220
TTAProgram::BasicBlockStatistics::instructionCount_
int instructionCount_
Definition: BasicBlock.hh:70
TTAProgram::CodeSnippet::startAddress
virtual Address startAddress() const
Definition: CodeSnippet.cc:780
TTAProgram::BasicBlock::copy
BasicBlock * copy() const
Definition: BasicBlock.cc:67
TTAProgram::BasicBlock::statistics_
BasicBlockStatistics statistics_
Definition: BasicBlock.hh:117
TTAProgram::BasicBlockStatistics::setBypassedCount
virtual void setBypassedCount(int)
Definition: BasicBlock.cc:239
TTAProgram::BasicBlock::innerLoop_
bool innerLoop_
Definition: BasicBlock.hh:119
TTAProgram::BasicBlockStatistics
Definition: BasicBlock.hh:55
TTAProgram::BasicBlock::skippedFirstInstructions
int skippedFirstInstructions() const
Definition: BasicBlock.cc:88
TTAProgram::BasicBlock::setTripCount
void setTripCount(unsigned count)
Definition: BasicBlock.hh:109
TTAProgram::BasicBlock::skipFirstInstructions
void skipFirstInstructions(int count)
Definition: BasicBlock.cc:98
TTAProgram::BasicBlock::liveRangeData_
LiveRangeData * liveRangeData_
Definition: BasicBlock.hh:111
TTAProgram::CodeSnippet::instructionCount
virtual int instructionCount() const
Definition: CodeSnippet.cc:205
TTAProgram::BasicBlockStatistics::immediateCount
virtual int immediateCount() const
Definition: BasicBlock.cc:185
TTAProgram::BasicBlockStatistics::immediateCount_
int immediateCount_
Definition: BasicBlock.hh:69
LiveRangeData
Definition: LiveRangeData.hh:47
TTAProgram::BasicBlockStatistics::BasicBlockStatistics
BasicBlockStatistics()
Definition: BasicBlock.cc:159
TTAProgram::BasicBlock::isEmpty
bool isEmpty()
Definition: BasicBlock.hh:98
TTAProgram::BasicBlock::BasicBlock
BasicBlock(int startAddress=0)
Definition: BasicBlock.cc:49
CodeSnippet.hh
TTAProgram::BasicBlock::statisticsValid_
bool statisticsValid_
Definition: BasicBlock.hh:116
TTAProgram::CodeSnippet
Definition: CodeSnippet.hh:59
TTAProgram::BasicBlockStatistics::setMoveCount
virtual void setMoveCount(int)
Definition: BasicBlock.cc:210
TTAProgram::BasicBlock
Definition: BasicBlock.hh:85
TTAProgram::BasicBlock::skippedFirstInstructions_
int skippedFirstInstructions_
Definition: BasicBlock.hh:115
TTAProgram::BasicBlock::tripCount
unsigned tripCount() const
in case the BB is inside a loop and trip count is known, returns it, otherwise returns 0
Definition: BasicBlock.hh:108
TTAProgram::BasicBlockStatistics::~BasicBlockStatistics
virtual ~BasicBlockStatistics()
Definition: BasicBlock.cc:169
TTAProgram::BasicBlock::tripCount_
unsigned tripCount_
Definition: BasicBlock.hh:120
TTAProgram::BasicBlockStatistics::bypassedCount
virtual int bypassedCount() const
Definition: BasicBlock.cc:201
TTAProgram::BasicBlockStatistics::instructionCount
virtual int instructionCount() const
Definition: BasicBlock.cc:193
TTAProgram::BasicBlock::isInInnerLoop
bool isInInnerLoop() const
returns true in case the BB is known to be inside an inner loop
Definition: BasicBlock.hh:103
TTAProgram::BasicBlock::~BasicBlock
virtual ~BasicBlock()
Definition: BasicBlock.cc:60
TTAProgram::BasicBlock::clear
virtual void clear()
Definition: BasicBlock.cc:152
TTAProgram::BasicBlock::setInInnerLoop
void setInInnerLoop(bool inner=true)
Definition: BasicBlock.hh:104