OpenASIP  2.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
DisasmTopCountAttrProvider Class Reference

#include <DisasmTopCountAttrProvider.hh>

Inheritance diagram for DisasmTopCountAttrProvider:
Inheritance graph
Collaboration diagram for DisasmTopCountAttrProvider:
Collaboration graph

Public Types

typedef std::set< InstructionAddressAddressSet
 
typedef std::map< ClockCycleCount, AddressSetExecutionCountTable
 

Public Member Functions

 DisasmTopCountAttrProvider (TracedSimulatorFrontend &simulator, size_t topCounts)
 
virtual ~DisasmTopCountAttrProvider ()
 
virtual void update ()
 
virtual wxGridCellAttr * moveCellAttr (InstructionAddress address, int move)
 
- Public Member Functions inherited from ProximDisasmAttrProvider
 ProximDisasmAttrProvider ()
 
virtual ~ProximDisasmAttrProvider ()
 

Private Member Functions

void updateTopCountTable ()
 
void addToTopCountTable (InstructionAddress address, ClockCycleCount execCount)
 
void createExecCountWindow ()
 
wxColour bgColour (ClockCycleCount execCount)
 

Private Attributes

ExecutionCountTable topCountTable_
 Top execution counts and set of instruction addresses with each count. More...
 
TracedSimulatorFrontendsimulator_
 Simulator frontend used for accessing the instructions and exec counts. More...
 
size_t topCounts_
 Number of top execution counts in the top execution count list. More...
 
DisasmExecCountFramelistWin_
 

Detailed Description

Attribute provider for disassembly window grid.

Highlights instructions with top execution counts with background colour.

Definition at line 53 of file DisasmTopCountAttrProvider.hh.

Member Typedef Documentation

◆ AddressSet

Definition at line 62 of file DisasmTopCountAttrProvider.hh.

◆ ExecutionCountTable

Definition at line 63 of file DisasmTopCountAttrProvider.hh.

Constructor & Destructor Documentation

◆ DisasmTopCountAttrProvider()

DisasmTopCountAttrProvider::DisasmTopCountAttrProvider ( TracedSimulatorFrontend simulator,
size_t  topCounts 
)

The Constructor.

Parameters
simulatorSimulator frontend for accessing instructions and execution counts.
topCountsNumber of top execution counts to list and highlight.

Definition at line 170 of file DisasmTopCountAttrProvider.cc.

171  :
173  simulator_(simulator), topCounts_(topCounts) {
174 
177 
178  listWin_->Show();
179 }

References ProximToolbox::disassemblyWindow(), listWin_, and topCountTable_.

Here is the call graph for this function:

◆ ~DisasmTopCountAttrProvider()

DisasmTopCountAttrProvider::~DisasmTopCountAttrProvider ( )
virtual

The Destructor.

Definition at line 185 of file DisasmTopCountAttrProvider.cc.

185  {
186  if (listWin_ != NULL) {
187  listWin_->Destroy();
188  }
189 }

References listWin_.

Member Function Documentation

◆ addToTopCountTable()

void DisasmTopCountAttrProvider::addToTopCountTable ( InstructionAddress  address,
ClockCycleCount  execCount 
)
private

Adds an instruction to the execution top count list if the count is high enough for the list.

Parameters
addressAddress of the instruction.
execCountExecution count of the instruction.

Definition at line 256 of file DisasmTopCountAttrProvider.cc.

257  {
258 
259  ExecutionCountTable::iterator iter = topCountTable_.find(execCount);
260  if (iter != topCountTable_.end()) {
261  (*iter).second.insert(address);
262  } else if (topCountTable_.empty() ||
263  execCount > ((*topCountTable_.begin())).first) {
264 
265  AddressSet addressSet;
266  addressSet.insert(address);
267  topCountTable_.insert(
268  std::pair<ClockCycleCount, AddressSet>(execCount, addressSet));
269  }
270 
271  if (topCountTable_.size() > topCounts_) {
272  topCountTable_.erase(topCountTable_.begin());
273  }
274 
275 }

References topCounts_, and topCountTable_.

Referenced by updateTopCountTable().

◆ bgColour()

wxColour DisasmTopCountAttrProvider::bgColour ( ClockCycleCount  execCount)
private

Returns background highlight colour for an instruction with the given exec count.

Parameters
execCountExecution count of the instruciton.
Returns
Background highlight colour for the instruction.

Definition at line 285 of file DisasmTopCountAttrProvider.cc.

285  {
286 
287  ExecutionCountTable::reverse_iterator iter = topCountTable_.rbegin();
288  size_t pos = 0;
289  while (iter != topCountTable_.rend()) {
290  if ((*iter).first == execCount) {
291  break;
292  }
293  pos++;
294  iter++;
295  }
296 
297  if (pos < topCounts_) {
298  int value = pos * (255 / topCounts_);
299  if (pos < (topCounts_ / 2)) {
300  return wxColour(255 , 2 * value, 0);
301  } else {
302  return wxColour(255 - (2 * (value-128)), 255, 0);
303  }
304  } else {
305  return wxColour(255, 255, 255);
306  }
307 
308 }

References topCounts_, and topCountTable_.

Referenced by moveCellAttr().

◆ createExecCountWindow()

void DisasmTopCountAttrProvider::createExecCountWindow ( )
private

◆ moveCellAttr()

wxGridCellAttr * DisasmTopCountAttrProvider::moveCellAttr ( InstructionAddress  address,
int  move 
)
virtual

Returns grid cell attributes for cell with given move.

Parameters
addressAddress of the cell's instruction.

Implements ProximDisasmAttrProvider.

