Skip to content

Commit

Permalink
add support for experimental CHasSpace instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
brettferdosi committed Apr 17, 2020
1 parent 2520cb3 commit 290e494
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cheri/cheri_insts.sail
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ function clause execute (CGetAndAddr(rd, cb, rs)) =
wGPR(rd) = capVal.address & rs_val;
}

union clause ast = CHasSpace : (regno, regno, regno)
function clause execute (CHasSpace (rd, cb, rs)) =
{
checkCP2usable();
let cb_val = readCapReg(cb);
let cb_cursor = getCapCursor(cb_val);
let cb_base = getCapBase(cb_val);
let cb_top = getCapTop(cb_val);
let rs_val = unsigned(rGPR(rs));
if ((cb_cursor + rs_val) <= cb_top) &
(cb_cursor < cb_top) &
(cb_cursor >= cb_base) then
wGPR(rd) = zero_extend(to_bits(1,1))
else
wGPR(rd) = zeros()
}

union clause ast = CGetPCC : regno
function clause execute (CGetPCC(cd)) =
{
Expand Down Expand Up @@ -1567,6 +1584,9 @@ function clause decode (0b010010 @ 0b00000 @ rt : IntRegEnc @ rs : IntRegEnc @

/* Three operand */

/* Capability Inspection */
function clause decode (0b010010 @ 0b00000 @ rd : IntRegEnc @ cb : CapRegEnc @ rs : IntRegEnc @ 0b100101) = Some(CHasSpace(rd, cb, rs))

/* Capability Modification */
function clause decode (0b010010 @ 0b00000 @ cd : CapRegEnc @ cs : CapRegEnc @ ct : CapRegEnc @ 0b001011) = Some(CSeal(cd, cs, ct))
function clause decode (0b010010 @ 0b00000 @ cd : CapRegEnc @ cs : CapRegEnc @ ct : CapRegEnc @ 0b001100) = Some(CUnseal(cd, cs, ct))
Expand Down

0 comments on commit 290e494

Please sign in to comment.