Electrical computers and digital processing systems: processing – Processing control – Branching
Reexamination Certificate
1999-11-04
2003-02-25
Ellis, Richard L. (Department: 2183)
Electrical computers and digital processing systems: processing
Processing control
Branching
C712S228000
Reexamination Certificate
active
06526503
ABSTRACT:
TECHNICAL FIELD
The present invention relates generally to information processing, and in particular to an apparatus and method for controlling link stack corruption during branching.
BACKGROUND INFORMATION
Modern high frequency microprocessors are typically deeply pipelined devices. For efficient instruction execution in such processors, instructions are often fetched and executed speculatively. An instruction may be fetched many cycles before it is executed. Since branch instructions may cause instruction fetching to start from a non-sequential location, the direction and target of a branch instruction is predicted when the branch is fetched so that instruction fetching can proceed from the most likely address. The prediction is compared with the actual direction and target of the branch instruction when the instruction is executed. If it is determined that the branch has been mispredicted (either its target or its direction), then the branch instruction is completed and all instructions fetched after the branch are flushed out of the instruction pipeline and new instructions are fetched either from the sequential path of the branch (if the branch is resolved as not taken) or from the target path of the branch (if the branch is resolved as taken).
Often there are a number of branches (i.e., subroutine calls and returns) between the instructions that are being fetched and the instructions that are being executed in the processor execution units. Therefore, to handle subroutine calls and returns efficiently, many high frequency microprocessors employ a link stack. On a subroutine call, the address of the following instruction is “pushed” into the stack while on a subroutine return, the contents at the top of the stack (which is expected to contain the address of the instruction following the original subroutine call) are “popped” from the stack. Since pushing and popping from a hardware stack can normally be done when the branch is fetched, which is several cycles before the corresponding branches are executed in a deeply pipelined processor, such a linked stack mechanism helps implement the instruction fetching scheme across subroutine calls and returns to a great extent. Notwithstanding, the link stack can become corrupted during the process of speculative instruction fetching and execution.
Consider, for example, the case where a subroutine call is performed using a “branch and link instruction” and a return from subroutine is achieved using a “branch to link register” or “bclr” instruction. It may happen that a “bclr” instruction, which for example returns to a location “A”, is fetched speculatively followed by a speculative fetch of a “branch and link” instruction, for example from call-site B. The link stack is updated at fetch time, such that after these instructions are fetched, the address location “A” is replaced by the address location “B+4” (each instruction consists of four bytes) at the top of the link stack. Since both the “bclr” and “branch and link” instructions are speculatively fetched, they may not ultimately be in the actual execution path. If these instructions are not in fact in the actual execution path, (in which case the instructions are flushed out), the link stack becomes corrupted.
Generally, any time one or more “bclr” instructions are followed by one or more “branch and link” instructions in the speculated path, the link stack becomes corrupted if the speculation turns out to be wrong. For a commercial programming workload, about 2% of the instructions are “bclr” instructions and therefore it becomes very important to be able to predict the target address for these instructions with a good degree of accuracy in deeply pipelined machines. Thus, the need has arisen for circuits, systems and methods to control link stack corruption, as well as to recover a link stack from corrupted condition.
SUMMARY OF THE INVENTION
The principles of the present invention are embodied in circuits, systems and methods for executing branch instructions. In accordance to one embodiment of these principles, instruction branching circuitry is disclosed which includes a plurality of logical stacks each having a plurality of entries for storing an address to a corresponding instruction in memory. A counter generates a pointer to an entry of an active one of the logical stacks, the counter including incrementation logic incrementing a stored pointer value following a Push operation and decrementation logic decrementing the stored pointer value following a Pop operation to the active logical stacks. Selector circuitry selects the active one of the logical stacks in accordance with the performance of the Push and Pop operations.
According to one specific embodiment of the inventive principles, the selector circuitry changes the active stack from a first stack to a second stack in response to a Pop operation followed by an instruction for a Push operation, the Push operation then performed to the second stack. In a second particular embodiment, the selector circuitry changes the active stack in response to the state of a bit associated with information popped from the active stack during a Pop operation.
The principles of the present invention provide substantial advantages over the prior art. Among other things, circuitry and methods are provided which allow for the control of link stack corruption. In particular, the present inventive principles allow for the construction and operation of a register file of m-logically separate stacks which allows recovery of m−1 number of redirections caused by misspeculation during the execution of branching instructions.
The foregoing has outlined rather broadly the features and technical advantages of the present invention in order that the detailed description of the invention that follows may be better understood. Additional features and advantages of the invention will be described hereinafter which form the subject of the claims of the invention.
REFERENCES:
patent: 5021993 (1991-06-01), Matoba et al.
patent: 5142634 (1992-08-01), Fite et al.
patent: 5313634 (1994-05-01), Eickemeyer
patent: 5574871 (1996-11-01), Hoyt et al.
Stephan Jourdan et al., “Recovery Requirements of Branch Prediction Storage Structures in the Presence of Mispredicted-Path Execution,”International Journal of Parallel Programming, vol. 25, No. 5 1997, p. 363-383.
Ellis Richard L.
McBurney Mark E.
Meonske Tonia
Newberger Barry S.
Winstead Sechrest & Minick P.C.
LandOfFree
Apparatus and method for accessing a memory device during... does not yet have a rating. At this time, there are no reviews or comments for this patent.
If you have personal experience with Apparatus and method for accessing a memory device during..., we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Apparatus and method for accessing a memory device during... will most certainly appreciate the feedback.
Profile ID: LFUS-PAI-O-3162736