Typedefs

Guy Harris guy at sun.uucp
Thu Oct 17 15:34:53 AEST 1985


> (The 4.x BSD C compiler) doesn't ignore register short definitions, it
> mearly does not put them in registers because registers can only be
> applied to types int and long on VAX.

It also puts pointers into registers as well; the rule is "if it's not 32 bits
wide, ignore the 'register' declaration."  The reason, according to the
4.1BSD manual page for "cc":

	BUGS
	     The compiler currently ignores advice to put "char",
	     "unsigned char", "short", or "unsigned short" variables
	     into registers.  It previously produced poor, and in
	     some cases incorrect, code for such declarations.

I remember running code through the System III VAX PCC and the 4.1BSD VAX
PCC (which is the S3 VAX PCC with long variable name support added, register
variables < 32 bits wide subtracted, and some other minor changes).  If I
remember correctly, the S3 compiler did, indeed, produces some
less-than-wonderful code for some constructs involving "register short"
variables.

The S5 VAX PCC will put types shorter than 32 bits into registers; it has
been claimed that it does not produce the same poor code.  I've provoked it
into producing code which widens things into registers and narrows them
again (or *vice versa*; it's been a while).  This may have been necessary to
preserve the semantics of C; I don't remember the exact circumstances.

> Or whould you have sizeof (int) return different numbers depending
> on whether it's in a register or not?

Huh?  The compiler keeps track of the type of all variables, so the code
that handles "sizeof" doesn't look at whether it's in a register or not.
Besides, an "int" on a VAX takes 32 bits whether it's in a register or not.

	Guy Harris



More information about the Comp.lang.c mailing list