MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / predict

Method predict

crates/virtual-machine/src/cpu/predictor.rs:47–51  ·  view source on GitHub ↗

Predict whether the branch at `pc` will be taken and what its target will be. Returns `(predicted_taken, predicted_target)`.

(&self, pc: u64)

Source from the content-addressed store, hash-verified

45 pub fn predict(&self, pc: u64) -> (bool, u64) {
46 let taken = self.pht[Self::pht_idx(pc)] >= 2;
47 let target = self.btb.get(&pc).copied().unwrap_or(pc.wrapping_add(4));
48 (taken, target)
49 }
50
51 /// Update the predictor with the actual outcome of a branch at `pc`.
52 /// Call this once per branch instruction as it exits the EX stage.
53 pub fn update(&mut self, pc: u64, was_taken: bool, actual_target: u64, predicted_taken: bool) {
54 let idx = Self::pht_idx(pc);

Callers 1

stage_ifMethod · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected