#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BranchClass {
Conditional,
Unconditional,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Jump {
Direct,
Indirect,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Retired {
pub class: BranchClass,
pub taken: bool,
pub indirect_target: Option<u64>,
}
pub trait DirectionPredictor {
type History;
fn lookup(&self, pc: u64, target: u64) -> (bool, Self::History);
fn unconditional(&self, pc: u64, jump: Jump) -> Self::History;
fn update_histories(&mut self, pc: u64, taken: bool, history: &Self::History);
fn squash(&mut self, history: &Self::History);
fn squash_done(&mut self) {}
fn correct(&mut self, pc: u64, taken: bool, history: &Self::History);
fn commit(&mut self, pc: u64, retired: Retired, history: &Self::History);
fn indirect_target(&self, _pc: u64) -> Option<u64> {
None
}
}