Skip to content

added support for logging branches - #2

Open
aansaarii wants to merge 5 commits into
developfrom
branch-trace
Open

aansaarii wants to merge 5 commits into
developfrom
branch-trace

Conversation

@aansaarii

Copy link
Copy Markdown

For comparing the sequences of instructions collected from qflex and gem5, I added modifications to this repo. Please review and approve the PR if you agree. These modifications enable logging the executed branches in a dedicated file.

Copilot AI review requested due to automatic review settings May 2, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds optional branch logging and basic-block metadata collection to the branch predictor plugin to support cross-simulator (qflex vs gem5) instruction/branch stream comparisons and checkpoint export.

Changes:

  • Add per-core branch PC logging to branch_trace_core_<id>.log when enabled via plugin options.
  • Track basic-block boundaries at instruction granularity and record bbl_bytes into BTB entries (and optionally into a new export-only BBL-BTB structure).
  • Extend checkpoint frontend export to include bbl_bytes in serialized BTB entries.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/bp/mod.rs Adds branch trace logging, basic-block tracking state, and instruction-exec callbacks to compute bbl_bytes.
src/components/bp/fetch.rs Adds bbl_bytes plumbing through training and introduces export-only restore state (RestoreExportState).
src/components/bp/fetch/btb.rs Extends BTB entries to store bbl_bytes and threads it through BTB training.
src/components/bp/fetch/bbl_btb.rs New data structure to record basic blocks (BBL-BTB) for export/restore workflows.
src/checkpoint/frontend.rs Includes bbl_bytes in the exported Flexus BTB JSON entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#[derive(Serialize, Deserialize)]
pub struct PerCoreFetchUnit {
btb: btb::BTB<{ parameter::BTB_SET }, { parameter::BTB_ASSO }>,
#[serde(default, alias = "btb")]
Comment thread src/components/bp/mod.rs
Comment on lines +247 to 265
unsafe fn on_translation(tb: *mut crate::qemu_api::qemu_plugin_tb) {
let instruction_count = unsafe { qemu_api::qemu_plugin_tb_n_insns(tb) };
if instruction_count == 0 {
return;
}

for i in 0..instruction_count {
let insn = unsafe { qemu_api::qemu_plugin_tb_get_insn(tb, i) };
let insn_addr = unsafe { qemu_api::qemu_plugin_insn_vaddr(insn) };
unsafe {
qemu_api::qemu_plugin_register_vcpu_insn_exec_cb(
insn,
Some(vcpu_insn_exec),
qemu_api::qemu_plugin_cb_flags_QEMU_PLUGIN_CB_NO_REGS,
insn_addr as *mut ffi::c_void,
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants