[m-dev.] argument packing

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed May 16 23:49:21 AEST 2018



On Tue, 15 May 2018 23:52:31 +1000, Peter Wang <novalazy at gmail.com> wrote:
> I made a quick modification to one of my programs and found a problem
> (not an assertion failure though). When constructing a term of type:
> 
> :- type thread
>     --->    thread( ... , int32, int32).
> 
> the compiler generated this code in hlc.gc:
> 
>     MR_hl_field(MR_mktag(0), base, 5) = (((uint32_t) Var_32) | ((((uint32_t) Var_33) << (MR_Integer) 32)));
> 
> for which gcc reports:
> 
>     warning: left shift count >= width of type [-Wshift-count-overflow]
>     warning: assignment makes pointer from integer without a cast [-Wint-conversion]

The attached diff fixes this problem. Thanks for reporting it.

> This is with mmc rotd-2018-05-12. I simply passed --allow-packing-ints
> which I realise is wrong.

It was enough to demonstrate this problem :-)
 
> PS. YesLogic don't have any code using sub-word-sized integers yet.

I intend to add some to the compiler. Specificially, I mean to use uint8s
to represent both primary tags, and the number of bits in arg_pos_widths
(and maybe in other contexts) where the number of bits is guaranteed to be
in the range 0 to 64. This should give us some dogfood.

By the way, Julien: You added arithmetic and logical operations on
sub-word-sized integers to builtin_ops.m. Did you intend to add any of
the conversion operations, such as int8 to int? Did you reject it as requiring
expansion of the expansion of the existing builtin_op framework?
For work on ptags and num_bits, it would be nice if at least the
unchecked conversions (casts) could be builtin.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.unsigned
Type: application/octet-stream
Size: 722 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20180516/6cc85262/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.unsigned
Type: application/octet-stream
Size: 17629 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20180516/6cc85262/attachment-0003.obj>


More information about the developers mailing list