Re: A MLton / C-- Experiment

Matthew Fluet <[email protected]>
Newsgroups gmane.comp.lang.ml.mlton.devel,gmane.comp.lang.c--
Message-ID <[email protected]>
>  > 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)).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.