Register unions

Robert English renglish at hpisod1.HP.COM
Wed Oct 26 06:29:47 AEST 1988


> / gwyn at smoke.BRL.MIL (Doug Gwyn ) /  2:16 pm  Oct 23, 1988 /

> The point is, on many architectures not all basic data types could actually
> share a register.  Your original example was of an integer and a floating
> type sharing a register, which doesn't work on any machines I'm aware of.
> And obviously a union of large types would not fit into a register.

> Simply permitting "register" to be crammed on the front of "union" would
> do no good; the hardware would have to actually support the usage for
> this to be worthwhile.  If the hardware DOES support this, its C
> implementation is allowed to use an actual register (so long as the
> address is not taken).  Good optimizing C compilers ignore the "register"
> specifiers and do their own register allocation anyway.

Even if the hardware could not support a register union of incompatible
data types, the information would be valuable to an optimizer.
"Register," in addition to expressing a storage preference, informs the
compiler that the variable is non-addressable, and that the compiler
needn't worry about the contents changing.

--bob--



More information about the Comp.lang.c mailing list