[fpc-devel] Successful implementation of inline support for pureassembler routines on x86
J. Gareth Moreton
gareth at moreton-family.com
Fri Mar 15 14:06:22 CET 2019
I mention intrinsics because, according to Florian, someone is already
developing support for them, although I can't remember the SVN repository
off-hand.
P.S. If such generics were to be supported with my code, it would have to
be akin to:
generic function ShufPS(aArg: TM128): TM128; vectorcall; assembler;
nostackframe; inline; { I know, that's a lot of directives! }
asm
SHUFPS XMM0, XMM0, N
end;
That may get messy in the compiler source very quickly, but depending on
how well-liked my inline assembler code is, it might be something to look
into and experiment with. One step at a time though.
There is an example of an intrinsic in one of the regression tests
actually... tests/test/cg/tvectorcall3.pp contains a function that just
calls ADDPS and has the "inline" directive - until now, "inline" was
ignored with a compiler hint, but with my additions, now actually inlines
the instruction.
Gareth aka. Kit
On Fri 15/03/19 13:37 , "Sven Barth" pascaldragon at googlemail.com sent:
J. Gareth Moreton schrieb am Fr., 15. März 2019, 12:33:
P.S. Though this feature can be used for implementing intrinsics, it is
not a direct replacement for them because instructions like SHUFPS cannot
be flexibly encoded due to its immediate operand (i.e. it has to be a raw
number... it can't take its value from a parameter).
That could maybe be managed once the support for constants as parameter
for generics is added (note: I don't know right now how SHUFPS works, so
take the following as pseudo code):
=== code begin ===
generic function ShufPS(aArg: Whatever): Whatever; inline;begin asm
SHUFPS %xmm1, %xmm2, N end;end;
=== code end ===
As long as the assembler reader correctly handles constants for those
parameters this could work as for each N the compiler creates a new
function...
Regards,Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190315/07c31ea3/attachment.html>
More information about the fpc-devel
mailing list