Commit 2c970ea6 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2005-03-06 Benoît Perrot <benoit@lrde.epita.fr>

	Display the number of executed R,I and J-type instructions on
	profile.

	* src/vm/cpu.hh, src/vm/cpu.cc: Add an array of counters and
	update them for each executed instruction.
	* src/vm/virtual_machine.hh: Add accessor to CPU.
	* src/vm-tasks.cc: Print the counters on profile.
parent c50f9289
2005-03-06 Benoît Perrot <benoit@lrde.epita.fr>
Display the number of executed R,I and J-type instructions on
profile.
* src/vm/cpu.hh, src/vm/cpu.cc: Add an array of counters and
update them for each executed instruction.
* src/vm/virtual_machine.hh: Add accessor to CPU.
* src/vm-tasks.cc: Print the counters on profile.
2005-03-06 Benoît Perrot <benoit@lrde.epita.fr>
Specify instruction format type to distinguish register, immediate
......
......@@ -41,9 +41,17 @@ namespace vm
if (profile_p)
{
std::cerr << "Number of cycles: "
<< vm.get_cp0().get_count()
<< std::endl;
std::cerr
<< "Number of cycles: " << vm.get_cp0().get_count() << std::endl
<< "Number of executed R-type CPU instructions: "
<< vm.get_cpu().get_instruction_counter(inst::Inst::r_type)
<< std::endl
<< "Number of executed I-type CPU instructions: "
<< vm.get_cpu().get_instruction_counter(inst::Inst::i_type)
<< std::endl
<< "Number of executed J-type CPU instructions: "
<< vm.get_cpu().get_instruction_counter(inst::Inst::j_type)
<< std::endl;
}
// FIXME: Quick and dirty, this should not be done here
......
......@@ -74,6 +74,10 @@ namespace vm
// Initialize pipeline with nops
for (unsigned i = 0; i < 6; ++i)
pipeline_[i] = bubble_;
counters_[0] = 0;
counters_[1] = 0;
counters_[2] = 0;
}
// --------------------------------------------------------------------------
......
......@@ -174,6 +174,11 @@ namespace vm
void set_pc(register_type r) { pc_ = r; }
/** \} */
unsigned get_instruction_counter(inst::Inst::format_type format) const
{
return counters_[format];
}
protected:
virtual void visit(const inst::Add& add);
virtual void visit(const inst::Addi& addi);
......@@ -327,6 +332,7 @@ namespace vm
pipeline_[d_stage] = pipeline_[i_stage];
pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
++counters_[ pipeline_[e_stage]->get_format() ];
pipeline_[e_stage]->accept(*this);
pc_ = pc_ + 4;
}
......@@ -343,7 +349,12 @@ namespace vm
w_stage ///< Writeback stage
};
inst::Inst* bubble_;
/// Instruction pipeline
const inst::Inst* pipeline_[6];
/// Instruction counters
unsigned counters_[3];
};
inline std::ostream &
......
......@@ -147,16 +147,15 @@ namespace vm
return cpu_.get_pc();
}
const Cp0 &get_cp0() const
{
return cp0_;
}
const Cp0 &get_cp0() const { return cp0_; }
const Cpu &get_cpu() const { return cpu_; }
protected:
/// The virtual machine mode.
mode_type mode_;
/// The virtual machine status.
status_type status_;
/** \} */
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment