Patent ID: 8694760

Claim:
A branch prediction device, comprising: an instruction execution unit operable to execute instructions; a function call notification unit operable to make a notification of execution of a function call instruction by the instruction execution unit; a call stack that stores therein at least one argument of a function that is called by the function call instruction when notified by the function call notification unit of the execution of the function call instruction; a branch instruction notification unit operable to make a notification of execution of a branch instruction by the instruction execution unit, the branch instruction being included in the function that is called by the function call instruction; a branch result buffer that stores therein branch result entries each showing the following (i), (ii), and (iii) in correspondence: (i) a branch instruction address; (ii) a leading value of the call stack at branch instruction execution time; and (iii) a branch destination; a branch prediction unit operable to (i) when notified by the branch instruction notification unit of the execution of the branch instruction, search the branch result buffer for any branch result entry therein that matches a branch instruction address of the executed branch instruction and an argument stored at a top of the call stack when the branch instruction is executed, and (ii) if a branch result entry that matches is found, regard a branch result of the branch result entry that matches as a predicted result of branching by the branch instruction; an instruction fetch unit operable to fetch instructions in accordance with the predicted result predicted by the branch prediction unit; a branch result record unit operable to, after the execution of the branch instruction is complete, record in the branch result buffer one branch result entry showing the following (i), (ii), and (iii) in correspondence: (i) the branch instruction address of the executed branch instruction; (ii) an address of a branch destination that has been branched to via the execution of the branch instruction; and (iii) a leading value of the call stack at execution time of the branch instruction; and a function return notification unit operable to make a notification of execution of a function return instruction by the instruction execution unit, wherein the call stack is cleared of any arguments of a function corresponding to the function return instruction when notified by the function return notification unit of the execution of the function return instruction.