Fri, 07 Aug 2009 13:47:31 -0700, Robert Jacques wrote: > On Fri, 07 Aug 2009 12:03:43 -0700, Yigal Chripun <[email protected]> > wrote: > >> regarding the div() function above, I was thinking about using D's naked >> asm feature. From what little I know about this, the compiler doesn't >> generate the usual asm code for this sort of function to handle >> registers, stack, etc, and you're supposed to do everything yourself in >> asm. > > IIRC naked asm only works for zero-argument and single arguments of size > 1,2 or 4 functions, which div is not. > >> I don't think your comment above about the function call overhead >> applies if div is implemented in such a way but I'm no expert and >> someone more knowledgeable can shed more light on this. (Don?) > > If you check the D ABI, one of the arguments must be passed on the stack, > the other in a specific register (EAX). > http://www.digitalmars.com/d/2.0/abi.html > So the backend can't do things like ECX = EBX / EDX. Instead it has to > save/restore whatever's in EAX, ECX and EDX before/after the div call.
Inlined functions become integral part of their outer functions and therefore are not obliged to follow ABI. They don't have prologues, epilogues, call overhead, etc. Moreover compiler intrinsics are functions which compiler recognizes and treats specially, usually by replacing them with a single processor instruction.
