OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
BasicBlockNode Class Reference

#include <BasicBlockNode.hh>

Inheritance diagram for BasicBlockNode:
Inheritance graph
Collaboration diagram for BasicBlockNode:
Collaboration graph

Public Member Functions

 BasicBlockNode (InstructionAddress originalStartAddress, InstructionAddress originalEndAddress, bool entry=false, bool exit=false)
 
 BasicBlockNode (TTAProgram::BasicBlock &bb, bool scheduled=false, bool refsUpdated=false, int originalStartAddress=0, bool loopScheduled=false)
 
virtual ~BasicBlockNode ()
 
bool isBasicBlockNode () const
 
bool isNormalBB () const
 
bool isEntryBB () const
 
bool isExitBB () const
 
std::string toString () const
 
TTAProgram::BasicBlockbasicBlock ()
 
const TTAProgram::BasicBlockbasicBlock () const
 
bool hasOriginalAddress () const
 
InstructionAddress originalStartAddress () const
 
InstructionAddress originalEndAddress () const
 
const TTAProgram::BasicBlockStatisticsstatistics ()
 
bool isScheduled () const
 
void setScheduled (bool state=true)
 
std::pair< TTAProgram::Move *, TTAProgram::Move * > findJumps ()
 
void updateHWloopLength (unsigned len)
 
void updateReferencesFromProcToCfg (TTAProgram::Program &prog)
 
bool isLoopScheduled () const
 
void setLoopScheduled ()
 
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 body (single BB) -> tail BB. Furthermore, preheader should use HWLOOP instruction for its fallthrough jump to its loop body.
 
bool isHWLoop () const
 
const BasicBlockNodesuccessor () const
 
const BasicBlockNodepredecessor () const
 
BasicBlockNodesuccessor ()
 
BasicBlockNodepredecessor ()
 
void link (BasicBlockNode *succ)
 
int maximumSize () const
 
void setMaximumSize (int sz)
 
- Public Member Functions inherited from GraphNode
 GraphNode (int nodeID)
 
 GraphNode ()
 
virtual ~GraphNode ()
 
virtual GraphNodeclone () const
 
int nodeID () const
 
virtual std::string dotString () const
 

Private Attributes

InstructionAddress originalStartAddress_
 start address of the original basic block, used for reconstructing the original program after modifying the CFG and its nodes
 
InstructionAddress originalEndAddress_
 end address of the original basic block, used for reconstructing the original program after modifying the CFG and its nodes
 
bool hasOriginalAddress_
 not all basic blocks have original addresses (completely new basic blocks, etc.), this flag is true in case it does
 
TTAProgram::BasicBlockbasicBlock_
 the actual payload data of the graph node (the basic block)
 
bool bbOwned_
 true if the BasicBlock is owned by the BasicBlockNode
 
bool entry_
 true if this is an entry basic block (not real one)
 
bool exit_
 true if this is an exit basic block (not real one)
 
bool scheduled_
 
bool refsUpdated_
 
bool loopScheduled_
 
bool isHardwareLoop_
 true if this bb is known to be a hwloop body
 
BasicBlockNodesuccessor_
 
BasicBlockNodepredecessor_
 
int maximumSize_
 Maximum number of instructions this can consume when scheduled.
 

Detailed Description

Node of the control flow graph. Each node represents one basic block.

A basic block is defined as an ordered sequence of adjacent instructions in which only the first can be target of jump and only the last one (save jump delay slots) can contain jumps.

Note
Instructions that contain function calls are control flow barriers also. For now they split basic blocks into two, with special type of edge connecting them.

Definition at line 64 of file BasicBlockNode.hh.

Constructor & Destructor Documentation

◆ BasicBlockNode() [1/2]

BasicBlockNode::BasicBlockNode ( InstructionAddress  originalStartAddress,
InstructionAddress  originalEndAddress,
bool  entry = false,
bool  exit = false 
)

Constructor.

