Skip to content

Feature request #3

bacelar edited this page Dec 10, 2021 · 3 revisions

support for reg ptr arguments in exported function

Goal

To allow reg ptr (and reg ptr arrays) to appear in arguments of exported function. Such as in:

param int NLIMBS = 7;
export fn bn_eq(reg ptr u64[NLIMBS] x y) -> reg u64 { ... }

This would allow to save an array copy between memory and the stack where those arrays are handled by the library.

Of course, such a declaration should also be read as a user provided assumption that the memory regions pointed by those reg ptr registers are not aliased between themselves and with any memory chunk reachable by other pointer arguments passed to the function.

In general, we would like not only readable reg ptrs, but also writable reg ptrs (and possibly in/out arguments, c.f. feature request #2). In that case, the syntax becomes a little bit stranger, because it would allow reg ptrs to appear at the result type of the exported function (even though they are of course absent from the generated code). E.g.

export fn bn_addn(reg ptr u64[NLIMBS] x y) -> reg ptr u64[NLIMBS] { ... }
Clone this wiki locally