A
Ancient_Hacker
In days of old, for no discernible reason, many CPU's had the ability
to execute one or more instructions out of registers. Not very common
today.
Which brings up a semi interesting point.
We know the "register" keyword suggests the compiler keep the
following variable in a register.
We also have the "inline" suggestion in C++ to suggest inlining a
function.
What if one could suggest: register int max(a,b) { return a>b?a:b }
.... meaning "you might want to keep this function in registers"
of course the usual "register" and "inline" restrictions would apply--
you cant take the address of this function or pass it as a function
parameter. Plus the registers would be unavailable for any other use.
I guess all these hints are kinda obsolescent as the hardware guys are
always trying to find ways of giving us more speed, like adding a cache
so some variables have register-like speed, same for code cache so some
code executes like it was in registers.
Kinda weird for a function being "there" but not having an address.
to execute one or more instructions out of registers. Not very common
today.
Which brings up a semi interesting point.
We know the "register" keyword suggests the compiler keep the
following variable in a register.
We also have the "inline" suggestion in C++ to suggest inlining a
function.
What if one could suggest: register int max(a,b) { return a>b?a:b }
.... meaning "you might want to keep this function in registers"
of course the usual "register" and "inline" restrictions would apply--
you cant take the address of this function or pass it as a function
parameter. Plus the registers would be unavailable for any other use.
I guess all these hints are kinda obsolescent as the hardware guys are
always trying to find ways of giving us more speed, like adding a cache
so some variables have register-like speed, same for code cache so some
code executes like it was in registers.
Kinda weird for a function being "there" but not having an address.