www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Inlining asm functions

reply Sean Kelly <sean f4.ca> writes:
I've noticed that the current behavior is to never inline functions 
containing asm blocks, and I was wondering if it might be practical to 
loosen this restriction a bit.  Would it be feasible to allow such 
functions to be inlined so long as the asm code doesn't explicitly 
reference stack (and possibly register) locations?  For example:

real sin(real x)
{
     asm
     {
         fld x;
         fsin;
     }
}

Since the above function refers to all data by name, it should be 
possible to inline.  I grant that this may be a good bit of work for 
little return, but it should allow for some intrinsics to be defined 
completely in library code which seems potentially useful.


Sean
Feb 08 2006
parent "Walter Bright" <newshound digitalmars.com> writes:
"Sean Kelly" <sean f4.ca> wrote in message 
news:dse1mg$2h76$1 digitaldaemon.com...
 I've noticed that the current behavior is to never inline functions 
 containing asm blocks, and I was wondering if it might be practical to 
 loosen this restriction a bit.  Would it be feasible to allow such 
 functions to be inlined so long as the asm code doesn't explicitly 
 reference stack (and possibly register) locations?  For example:

 real sin(real x)
 {
     asm
     {
         fld x;
         fsin;
     }
 }

 Since the above function refers to all data by name, it should be possible 
 to inline.  I grant that this may be a good bit of work for little return, 
 but it should allow for some intrinsics to be defined completely in 
 library code which seems potentially useful.

Yes, it would be useful, but there are technical problems. The worst is that writing inline assembler to be used as an expression can be very different from that is used as a function. Inlineable functions have to work, without source modification, both ways.
Feb 08 2006