[fpc-devel] using sse2 packed doubles
Vincent Snijders
vsnijders at quicknet.nl
Fri Oct 6 09:48:59 CEST 2006
Hi,
I wondered if it is possible to add support for using sse2 packed doubles in fpc.
I tried to create a sse2doubles type and define a operator + on it. Eventually I
want to move this type and all operators on it to a separate sse2 unit, so that the
user of this type doesn't need to see the assembler. The following program works,
but not as efficiently as I had hoped, because the operator is not inlined, probably
because of the assembler code.
Is it possible to create this purely in RTL /units or is compiler support needed?
Does it make sense to create a 'feature request'bug tracker item for this? Compiler
hacking is out of my league.
program optsse2;
{$mode objfpc}{$H+}{$ASMMODE ATT}
{$FPUTYPE SSE2}
type
sse2doubles = record
d1, d2: double;
end;
operator + (d1, d2: sse2doubles) : sse2doubles; assembler; inline;
{begin
result.d1 := d1.d1 + d2.d1;
result.d2 := d1.d2 + d2.d2;
end;}
asm
movupd (%eax), %xmm0
addpd (%edx), %xmm0
movupd %xmm0, (%ecx)
end;
procedure test;
var
sd1, sd2, sd3: sse2doubles;
begin
sd1.d1 := 1;
sd1.d2 := 2;
sd2.d1 := 3;
sd2.d2 := 4;
sd3 := sd1 + sd2;
writeln(sd3.d1);
writeln(sd3.d2);
end;
begin
test;
end.
More information about the fpc-devel
mailing list