-
Notifications
You must be signed in to change notification settings - Fork 10
Description
If we know that the length we're materializing is a constant and that it's guaranteed to be representable, we could replace the li; CSetBoundsExact sequence with just a CSetBoundsImm. Consider, for concrete example,
Capability cap{p};
cap.bounds() = 1;
which presently compiles, via the __builtin_cheri_bounds_set_exact primop, to
li a1, 0x1
csetboundsexact ca0, ca0, a1
The CSetBoundsImm instruction has a 12 bit immediate. I'll leave it to better-informed people (@davidchisnall, say) to decide whether we want to limit the compiler's understanding of "guaranteed to be representable" to the "exponent 0" case (so between 0 and 511 bytes on CHERIoT's present encoding") or whether we want to permit some other choices of exponents for suitably aligned pointee types (up to 1022 for 2-aligned, &c...; this would be at the cost of requiring intra-pointer bit stunts happening exclusively after bounds are applied, which seems reasonable).