Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-03

Re: Successful implementation of inline support for pureassembler routines on x86

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

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" 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 

Reply by email

J. Gareth Moreton

Well, I guess that's good. I did wonder
though, because the XML dump patches have
been sitting in the bug tracker since the
start of February:
https://bugs.freepascal.org/view.php?
id=35017

Gareth aka. Kit

On Thu 21/03/19 07:08 , "Jonas Maebe"
sent:

On 2019-03-19 20:17, J. Gareth Moreton
> If you want to inline regular

functions with

assembler blocks, you'll > need the attached bug fixes. The rest

I'll

leave up to you. Thanks, I'll have a look at the patch

this weekend.

> What is Florian's and your vision for

Free

Pascal? You already have a > cross-platform Object Pascal

compiler... what's

next for it? Does any > of my proposals even have a place in

that

Show quoted text 8 lines
vision, because honestly I > don't know if the following is wanted: > > - pure functions > - XML node dump (compiler debugging

feature) - I

personally need it for > pure functions and for fixing #32913. > - faster and smarter optimization on

x86-64

I don't see inherent problems with any

of these features, unlike with

Show quoted text 13 lines
pure assembler function inlining. Jonas

Reply by email