Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 28, 2013 Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
Hello, Is it possible for an ASM function to be inlined in D? for example I compile with -Release -inline, this function (used in a simple console app obviously): --- int SSERound(double AValue) { asm { cvtsd2si EAX,[AValue]; } } --- but, under win32, the code generated looks like this: --- sub_402010 proc near ; CODE XREF: _TEXT:0040209Dp _TEXT:00402010 _TEXT:00402010 arg_0 = qword ptr 8 _TEXT:00402010 _TEXT:00402010 push ebp _TEXT:00402011 mov ebp, esp _TEXT:00402013 cvtsd2si eax, [ebp+arg_0] _TEXT:00402018 pop ebp _TEXT:00402019 retn 8 _TEXT:00402019 sub_402010 endp --- Which looks a bit odd as there is a CALL, a PUSH, a POP and a RET just for one SSE instruction. I've tried with "naked", but I've fastly get that this keyword simply mean that it's up to the user to clean the regs or to push pop the wtacks etc. Can dmd "inline" this simple function ? the D manual doesn't seem to specify that there is a restriction over inlining when a function contains an asm block. |
February 28, 2013 Re: Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
Posted in reply to D-ratiseur | On Thu, 28 Feb 2013 16:22:49 +0100, D-ratiseur <ThisAdressDoesntExist@nowhere.fr> wrote: > Hello, Is it possible for an ASM function to be inlined in D? Nope. -- Simen |
February 28, 2013 Re: Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | On Thursday, 28 February 2013 at 15:35:07 UTC, Simen Kjærås wrote:
> Nope.
Ok, thx, so it's like in Delphi/Fpc. Maybe the manual could contain a remark about this.
|
February 28, 2013 Re: Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
Posted in reply to D-ratiseur | D-ratiseur:
> Maybe the manual could contain a remark about this.
I think it's written somewhere in the site.
But LDC is able (with a compiler-specific pragma) to inline functions that contain asm.
Bye,
bearophile
|
February 28, 2013 Re: Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
On Thu, 28 Feb 2013, Simen Kj?r?s wrote:
> On Thu, 28 Feb 2013 16:22:49 +0100, D-ratiseur <ThisAdressDoesntExist@nowhere.fr> wrote:
>
> > Hello, Is it possible for an ASM function to be inlined in D?
>
> Nope.
To be a little more accurate: it's possible in the technical sense. No D compiler today does it automatically. There's no way with DMD to force it, but might be with GDC and/or LDC.
The lack of inlining in a number of cases that seem like they should is a quality of implementation issue and not a language definition issue.
|
March 01, 2013 Re: Inlining a "pure" ASM function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad Roberts | Am Thu, 28 Feb 2013 14:33:15 -0800 (PST)
schrieb Brad Roberts <braddr@puremagic.com>:
> On Thu, 28 Feb 2013, Simen Kj?r?s wrote:
>
> > On Thu, 28 Feb 2013 16:22:49 +0100, D-ratiseur <ThisAdressDoesntExist@nowhere.fr> wrote:
> >
> > > Hello, Is it possible for an ASM function to be inlined in D?
> >
> > Nope.
>
> To be a little more accurate: it's possible in the technical sense. No D compiler today does it automatically. There's no way with DMD to force it, but might be with GDC and/or LDC.
>
> The lack of inlining in a number of cases that seem like they should is a quality of implementation issue and not a language definition issue.
IIRC gdc dropped support for dmd-style inline assembly. For gcc style inline assembly inlining should just work.
|
Copyright © 1999-2021 by the D Language Foundation