jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

VMOV silently drop the size annotation

Open eponier opened this issue 4 years ago • 4 comments

When compiling the following program

export fn main () -> reg u256 {
  reg u256 xmm;
  reg u64 x;
  x = 2;
  xmm = #VMOV_256(x);
  return xmm;
}

we get a typing error because xmm is of type u256 instead of u128. Indeed, the annotation _256 is silently dropped. It would be better to have an error in this case. Maybe it was done like this to avoid another constructor PrimXXX?

eponier avatar Dec 07 '21 14:12 eponier

I discovered that for VMOV, but there are certainly other instructions with the same problem.

eponier avatar Dec 07 '21 14:12 eponier

The instructions descriptors should be slightly redesigned to explicitly document what sizes they support: currently this information is spread in the instruction syntax, semantics, parsing rules etc. Would it also fix this issue?

vbgl avatar Dec 07 '21 14:12 vbgl

I guess so. But I think this could also be solved without such a refactoring (probably a tedious work though).

As usual, I am used to creating an issue as soon as I discover a strange behaviour, but this does not mean I care much about the issue being solved. I want to be sure that we have a trace of the issue.

eponier avatar Dec 07 '21 14:12 eponier

Btw, at least from a user perspective, this issue is similar to https://github.com/jasmin-lang/jasmin/issues/69 where another annotation is silently ignored.

eponier avatar Dec 07 '21 14:12 eponier

In this case, the annotation is not ignored. It qualifies the argument to the intrinsic (here expression “x”). The result is always a u128, hence the error message.

If the failing line is changed to:

xmm = (256u)#VMOV_256(x);

then we get a type-error about the argument:

typing error: can not implicitly cast u64 into u256

I do not deny that there is some UX issue (it is difficult to properly use the MOVD / VMOV intrinsics), but I think that this issue is invalid and should be closed.

vbgl avatar Sep 05 '22 13:09 vbgl

Indeed, the annotation has an impact only the type of the argument. It's probably better to close this.

eponier avatar Sep 15 '22 13:09 eponier