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

#include <StaticProgramAnalyzer.hh>

Collaboration diagram for StaticProgramAnalyzer:
Collaboration graph

Public Member Functions

 StaticProgramAnalyzer ()
 
virtual ~StaticProgramAnalyzer ()
 
void addProgram (const TTAProgram::Program &program)
 
std::set< std::string > operationsUsed () const
 
std::set< SIntWordintegerRegisterIndexes () const
 
std::map< int, int > immediateBitWidths () const
 
InstructionAddress biggestAddress () const
 
void resetCounters ()
 

Private Attributes

std::set< SIntWordintegerVariables_
 Set of integer variables used in the applications.
 
std::set< std::string > operations_
 Set of operations used in the applications.
 
std::map< int, int > immediates_
 Set of immediate widths used in the applications.
 
unsigned int biggestAddress_
 Memory used by programs.
 

Detailed Description

Analyzes sequential programs operation use, register needs and immediate widths.

Definition at line 49 of file StaticProgramAnalyzer.hh.

Constructor & Destructor Documentation

◆ StaticProgramAnalyzer()

StaticProgramAnalyzer::StaticProgramAnalyzer ( )

The constructor.

Definition at line 50 of file StaticProgramAnalyzer.cc.

50 :
52}
unsigned int biggestAddress_
Memory used by programs.

◆ ~StaticProgramAnalyzer()

StaticProgramAnalyzer::~StaticProgramAnalyzer ( )
virtual

The destructor.

Definition at line 57 of file StaticProgramAnalyzer.cc.

57 {
58}

Member Function Documentation

◆ addProgram()

void StaticProgramAnalyzer::addProgram ( const TTAProgram::Program program)

Adds a new program to the analyzer and analyzes it. Results are added to the previously analyzed results.

Parameters
programSequential program to be analyzed.

Definition at line 67 of file StaticProgramAnalyzer.cc.

67 {
68
69 Instruction* instruction = &program.firstInstruction();
70 Instruction* lastInstruction = &program.lastInstruction();
71 while (instruction != lastInstruction) {
72 for (int i = 0; i < instruction->moveCount(); i++) {
73 Move& move = instruction->move(i);
74 Terminal* source = &move.source();
75 Terminal* destination = &move.destination();
76 if (source->isGPR()) {
77 integerVariables_.insert(source->index());
78 } else if (source->isImmediate()) {
80 source->value().unsignedValue())] += 1;
81 }
82 if (destination->isFUPort()) {
83 if (destination->isOpcodeSetting()) {
84 operations_.insert(
86 destination->operation().name()));
87 }
88 } else if (destination->isGPR()) {
89 integerVariables_.insert(destination->index());
90 }
91
92 }
93 instruction = &program.nextInstruction(*instruction);
94 }
95 // analyze the needed memory
96 for (int i = 0; i < program.dataMemoryCount(); i++) {
97 DataMemory& dataMemory = program.dataMemory(i);
98 int definitionCount = dataMemory.dataDefinitionCount();
99 DataDefinition& definition =
100 dataMemory.dataDefinition(definitionCount - 1);
101 Address address = definition.startAddress();
102 InstructionAddress instructionAddress = address.location();
103 instructionAddress += definition.size();
104 if (biggestAddress_ < instructionAddress) {
105 biggestAddress_ = instructionAddress;
106 }
107 }
108}
UInt32 InstructionAddress
Definition BaseType.hh:175
find Finds info of the inner loops in the program
static int requiredBits(unsigned long int number)
virtual TCEString name() const
Definition Operation.cc:93
unsigned int unsignedValue() const
Definition SimValue.cc:919
std::map< int, int > immediates_
Set of immediate widths used in the applications.
std::set< SIntWord > integerVariables_
Set of integer variables used in the applications.
std::set< std::string > operations_
Set of operations used in the applications.
static std::string stringToLower(const std::string &source)
InstructionAddress location() const
virtual Address startAddress() const
DataDefinition & dataDefinition(Address address) const
Definition DataMemory.cc:79
int dataDefinitionCount() const
Move & move(int i) const
Terminal & source() const
Definition Move.cc:302
Terminal & destination() const
Definition Move.cc:323
virtual SimValue value() const
Definition Terminal.cc:178
virtual int index() const
Definition Terminal.cc:274
virtual bool isOpcodeSetting() const
Definition Terminal.cc:285
virtual Operation & operation() const
Definition Terminal.cc:319
virtual bool isGPR() const
Definition Terminal.cc:107
virtual bool isImmediate() const
Definition Terminal.cc:63
virtual bool isFUPort() const
Definition Terminal.cc:118

