OpenASIP  2.0
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 More...
 
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 More...
 
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. More...
 
typedef InsList::iterator InsIter
 Iterator for the instruction list. More...
 
- Protected Attributes inherited from TTAProgram::CodeSnippet
InsList instructions_
 The instructions in this procedure. More...
 
Programparent_
 The parent program of the procedure. More...
 
Address startAddr_
 The start (lowest) address of the procedure. More...
 
Address endAddr_
 The highest address of the procedure. More...
 

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)

Constructor.

Definition at line 49 of file BasicBlock.cc.

Referenced by copy().

◆ ~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 
69  BasicBlock* newBB = new BasicBlock(startAddr_.location());
70  if (instructionCount() > 0) {
71  for (int i = skippedFirstInstructions(); i < instructionCount(); i++) {
72  newBB->add(instructionAtIndex(i).copy());
73  }
74  }
75  return newBB;
76 }

References TTAProgram::CodeSnippet::add(), BasicBlock(), 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(), and ControlFlowGraph::createBlock().

◆ setTripCount()

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

◆ 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(), and CopyingDelaySlotFiller::updateFTBBAndCfg().

◆ 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;
131  j < instructionAtIndex(i).moveCount();
132  j++) {
133  TTAProgram::Move& tempMove =
134  instructionAtIndex(i).move(j);
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 }

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(), BFRegCopy::createAntidepsForReg(), RegisterCopyAdder::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:
TTAProgram::BasicBlockStatistics::setInstructionCount
virtual void setInstructionCount(int)
Definition: BasicBlock.cc:230
TTAProgram::Terminal::isFUPort
virtual bool isFUPort() const
Definition: Terminal.cc:118
TTAMachine::NullAddressSpace::instance
static NullAddressSpace & instance()
Definition: NullAddressSpace.cc:62
TTAProgram::BasicBlockStatistics::moveCount
virtual int moveCount() const
Definition: BasicBlock.cc:177
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::CodeSnippet::clear
virtual void clear()
Definition: CodeSnippet.cc:89
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
TTAProgram::BasicBlockStatistics::setImmediateCount
virtual void setImmediateCount(int)
Definition: BasicBlock.cc:220
TTAProgram::CodeSnippet::startAddress
virtual Address startAddress() const
Definition: CodeSnippet.cc:780
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::BasicBlock::skippedFirstInstructions
int skippedFirstInstructions() const
Definition: BasicBlock.cc:88
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::CodeSnippet::add
virtual void add(Instruction *ins)
Definition: CodeSnippet.cc:432
TTAProgram::Instruction::copy
Instruction * copy() const
Definition: Instruction.cc:379
TTAProgram::BasicBlock::BasicBlock
BasicBlock(int startAddress=0)
Definition: BasicBlock.cc:49
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::Move
Definition: Move.hh:55
TTAProgram::BasicBlock::statisticsValid_
bool statisticsValid_
Definition: BasicBlock.hh:116
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::Instruction::immediateCount
int immediateCount() const
Definition: Instruction.cc:267
TTAProgram::BasicBlock::tripCount_
unsigned tripCount_
Definition: BasicBlock.hh:120
TTAProgram::CodeSnippet::instructionAtIndex
virtual Instruction & instructionAtIndex(int index) const
Definition: CodeSnippet.cc:285
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
TTAProgram::BasicBlockStatistics::bypassedCount
virtual int bypassedCount() const
Definition: BasicBlock.cc:201
TTAProgram::CodeSnippet::startAddr_
Address startAddr_
The start (lowest) address of the procedure.
Definition: CodeSnippet.hh:130
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
TTAProgram::CodeSnippet::CodeSnippet
CodeSnippet()
Definition: CodeSnippet.cc:55