summaryrefslogtreecommitdiff
path: root/cheri
diff options
context:
space:
mode:
authorRobert Norton2017-02-17 15:49:25 +0000
committerRobert Norton2017-02-17 15:49:25 +0000
commitcc2e15911d006f0abb033a9147953b0b60a83251 (patch)
tree52aa40d2337039a6ac2b489500dceed7fdb004d6 /cheri
parent83f8e574024df56e75bc1d3f6e6b50ce99ba9042 (diff)
use fast representable check for csetoffset as well as cincoffset.
Diffstat (limited to 'cheri')
-rw-r--r--cheri/cheri_prelude_128.sail17
1 files changed, 7 insertions, 10 deletions
diff --git a/cheri/cheri_prelude_128.sail b/cheri/cheri_prelude_128.sail
index 08fd8cf3..345d9502 100644
--- a/cheri/cheri_prelude_128.sail
+++ b/cheri/cheri_prelude_128.sail
@@ -214,16 +214,6 @@ function CapLen getCapLength((CapStruct) c) = getCapTop(c) - getCapBase(c)
function uint64 getCapCursor((CapStruct) cap) = unsigned(cap.address)
-function (bool, CapStruct) setCapOffset((CapStruct) c, (bit[64]) offset) =
- let oldBase = getCapBase(c) in
- let oldTop = getCapTop(c) in
- let (bit[64]) newAddress = oldBase + offset in
- let newCap = { c with address = newAddress } in
- let newBase = getCapBase(newCap) in
- let newTop = getCapTop(newCap) in
- let representable = (oldBase == newBase) & (oldTop == newTop) in
- (representable, newCap)
-
function bool fastRepCheck((CapStruct) c, (bit[64]) i) =
let E = min(unsigned(c.E), 45) in
let i_top = signed(i[63..E+20]) in
@@ -238,6 +228,13 @@ function bool fastRepCheck((CapStruct) c, (bit[64]) i) =
case _ -> false
} | (E >= 44)
+function (bool, CapStruct) setCapOffset((CapStruct) c, (bit[64]) offset) =
+ let (bit[64]) base = (bit[64]) (getCapBase(c)) in
+ let (bit[64]) newAddress = base + offset in
+ let newCap = { c with address = newAddress } in
+ let representable = fastRepCheck(c, (newAddress - c.address)) in
+ (representable, newCap)
+
function (bool, CapStruct) incCapOffset((CapStruct) c, (bit[64]) delta) =
let (bit[64]) newAddress = c.address + delta in
let newCap = { c with address = newAddress } in