fix cycle estimation plugin
This commit is contained in:
parent
98b418ff43
commit
09b0f0d0c8
|
@ -201,7 +201,7 @@ public:
|
|||
|
||||
void disass_output(uint64_t pc, const std::string instr) override {
|
||||
CLOG(INFO, disass) << fmt::format("0x{:016x} {:40} [s:0x{:x};c:{}]",
|
||||
pc, instr, (reg_t)state.mstatus, this->reg.icount);
|
||||
pc, instr, (reg_t)state.mstatus, this->reg.icount + cycle_offset);
|
||||
};
|
||||
|
||||
iss::instrumentation_if *get_instrumentation_if() override { return &instr_if; }
|
||||
|
|
|
@ -307,7 +307,7 @@ public:
|
|||
|
||||
void disass_output(uint64_t pc, const std::string instr) override {
|
||||
CLOG(INFO, disass) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]",
|
||||
pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus, this->reg.ccount);
|
||||
pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus, this->reg.ccount + cycle_offset);
|
||||
};
|
||||
|
||||
iss::instrumentation_if *get_instrumentation_if() override { return &instr_if; }
|
||||
|
|
|
@ -216,7 +216,7 @@ public:
|
|||
|
||||
void disass_output(uint64_t pc, const std::string instr) override {
|
||||
CLOG(INFO, disass) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]",
|
||||
pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus, this->reg.icount);
|
||||
pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus, this->reg.icount + cycle_offset);
|
||||
};
|
||||
|
||||
iss::instrumentation_if *get_instrumentation_if() override { return &instr_if; }
|
||||
|
|
|
@ -49,11 +49,13 @@ class cycle_estimate: public iss::vm_plugin {
|
|||
BEGIN_BF_DECL(instr_desc, uint32_t)
|
||||
BF_FIELD(taken, 24, 8)
|
||||
BF_FIELD(not_taken, 16, 8)
|
||||
BF_FIELD(size, 0, 16)
|
||||
instr_desc(uint32_t size, uint32_t taken, uint32_t not_taken): instr_desc() {
|
||||
BF_FIELD(is_branch, 8, 8)
|
||||
BF_FIELD(size, 0, 8)
|
||||
instr_desc(uint32_t size, uint32_t taken, uint32_t not_taken, bool branch): instr_desc() {
|
||||
this->size=size;
|
||||
this->taken=taken;
|
||||
this->not_taken=not_taken;
|
||||
this->is_branch=branch;
|
||||
}
|
||||
END_BF_DECL();
|
||||
|
||||
|
|
|
@ -75,10 +75,14 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if&
|
|||
auto& name = (*it)["name"];
|
||||
auto& size = (*it)["size"];
|
||||
auto& delay = (*it)["delay"];
|
||||
auto& branch = (*it)["branch"];
|
||||
if(delay.IsArray()) {
|
||||
delays.push_back(instr_desc{size.Get<unsigned>(), delay[0].Get<unsigned>(), delay[1].Get<unsigned>()});
|
||||
auto dt = delay[0].Get<unsigned>();
|
||||
auto dnt = delay[1].Get<unsigned>();
|
||||
delays.push_back(instr_desc{size.Get<unsigned>(), dt, dnt, branch.Get<bool>()});
|
||||
} else if(delay.Is<unsigned>()) {
|
||||
delays.push_back(instr_desc{size.Get<unsigned>(), delay.Get<unsigned>(), 0});
|
||||
auto d = delay.Get<unsigned>();
|
||||
delays.push_back(instr_desc{size.Get<unsigned>(), d, d, branch.Get<bool>()});
|
||||
} else
|
||||
throw runtime_error("JSON parse error");
|
||||
}
|
||||
|
@ -103,11 +107,11 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if&
|
|||
|
||||
}
|
||||
|
||||
void iss::plugin::cycle_estimate::callback(instr_info_t instr_info, exec_info const&) {
|
||||
void iss::plugin::cycle_estimate::callback(instr_info_t instr_info, exec_info const& exc_info) {
|
||||
assert(arch_instr && "No instrumentation interface available but callback executed");
|
||||
auto entry = delays[instr_info.instr_id];
|
||||
bool taken = (arch_instr->get_next_pc()-arch_instr->get_pc()) != (entry.size/8);
|
||||
if (taken && entry.taken > 1)
|
||||
bool taken = exc_info.branch_taken;
|
||||
if (exc_info.branch_taken && entry.taken > 1)
|
||||
arch_instr->set_curr_instr_cycles(entry.taken);
|
||||
else if (entry.not_taken > 1)
|
||||
arch_instr->set_curr_instr_cycles(entry.not_taken);
|
||||
|
|
|
@ -136,7 +136,8 @@ public:
|
|||
if (!owner->disass_output(pc, instr)) {
|
||||
std::stringstream s;
|
||||
s << "[p:" << lvl[this->reg.PRIV] << ";s:0x" << std::hex << std::setfill('0')
|
||||
<< std::setw(sizeof(reg_t) * 2) << (reg_t)this->state.mstatus << std::dec << ";c:" << this->reg.icount << "]";
|
||||
<< std::setw(sizeof(reg_t) * 2) << (reg_t)this->state.mstatus << std::dec << ";c:"
|
||||
<< this->reg.icount + this->cycle_offset << "]";
|
||||
SCCDEBUG(owner->name())<<"disass: "
|
||||
<< "0x" << std::setw(16) << std::right << std::setfill('0') << std::hex << pc << "\t\t" << std::setw(40)
|
||||
<< std::setfill(' ') << std::left << instr << s.str();
|
||||
|
|
Loading…
Reference in New Issue