On 10/18/2017 06:39 PM, Richard Sandiford wrote:
Aldy Hernandez <al...@redhat.com> writes:
On Tue, Oct 17, 2017 at 6:05 PM, Richard Sandiford
Ah! OK. Yeah, I agree it doesn't make sense to print sign-extension
bits above the precision. I think it'd work if print_hex used
extract_uhwi insteead of elt, which would also remove the need
to handle "negative" numbers specially. I'll try that tomorrow.
Thanks.
Currently I'm doing this to chop off the unnecessary bits:
/* Wide ints may be sign extended to the full extent of the
underlying HWI storage, even if the precision we care about
is smaller. Chop off the excess bits for prettier output. */
signop sign = TYPE_UNSIGNED (type) ? UNSIGNED : SIGNED;
widest_int val = widest_int::from (bounds[i], sign);
val &= wi::mask<widest_int> (bounds[i].get_precision (), false);
if (val > 0xffff)
print_hex (val, pp_buffer (buffer)->digit_buffer);
else
print_dec (val, pp_buffer (buffer)->digit_buffer, sign);
Since I am calling print_hex() on the widest_int, I get the leading 0.
Do you recommend another way of accomplishing this?
Is it just print_hex that's the problem? Does print_dec handle
big negative numbers properly?
I haven't checked. I don't bother printing in decimal when the number
is larger than say, 0xffff, hence the code above :).
Aldy