GCC Middle and Back End API Reference
generic_wide_int< storage > Class Template Reference

#include <wide-int.h>

Inheritance diagram for generic_wide_int< storage >:
Collaboration diagram for generic_wide_int< storage >:

Public Member Functions

 generic_wide_int ()
 
template<typename T >
 generic_wide_int (const T &)
 
template<typename T >
 generic_wide_int (const T &, unsigned int)
 
HOST_WIDE_INT to_shwi (unsigned int) const
 
HOST_WIDE_INT to_shwi () const
 
unsigned HOST_WIDE_INT to_uhwi (unsigned int) const
 
unsigned HOST_WIDE_INT to_uhwi () const
 
HOST_WIDE_INT to_short_addr () const
 
HOST_WIDE_INT sign_mask () const
 
HOST_WIDE_INT elt (unsigned int) const
 
HOST_WIDE_INT sext_elt (unsigned int) const
 
unsigned HOST_WIDE_INT ulow () const
 
unsigned HOST_WIDE_INT uhigh () const
 
HOST_WIDE_INT slow () const
 
HOST_WIDE_INT shigh () const
 
template<typename T >
generic_wide_intoperator= (const T &)
 
void dump () const
 
template<typename T >
generic_wide_int< storage > & operator= (const T &x)
 

Static Public Attributes

static const bool is_sign_extended = wi::int_traits <generic_wide_int <storage> >::is_sign_extended
 
static const bool needs_write_val_arg = wi::int_traits <generic_wide_int <storage> >::needs_write_val_arg
 

Detailed Description

template<typename storage>
class generic_wide_int< storage >
This class defines an integer type using the storage provided by the
template argument.  The storage class must provide the following
functions:

unsigned int get_precision () const
  Return the number of bits in the integer.

HOST_WIDE_INT *get_val () const
  Return a pointer to the array of blocks that encodes the integer.

unsigned int get_len () const
  Return the number of blocks in get_val ().  If this is smaller
  than the number of blocks implied by get_precision (), the
  remaining blocks are sign extensions of block get_len () - 1.

Although not required by generic_wide_int itself, writable storage
classes can also provide the following functions:

HOST_WIDE_INT *write_val (unsigned int)
  Get a modifiable version of get_val ().  The argument should be
  upper estimation for LEN (ignored by all storages but
  widest_int_storage).

unsigned int set_len (unsigned int len)
  Set the value returned by get_len () to LEN.   

Constructor & Destructor Documentation

◆ generic_wide_int() [1/3]

template<typename storage >
generic_wide_int< storage >::generic_wide_int ( )
inline

◆ generic_wide_int() [2/3]

template<typename storage >
template<typename T >
generic_wide_int< storage >::generic_wide_int ( const T & x)
inline

◆ generic_wide_int() [3/3]

template<typename storage >
template<typename T >
generic_wide_int< storage >::generic_wide_int ( const T & x,
unsigned int precision )
inline

Member Function Documentation

◆ dump()

template<typename storage >
void generic_wide_int< storage >::dump ( ) const
Dump the contents of the integer to stderr, for debugging.   

References ggc_alloc(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_PRINT_HEX, and i.

Referenced by debug(), and debug().

◆ elt()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::elt ( unsigned int i) const
inline
Return block I, which might be implicitly or explicit encoded.   

References i.

Referenced by immed_wide_int_const_1(), insert_wide_int(), real_from_integer(), and streamer_write_wide_int().

◆ operator=() [1/2]

template<typename storage >
template<typename T >
generic_wide_int & generic_wide_int< storage >::operator= ( const T & )

◆ operator=() [2/2]

template<typename storage >
template<typename T >
generic_wide_int< storage > & generic_wide_int< storage >::operator= ( const T & x)
inline

◆ sext_elt()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::sext_elt ( unsigned int i) const
inline
Like elt, but sign-extend beyond the upper bit, instead of returning
the raw encoding.   

References ggc_alloc(), HOST_BITS_PER_WIDE_INT, i, and sext_hwi().

Referenced by inchash::hash::add_wide_int().

◆ shigh()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::shigh ( ) const
inline
Return the signed value of the most-significant explicitly-encoded
block.   

◆ sign_mask()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::sign_mask ( ) const
inline
Return the implicit value of blocks above get_len ().   

References gcc_assert, ggc_alloc(), and HOST_BITS_PER_WIDE_INT.

Referenced by wi::clz(), wi::exact_log2(), and wi::popcount().

◆ slow()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::slow ( ) const
inline
Return the signed value of the least-significant explicitly-encoded
block.   

◆ to_short_addr()

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::to_short_addr ( ) const
inline
TODO: The compiler is half converted from using HOST_WIDE_INT to
represent addresses to using offset_int to represent addresses.
We use to_short_addr at the interface from new code to old,
unconverted code.   

◆ to_shwi() [1/2]

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::to_shwi ( ) const
inline
Return THIS as a signed HOST_WIDE_INT, in its natural precision.   

◆ to_shwi() [2/2]

template<typename storage >
HOST_WIDE_INT generic_wide_int< storage >::to_shwi ( unsigned int precision) const
inline
Return THIS as a signed HOST_WIDE_INT, sign-extending from PRECISION.
If THIS does not fit in PRECISION, the information is lost.   

References HOST_BITS_PER_WIDE_INT, and sext_hwi().

Referenced by analyze_subscript_affine_affine(), wi::divmod_internal(), field_byte_offset(), maybe_flat_loop_profile(), most_expensive_mult_to_index(), and wi::mul_internal().

◆ to_uhwi() [1/2]

template<typename storage >
unsigned HOST_WIDE_INT generic_wide_int< storage >::to_uhwi ( ) const
inline
Return THIS as an signed HOST_WIDE_INT, in its natural precision.   

◆ to_uhwi() [2/2]

template<typename storage >
unsigned HOST_WIDE_INT generic_wide_int< storage >::to_uhwi ( unsigned int precision) const
inline
Return THIS as an unsigned HOST_WIDE_INT, zero-extending from
PRECISION.  If THIS does not fit in PRECISION, the information
is lost.   

References HOST_BITS_PER_WIDE_INT, and zext_hwi().

Referenced by bit_value_assume_aligned(), ccp_finalize(), strlen_pass::count_nonzero_bytes_addr(), wi::divmod_internal(), ccp_folder::fold_stmt(), ipcp_update_vr(), and wi::mul_internal().

◆ uhigh()

template<typename storage >
unsigned HOST_WIDE_INT generic_wide_int< storage >::uhigh ( ) const
inline
Return the unsigned value of the most-significant
explicitly-encoded block.   

Referenced by wi::clrsb(), wi::clz(), and wi::popcount().

◆ ulow()

template<typename storage >
unsigned HOST_WIDE_INT generic_wide_int< storage >::ulow ( ) const
inline
Return the unsigned value of the least-significant
explicitly-encoded block.   

Referenced by wi::ctz(), and wi::mul_internal().

Field Documentation

◆ is_sign_extended

template<typename storage >
const bool generic_wide_int< storage >::is_sign_extended = wi::int_traits <generic_wide_int <storage> >::is_sign_extended
static

◆ needs_write_val_arg

template<typename storage >
const bool generic_wide_int< storage >::needs_write_val_arg = wi::int_traits <generic_wide_int <storage> >::needs_write_val_arg
static

The documentation for this class was generated from the following files: