Am 06.04.2022 um 20:32 schrieb J. Gareth Moreton via fpc-devel:
Another problem... I've tried to declare an ADDPD intrinsic as follows:

function x86_addpd(r0, r1: __m128d): __m128d; [INTERNPROC: fpc_in_x86_addpd];

I thought using __m128d instead of __m128 was fairly logical since ADDPD works with Doubles, not Singles, but this can cause problems.  For example, with the following setup:

    function Special(z1, z2 : __m128d): __m128d; vectorcall;
      begin
        Special := x86_addpd(z1, z2);
      end;

I get the following: Error: Incompatible types: got "__m128" expected "__m128d" (the file location is between the closing bracket and the semicolon of "Special := x86_addpd(z1, z2);" - it seems that it's hard-coded to expect __m128 (error occurs even if vectorcall is not specified).

I know there's still some work to do and things to work out with the vector types and intrinsics.  I will admit that personally I don't like Microsoft Visual C++'s approach of forcing the use of the MM types because it feels inflexible and unfriendly, especially as you might, for example, want to declare and use something like the following?

type TVector4 = packed record
  X, Y, Z, W: Single;
end align 16;

Pascal simply is a strongly typed language. Vector intrinsics are no reason to weaken this. Thus you need to declare operator overloads that hide the nitty, gritty details of assigning a TVector4 to a __m128, e.g.:

type
  TVector4 = packed record
    X, Y, Z, W: Single;
    class operator := (const aArg: TVector4): __m128;
    class operator := (const aArg: __m128): TVector4;
  end;

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to