On Fri, Jul 13, 2018 at 4:39 AM, Pierre G. <
pig...@gmail.com> wrote:>
jalr x6, x7, imm // none are link register
>
> new state :
> pc <= x7 + imm
As I understand things, the return address stack is an implementation
detail, an optimization if you will, to facilitate faster subroutine
calls and returns by priming branch prediction logic. It does not
affect the register update of Rd when executing the JAL(R)
instruction, and should prediction fail, the core *must* jump to
rs1+imm.
new state:
pc <= x7 + imm
x6 <= old pc+4
> jalr x6, x1, imm // 2nd case as x6 is not link, but x1 is. This is pop.
>
> new state :
> pc <= x1. // in this case imm is useless.
The immediate field can never useless.
When you pop the RAS stack, the intent is to predict the return
address. E.g., the instruction *fetch* stage starts fetching at the
peeked[1] address, in the *hopes* that it's doing the right thing.
That prediction can be wrong; the prediction is right if, and only if,
rs1+imm == top of RAS at the time the JALR actually *executes* (e.g.,
reaches an execute stage). If the two values are not correct, you'll
need to invalidate the pipeline stages leading up to the JALR
execution stage, and fetch again from rs1+imm.
new state:
pc <= x1 + imm // imm can't be useless, or you'll break
compatibility with earlier non-privileged ISA specs.
x6 <= old pc + 4
________
1. A stack typically has three operations, not just two. Push and
pop we're all familiar with, and this is what happens during the
*execute* stage. A *Peek* is a non-destructive read of the top of
stack.
--
Samuel A. Falvo II