Inlining a "pure" ASM function

D-ratiseur ThisAdressDoesntExist at nowhere.fr
Thu Feb 28 07:22:49 PST 2013


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.


More information about the Digitalmars-d-learn mailing list