OpenASIP
2.0
|
#include <BasicBlockNode.hh>
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::BasicBlock & | basicBlock () |
const TTAProgram::BasicBlock & | basicBlock () const |
bool | hasOriginalAddress () const |
InstructionAddress | originalStartAddress () const |
InstructionAddress | originalEndAddress () const |
const TTAProgram::BasicBlockStatistics & | statistics () |
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. More... | |
bool | isHWLoop () const |
const BasicBlockNode * | successor () const |
const BasicBlockNode * | predecessor () const |
BasicBlockNode * | successor () |
BasicBlockNode * | predecessor () |
void | link (BasicBlockNode *succ) |
int | maximumSize () const |
void | setMaximumSize (int sz) |
Public Member Functions inherited from GraphNode | |
GraphNode (int nodeID) | |
GraphNode () | |
virtual | ~GraphNode () |
virtual GraphNode * | clone () 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 More... | |
InstructionAddress | originalEndAddress_ |
end address of the original basic block, used for reconstructing the original program after modifying the CFG and its nodes More... | |
bool | hasOriginalAddress_ |
not all basic blocks have original addresses (completely new basic blocks, etc.), this flag is true in case it does More... | |
TTAProgram::BasicBlock * | basicBlock_ |
the actual payload data of the graph node (the basic block) More... | |
bool | bbOwned_ |
true if the BasicBlock is owned by the BasicBlockNode More... | |
bool | entry_ |
true if this is an entry basic block (not real one) More... | |
bool | exit_ |
true if this is an exit basic block (not real one) More... | |
bool | scheduled_ |
bool | refsUpdated_ |
bool | loopScheduled_ |
bool | isHardwareLoop_ |
true if this bb is known to be a hwloop body More... | |
BasicBlockNode * | successor_ |
BasicBlockNode * | predecessor_ |
int | maximumSize_ |
Maximum number of instructions this can consume when scheduled. More... | |
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.
Definition at line 64 of file BasicBlockNode.hh.
BasicBlockNode::BasicBlockNode | ( | InstructionAddress | originalStartAddress, |
InstructionAddress | originalEndAddress, | ||
bool | entry = false , |
||
bool | exit = false |
||
) |
Constructor.
originalStartAddress | The starting address of the basic block in the original program (address of the first instruction). |
originalEndAddress | The ending address of the basic block in the original program (address of the last instruction). |
entry | True if the basic block is a (pseudo) entry basic block. |
exit | True if the basic block is a (pseudo) exit basic block. |
Definition at line 60 of file BasicBlockNode.cc.
References __func__, hasOriginalAddress_, originalEndAddress(), and originalStartAddress().
|
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.
|
virtual |
Destructor.
Definition at line 107 of file BasicBlockNode.cc.
References basicBlock_, bbOwned_, predecessor_, and successor_.
const TTAProgram::BasicBlock & BasicBlockNode::basicBlock | ( | ) |
Returns the basic block object this node represents.
Returns the basic block object this node represents (const version).
Definition at line 126 of file BasicBlockNode.cc.
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(), BFRegCopy::createAntidepsForReg(), RegisterCopyAdder::createAntidepsForReg(), ControlFlowGraph::createBlock(), 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(), CallsToJumps::handleControlFlowGraph(), ScheduleEstimator::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().
const TTAProgram::BasicBlock& BasicBlockNode::basicBlock | ( | ) | const |
std::pair< TTAProgram::Move *, TTAProgram::Move * > BasicBlockNode::findJumps | ( | ) |
Finds jumps from a BasicBlockNode.
Definition at line 283 of file BasicBlockNode.cc.
References basicBlock_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Move::isJump(), TTAProgram::Instruction::move(), and TTAProgram::Instruction::moveCount().
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.
Definition at line 150 of file BasicBlockNode.cc.
References hasOriginalAddress_.
Referenced by ProcedurePass::copyCfgToProcedure().
|
inline |
Definition at line 77 of file BasicBlockNode.hh.
bool BasicBlockNode::isEntryBB | ( | ) | const |
Returns true if the basic block is representing artificial Entry node.
Definition at line 248 of file BasicBlockNode.cc.
References entry_.
Referenced by ControlDependenceGraph::createPostDominanceTree(), ControlDependenceGraph::detectControlDependencies(), ControlFlowGraph::entryNode(), ControlFlowGraph::fallThroughPredecessor(), ControlDependenceNode::isEntryNode(), and toString().
bool BasicBlockNode::isExitBB | ( | ) | const |
Return true if basic block is representing artificial Exit node.
Definition at line 257 of file BasicBlockNode.cc.
References exit_.
Referenced by ControlFlowGraph::exitNode(), ControlFlowGraph::fallThruSuccessor(), ControlDependenceNode::isExitNode(), and toString().
|
inline |
Definition at line 114 of file BasicBlockNode.hh.
References isHardwareLoop_.
Referenced by BBSchedulerController::executeDDGPass(), and CopyingDelaySlotFiller::fillDelaySlots().
|
inline |
Definition at line 101 of file BasicBlockNode.hh.
References loopScheduled_.
Referenced by CopyingDelaySlotFiller::fillDelaySlots().
bool BasicBlockNode::isNormalBB | ( | ) | const |
Returns true if object is ordinary basic block containing code snippet with instructions.
Definition at line 239 of file BasicBlockNode.cc.
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(), CompiledSimCodeGenerator::findBasicBlocks(), ControlFlowGraph::findLimmWrite(), ControlFlowGraph::findReachableNodes(), ControlFlowGraph::findRelJumpDistance(), DataDependenceGraphBuilder::findStaticRegisters(), ControlFlowGraph::findUnreachableNodes(), CopyingDelaySlotFiller::finishBB(), ControlFlowGraph::firstNormalNode(), BBSchedulerController::handleBBNode(), CallsToJumps::handleControlFlowGraph(), ScheduleEstimator::handleControlFlowGraph(), DataDependenceGraphBuilder::initializeBBStates(), ControlFlowGraph::jumpToBBN(), ControlFlowGraph::mergeNodes(), CopyingDelaySlotFiller::mightFillIncomingTo(), ControlFlowGraph::optimizeBBOrdering(), SimpleIfConverter::searchCandidate(), statistics(), ControlFlowGraph::statistics(), Peel2BBLoops::testIf2BBLoop(), toString(), and updateReferencesFromProcToCfg().
|
inline |
Definition at line 93 of file BasicBlockNode.hh.
References scheduled_.
Referenced by ControlFlowGraph::allScheduledInBetween(), DataDependenceGraphBuilder::constructIndividualBB(), DataDependenceGraphBuilder::constructIndividualFromInlineAsmBB(), ControlFlowGraphPass::executeBasicBlockPass(), BBSchedulerController::handleBBNode(), CallsToJumps::handleControlFlowGraph(), ScheduleEstimator::handleControlFlowGraph(), ControlFlowGraph::optimizeBBOrdering(), ControlFlowGraph::splitBasicBlockAtIndex(), and ControlFlowGraph::splitBB().
void BasicBlockNode::link | ( | BasicBlockNode * | succ | ) |
Definition at line 352 of file BasicBlockNode.cc.
References assert, predecessor_, successor(), and successor_.
Referenced by ControlFlowGraph::optimizeBBOrdering(), and ControlFlowGraph::splitBB().
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.
References basicBlock(), TTAProgram::CodeSnippet::instructionCount(), maximumSize_, scheduled_, and TTAProgram::BasicBlock::skippedFirstInstructions().
Referenced by ControlFlowGraph::findRelJumpDistance().
InstructionAddress BasicBlockNode::originalEndAddress | ( | ) | const |
The end address of the basic block in the original program.
Returned value is undefined in case hasOriginalAddress() returns false.
Definition at line 174 of file BasicBlockNode.cc.
References originalEndAddress_.
Referenced by BasicBlockNode(), DataDependenceGraphBuilder::constructIndividualBB(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::createControlFlowEdge(), and CompiledSimCodeGenerator::findBasicBlocks().
InstructionAddress BasicBlockNode::originalStartAddress | ( | ) | const |
The starting address of the basic block in the original program.
Returned value is undefined in case hasOriginalAddress() returns false.
Definition at line 162 of file BasicBlockNode.cc.
References originalStartAddress_.
Referenced by BasicBlockNode(), LoopPrologAndEpilogBuilder::build(), DataDependenceGraphBuilder::constructIndividualBB(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::createControlFlowEdge(), CompiledSimCodeGenerator::findBasicBlocks(), and CopyingDelaySlotFiller::mightFillIncomingTo().
|
inline |
|
inline |
Definition at line 121 of file BasicBlockNode.hh.
References predecessor_.
Referenced by BBSchedulerController::executeDDGPass(), and ControlFlowGraph::findRelJumpDistance().
|
inline |
Definition at line 103 of file BasicBlockNode.hh.
References bbOwned_.
Referenced by llvm::LLVMTCEIRBuilder::buildTCECFG().
|
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.
References isHardwareLoop_.
Referenced by llvm::LLVMTCEIRBuilder::buildTCECFG().
|
inline |
|
inline |
Definition at line 128 of file BasicBlockNode.hh.
References maximumSize_.
Referenced by ScheduleEstimator::handleControlFlowGraph().
|
inline |
Definition at line 94 of file BasicBlockNode.hh.
References scheduled_.
Referenced by LoopPrologAndEpilogBuilder::addEpilogFromRM(), LoopPrologAndEpilogBuilder::addPrologFromRM(), llvm::LLVMTCEIRBuilder::buildTCECFG(), ControlFlowGraphPass::executeBasicBlockPass(), BBSchedulerController::handleBBNode(), ControlFlowGraph::splitBasicBlockAtIndex(), and ControlFlowGraph::splitBB().
const TTAProgram::BasicBlockStatistics & BasicBlockNode::statistics | ( | ) |
Updates and returns the statistics about Basic Block
Definition at line 267 of file BasicBlockNode.cc.
References basicBlock_, isNormalBB(), and TTAProgram::BasicBlock::statistics().
Referenced by ControlFlowGraph::statistics().
|
inline |
|
inline |
Definition at line 120 of file BasicBlockNode.hh.
References successor_.
Referenced by ControlFlowGraph::allScheduledInBetween(), ControlFlowGraph::findRelJumpDistance(), and link().
|
virtual |
Returns the description of basic block as string.
Reimplemented from GraphNode.
Definition at line 185 of file BasicBlockNode.cc.
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().
void BasicBlockNode::updateHWloopLength | ( | unsigned | len | ) |
Update hwloop instruction count.
Definition at line 308 of file BasicBlockNode.cc.
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().
void BasicBlockNode::updateReferencesFromProcToCfg | ( | TTAProgram::Program & | prog | ) |
Updates instruction references to this BB from procedure to cfg
prog | program where instructions are. |
Definition at line 331 of file BasicBlockNode.cc.
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().
|
private |
the actual payload data of the graph node (the basic block)
Definition at line 140 of file BasicBlockNode.hh.
Referenced by basicBlock(), findJumps(), statistics(), updateHWloopLength(), updateReferencesFromProcToCfg(), and ~BasicBlockNode().
|
private |
true if the BasicBlock is owned by the BasicBlockNode
Definition at line 142 of file BasicBlockNode.hh.
Referenced by setBBOwnership(), and ~BasicBlockNode().
|
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().
|
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().
|
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().
|
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().
|
private |
Definition at line 151 of file BasicBlockNode.hh.
Referenced by isLoopScheduled(), and setLoopScheduled().
|
private |
Maximum number of instructions this can consume when scheduled.
Definition at line 159 of file BasicBlockNode.hh.
Referenced by maximumSize(), and setMaximumSize().
|
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().
|
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().
|
private |
Definition at line 156 of file BasicBlockNode.hh.
Referenced by link(), predecessor(), and ~BasicBlockNode().
|
private |
Definition at line 149 of file BasicBlockNode.hh.
Referenced by updateReferencesFromProcToCfg().
|
private |
Definition at line 148 of file BasicBlockNode.hh.
Referenced by isScheduled(), maximumSize(), and setScheduled().
|
private |
Definition at line 155 of file BasicBlockNode.hh.
Referenced by link(), successor(), and ~BasicBlockNode().