From 4b2c3b11146b142dfe0007d7ca1881add43578da Mon Sep 17 00:00:00 2001 From: jon Date: Thu, 16 Apr 2020 18:07:39 +0100 Subject: [PATCH] An attempt at doing the "right thing" with Jr targets and links with respect to PCC. This is not easy to test until we have CSetBounds. --- src_Core/RISCY_OOO/procs/lib/Exec.bsv | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src_Core/RISCY_OOO/procs/lib/Exec.bsv b/src_Core/RISCY_OOO/procs/lib/Exec.bsv index 8e0ffbf..7fefc6c 100755 --- a/src_Core/RISCY_OOO/procs/lib/Exec.bsv +++ b/src_Core/RISCY_OOO/procs/lib/Exec.bsv @@ -179,9 +179,10 @@ function Bool aluBr(Data a, Data b, BrFunc brFunc); endfunction (* noinline *) -function Addr brAddrCalc(Addr pc, Data val, IType iType, Data imm, Bool taken, Bit #(32) orig_inst); +function Addr brAddrCalc(Addr pc, Addr pccBase, Data val, IType iType, Data imm, Bool taken, Bit #(32) orig_inst, Bool cap); Addr fallthrough_incr = ((orig_inst [1:0] == 2'b11) ? 4 : 2); Addr pcPlusN = pc + fallthrough_incr; + if (!cap) val = pccBase + val; Addr targetAddr = (case (iType) J : (pc + imm); Jr : {(val + imm)[valueOf(AddrSz)-1:1], 1'b0}; @@ -190,7 +191,7 @@ function Addr brAddrCalc(Addr pc, Data val, IType iType, Data imm, Bool taken, B endcase); return targetAddr; endfunction - +/* (* noinline *) function ControlFlow getControlFlow(DecodedInst dInst, Data rVal1, Data rVal2, Addr pc, Addr ppc, Bit #(32) orig_inst); ControlFlow cf = unpack(0); @@ -206,7 +207,7 @@ function ControlFlow getControlFlow(DecodedInst dInst, Data rVal1, Data rVal2, A return cf; endfunction - +*/ (* noinline *) function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, CapPipe pcc, Addr ppc, Bit #(32) orig_inst); // just data, addr, and control flow @@ -243,7 +244,7 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C // Default branch function is not taken BrFunc br_f = dInst.execFunc matches tagged Br .br_f ? br_f : NT; cf.taken = aluBr(getAddr(rVal1), getAddr(rVal2), br_f); - cf.nextPc = brAddrCalc(pc, getAddr(rVal1), dInst.iType, fromMaybe(0,getDInstImm(dInst)), cf.taken, orig_inst); + cf.nextPc = brAddrCalc(pc, getBase(pcc), getAddr(rVal1), dInst.iType, fromMaybe(0,getDInstImm(dInst)), cf.taken, orig_inst, (ccall || cjalr)); cf.mispredict = cf.nextPc != ppc; Addr fallthrough_incr = ((orig_inst [1:0] == 2'b11) ? 4 : 2); @@ -256,7 +257,7 @@ function ExecResult basicExec(DecodedInst dInst, CapPipe rVal1, CapPipe rVal2, C J : nullWithAddr(getAddr(link_pcc)); Jr &&& (ccall): cap_alu_result; // Depending on defaults falling through! Jr &&& (cjalr): link_pcc; - Jr : nullWithAddr(getAddr(link_pcc)); + Jr : nullWithAddr(getOffset(link_pcc)); Auipc : nullWithAddr(pc + fromMaybe(?, getDInstImm(dInst))); // could be computed with alu Csr : rVal1; default : cap_alu_result;