digitalmars.D - inlining with D
- orgoton (2/2) Jan 18 2007 With C++ i used the "inline" keyword. How to I instrument the D compiler...
- BCS (8/11) Jan 18 2007 A quick and dirty way to see what functions /may/ be inlined is to run
- Sean Kelly (8/10) Jan 18 2007 It does this automatically so long as the -inline flag it set when
With C++ i used the "inline" keyword. How to I instrument the D compiler to inline a function? If it does this automatically, what are the criteria?
Jan 18 2007
orgoton wrote:With C++ i used the "inline" keyword. How to I instrument the D compiler to inline a function?use the -inline command line flag and DMD will start inlineing functionsIf it does this automatically, what are the criteria?A quick and dirty way to see what functions /may/ be inlined is to run DMD with the -H flag. This will generate a "header" file (<filename>.di) that has prototypes for some functions and source for others. IIRC the cases with source are candidates for inlineing. I seem to recall it amounts to short functions without ASM blocks or loops. But I'm sure that's not all and I may be wrong on that.
Jan 18 2007
orgoton wrote:With C++ i used the "inline" keyword. How to I instrument the D compiler to inline a function? If it does this automatically, what are the criteria?It does this automatically so long as the -inline flag it set when compiling. Any function which has an available implementation at compile-time is a candidate for inlining (ie. excluding a C-style "header" module as an interface for a pre-compiled library). At the moment, DMD will not inline delegates, functions containing loops, or ASM code, but all are eventually candidates with compiler refinements. Sean
Jan 18 2007