digitalmars.D.learn - Inlining a "pure" ASM function
- D-ratiseur (34/34) Feb 28 2013 Hello, Is it possible for an ASM function to be inlined in D?
- =?iso-8859-15?Q?Simen_Kj=E6r=E5s?= (5/6) Feb 28 2013 Nope.
- D-ratiseur (3/4) Feb 28 2013 Ok, thx, so it's like in Delphi/Fpc. Maybe the manual could
- bearophile (6/7) Feb 28 2013 I think it's written somewhere in the site.
- Brad Roberts (6/12) Feb 28 2013 To be a little more accurate: it's possible in the technical sense. No...
- Johannes Pfau (4/20) Mar 01 2013 IIRC gdc dropped support for dmd-style inline assembly. For gcc style
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.
Feb 28 2013
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
Feb 28 2013
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.
Feb 28 2013
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
Feb 28 2013
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: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.Hello, Is it possible for an ASM function to be inlined in D?Nope.
Feb 28 2013
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:IIRC gdc dropped support for dmd-style inline assembly. For gcc style inline assembly inlining should just work.On Thu, 28 Feb 2013 16:22:49 +0100, D-ratiseur <ThisAdressDoesntExist nowhere.fr> wrote: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.Hello, Is it possible for an ASM function to be inlined in D?Nope.
Mar 01 2013