[varasm] patch for integer_cst non-int-sized pointer initializers
Roger Sayle
roger@eyesopen.com
Fri Jan 20 08:33:00 GMT 2006
Hi DJ,
On Thu, 1 Dec 2005, DJ Delorie wrote:
>
> * initializer_constant_valid_p: Allow pointers to be
> initialized from integer constants of lesser precision.
> * output_constant: Allow non-int-sized pointer modes to be
> initialized from integer constants.
This is OK for mainline, with some minor tweaks. Most obviously
the ChangeLog entry above doesn't do justice to your years of
sterling service to GCC. I know that you meant to write :-)
* varasm.c (initialize_constant_valid_p): Allow pointers
initialized from integer constants of lesser precision.
(output_constant): Allow non-int-sized pointer modes to be
initialized from integer constants.
> @@ -3907,6 +3910,10 @@ output_constant (tree exp, unsigned HOST
> + /* Likewise for constant ints. */
> + else if (TREE_CODE (exp) == INTEGER_CST)
> + exp = build_int_cst (saved_type, TREE_INT_CST_LOW(exp));
A space between "TREE_INT_CST_LOW" and "(exp)", but I think this
is much better written as:
exp = build_int_cst_wide (saved_type, TREE_INT_CST_LOW (exp),
TREE_INT_CST_HIGH (exp));
This makes the code slightly more generic, handling constants larger
than HOST_WIDE_INT, but also mirrors what fold_convert would do (via
fold-const.c's fold_convert_const_int_from_int).
It must have been a bad day at the office as you also didn't mention
whether and where you'd bootstraped it, but the recent ping confirmed
that this has been tested on some x86_64 triple.
Ok for mainline with the obvious corrections above.
Roger
--
More information about the Gcc-patches
mailing list