OpenASIP 2.2
Loading...
Searching...
No Matches
BasicBlockNode.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 BasicBlockNode.hh
26 *
27 * Prototype control flow graph of TTA program representation: declaration
28 * of graph node (basic block).
29 *
30 * @author Andrea Cilio 2005 (cilio-no.spam-cs.tut.fi)
31 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
32 * @note rating: red
33 */
34
35#ifndef TTA_BASIC_BLOCK_NODE_HH
36#define TTA_BASIC_BLOCK_NODE_HH
37
38#include <string>
39
40#include "GraphNode.hh"
41#include "Address.hh"
42
43namespace TTAProgram {
44 class Program;
45 class Move;
46 class Instruction;
47 class CodeSnippet;
48 class BasicBlock;
49 class BasicBlockStatistics;
50}
51
52
53/**
54 * Node of the control flow graph. Each node represents one basic block.
55 *
56 * A basic block is defined as an ordered sequence of adjacent instructions
57 * in which only the first can be target of jump and only the last one (save
58 * jump delay slots) can contain jumps.
59 *
60 * @note Instructions that contain function calls are control flow barriers
61 * also. For now they split basic blocks into two, with special type of edge
62 * connecting them.
63 */
64class BasicBlockNode : public GraphNode {
65public:
69 bool entry = false,
70 bool exit = false);
71 explicit BasicBlockNode(
72 TTAProgram::BasicBlock& bb, bool scheduled = false,
73 bool refsUpdated = false,
74 int originalStartAddress = 0, bool loopScheduled = false);
75 virtual ~BasicBlockNode();
76
77 bool isBasicBlockNode() const { return true; }
78 bool isNormalBB() const;
79 bool isEntryBB() const;
80 bool isExitBB() const;
81
82 std::string toString() const;
83
86
87 bool hasOriginalAddress() const;
90
92
93 bool isScheduled() const { return scheduled_; }
94 void setScheduled(bool state=true) { scheduled_ = state;}
95
96 std::pair<TTAProgram::Move*,TTAProgram::Move*> findJumps();
97 void updateHWloopLength(unsigned len);
98
100
101 bool isLoopScheduled() const { return loopScheduled_; }
103 void setBBOwnership(bool ownership = true) { bbOwned_ = ownership; }
104
105 /// Set true if the bbn is known to be a loop body of a hwloop with
106 /// loop pattern- preheader BB -> loop body (single BB) -> tail BB.
107 /// Furthermore, preheader should use HWLOOP instruction for its
108 /// fallthrough jump to its loop body.
109 void
110 setHWLoop(bool hwloop = true) {
111 isHardwareLoop_ = hwloop;
112 }
113 bool
114 isHWLoop() const {
115 return isHardwareLoop_;
116 }
117
118 // Ordering of basic blocks in a procedure.
119 // These are NULL if not set/decided.
120 const BasicBlockNode* successor() const { return successor_; }
121 const BasicBlockNode* predecessor() const { return predecessor_; }
124
125 void link(BasicBlockNode* succ);
126
127 int maximumSize() const;
128 void setMaximumSize(int sz) { maximumSize_ = sz; }
129private:
130 /// start address of the original basic block, used for reconstructing
131 /// the original program after modifying the CFG and its nodes
133 /// end address of the original basic block, used for reconstructing
134 /// the original program after modifying the CFG and its nodes
136 /// not all basic blocks have original addresses (completely new
137 /// basic blocks, etc.), this flag is true in case it does
139 /// the actual payload data of the graph node (the basic block)
141 /// true if the BasicBlock is owned by the BasicBlockNode
143 /// true if this is an entry basic block (not real one)
144 bool entry_;
145 /// true if this is an exit basic block (not real one)
146 bool exit_;
147
150 // if this bb was scheduled with loop scheduler
152 /// true if this bb is known to be a hwloop body
154
157
158 /// Maximum number of instructions this can consume when scheduled.
160};
161
162#endif
UInt32 InstructionAddress
Definition BaseType.hh:175
BasicBlockNode * predecessor_
void setScheduled(bool state=true)
bool isLoopScheduled() const
TTAProgram::BasicBlock & basicBlock()
const TTAProgram::BasicBlockStatistics & statistics()
bool isNormalBB() const
InstructionAddress originalEndAddress() const
virtual ~BasicBlockNode()
bool isHardwareLoop_
true if this bb is known to be a hwloop body
void link(BasicBlockNode *succ)
bool isHWLoop() const
bool isBasicBlockNode() const
InstructionAddress originalStartAddress_
start address of the original basic block, used for reconstructing the original program after modifyi...
bool isExitBB() const
std::pair< TTAProgram::Move *, TTAProgram::Move * > findJumps()
bool hasOriginalAddress_
not all basic blocks have original addresses (completely new basic blocks, etc.), this flag is true i...
bool isEntryBB() const
bool bbOwned_
true if the BasicBlock is owned by the BasicBlockNode
BasicBlockNode * successor()
InstructionAddress originalStartAddress() const
int maximumSize_
Maximum number of instructions this can consume when scheduled.
int maximumSize() const
void setMaximumSize(int sz)
TTAProgram::BasicBlock * basicBlock_
the actual payload data of the graph node (the basic block)
const BasicBlockNode * predecessor() const
InstructionAddress originalEndAddress_
end address of the original basic block, used for reconstructing the original program after modifying...
std::string toString() const
bool exit_
true if this is an exit basic block (not real one)
bool isScheduled() const
const BasicBlockNode * successor() const
BasicBlockNode * successor_
bool hasOriginalAddress() const
void updateHWloopLength(unsigned len)
void updateReferencesFromProcToCfg(TTAProgram::Program &prog)
bool entry_
true if this is an entry basic block (not real one)
void setBBOwnership(bool ownership=true)
void setHWLoop(bool hwloop=true)
Set true if the bbn is known to be a loop body of a hwloop with loop pattern- preheader BB -> loop bo...
BasicBlockNode * predecessor()