use crate::uarch::ctx::CoreCtx;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IssueHold {
Operands,
Unit,
Ordering,
}
pub fn count_issue_stalls(
state: &mut CoreCtx<'_>,
unit_stalled: bool,
issued_any: bool,
oldest: Option<IssueHold>,
) {
let paths = &state.core.stat_paths.pipeline;
let idle = match oldest.filter(|_| !issued_any) {
Some(IssueHold::Operands) => Some(paths.stalls_data),
Some(IssueHold::Ordering) => Some(paths.stalls_ordering),
Some(IssueHold::Unit) | None => None,
};
let structural = unit_stalled.then_some(paths.stalls_fu_structural);
for stat in [structural, idle].into_iter().flatten() {
state.uncore.stats.counter(stat).inc();
}
}