Parameters
originalStartAddressThe starting address of the basic block in the original program (address of the first instruction).
originalEndAddressThe ending address of the basic block in the original program (address of the last instruction).
entryTrue if the basic block is a (pseudo) entry basic block.
exitTrue if the basic block is a (pseudo) exit basic block.

Definition at line 60 of file BasicBlockNode.cc.

64 :
69 bbOwned_(true),
70 entry_(entry), exit_(exit),
71 scheduled_(false), refsUpdated_(false), loopScheduled_(false),
72 isHardwareLoop_(false),
73 successor_(NULL), predecessor_(NULL), maximumSize_(INT_MAX) {
74
75 if (entry || exit) {
76 hasOriginalAddress_ = false;
77 } else {
79 throw InvalidData(
80 __FILE__, __LINE__, __func__,
81 "Basic block start address is higher then it's end address");
82 }
83 }
84}
#define __func__
BasicBlockNode * predecessor_
InstructionAddress originalEndAddress() const
bool isHardwareLoop_
true if this bb is known to be a hwloop body
InstructionAddress originalStartAddress_
start address of the original basic block, used for reconstructing the original program after modifyi...
bool hasOriginalAddress_
not all basic blocks have original addresses (completely new basic blocks, etc.), this flag is true i...
bool bbOwned_
true if the BasicBlock is owned by the BasicBlockNode
InstructionAddress originalStartAddress() const
int maximumSize_
Maximum number of instructions this can consume when scheduled.
TTAProgram::BasicBlock * basicBlock_
the actual payload data of the graph node (the basic block)
InstructionAddress originalEndAddress_
end address of the original basic block, used for reconstructing the original program after modifying...
bool exit_
true if this is an exit basic block (not real one)
BasicBlockNode * successor_
bool entry_
true if this is an entry basic block (not real one)

References __func__, hasOriginalAddress_, originalEndAddress(), and originalStartAddress().

Here is the call graph for this function:

◆ BasicBlockNode() [2/2]

BasicBlockNode::BasicBlockNode ( TTAProgram::BasicBlock bb,
bool  scheduled = false,
bool  refsUpdated = false,
int  originalStartAddress = 0,
bool  loopScheduled = false 
)
explicit

Constructor.

A wrapper for BasicBlock. When constructed with this one, the given bb will not be deleted in the destructor.

Definition at line 92 of file BasicBlockNode.cc.

94 :
96 hasOriginalAddress_(false), basicBlock_(&bb), bbOwned_(false),
97 entry_(false), exit_(false),
98 scheduled_(scheduled), refsUpdated_(refsUpdated),
99 loopScheduled_(loopScheduled),
100 isHardwareLoop_(false),
101 successor_(NULL), predecessor_(NULL), maximumSize_(INT_MAX) {
102}

◆ ~BasicBlockNode()

BasicBlockNode::~BasicBlockNode ( )
virtual

Destructor.

Definition at line 107 of file BasicBlockNode.cc.

107 {
108 if (bbOwned_)
109 delete basicBlock_;
110 basicBlock_ = NULL;
111
112 if (successor_ != nullptr && successor_->predecessor_ == this) {
114 }
115 if (predecessor_ != nullptr && predecessor_->successor_ == this) {
117 }
118}

References basicBlock_, bbOwned_, predecessor_, and successor_.

Member Function Documentation

◆ basicBlock() [1/2]

TTAProgram::BasicBlock & BasicBlockNode::basicBlock ( )

Returns the basic block object this node represents.

Returns
The basic block object (can be modified).

Definition at line 126 of file BasicBlockNode.cc.

126 {
127 return *basicBlock_;
128}

References basicBlock_.

Referenced by SimpleIfConverter::addJump(), LoopAnalyzer::analyze(), Peel2BBLoops::appendBB(), CopyingDelaySlotFiller::bbnScheduled(), LLVMTCEDataDependenceGraphBuilder::buildFromCFG(), llvm::LLVMTCEIRBuilder::buildTCECFG(), PreOptimizer::cfgAllowsJumpReversal(), DataDependenceGraphBuilder::clearUnneededBookkeeping(), CopyingDelaySlotFiller::collectMoves(), DataDependenceGraphBuilder::constructIndividualBB(), DataDependenceGraphBuilder::constructIndividualFromInlineAsmBB(), ControlFlowGraph::convertBBRefsToInstRefs(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToLLVMMachineFunction(), ControlFlowGraph::copyToProcedure(), RegisterCopyAdder::createAntidepsForReg(), BFRegCopy::createAntidepsForReg(), ProgramDependenceGraph::createJump(), DataDependenceGraphBuilder::createTriggerDependencies(), SimpleIfConverter::detectDiamond(), SimpleIfConverter::detectTriangleViaFt(), SimpleIfConverter::detectTriangleViaJump(), ControlFlowGraphPass::executeBasicBlockPass(), CopyingDelaySlotFiller::fillDelaySlots(), ControlFlowGraph::findJumpAddress(), ControlFlowGraph::findLimmWrite(), DataDependenceGraphBuilder::findStaticRegisters(), CopyingDelaySlotFiller::finishBB(), DataDependenceGraph::fixInterBBAntiEdges(), llvm::LLVMTCEIRBuilder::fixJumpTableDestinations(), BBSchedulerController::handleBasicBlock(), BBSchedulerController::handleBBNode(), ScheduleEstimator::handleControlFlowGraph(), CallsToJumps::handleControlFlowGraph(), DataDependenceGraphBuilder::initializeBBStates(), ControlDependenceNode::instruction(), ControlDependenceNode::instructionCount(), ControlFlowGraph::jumpToBBN(), maximumSize(), ControlFlowGraph::mergeNodes(), LoopPrologAndEpilogBuilder::moveJumpDestination(), ControlFlowGraph::optimizeBBOrdering(), Peel2BBLoops::performCodeMotion(), DataDependenceGraphBuilder::processEntryNode(), ProgramDependenceGraph::processLoopClose(), DataDependenceGraphBuilder::processMemUse(), DataDependenceGraphBuilder::processMemWrite(), ProgramDependenceGraph::processPredicate(), ProgramDependenceGraph::processRegion(), DataDependenceGraphBuilder::processRegUse(), DataDependenceGraphBuilder::processRegWrite(), ControlFlowGraph::removeUnreachableNodes(), BF2Scheduler::revertBBLiveRangeBookkeepingForDestination(), BF2Scheduler::revertBBLiveRangeBookkeepingForSource(), DataDependenceGraphBuilder::setSucceedingPredeps(), DataDependenceGraphBuilder::setSucceedingPredepsForBB(), ControlFlowGraph::splitBasicBlockAtIndex(), ControlFlowGraph::splitBasicBlocksWithCallsAndRefs(), ControlFlowGraph::splitBB(), SimpleIfConverter::successors(), toString(), CopyingDelaySlotFiller::tryToFillSlots(), DataDependenceGraphBuilder::updateBB(), CopyingDelaySlotFiller::updateFTBBAndCfg(), CopyingDelaySlotFiller::updateJumpsAndCfg(), DataDependenceGraphBuilder::updateMemAndFuAliveAfter(), DataDependenceGraphBuilder::updateMemUse(), DataDependenceGraphBuilder::updateMemWrite(), DataDependenceGraphBuilder::updatePreceedingRegistersUsedAfter(), DataDependenceGraphBuilder::updateRegistersAliveAfter(), and DataDependenceGraphBuilder::updateRegistersUsedInOrAfter().

◆ basicBlock() [2/2]

const TTAProgram::BasicBlock & BasicBlockNode::basicBlock ( ) const

Returns the basic block object this node represents (const version).

Returns
The basic block object (can be modified).

Definition at line 136 of file BasicBlockNode.cc.

136 {
137 return *basicBlock_;
138}

References basicBlock_.

◆ findJumps()

std::pair< TTAProgram::Move *, TTAProgram::Move * > BasicBlockNode::findJumps ( )

Finds jumps from a BasicBlockNode.

Returns
second is last jump or NULL if no jumps, first NULL or first jump if the BB has two jumps

Definition at line 283 of file BasicBlockNode.cc.

283 {
284 std::pair<TTAProgram::Move*, TTAProgram::Move*> moves(NULL,NULL);
285 for (int i = basicBlock_->instructionCount()-1; i >= 0; i--) {
287 for (int j = 0; j < ins.moveCount(); j++) {
288 TTAProgram::Move& move = ins.move(j);
289 if (move.isJump()) {
290 if (moves.second == NULL) {
291 moves.second = &move;
292 } else {
293 moves.first = &move;
294 return moves;
295 break;
296 }
297 }
298 }
299 }
300 return moves;
301}
virtual int instructionCount() const
virtual Instruction & instructionAtIndex(int index) const
Move & move(int i) const
bool isJump() const
Definition Move.cc:164

References basicBlock_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isJump(), TTAProgram::Instruction::move(), and TTAProgram::Instruction::moveCount().

Here is the call graph for this function:

◆ hasOriginalAddress()

bool BasicBlockNode::hasOriginalAddress ( ) const

Returns true if the original adress of this basic block is known.

The basic block might not have original program address in case it's a pseudo basic block, or a completely new basic block which did not exist in the original program.

Returns
True in case original address is known.

Definition at line 150 of file BasicBlockNode.cc.

150 {
151 return hasOriginalAddress_;
152}

References hasOriginalAddress_.

Referenced by ProcedurePass::copyCfgToProcedure().

◆ isBasicBlockNode()

bool BasicBlockNode::isBasicBlockNode ( ) const
inline

Definition at line 77 of file BasicBlockNode.hh.

77{ return true; }

◆ isEntryBB()

bool BasicBlockNode::isEntryBB ( ) const

Returns true if the basic block is representing artificial Entry node.

Returns
True if the basic block is artificially added Entry node.

Definition at line 248 of file BasicBlockNode.cc.

248 {
249 return entry_;
250}

References entry_.

Referenced by ControlDependenceGraph::createPostDominanceTree(), ControlDependenceGraph::detectControlDependencies(), ControlFlowGraph::entryNode(), ControlFlowGraph::fallThroughPredecessor(), ControlDependenceNode::isEntryNode(), and toString().

◆ isExitBB()

bool BasicBlockNode::isExitBB ( ) const

Return true if basic block is representing artificial Exit node.

Returns
True if basic block is Exit node.

Definition at line 257 of file BasicBlockNode.cc.

257 {
258 return exit_;
259}

References exit_.

Referenced by ControlFlowGraph::exitNode(), ControlFlowGraph::fallThruSuccessor(), ControlDependenceNode::isExitNode(), and toString().

◆ isHWLoop()

bool BasicBlockNode::isHWLoop ( ) const
inline

Definition at line 114 of file BasicBlockNode.hh.

114 {
115 return isHardwareLoop_;
116 }

References isHardwareLoop_.

Referenced by BBSchedulerController::executeDDGPass(), and CopyingDelaySlotFiller::fillDelaySlots().

◆ isLoopScheduled()

bool BasicBlockNode::isLoopScheduled ( ) const
inline

Definition at line 101 of file BasicBlockNode.hh.

101{ return loopScheduled_; }

References loopScheduled_.

Referenced by CopyingDelaySlotFiller::fillDelaySlots().

◆ isNormalBB()

bool BasicBlockNode::isNormalBB ( ) const

Returns true if object is ordinary basic block containing code snippet with instructions.

Returns
True if the basic block is normal storage for instructions.

Definition at line 239 of file BasicBlockNode.cc.

239 {
240 return (!entry_) && (!exit_);
241}

References entry_, and exit_.

Referenced by ControlFlowGraph::allScheduledInBetween(), CopyingDelaySlotFiller::areAllJumpPredsFilled(), CopyingDelaySlotFiller::areAllJumpPredsScheduled(), DataDependenceGraphBuilder::clearUnneededBookkeeping(), SimpleIfConverter::combineBlocks(), ControlFlowGraph::convertBBRefsToInstRefs(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToLLVMMachineFunction(), ControlFlowGraph::copyToProcedure(), ProgramDependenceGraph::createJump(), SimpleIfConverter::detectDiamond(), ControlFlowGraphPass::executeBasicBlockPass(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::fillDelaySlots(), CompiledSimCodeGenerator::findBasicBlocks(), ControlFlowGraph::findLimmWrite(), ControlFlowGraph::findReachableNodes(), ControlFlowGraph::findRelJumpDistance(), DataDependenceGraphBuilder::findStaticRegisters(), ControlFlowGraph::findUnreachableNodes(), CopyingDelaySlotFiller::finishBB(), ControlFlowGraph::firstNormalNode(), BBSchedulerController::handleBBNode(), ScheduleEstimator::handleControlFlowGraph(), CallsToJumps::handleControlFlowGraph(), DataDependenceGraphBuilder::initializeBBStates(), ControlFlowGraph::jumpToBBN(), ControlFlowGraph::mergeNodes(), CopyingDelaySlotFiller::mightFillIncomingTo(), ControlFlowGraph::optimizeBBOrdering(), SimpleIfConverter::searchCandidate(), statistics(), Peel2BBLoops::testIf2BBLoop(), toString(), and updateReferencesFromProcToCfg().

◆ isScheduled()

bool BasicBlockNode::isScheduled ( ) const
inline

◆ link()

void BasicBlockNode::link ( BasicBlockNode succ)

Definition at line 352 of file BasicBlockNode.cc.

352 {
353 // this is already the successor!
354 if (successor == successor_) {
356 return;
357 }
358
359 // link the new one between previous successor
360 if (successor_) {
361 auto oldSucc = successor_;
362 oldSucc->predecessor_ = successor;
363 successor->successor_ = oldSucc;
364 }
365
366 if (successor != NULL) {
367 // make sure no inconsistent links.
368 if (successor->predecessor_ != NULL &&
371 }
372 successor->predecessor_ = this;
373 }
375}
#define assert(condition)
const BasicBlockNode * successor() const

References assert, predecessor_, successor(), and successor_.

Referenced by ControlFlowGraph::optimizeBBOrdering(), and ControlFlowGraph::splitBB().

Here is the call graph for this function:

◆ maximumSize()

int BasicBlockNode::maximumSize ( ) const

Returns maximum size of a basic block. If scheduled, return the actual size.

If not scheduled, return the size stored in max size field.

Definition at line 384 of file BasicBlockNode.cc.

384 {
385 return scheduled_ ?
389}
TTAProgram::BasicBlock & basicBlock()
int skippedFirstInstructions() const
Definition BasicBlock.cc:88

References basicBlock(), TTAProgram::CodeSnippet::instructionCount(), maximumSize_, scheduled_, and TTAProgram::BasicBlock::skippedFirstInstructions().

Referenced by ControlFlowGraph::findRelJumpDistance().

Here is the call graph for this function:

◆ originalEndAddress()

InstructionAddress BasicBlockNode::originalEndAddress ( ) const

The end address of the basic block in the original program.

Returned value is undefined in case hasOriginalAddress() returns false.

Returns
The original ending address of the basic block.

Definition at line 174 of file BasicBlockNode.cc.

174 {
175 return originalEndAddress_;
176}

References originalEndAddress_.

Referenced by BasicBlockNode(), DataDependenceGraphBuilder::constructIndividualBB(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::createControlFlowEdge(), and CompiledSimCodeGenerator::findBasicBlocks().

◆ originalStartAddress()

InstructionAddress BasicBlockNode::originalStartAddress ( ) const

The starting address of the basic block in the original program.

Returned value is undefined in case hasOriginalAddress() returns false.

Returns
The original starting address of the basic block.

Definition at line 162 of file BasicBlockNode.cc.

162 {
164}

References originalStartAddress_.

Referenced by BasicBlockNode(), LoopPrologAndEpilogBuilder::build(), DataDependenceGraphBuilder::constructIndividualBB(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::createControlFlowEdge(), CompiledSimCodeGenerator::findBasicBlocks(), and CopyingDelaySlotFiller::mightFillIncomingTo().

◆ predecessor() [1/2]

BasicBlockNode * BasicBlockNode::predecessor ( )
inline

Definition at line 123 of file BasicBlockNode.hh.

123{ return predecessor_; }

References predecessor_.

◆ predecessor() [2/2]

const BasicBlockNode * BasicBlockNode::predecessor ( ) const
inline

Definition at line 121 of file BasicBlockNode.hh.

121{ return predecessor_; }

References predecessor_.

Referenced by BBSchedulerController::executeDDGPass(), and ControlFlowGraph::findRelJumpDistance().

◆ setBBOwnership()

void BasicBlockNode::setBBOwnership ( bool  ownership = true)
inline

Definition at line 103 of file BasicBlockNode.hh.

103{ bbOwned_ = ownership; }

References bbOwned_.

Referenced by llvm::LLVMTCEIRBuilder::buildTCECFG().

◆ setHWLoop()

void BasicBlockNode::setHWLoop ( bool  hwloop = true)
inline

Set true if the bbn is known to be a loop body of a hwloop with loop pattern- preheader BB -> loop body (single BB) -> tail BB. Furthermore, preheader should use HWLOOP instruction for its fallthrough jump to its loop body.

Definition at line 110 of file BasicBlockNode.hh.

110 {
111 isHardwareLoop_ = hwloop;
112 }

References isHardwareLoop_.

Referenced by llvm::LLVMTCEIRBuilder::buildTCECFG().

◆ setLoopScheduled()

void BasicBlockNode::setLoopScheduled ( )
inline

Definition at line 102 of file BasicBlockNode.hh.

102{ loopScheduled_ = true; }

References loopScheduled_.

◆ setMaximumSize()

void BasicBlockNode::setMaximumSize ( int  sz)
inline

Definition at line 128 of file BasicBlockNode.hh.

128{ maximumSize_ = sz; }

References maximumSize_.

Referenced by ScheduleEstimator::handleControlFlowGraph().

◆ setScheduled()

void BasicBlockNode::setScheduled ( bool  state = true)
inline

◆ statistics()

const TTAProgram::BasicBlockStatistics & BasicBlockNode::statistics ( )

Updates and returns the statistics about Basic Block

Returns
refrence to structure with information about basic block

Definition at line 267 of file BasicBlockNode.cc.

267 {
268 if (isNormalBB()) {
269 return basicBlock_->statistics();
270 }
273 return *bbs;
274}
bool isNormalBB() const
const BasicBlockStatistics & statistics()

References basicBlock_, isNormalBB(), and TTAProgram::BasicBlock::statistics().

Here is the call graph for this function:

◆ successor() [1/2]

BasicBlockNode * BasicBlockNode::successor ( )
inline

Definition at line 122 of file BasicBlockNode.hh.

122{ return successor_; }

References successor_.

◆ successor() [2/2]

const BasicBlockNode * BasicBlockNode::successor ( ) const
inline

Definition at line 120 of file BasicBlockNode.hh.

120{ return successor_; }

References successor_.

Referenced by ControlFlowGraph::allScheduledInBetween(), ControlFlowGraph::findRelJumpDistance(), and link().

◆ toString()

std::string BasicBlockNode::toString ( ) const
virtual

Returns the description of basic block as string.

Note
Used in writting graph to .dot file.
Returns
The description of basic block

Reimplemented from GraphNode.

Definition at line 185 of file BasicBlockNode.cc.

185 {
186
187 if (isNormalBB()) {
188 TCEString content = "";
189 int iCount = basicBlock().instructionCount();
190 if (iCount > basicBlock().skippedFirstInstructions()) {
191 const TTAProgram::Instruction& first =
193 basicBlock().skippedFirstInstructions());
194 if (first.moveCount() > 0 &&
195 first.move(0).hasSourceLineNumber())
196 content << " srclines: " << first.move(0).sourceLineNumber();
197
198 const TTAProgram::Instruction& last =
200 if (last.moveCount() > 0 &&
201 last.move(0).hasSourceLineNumber())
202 content << "-" << last.move(0).sourceLineNumber();
203
204 content << "\\n0: ";
205 content << first.toString();
206
207 // print at most last 4 instructions to (usually) print out the
208 for (int i = 3; i >= 0; --i) {
209 int loc = iCount - i - 1;
210 if (loc <= basicBlock().skippedFirstInstructions())
211 continue;
212 const TTAProgram::Instruction& instr =
214 if (i == 3)
215 content << "\\n...\\n";
216 content << "\\n";
217 content << loc << ": ";
218 content << instr.toString();
219 }
220 }
221 return content;
222 } else if (isEntryBB()) {
223 return "Entry";
224 } else if (isExitBB()) {
225 return "Exit";
226 }
227 return "";
228}
bool isExitBB() const
bool isEntryBB() const
virtual Instruction & lastInstruction() const
std::string toString() const
bool hasSourceLineNumber() const
Definition Move.cc:445
int sourceLineNumber() const
Definition Move.cc:459

References basicBlock(), TTAProgram::Move::hasSourceLineNumber(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), isEntryBB(), isExitBB(), isNormalBB(), TTAProgram::CodeSnippet::lastInstruction(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Move::sourceLineNumber(), and TTAProgram::Instruction::toString().

Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), ProgramDependenceGraph::addLeafEdges(), LoopPrologAndEpilogBuilder::addPrologFromRM(), ProgramDependenceGraph::copyRegionEECComponent(), ControlFlowGraph::copyToLLVMMachineFunction(), ControlFlowGraph::copyToProcedure(), ProgramDependenceGraph::createJump(), ControlDependenceGraph::detectControlDependencies(), BBSchedulerController::handleBasicBlock(), ControlFlowGraph::optimizeBBOrdering(), ControlFlowGraph::reverseGuardOnOutEdges(), SimpleIfConverter::successors(), and ControlDependenceNode::toString().

Here is the call graph for this function:

◆ updateHWloopLength()

void BasicBlockNode::updateHWloopLength ( unsigned  len)

Update hwloop instruction count.

Definition at line 308 of file BasicBlockNode.cc.

308 {
309 for (int i = 0; i < basicBlock_->instructionCount(); i++) {
311 for (int j = 0; j < ins.moveCount(); j++) {
312 TTAProgram::Move& move = ins.move(j);
313 if (move.toString().find("hwloop") != std::string::npos &&
314 move.isTriggering()) {
315 // Only process hwloop instr-length setting
316 auto& s = move.source();
317 assert(s.isImmediate() && "hwloop instruction should be imm");
318 move.setSource(
320 }
321 }
322 }
323}
void setSource(Terminal *src)
Definition Move.cc:312
std::string toString() const
Definition Move.cc:436
Terminal & source() const
Definition Move.cc:302
bool isTriggering() const
Definition Move.cc:284

References assert, basicBlock_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isTriggering(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), and TTAProgram::Move::toString().

Referenced by BBSchedulerController::executeDDGPass().

Here is the call graph for this function:

◆ updateReferencesFromProcToCfg()

void BasicBlockNode::updateReferencesFromProcToCfg ( TTAProgram::Program prog)

Updates instruction references to this BB from procedure to cfg

Parameters
progprogram where instructions are.

Definition at line 331 of file BasicBlockNode.cc.

331 {
332
333 if (refsUpdated_) {
334 return;
335 }
338
339 if (isNormalBB()) {
340 if (basicBlock_->instructionCount() > 0) {
344 if (refManager.hasReference(oldIns)) {
345 refManager.replace(oldIns, newIns);
346 }
347 }
348 }
349 refsUpdated_ = true;
350}
virtual Instruction & firstInstruction() const
void replace(Instruction &insA, Instruction &insB)
Instruction & instructionAt(InstructionAddress address) const
Definition Program.cc:374
InstructionReferenceManager & instructionReferenceManager() const
Definition Program.cc:688

References basicBlock_, TTAProgram::CodeSnippet::firstInstruction(), TTAProgram::InstructionReferenceManager::hasReference(), TTAProgram::Program::instructionAt(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Program::instructionReferenceManager(), isNormalBB(), originalStartAddress_, refsUpdated_, and TTAProgram::InstructionReferenceManager::replace().

Referenced by ControlFlowGraph::updateReferencesFromProcToCfg().

Here is the call graph for this function:

Member Data Documentation

◆ basicBlock_

TTAProgram::BasicBlock* BasicBlockNode::basicBlock_
private

the actual payload data of the graph node (the basic block)

Definition at line 140 of file BasicBlockNode.hh.

Referenced by basicBlock(), basicBlock(), findJumps(), statistics(), updateHWloopLength(), updateReferencesFromProcToCfg(), and ~BasicBlockNode().

◆ bbOwned_

bool BasicBlockNode::bbOwned_
private

true if the BasicBlock is owned by the BasicBlockNode

Definition at line 142 of file BasicBlockNode.hh.

Referenced by setBBOwnership(), and ~BasicBlockNode().

◆ entry_

bool BasicBlockNode::entry_
private

true if this is an entry basic block (not real one)

Definition at line 144 of file BasicBlockNode.hh.

Referenced by isEntryBB(), and isNormalBB().

◆ exit_

bool BasicBlockNode::exit_
private

true if this is an exit basic block (not real one)

Definition at line 146 of file BasicBlockNode.hh.

Referenced by isExitBB(), and isNormalBB().

◆ hasOriginalAddress_

bool BasicBlockNode::hasOriginalAddress_
private

not all basic blocks have original addresses (completely new basic blocks, etc.), this flag is true in case it does

Definition at line 138 of file BasicBlockNode.hh.

Referenced by BasicBlockNode(), and hasOriginalAddress().

◆ isHardwareLoop_

bool BasicBlockNode::isHardwareLoop_
private

true if this bb is known to be a hwloop body

Definition at line 153 of file BasicBlockNode.hh.

Referenced by isHWLoop(), and setHWLoop().

◆ loopScheduled_

bool BasicBlockNode::loopScheduled_
private

Definition at line 151 of file BasicBlockNode.hh.

Referenced by isLoopScheduled(), and setLoopScheduled().

◆ maximumSize_

int BasicBlockNode::maximumSize_
private

Maximum number of instructions this can consume when scheduled.

Definition at line 159 of file BasicBlockNode.hh.

Referenced by maximumSize(), and setMaximumSize().

◆ originalEndAddress_

InstructionAddress BasicBlockNode::originalEndAddress_
private

end address of the original basic block, used for reconstructing the original program after modifying the CFG and its nodes

Definition at line 135 of file BasicBlockNode.hh.

Referenced by originalEndAddress().

◆ originalStartAddress_

InstructionAddress BasicBlockNode::originalStartAddress_
private

start address of the original basic block, used for reconstructing the original program after modifying the CFG and its nodes

Definition at line 132 of file BasicBlockNode.hh.

Referenced by originalStartAddress(), and updateReferencesFromProcToCfg().

◆ predecessor_

BasicBlockNode* BasicBlockNode::predecessor_
private

Definition at line 156 of file BasicBlockNode.hh.

Referenced by link(), predecessor(), predecessor(), and ~BasicBlockNode().

◆ refsUpdated_

bool BasicBlockNode::refsUpdated_
private

Definition at line 149 of file BasicBlockNode.hh.

Referenced by updateReferencesFromProcToCfg().

◆ scheduled_

bool BasicBlockNode::scheduled_
private

Definition at line 148 of file BasicBlockNode.hh.

Referenced by isScheduled(), maximumSize(), and setScheduled().

◆ successor_

BasicBlockNode* BasicBlockNode::successor_
private

Definition at line 155 of file BasicBlockNode.hh.

Referenced by link(), successor(), successor(), and ~BasicBlockNode().


The documentation for this class was generated from the following files: