next up previous contents
Next: Instruction issue Up: RSIM_EVENT and the Out-of-order Previous: Instruction fetch and decode

Branch prediction

Source files: src/Processor/branchpred.cc, src/Processor/branchqelt.cc, src/Processor/branchresolve.cc

Headers: incl/Processor/bpb.h, src/Processor/branchq.h,

Although branch prediction can be considered part of instruction fetching and decoding, it is sufficiently important to be discussed separately. The decode_branch_instruction calls StartCtlXfer to determine the prediction for the branch.

If the branch is an unconditional transfer with a known address (either a call instruction or any variety of ``branch always''), then StartCtlXfer returns -1 to indicate that the branch is taken non-speculatively. On call instructions, this function also adds the current PC to the return address stack. For other types of branches, this function either predicts them using the return address stack (for procedure returns) or the branch prediction buffer (for ordinary branches), or does not attempt to predict their targets (for calculated jumps).

Based on the return value of StartCtlXfer and the category of branch (conditional vs. unconditional, annulling vs. non-annulling), decode_branch_instruction sets the processor PC and NPC appropriately, as well as setting processor fields such as copymappernext (for speculative branches which always have a delay slot) and unpredbranch (for branches that are not predicted). Additionally, this function may set the branchdep of the instance for unpredicted branches or branches that may be annulling and thus need to associate a shadow mapper with the branch itself (rather than with a delay slot).

The function AddBranchQ is called by check_dependencies to allocate a shadow mapper for a speculative branch. If a mapper is available, this function copies the current integer and floating-point register map tables into the shadow mapper data structure.



Vijay Sadananda Pai
Thu Aug 7 14:18:56 CDT 1997