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

#include <BasicBlock.hh>

Inheritance diagram for TTAProgram::BasicBlock:
Inheritance graph
Collaboration diagram for TTAProgram::BasicBlock:
Collaboration graph

Public Member Functions

 BasicBlock (int startAddress=0)
 
virtual ~BasicBlock ()
 
BasicBlockcopy () const
 
virtual void clear ()
 
int skippedFirstInstructions () const
 
void skipFirstInstructions (int count)
 
const BasicBlockStatisticsstatistics ()
 
bool isEmpty ()
 
bool isInInnerLoop () const
 returns true in case the BB is known to be inside an inner loop
 
void setInInnerLoop (bool inner=true)
 
unsigned tripCount () const
 in case the BB is inside a loop and trip count is known, returns it, otherwise returns 0
 
void setTripCount (unsigned count)
 
- Public Member Functions inherited from TTAProgram::CodeSnippet
 CodeSnippet ()
 
 CodeSnippet (const TTAProgram::Address &start)
 
virtual ~CodeSnippet ()
 
virtual void removeLastInstruction ()
 
virtual int instructionCount () const
 
virtual Programparent () const
 
virtual void setParent (Program &prog)
 
virtual bool isInProgram () const
 
virtual Address address (const Instruction &ins) const
 
virtual Address startAddress () const
 
virtual void setStartAddress (Address start)
 
virtual Address endAddress () const
 
virtual void setEndAddress (Address end)
 
virtual InstructionfirstInstruction () const
 
virtual InstructioninstructionAt (UIntWord address) const
 
virtual InstructioninstructionAtIndex (int index) const
 
virtual Instructionoperator[] (size_t index) const
 
virtual bool hasNextInstruction (const Instruction &ins) const
 
virtual InstructionnextInstruction (const Instruction &ins) const
 
virtual InstructionpreviousInstruction (const Instruction &ins) const
 
virtual InstructionlastInstruction () const
 
virtual void addFront (Instruction *ins)
 
virtual void add (Instruction *ins)
 
virtual void insertAfter (const Instruction &pos, Instruction *ins)
 
virtual void insertBefore (const Instruction &pos, Instruction *ins)
 
virtual void remove (Instruction &ins)
 
virtual void deleteInstructionAt (InstructionAddress address)
 
virtual void prepend (const CodeSnippet &cs)
 
virtual void prepend (CodeSnippet *cs)
 
virtual void append (const CodeSnippet &cs)
 
virtual void append (CodeSnippet *cs)
 
virtual void insertBefore (const Instruction &pos, const CodeSnippet &cs)
 
virtual void insertBefore (const Instruction &pos, CodeSnippet *cs)
 
virtual void insertAfter (const Instruction &pos, const CodeSnippet &cs)
 
virtual void insertAfter (const Instruction &pos, CodeSnippet *cs)
 
bool hasReturn () const
 
virtual std::string disassembly () const
 
virtual std::string toString () const
 

Public Attributes

LiveRangeDataliveRangeData_
 

Private Attributes

int skippedFirstInstructions_
 
bool statisticsValid_
 
BasicBlockStatistics statistics_
 
bool innerLoop_
 
unsigned tripCount_
 

Additional Inherited Members

- Protected Types inherited from TTAProgram::CodeSnippet
typedef std::vector< Instruction * > InsList
 List of instructions.
 
typedef InsList::iterator InsIter
 Iterator for the instruction list.
 
- Protected Attributes inherited from TTAProgram::CodeSnippet
InsList instructions_
 The instructions in this procedure.
 
Programparent_
 The parent program of the procedure.
 
Address startAddr_
 The start (lowest) address of the procedure.
 
Address endAddr_
 The highest address of the procedure.
 

Detailed Description

Represents contents and information of 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 85 of file BasicBlock.hh.

Constructor & Destructor Documentation

◆ BasicBlock()

BasicBlock::BasicBlock ( int  startAddress = 0)

◆ ~BasicBlock()

BasicBlock::~BasicBlock ( )
virtual

To prevent compiler warning of virtual destructor.

Definition at line 60 of file BasicBlock.cc.

60 {
61}

Member Function Documentation

◆ clear()

void BasicBlock::clear ( )
virtual

Trigger recorded statistics about BB invalid and calls clear of code snippet.

Reimplemented from TTAProgram::CodeSnippet.

Definition at line 152 of file BasicBlock.cc.

152 {
153 statisticsValid_ = false;
155}

References TTAProgram::CodeSnippet::clear(), and statisticsValid_.

Referenced by BasicBlockPass::copyRMToBB().

Here is the call graph for this function:

◆ copy()

BasicBlock * BasicBlock::copy ( ) const
virtual

Creates a deep copy of the basic block.

Reimplemented from TTAProgram::CodeSnippet.

Definition at line 67 of file BasicBlock.cc.

