jasmin-lang / jasmin

Language for high-assurance and high-speed cryptography
MIT License
268 stars 55 forks source link

Subarrays for stkptr #929

Open eponier opened 4 weeks ago

eponier commented 4 weeks ago

I tested whether we could access and assign subarrays of stkptr, and it appears that it is accepted by stack alloc, but fails at linearization.

param int N = 4;

// we want to do pointer arithmetic with stk ptr, but this fails

export fn main (reg ptr u64[N] r) -> reg u64 {
  reg u64 res = 0;

  stack ptr u64[N] s;
  stack ptr u64[1] s1;
  reg ptr u64[1] r1;

  s = r;
  s1 = s[1:1];
  r1 = s1;

  res = r1[0];

  return res;
}

Do we want to allow such a thing?

eponier commented 4 weeks ago

(it probably makes sense only on x86, but I think it does make sense there)