[MLton] different word sizes

Stephen Weeks MLton@mlton.org
Fri, 23 Apr 2004 22:21:13 -0700


> Like Henry, I'm not quite sure what exactly you are proposing.
> Certainly one downside of dropping Word8 and Word16 would be loss of
> some FFI stuff.

The issue is that when faced with representing a value that takes,
say, five bits, I can either use a Word8, a Word16, or a Word32.  Of
course, the whole idea of packing is that when I store the five bits
in some data structure, I will only use the five bits, either padding
out the rest of the word or storing some other value there.  But when
I have a complete five-bit value in a (Rssa/Machine) register, I can
have the register be of size 8, 16, or 32.  For now, I always choose
the smallest size that is big enough to hold the value.  But this
seems to cause a lot of unnecessary coercions between different sizes.

So, I was wondering what would be bad if I always used a 32 bit
register to hold such values.  I'm not proposing any change to data
layout of heap objects or even stack frames.  I'm simply thinking of
always dealing with word-sized values in registers.

I don't actually need any support from the codegens to do this.  I can
express it in the representation pass.  So, I'll put it on my todo as
an experiment.  But I am curious if anyone has any thoughts why it
might be good or bad.