Inlining asm functions
    Brad Roberts 
    braddr at bellevue.puremagic.com
       
    Thu Jun 11 16:13:23 PDT 2009
    
    
  
On Thu, 11 Jun 2009, Frits van Bommel wrote:
> bearophile wrote:
> > creal expi(real y) {
> >     version (LDC) pragma(allow_inline);
> > 	asm {           		fld y;
> > 		fsincos;
> > 		fxch ST(1), ST(0);
> > 	}
> >     // add code here if asm isn't allowed
> > }
> > 
> Note that for LDC, an even more optimal arrangement is something like[1]:
> -----
> version(LDC)
>     import ldc.llvmasm;
> 
> creal expi(real y) {
>     return __asm!(creal)("fsincos", "={st(0)},={st(1)},0", y);
> }
> -----
My appologies if I cut too much context, but one of the things Walter 
explicitly wanted with D's asm syntax was that it be portable across 
compilers.  Having to have special syntax for each compiler is a problem.  
I strongly agree that functions using asm should be inlineable.
Some will almost certainly point out that the proposed macros for d-future 
will solve the problem, and yes, it could be used here.  But should it be 
necessary just to accomplish what should already be doable with standard
inlining techniques?
Anyway, food for thought.
Later,
Brad
    
    
More information about the Digitalmars-d
mailing list