Commit 7fa5296e by Richard Guenther Committed by Richard Biener

expr.c (get_inner_reference): Use double_int for bit_offset calculation.

2010-06-17  Richard Guenther  <rguenther@suse.de>

	* expr.c (get_inner_reference): Use double_int for bit_offset
	calculation.

From-SVN: r160902
parent b4f73deb
2010-06-17 Richard Guenther <rguenther@suse.de>
* expr.c (get_inner_reference): Use double_int for bit_offset
calculation.
2010-06-16 DJ Delorie <dj@redhat.com> 2010-06-16 DJ Delorie <dj@redhat.com>
* common.opt (-fstrict-volatile-bitfields): new. * common.opt (-fstrict-volatile-bitfields): new.
......
...@@ -5984,7 +5984,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -5984,7 +5984,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
enum machine_mode mode = VOIDmode; enum machine_mode mode = VOIDmode;
bool blkmode_bitfield = false; bool blkmode_bitfield = false;
tree offset = size_zero_node; tree offset = size_zero_node;
tree bit_offset = bitsize_zero_node; double_int bit_offset = double_int_zero;
/* First get the mode, signedness, and size. We do this from just the /* First get the mode, signedness, and size. We do this from just the
outermost expression. */ outermost expression. */
...@@ -6045,8 +6045,9 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -6045,8 +6045,9 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
switch (TREE_CODE (exp)) switch (TREE_CODE (exp))
{ {
case BIT_FIELD_REF: case BIT_FIELD_REF:
bit_offset = size_binop (PLUS_EXPR, bit_offset, bit_offset
TREE_OPERAND (exp, 2)); = double_int_add (bit_offset,
tree_to_double_int (TREE_OPERAND (exp, 2)));
break; break;
case COMPONENT_REF: case COMPONENT_REF:
...@@ -6061,8 +6062,9 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -6061,8 +6062,9 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
break; break;
offset = size_binop (PLUS_EXPR, offset, this_offset); offset = size_binop (PLUS_EXPR, offset, this_offset);
bit_offset = size_binop (PLUS_EXPR, bit_offset, bit_offset = double_int_add (bit_offset,
DECL_FIELD_BIT_OFFSET (field)); tree_to_double_int
(DECL_FIELD_BIT_OFFSET (field)));
/* ??? Right now we don't do anything with DECL_OFFSET_ALIGN. */ /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN. */
} }
...@@ -6094,8 +6096,8 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -6094,8 +6096,8 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
break; break;
case IMAGPART_EXPR: case IMAGPART_EXPR:
bit_offset = size_binop (PLUS_EXPR, bit_offset, bit_offset = double_int_add (bit_offset,
bitsize_int (*pbitsize)); uhwi_to_double_int (*pbitsize));
break; break;
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
...@@ -6126,9 +6128,11 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -6126,9 +6128,11 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
this conversion. */ this conversion. */
if (host_integerp (offset, 0)) if (host_integerp (offset, 0))
{ {
double_int tem = double_int_mul (tree_to_double_int (offset), double_int tem = double_int_lshift (tree_to_double_int (offset),
uhwi_to_double_int (BITS_PER_UNIT)); BITS_PER_UNIT == 8
tem = double_int_add (tem, tree_to_double_int (bit_offset)); ? 3 : exact_log2 (BITS_PER_UNIT),
HOST_BITS_PER_DOUBLE_INT, true);
tem = double_int_add (tem, bit_offset);
if (double_int_fits_in_shwi_p (tem)) if (double_int_fits_in_shwi_p (tem))
{ {
*pbitpos = double_int_to_shwi (tem); *pbitpos = double_int_to_shwi (tem);
...@@ -6139,7 +6143,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize, ...@@ -6139,7 +6143,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
/* Otherwise, split it up. */ /* Otherwise, split it up. */
if (offset) if (offset)
{ {
*pbitpos = tree_low_cst (bit_offset, 0); *pbitpos = double_int_to_shwi (bit_offset);
*poffset = offset; *poffset = offset;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment