Re: Do not spill variables/registers on the stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Enrico Weigelt <weigelt@xxxxxxxx> writes:

> What does the ANSI C spec say about the "register" keyword ?

6.7.1.  "A declaration of an identifier for an object with storage-class
specifier register suggests that access to the object be as fast as
possible.  The extent to which such suggestions are effective is
implementation-defined."

Then a footnote to that text says "The implementation may treat any
register declaration simply as an auto declaration.  However, whether or
not addressable storage is actually used, the address of any part of an
object declared with storage-class specifier register cannot be
computed, either explicitly (by use of the unary & operator as discussed
in 6.5.3.2) or implicitly (by converting an array name to a pointer as
discussed in 6.3.2.1).  Thus, the only operator that can be applied to
an array declared with storage-class specifier register is sizeof."


> Does GCC issue some warning when it fails to put such a variable
> directly into a register ?

No.

> Is it that keyword still useful at all on todays compilers ?

No, except for things like gcc's extension to specify the hardware
register where a variable should live.

> I'm not really experienced at that low level, but i can imagine 
> scenarios where it's essential to keep certain things in registers
> (eg. when there's no valid stack), so the compiler should issue
> a warning (which can be made fatal w/ -Werror) in those cases.

Such code can not be written in standard C.  It always requires
extensions.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux