H1 2015 Priorities and Bare-Metal Programming

Mike via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 3 01:11:04 PST 2015


On Tuesday, 3 February 2015 at 08:28:42 UTC, Walter Bright wrote:
>
> The compiler offers a -inline switch, which will inline 
> everything it can. Performance oriented code will use that 
> switch.
>
> pragma(inline,true) tells the compiler that this function is 
> 'hot', and pragma(inline, false) that this function is 'cold'. 
> Knowing the hot and cold paths enables the optimizer to do a 
> better job.
>

Assume I'm creating a bare-metal program with 2 functions: an 
entry point `void _start` and a function that puts a byte in a 
MMIO UART's send buffer `void send(byte b)`. `_start` calls 
`send`.  There is no phobos, druntime, or any other libraries.  
It is just my "test.d" source file only.  (Please don't knit-pick 
this with irrelevant technicalities)

scenario A)
compile test.d with -inline
`_start` is pragma(inline, false)
`send` is pragma(inline, true)     -- this is redundant, yes?

scenario B)
compile with -inline
`_start` is pragma(inline, false)
`send` is pragma(inline)

scenario C)
compile without -inline
`_start` is pragma(inline, false)
`send` is pragma(inline, true)

All things being equal, will there be any difference between the 
resulting binaries for each of these scenarios?

Another way of putting it:  Does pragma(inline, true) simply 
allow the user to compiler parts of their source file with 
-inline?

Mike


More information about the Digitalmars-d mailing list