References biggestAddress_, TTAProgram::DataMemory::dataDefinition(), TTAProgram::DataMemory::dataDefinitionCount(), TTAProgram::Move::destination(), immediates_, TTAProgram::Terminal::index(), integerVariables_, TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isOpcodeSetting(), TTAProgram::Address::location(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), Operation::name(), TTAProgram::Terminal::operation(), operations_, program, MathTools::requiredBits(), TTAProgram::DataDefinition::size(), TTAProgram::Move::source(), TTAProgram::DataDefinition::startAddress(), StringTools::stringToLower(), SimValue::unsignedValue(), and TTAProgram::Terminal::value().

Here is the call graph for this function:

◆ biggestAddress()

InstructionAddress StaticProgramAnalyzer::biggestAddress ( ) const

Returns the biggest instruction address used in the analyzed programs.

Returns
The biggest instruction address.

Definition at line 148 of file StaticProgramAnalyzer.cc.

148 {
149 return biggestAddress_;
150}

References biggestAddress_.

◆ immediateBitWidths()

std::map< int, int > StaticProgramAnalyzer::immediateBitWidths ( ) const

Returns set of immediate bit widths used in the analyzed programs.

Returns
Set of immediate bit widths used in the analyzed programs.

Definition at line 138 of file StaticProgramAnalyzer.cc.

138 {
139 return immediates_;
140}

References immediates_.

◆ integerRegisterIndexes()

std::set< SIntWord > StaticProgramAnalyzer::integerRegisterIndexes ( ) const

Returns set of register indexes used in the analyzed programs.

Returns
Set of register indexes used in the analyzed programs.

Definition at line 128 of file StaticProgramAnalyzer.cc.

128 {
129 return integerVariables_;
130}

References integerVariables_.

◆ operationsUsed()

std::set< std::string > StaticProgramAnalyzer::operationsUsed ( ) const

Returns set of operations used in the analyzed programs.

Operation names in the se are in lower case.

Returns
Set of operations used in the analyzed programs.

Definition at line 118 of file StaticProgramAnalyzer.cc.

118 {
119 return operations_;
120}

References operations_.

◆ resetCounters()

void StaticProgramAnalyzer::resetCounters ( )

Resets the all counters used be the analyzer.

Definition at line 157 of file StaticProgramAnalyzer.cc.

157 {
158 operations_.clear();
159 integerVariables_.clear();
160}

References integerVariables_, and operations_.

Member Data Documentation

◆ biggestAddress_

unsigned int StaticProgramAnalyzer::biggestAddress_
private

Memory used by programs.

Definition at line 69 of file StaticProgramAnalyzer.hh.

Referenced by addProgram(), and biggestAddress().

◆ immediates_

std::map<int, int> StaticProgramAnalyzer::immediates_
private

Set of immediate widths used in the applications.

Definition at line 67 of file StaticProgramAnalyzer.hh.

Referenced by addProgram(), and immediateBitWidths().

◆ integerVariables_

std::set<SIntWord> StaticProgramAnalyzer::integerVariables_
private

Set of integer variables used in the applications.

Definition at line 63 of file StaticProgramAnalyzer.hh.

Referenced by addProgram(), integerRegisterIndexes(), and resetCounters().

◆ operations_

std::set<std::string> StaticProgramAnalyzer::operations_
private

Set of operations used in the applications.

Definition at line 65 of file StaticProgramAnalyzer.hh.

Referenced by addProgram(), operationsUsed(), and resetCounters().


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