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 pure assembler routines on x86

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

J. Gareth Moreton

Normally Florian or another administrator will say if the patch has been applied and mark the ticket as "resolved" if they're happy.  Once they are added I will have a play around.

Admittedly one thing I'm also waiting on is the node XML dump feature ( https://bugs.freepascal.org/view.php?id=35017 ), since that will allow me to see how procedures are constructed at the intermediate level, plus I sort of need it in order to work out what's going on with https://bugs.freepascal.org/view.php?id=32913 , something I've vowed to fix but has been sitting dormant for ages now - I'll have to apologise to David Hawk (the reporter) afterwards.

Gareth aka. Kit

On Sat 16/03/19 16:07 , Ryan Joseph sent:

On Mar 15, 2019, at 9:37 AM, Sven Barth via fpc-devel wrote: 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):

I fixed the patch for constants in generics and uploaded again (https://bugs.freepascal.org/view.php?id=35140). [2] Not sure if they added it yet or they were waiting for my to fix things. Let me know if that patch is in the correct format so I can fix the other one for multi-helpers.

Regards,
Ryan Joseph

Reply by email

J. Gareth Moreton

I would have allowed writing to the stack with inline assembly functions if a way could be found to ensure that the compiled program behaves the same way whether the function is inlined or called directly (e.g. through a direct CALL or a function pointer), which would otherwise require shifting byte offsets depending on if the function return address was pushed or not, so I decided to just forbid it completely.

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

Gareth aka. Kit

On Tue 19/03/19 08:04 , Jonas Maebe sent:

J. Gareth Moreton wrote
I guess there's no place for me here. I don't have the facilities or knowledge to develop beyond i386 and x86_64, and there's too much conflict. You win. What am I but a rowdy tyke who doesn't listen to his elders and betters?

I don't consider myself to be better than you, and you giving up is not me "winning". You also don't need to develop beyond i386/x86-64, but you do have to take into account that they exist. This means that unless a feature is inherently specific to a particular platform, it has to be generalisable and can be made to function in a predictable way everywhere (within the bounds of defined behaviour; what that is, is defined by the implementer of the functionality, but it should be possible to specify it and preferably with not too many rules, so it can be understood easily by users and other platform maintainers alike).

That is not possible for parsing and trying to understand inline assembly using automated means. It is very fragile, which makes specifying the defined behaviour very hard. It needs a ton of exceptions, many of which will be platform specific, which makes its functionality unpredictable.

I guess I don't understand the philosophy of FPC after all, or can even program well.

This is not about your programming skills, those are quite good. It is, however, indeed very much about FPC's philosophy. That said, this particular feature is something that at least most other compilers (even for other languages) don't implement either, afaik. Most of them even don't support defining pure assembler functions inside the host language's source file, and require you to use external assembler files. They do allow you to inline regular functions that contain inline assembly though.

Jonas

Reply by email

Ryan Joseph
to J. Gareth Moreton
Show quoted text 7 lines
On Mar 19, 2019, at 3:17 PM, J. Gareth Moreton wrote: 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 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 remember you getting feedback and support for pure functions so that one’s a go for sure.

Regards,
Ryan Joseph

Reply by email

Jonas Maebe
to J. Gareth Moreton: I would have allowed writing to the stack with inline assembly functions if a way could…
J. Gareth Moreton wrote
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.

Show quoted text 9 lines
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 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 pure assembler function inlining.

Jonas

Reply by email

Florian Klämpfl
to J. Gareth Moreton: I would have allowed writing to the stack with inline assembly functions if a way could…
J. Gareth Moreton wrote 15 lines
I would have allowed writing to the stack with inline assembly functions if a way could be found to ensure that the compiled program behaves the same way whether the function is inlined or called directly (e.g. through a direct CALL or a function pointer), which would otherwise require shifting byte offsets depending on if the function return address was pushed or not, so I decided to just forbid it completely. 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. 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 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

All of them are in the scope of FPC imo, currently things are time limited though :(

Reply by email