Definition at line 207 of file DisasmTopCountAttrProvider.cc.

208  {
209 
210  wxGridCellAttr* attr = new wxGridCellAttr();
211 
212  ClockCycleCount execCount =
214 
215  if (execCount == 0) {
216  attr->SetBackgroundColour(wxColour(220, 220, 220));
217  } else {
218  attr->SetBackgroundColour(bgColour(execCount));
219  }
220 
221  return attr;
222 }

References bgColour(), SimulatorFrontend::executableInstructionAt(), ExecutableInstruction::executionCount(), and simulator_.

Here is the call graph for this function:

◆ update()

void DisasmTopCountAttrProvider::update ( )
virtual

Updates the list of top execution counts when simulation stops.

Reimplemented from ProximDisasmAttrProvider.

Definition at line 195 of file DisasmTopCountAttrProvider.cc.

195  {
197  listWin_->update();
198 }

References listWin_, DisasmExecCountFrame::update(), and updateTopCountTable().

Referenced by HighlightTopExecCountsCmd::Do().

Here is the call graph for this function:

◆ updateTopCountTable()

void DisasmTopCountAttrProvider::updateTopCountTable ( )
private

Updates the list of top execution counts.

Definition at line 228 of file DisasmTopCountAttrProvider.cc.

228  {
229 
230  topCountTable_.clear();
232  const TTAProgram::Instruction* instruction = &program.firstInstruction();
233 
234  while (instruction != &TTAProgram::NullInstruction::instance()) {
235  InstructionAddress address = instruction->address().location();
236  ClockCycleCount execCount =
238 
239  if (execCount > 0) {
240  addToTopCountTable(address, execCount);
241  }
242 
243  instruction = &program.nextInstruction(*instruction);
244  }
245 
246 }

References TTAProgram::Instruction::address(), addToTopCountTable(), SimulatorFrontend::executableInstructionAt(), ExecutableInstruction::executionCount(), TTAProgram::NullInstruction::instance(), TTAProgram::Address::location(), program, SimulatorFrontend::program(), simulator_, and topCountTable_.

Referenced by update().

Here is the call graph for this function:

Member Data Documentation

◆ listWin_

DisasmExecCountFrame* DisasmTopCountAttrProvider::listWin_
private

◆ simulator_

TracedSimulatorFrontend& DisasmTopCountAttrProvider::simulator_
private

Simulator frontend used for accessing the instructions and exec counts.

Definition at line 75 of file DisasmTopCountAttrProvider.hh.

Referenced by moveCellAttr(), and updateTopCountTable().

◆ topCounts_

size_t DisasmTopCountAttrProvider::topCounts_
private

Number of top execution counts in the top execution count list.

Definition at line 77 of file DisasmTopCountAttrProvider.hh.

Referenced by addToTopCountTable(), and bgColour().

◆ topCountTable_

ExecutionCountTable DisasmTopCountAttrProvider::topCountTable_
private

Top execution counts and set of instruction addresses with each count.

Definition at line 73 of file DisasmTopCountAttrProvider.hh.

Referenced by addToTopCountTable(), bgColour(), DisasmTopCountAttrProvider(), and updateTopCountTable().


The documentation for this class was generated from the following files:
TTAProgram::Program
Definition: Program.hh:63
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
DisasmTopCountAttrProvider::AddressSet
std::set< InstructionAddress > AddressSet
Definition: DisasmTopCountAttrProvider.hh:62
ExecutableInstruction::executionCount
ClockCycleCount executionCount() const
Definition: ExecutableInstruction.cc:85
TTAProgram::Instruction
Definition: Instruction.hh:57
DisasmTopCountAttrProvider::bgColour
wxColour bgColour(ClockCycleCount execCount)
Definition: DisasmTopCountAttrProvider.cc:285
DisasmTopCountAttrProvider::updateTopCountTable
void updateTopCountTable()
Definition: DisasmTopCountAttrProvider.cc:228
DisasmTopCountAttrProvider::listWin_
DisasmExecCountFrame * listWin_
Definition: DisasmTopCountAttrProvider.hh:78
ProximDisasmAttrProvider::ProximDisasmAttrProvider
ProximDisasmAttrProvider()
Definition: ProximDisasmAttrProvider.cc:39
SimulatorFrontend::executableInstructionAt
const ExecutableInstruction & executableInstructionAt(InstructionAddress address) const
Definition: SimulatorFrontend.cc:2208
DisasmTopCountAttrProvider::simulator_
TracedSimulatorFrontend & simulator_
Simulator frontend used for accessing the instructions and exec counts.
Definition: DisasmTopCountAttrProvider.hh:75
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
DisasmTopCountAttrProvider::addToTopCountTable
void addToTopCountTable(InstructionAddress address, ClockCycleCount execCount)
Definition: DisasmTopCountAttrProvider.cc:256
DisasmTopCountAttrProvider::topCounts_
size_t topCounts_
Number of top execution counts in the top execution count list.
Definition: DisasmTopCountAttrProvider.hh:77
DisasmTopCountAttrProvider::topCountTable_
ExecutionCountTable topCountTable_
Top execution counts and set of instruction addresses with each count.
Definition: DisasmTopCountAttrProvider.hh:73
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
ProximToolbox::disassemblyWindow
static ProximDisassemblyWindow * disassemblyWindow()
Definition: ProximToolbox.cc:150
DisasmExecCountFrame
Definition: DisasmTopCountAttrProvider.hh:85
DisasmExecCountFrame::update
void update()
Definition: DisasmTopCountAttrProvider.cc:87
TTAProgram::Instruction::address
Address address() const
Definition: Instruction.cc:327