HOST_WIDE_INT bitsize = -1;
HOST_WIDE_INT maxsize = -1;
tree size_tree = NULL_TREE;
- double_int bit_offset = double_int_zero;
+ offset_int bit_offset = 0;
HOST_WIDE_INT hbit_offset;
bool seen_variable_array_ref = false;
}
if (size_tree != NULL_TREE)
{
- if (! host_integerp (size_tree, 1))
+ if (! tree_fits_uhwi_p (size_tree))
bitsize = -1;
else
- bitsize = TREE_INT_CST_LOW (size_tree);
+ bitsize = tree_to_uhwi (size_tree);
}
/* Initially, maxsize is the same as the accessed element size.
switch (TREE_CODE (exp))
{
case BIT_FIELD_REF:
- bit_offset += tree_to_double_int (TREE_OPERAND (exp, 2));
+ bit_offset += wi::to_offset (TREE_OPERAND (exp, 2));
break;
case COMPONENT_REF:
if (this_offset && TREE_CODE (this_offset) == INTEGER_CST)
{
- double_int doffset = tree_to_double_int (this_offset);
- doffset = doffset.lshift (BITS_PER_UNIT == 8
- ? 3 : exact_log2 (BITS_PER_UNIT));
- doffset += tree_to_double_int (DECL_FIELD_BIT_OFFSET (field));
- bit_offset = bit_offset + doffset;
+ offset_int woffset = wi::to_offset (this_offset);
+ woffset = wi::lshift (woffset,
+ (BITS_PER_UNIT == 8
+ ? 3 : exact_log2 (BITS_PER_UNIT)));
+ woffset += wi::to_offset (DECL_FIELD_BIT_OFFSET (field));
+ bit_offset += woffset;
/* If we had seen a variable array ref already and we just
referenced the last field of a struct or a union member
{
tree fsize = DECL_SIZE_UNIT (field);
tree ssize = TYPE_SIZE_UNIT (stype);
- if (host_integerp (fsize, 0)
- && host_integerp (ssize, 0)
- && doffset.fits_shwi ())
- maxsize += ((TREE_INT_CST_LOW (ssize)
- - TREE_INT_CST_LOW (fsize))
+ if (tree_fits_shwi_p (fsize)
+ && tree_fits_shwi_p (ssize)
+ && wi::fits_shwi_p (woffset))
+ maxsize += ((tree_to_shwi (ssize)
+ - tree_to_shwi (fsize))
* BITS_PER_UNIT
- - doffset.to_shwi ());
+ - woffset.to_shwi ());
else
maxsize = -1;
}
because that would get us out of the structure otherwise. */
if (maxsize != -1
&& csize
- && host_integerp (csize, 1)
- && bit_offset.fits_shwi ())
- maxsize = TREE_INT_CST_LOW (csize)
+ && tree_fits_uhwi_p (csize)
+ && wi::fits_shwi_p (bit_offset))
+ maxsize = tree_to_shwi (csize)
- bit_offset.to_shwi ();
else
maxsize = -1;
&& (unit_size = array_ref_element_size (exp),
TREE_CODE (unit_size) == INTEGER_CST))
{
- double_int doffset
- = (TREE_INT_CST (index) - TREE_INT_CST (low_bound))
- .sext (TYPE_PRECISION (TREE_TYPE (index)));
- doffset *= tree_to_double_int (unit_size);
- doffset = doffset.lshift (BITS_PER_UNIT == 8
- ? 3 : exact_log2 (BITS_PER_UNIT));
- bit_offset = bit_offset + doffset;
+ offset_int woffset
+ = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound),
+ TYPE_PRECISION (TREE_TYPE (index)));
+ woffset *= wi::to_offset (unit_size);
+ woffset = wi::lshift (woffset,
+ (BITS_PER_UNIT == 8
+ ? 3 : exact_log2 (BITS_PER_UNIT)));
+ bit_offset += woffset;
/* An array ref with a constant index up in the structure
hierarchy will constrain the size of any variable array ref
because that would get us outside of the array otherwise. */
if (maxsize != -1
&& asize
- && host_integerp (asize, 1)
- && bit_offset.fits_shwi ())
- maxsize = TREE_INT_CST_LOW (asize)
- - bit_offset.to_shwi ();
+ && tree_fits_uhwi_p (asize)
+ && wi::fits_shwi_p (bit_offset))
+ maxsize = tree_to_uhwi (asize) - bit_offset.to_shwi ();
else
maxsize = -1;
break;
case IMAGPART_EXPR:
- bit_offset += double_int::from_uhwi (bitsize);
+ bit_offset += bitsize;
break;
case VIEW_CONVERT_EXPR:
&& (TMR_INDEX (exp) || TMR_INDEX2 (exp)))
{
exp = TREE_OPERAND (TMR_BASE (exp), 0);
- bit_offset = double_int_zero;
+ bit_offset = 0;
maxsize = -1;
goto done;
}
if (seen_variable_array_ref
&& maxsize != -1
&& (!bit_offset.fits_shwi ()
- || !host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
+ || !tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp)))
|| (bit_offset.to_shwi () + maxsize
- == (signed) TREE_INT_CST_LOW
+ == (signed) tree_to_uhwi
(TYPE_SIZE (TREE_TYPE (exp))))))
maxsize = -1;
exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
else
{
- double_int off = mem_ref_offset (exp);
- off = off.lshift (BITS_PER_UNIT == 8
- ? 3 : exact_log2 (BITS_PER_UNIT));
+ offset_int off = mem_ref_offset (exp);
+ off = wi::lshift (off, (BITS_PER_UNIT == 8
+ ? 3 : exact_log2 (BITS_PER_UNIT)));
off += bit_offset;
- if (off.fits_shwi ())
+ if (wi::fits_shwi_p (off))
{
bit_offset = off;
exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
if (seen_variable_array_ref
&& maxsize != -1
&& (!bit_offset.fits_shwi ()
- || !host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
+ || !tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp)))
|| (bit_offset.to_shwi () + maxsize
- == (signed) TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))))
+ == (signed) tree_to_uhwi (TYPE_SIZE (TREE_TYPE (exp))))))
maxsize = -1;
done:
- if (!bit_offset.fits_shwi ())
+ if (!wi::fits_shwi_p (bit_offset))
{
*poffset = 0;
*psize = bitsize;
/* If maxsize is unknown adjust it according to the size of the
base decl. */
if (maxsize == -1
- && host_integerp (DECL_SIZE (exp), 1))
- maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - hbit_offset;
+ && tree_fits_uhwi_p (DECL_SIZE (exp)))
+ maxsize = tree_to_uhwi (DECL_SIZE (exp)) - hbit_offset;
}
else if (CONSTANT_CLASS_P (exp))
{
/* If maxsize is unknown adjust it according to the size of the
base type constant. */
if (maxsize == -1
- && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1))
- maxsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset;
+ && tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp))))
+ maxsize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset;
}
/* ??? Due to negative offsets in ARRAY_REF we can end up with