jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

Using mmx on ARM produces strange errors

Open eponier opened this issue 1 year ago • 9 comments

Compiling for ARM the program

export fn main () -> reg u32 {
  #mmx reg u32 x;
  reg u32 y;

  y = 0;
  x = y;
  y = x;
  return y;
}

produces

compilation error:
register allocation: no more free register to allocate variable:
    x.180 (defined at "file.jazz", line 6 (2-3))
Conflicts with:

Note that the list of conflicts is empty, so the message is a bit confusing.

Compiling this other program

export fn main () -> reg u32 {
  #mmx reg u32 x;
  reg u32 x2 y z;

  y = 0;
  x = y;
  x2 = y;
  y = x;
  z = x2;
  y += z;
  return y;
}

raises an exception

compilation error:
register allocation: no more free register to allocate variable:
    x.192 (defined at "file.jazz", line 6 (2-3))
Conflicts with:
Fatal error: exception Not_found

eponier avatar Jan 19 '24 16:01 eponier

Maybe related to https://github.com/jasmin-lang/jasmin/issues/601?

eponier avatar Jan 19 '24 16:01 eponier

I guess the annotation should be ignored, with a warning.

vbgl avatar Jan 19 '24 17:01 vbgl

The second example reveals a real problem in the allocator if I'm not mistaken: the fact that registers and extra registers can conflict. The problem does not happen with large registers because they have different types from scalar register. When dealing with a class of registers, we have at our disposal the table of the variables corresponding to that class, so printing a conflict with a variable from another class fails.

eponier avatar Jan 19 '24 18:01 eponier

For example 1, it depends whether we want to be able to write code working both for ARM and x86. If we do not care, there is no problem rejecting programs that use mmx. We just need a better error message.

eponier avatar Jan 19 '24 18:01 eponier

I think this is fix with the last commit of #692

bgregoir avatar Jan 19 '24 20:01 bgregoir

No, the conflict may arise also if there are extra registers available. If we use all of them, we end up in this case too. This is just a bit more difficult to craft an example.

eponier avatar Jan 19 '24 23:01 eponier

Thanks. This crash (Fatal error: exception Not_found) of the second example is addressed by #694.

vbgl avatar Jan 22 '24 10:01 vbgl

Can we close this issus or we still have a pb with the first example.

bgregoir avatar Jan 23 '24 17:01 bgregoir

I think we need a dedicated error message when the bank is empty. Having an error explaining that it conflicts with nothing is really confusing.

eponier avatar Jan 25 '24 16:01 eponier