Thread overview | |||||
---|---|---|---|---|---|
|
January 18, 2007 inlining with D | ||||
---|---|---|---|---|
| ||||
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? |
January 18, 2007 Re: inlining with D | ||||
---|---|---|---|---|
| ||||
Posted in reply to orgoton | 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 functions
> If 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.
|
January 18, 2007 Re: inlining with D | ||||
---|---|---|---|---|
| ||||
Posted in reply to orgoton | 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
|
Copyright © 1999-2021 by the D Language Foundation