New function for adding to the address unsafely.
Would used an increment size based on mantissa width, but this is not available in the type class, so just use 1 byte. This function is currently used for adding small increments to the PC, so does not need support for larger offsets.
This commit is contained in:
@@ -928,6 +928,7 @@ instance CHERICap #(CapMem, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
capMem.address = address;
|
||||
return pack(capMem);
|
||||
endfunction
|
||||
function addAddrUnsafe (cap, inc) = setAddrUnsafe(cap, getAddr(cap) + signExtend(inc));
|
||||
function getOffset = error("getOffset not implemented for CapMem");
|
||||
function modifyOffset = error("modifyOffset not implemented for CapMem");
|
||||
function getBase = error("getBase not implemented for CapMem");
|
||||
@@ -1062,6 +1063,8 @@ instance CHERICap #(CapReg, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
return setCapPointer(cap, zeroExtend(address));
|
||||
endfunction
|
||||
|
||||
function addAddrUnsafe (cap, inc) = setAddrUnsafe(cap, getAddr(cap) + signExtend(inc));
|
||||
|
||||
function getOffset = error("getOffset not implemented for CapReg");
|
||||
function modifyOffset = error("modifyOffset not implemented for CapReg");
|
||||
function getBase = error("getBase not implemented for CapReg");
|
||||
@@ -1181,6 +1184,8 @@ instance CHERICap #(CapPipe, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
return cap;
|
||||
endfunction
|
||||
|
||||
function addAddrUnsafe (cap, inc) = setAddrUnsafe(cap, getAddr(cap) + signExtend(inc));
|
||||
|
||||
function getOffset (x) = getOffsetFat(x.capFat, x.tempFields);
|
||||
|
||||
function Exact#(CapPipe) modifyOffset (CapPipe cap, Bit#(CapAddressW) offset, Bool doInc);
|
||||
|
||||
@@ -124,6 +124,8 @@ typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n, n
|
||||
function Exact#(t) setAddr (t cap, Bit#(n) addr);
|
||||
// Set the address of the capability. Result assumed to be representable
|
||||
function t setAddrUnsafe (t cap, Bit#(n) addr);
|
||||
// Add to the address of the capability. Result assumed to be representable
|
||||
function t addAddrUnsafe (t cap, Bit#(8) inc);
|
||||
|
||||
// Get the offset of the capability
|
||||
function Bit#(n) getOffset (t cap) = getAddr(cap) - getBase(cap);
|
||||
|
||||
Reference in New Issue
Block a user