Re: Windows X64 Calling conventions

2017-04-20 Thread Tofu Ninja via Digitalmars-d-learn

On Thursday, 20 April 2017 at 08:36:32 UTC, kinke wrote:

On Thursday, 20 April 2017 at 01:16:11 UTC, Tofu Ninja wrote:
My question is, why is it passed twice, both in xmm0 and rcx? 
The MSDN docs say floating point are passed in xmm registers, 
why is it also copied in into rcx? Is it necessary for 
anything?


That is only required for variadics, quoting MSDN 
[https://msdn.microsoft.com/en-us/library/dd2wa36c.aspx]:

For floating-point values only, both the integer and the
floating-point register will contain the float value in case
the callee expects the value in the integer registers.


Oh thanks, that answers my question, but it seem odd that dmd 
does it no matter what even when variadics are not used.


Re: Windows X64 Calling conventions

2017-04-20 Thread kinke via Digitalmars-d-learn

On Thursday, 20 April 2017 at 01:16:11 UTC, Tofu Ninja wrote:
My question is, why is it passed twice, both in xmm0 and rcx? 
The MSDN docs say floating point are passed in xmm registers, 
why is it also copied in into rcx? Is it necessary for anything?


That is only required for variadics, quoting MSDN 
[https://msdn.microsoft.com/en-us/library/dd2wa36c.aspx]:

For floating-point values only, both the integer and the
floating-point register will contain the float value in case
the callee expects the value in the integer registers.


Windows X64 Calling conventions

2017-04-19 Thread Tofu Ninja via Digitalmars-d-learn
I am trying to learn the calling conventions in DMD, I am sure I 
will have more than one question about them so as I come across 
them I will ask them in this thread. I am mainly reading the MSDN 
docs on the x64 calls and looking at disassemblies to confirm 
what I learn.



While I was looking at a call of the form void foo(float), I get 
the following disassembly:


movss   xmm0,dword ptr [_TMP0]
sub rsp,20h
movdrcx,xmm0
callvoid main.foo(float)
add rsp,20h


My question is, why is it passed twice, both in xmm0 and rcx? The 
MSDN docs say floating point are passed in xmm registers, why is 
it also copied in into rcx? Is it necessary for anything? If it 
was skipped would anything break?



Thanks