67 {
68
70 if (instructionCount() > 0) {
71 for (int i = skippedFirstInstructions(); i < instructionCount(); i++) {
72 newBB->add(instructionAtIndex(i).copy());
73 }
74 }
75 return newBB;
76}
InstructionAddress location() const
int skippedFirstInstructions() const
Definition BasicBlock.cc:88
Address startAddr_
The start (lowest) address of the procedure.
virtual void add(Instruction *ins)
virtual int instructionCount() const
virtual Instruction & instructionAtIndex(int index) const
Instruction * copy() const

References TTAProgram::CodeSnippet::add(), TTAProgram::Instruction::copy(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Address::location(), skippedFirstInstructions(), and TTAProgram::CodeSnippet::startAddr_.

Here is the call graph for this function:

◆ isEmpty()

bool TTAProgram::BasicBlock::isEmpty ( )
inline

Definition at line 98 of file BasicBlock.hh.

98 {
100 }

References TTAProgram::CodeSnippet::instructionCount(), and skippedFirstInstructions().

Referenced by ControlFlowGraph::optimizeBBOrdering().

Here is the call graph for this function:

◆ isInInnerLoop()

bool TTAProgram::BasicBlock::isInInnerLoop ( ) const
inline

returns true in case the BB is known to be inside an inner loop

Definition at line 103 of file BasicBlock.hh.

103{ return innerLoop_; }

References innerLoop_.

Referenced by BasicBlockPass::copyRMToBB(), and BBSchedulerController::executeDDGPass().

◆ setInInnerLoop()

void TTAProgram::BasicBlock::setInInnerLoop ( bool  inner = true)
inline

Definition at line 104 of file BasicBlock.hh.

104{ innerLoop_ = inner; }

References innerLoop_.

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

◆ setTripCount()

void TTAProgram::BasicBlock::setTripCount ( unsigned  count)
inline

Definition at line 109 of file BasicBlock.hh.

109{ tripCount_ = count; }

References tripCount_.

Referenced by llvm::LLVMTCEIRBuilder::buildTCECFG(), and BBSchedulerController::handleBasicBlock().

◆ skipFirstInstructions()

void BasicBlock::skipFirstInstructions ( int  count)

Sets n first instructions of this BB to be skipped instructions, ie. instructions that do not logically belong here but are here because cannot have been removed without messing soem data structures (liek RM bookkeeping)

Parameters
countnumber of instructions to mark as skipped instructions

Definition at line 98 of file BasicBlock.cc.

98 {
100}

References skippedFirstInstructions_.

Referenced by ControlFlowGraph::optimizeBBOrdering(), CopyingDelaySlotFiller::updateFTBBAndCfg(), and CopyingDelaySlotFiller::updateJumpsAndCfg().

◆ skippedFirstInstructions()

int BasicBlock::skippedFirstInstructions ( ) const

Returns the count of instructions in the beginning of this BB that should not be copied out from this BB, ie. logically don't belong here but are here because they cannot have been removed without messing some data structures (like RM bookkeeping)

Returns
count of first instructions to skip

Definition at line 88 of file BasicBlock.cc.

88 {
90}

References skippedFirstInstructions_.

Referenced by ControlFlowGraph::buildMBBFromBB(), copy(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::findJumpImmediate(), isEmpty(), BasicBlockNode::maximumSize(), ControlFlowGraph::mergeNodes(), LoopPrologAndEpilogBuilder::moveJumpDestination(), ControlFlowGraph::splitBB(), PostpassOperandSharer::tryRemoveOperandWrite(), and CopyingDelaySlotFiller::updateJumpsAndCfg().

◆ statistics()

const BasicBlockStatistics & BasicBlock::statistics ( )

Updates and returns the statistics about Basic Block

Returns
refrence to structure with information about basic block

Definition at line 111 of file BasicBlock.cc.

111 {
112 // hack, statistics should be cached when all the operations that
113 // could change the moves in instructions are taken care of.
114 statisticsValid_ = false;
115 if (statisticsValid_) {
116 return statistics_;
117 } else {
122 for (int i = 0; i < instructionCount(); i++) {
123 int newMoveCount =
125 statistics_.setMoveCount(newMoveCount);
126 int newImmCount =
129 statistics_.setImmediateCount(newImmCount);
130 for (int j = 0;
132 j++) {
133 TTAProgram::Move& tempMove =
135 if (tempMove.source().isFUPort() &&
136 tempMove.destination().isFUPort()) {
137 int newBypassCount = statistics_.bypassedCount() + 1;
138 statistics_.setBypassedCount(newBypassCount);
139 }
140 }
141 }
142 statisticsValid_ = true;
143 return statistics_;
144 }
145}
virtual void setInstructionCount(int)
virtual void setBypassedCount(int)
virtual int bypassedCount() const
virtual void setImmediateCount(int)
virtual int moveCount() const
virtual int immediateCount() const
BasicBlockStatistics statistics_
Move & move(int i) const
Terminal & source() const
Definition Move.cc:302
Terminal & destination() const
Definition Move.cc:323
virtual bool isFUPort() const
Definition Terminal.cc:118

References TTAProgram::BasicBlockStatistics::bypassedCount(), TTAProgram::Move::destination(), TTAProgram::BasicBlockStatistics::immediateCount(), TTAProgram::Instruction::immediateCount(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::isFUPort(), TTAProgram::Instruction::move(), TTAProgram::BasicBlockStatistics::moveCount(), TTAProgram::Instruction::moveCount(), TTAProgram::BasicBlockStatistics::setBypassedCount(), TTAProgram::BasicBlockStatistics::setImmediateCount(), TTAProgram::BasicBlockStatistics::setInstructionCount(), TTAProgram::BasicBlockStatistics::setMoveCount(), TTAProgram::Move::source(), statistics_, and statisticsValid_.

Referenced by BasicBlockNode::statistics().

Here is the call graph for this function:

◆ tripCount()

unsigned TTAProgram::BasicBlock::tripCount ( ) const
inline

in case the BB is inside a loop and trip count is known, returns it, otherwise returns 0

Definition at line 108 of file BasicBlock.hh.

108{ return tripCount_; }

References tripCount_.

Referenced by BasicBlockPass::copyRMToBB(), and BBSchedulerController::handleBasicBlock().

Member Data Documentation

◆ innerLoop_

bool TTAProgram::BasicBlock::innerLoop_
private

Definition at line 119 of file BasicBlock.hh.

Referenced by isInInnerLoop(), and setInInnerLoop().

◆ liveRangeData_

LiveRangeData* TTAProgram::BasicBlock::liveRangeData_

Definition at line 111 of file BasicBlock.hh.

Referenced by InlineAsmParser::addLiveRangeData(), DataDependenceGraphBuilder::build(), DataDependenceGraphBuilder::clearUnneededBookkeeping(), DataDependenceGraphBuilder::constructIndividualBB(), RegisterCopyAdder::createAntidepsForReg(), BFRegCopy::createAntidepsForReg(), DataDependenceGraphBuilder::createTriggerDependencies(), BasicBlockPass::executeDDGPass(), BBSchedulerController::handleBasicBlock(), DataDependenceGraphBuilder::initializeBBStates(), RegisterRenamer::initializeFreeRegisters(), ControlFlowGraph::mergeNodes(), DataDependenceGraphBuilder::processEntryNode(), DataDependenceGraphBuilder::processMemUse(), DataDependenceGraphBuilder::processMemWrite(), DataDependenceGraphBuilder::processRegUse(), DataDependenceGraphBuilder::processRegWrite(), RegisterRenamer::renameLiveRange(), BF2Scheduler::revertBBLiveRangeBookkeepingForDestination(), BF2Scheduler::revertBBLiveRangeBookkeepingForSource(), RegisterRenamer::revertedRenameToRegister(), BFRenameLiveRange::setFirstDefsAndUses(), BFRenameLiveRange::setIncomingDeps(), BFRenameLiveRange::setOutgoingDeps(), BFRenameLiveRange::setRegDefsAndLastUses(), DataDependenceGraphBuilder::setSucceedingPredepsForBB(), ControlFlowGraph::splitBasicBlockAtIndex(), BFRenameLiveRange::undoSetFirstDefsAndUses(), BFRenameLiveRange::undoSetRegDefsAndLastUses(), BFRenameLiveRange::unsetIncomingDeps(), BFRenameLiveRange::unsetOutgoingDeps(), RegisterRenamer::updateAntiEdgesFromLRTo(), DataDependenceGraphBuilder::updateBB(), DataDependenceGraphBuilder::updateMemAndFuAliveAfter(), DataDependenceGraphBuilder::updateMemUse(), DataDependenceGraphBuilder::updateMemWrite(), DataDependenceGraphBuilder::updatePreceedingRegistersUsedAfter(), DataDependenceGraphBuilder::updateRegistersAliveAfter(), DataDependenceGraphBuilder::updateRegistersUsedInOrAfter(), DataDependenceGraph::updateRegUse(), and DataDependenceGraph::updateRegWrite().

◆ skippedFirstInstructions_

int TTAProgram::BasicBlock::skippedFirstInstructions_
private

Definition at line 115 of file BasicBlock.hh.

Referenced by skipFirstInstructions(), and skippedFirstInstructions().

◆ statistics_

BasicBlockStatistics TTAProgram::BasicBlock::statistics_
private

Definition at line 117 of file BasicBlock.hh.

Referenced by statistics().

◆ statisticsValid_

bool TTAProgram::BasicBlock::statisticsValid_
private

Definition at line 116 of file BasicBlock.hh.

Referenced by clear(), and statistics().

◆ tripCount_

unsigned TTAProgram::BasicBlock::tripCount_
private

Definition at line 120 of file BasicBlock.hh.

Referenced by setTripCount(), and tripCount().


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