[MLton] Re: A MLton / C-- Experiment

Matthew Fluet fluet@cs.cornell.edu
Mon, 14 Mar 2005 16:01:55 -0500 (EST)

>  > Fair enough.  The next reasonable option would be to peform the 64-bit
>  > addition out of a 32-bit add and a 32-bit add with carry.
>  > Unfortunately, there does not appear to be a way to directly
>  > extracting the high bits of a C-- local variable.  I could extract the
>  > low bits with %lobits, but without %shra at 64-bits, I can't get to
>  > the high bits.  
> Actually %lobits32(n >> 32) should work---this is what we use
> internally in the compiler.  I guess the documentation is not clear on
> this point; I'll see what I can do to fix it.

Indeed, I never even tried %shra; once I saw that %add didn't work at
64-bits, I avoided all arithmetic and bit operations.  Though, I must
admit, I am confused as to why:

foo (bits64 src) {
	return (%lobits32(%shrl(src, 32 :: bits64)));

compiles, but

foo (bits64 src) {
	bits64 shifted;
	shifted = %shrl(src, 32 :: bits64);
	return (%lobits32(shifted));

gives "No acceptable widths for %shrl on target 'x86'".

> I would prefer to retain %lobits32(n >> 32) rather than introduce the
> %hibits operator as a synonym.

In my mind, the fact that the compiler distinguishes between the two
programs is indicative of the fact that %hibits32 is _not_ synonymous with
%lobits32(%shrl(n, 32 :: bits64)).