Code Generation (register byte, short...)

Dick Dunn rcd at opus.UUCP
Fri Nov 22 19:20:30 AEST 1985


On the VAX C compiler ignoring "register" for char and short...
Key: >>> Natalie, >> Torek, > Cottrell
> > > It 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
> > You can indeed apply
> > registers to `short's and `char's and even `float's and `double's;
> > it is merely much more difficult to get the code generation right.
> Why is that? For the moment lets forget about the floating types.
> From the way I read my manual, using the byte & word flavors of
> instruxions makes the registers appear to be 8 & 16 bits wide.

Honestly, the code generation difficulties are not great; neither are they
completely trivial.  Consider, for example, that the sum/difference/product
of two bytes is a word, so you need to be sure that you choose the right
operation but it's not much more difficult than that.  Keep some info with
register variables so that you know what types they are.

The nasty thing is that with the VAX working the way it does now, there is
a PENALTY for saying, e.g., `register short' instead of `register int'.  I
have been stung by this one more than once.  The situation arises because
I'm careful to declare `short' when I mean it--it makes a LOT of difference
on a 68000, where short*short is a single machine instruction but int*int
is a long procedure call.  Now I take this code, written carefully but not
particularly tuned to a particular machine, and move it to the VAX.  I
discover that I get better (==smaller&faster) code by LENGTHening the
operands?!  That's silly, also annoying, and should not be necessary.
-- 
Dick Dunn	{hao,ucbvax,allegra}!nbires!rcd		(303)444-5710 x3086
   ...If you get confused just listen to the music play...



More information about the Comp.lang.c mailing list