GCC Middle and Back End API Reference
|
#include <double-int.h>
Static Public Member Functions | |
static double_int | from_uhwi (unsigned HOST_WIDE_INT cst) |
static double_int | from_shwi (HOST_WIDE_INT cst) |
static double_int | from_pair (HOST_WIDE_INT high, unsigned HOST_WIDE_INT low) |
static double_int | from_buffer (const unsigned char *buffer, int len) |
static double_int | mask (unsigned prec) |
static double_int | max_value (unsigned int prec, bool uns) |
static double_int | min_value (unsigned int prec, bool uns) |
Data Fields | |
unsigned HOST_WIDE_INT | low |
HOST_WIDE_INT | high |
A large integer is currently represented as a pair of HOST_WIDE_INTs. It therefore represents a number with precision of 2 * HOST_BITS_PER_WIDE_INT bits (it is however possible that the internal representation will change, if numbers with greater precision are needed, so the users should not rely on it). The representation does not contain any information about signedness of the represented value, so it can be used to represent both signed and unsigned numbers. For operations where the results depend on signedness (division, comparisons), it must be specified separately. For each such operation, there are three versions of the function -- double_int_op, that takes an extra UNS argument giving the signedness of the values, and double_int_sop and double_int_uop that stand for its specializations for signed and unsigned values. You may also represent with numbers in smaller precision using double_int. You however need to use double_int_ext (that fills in the bits of the number over the prescribed precision with zeros or with the sign bit) before operations that do not perform arithmetics modulo 2^precision (comparisons, division), and possibly before storing the results, if you want to keep them in some canonical form). In general, the signedness of double_int_ext should match the signedness of the operation. ??? The components of double_int differ in signedness mostly for historical reasons (they replace an older structure used to represent numbers with precision higher than HOST_WIDE_INT). It might be less confusing to have them both signed or both unsigned.
double_int double_int::add_with_sign | ( | double_int | b, |
bool | unsigned_p, | ||
bool * | overflow | ||
) | const |
Returns A + B. If the operation overflows according to UNSIGNED_P, *OVERFLOW is set to nonzero.
double_int double_int::alshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Arithmetic shift A left by COUNT places keeping only PREC bits of result. Shift right if COUNT is negative.
Referenced by simplify_const_binary_operation().
|
inline |
Returns A & ~B.
Referenced by bit_value_binop_1(), and vrp_intersect_ranges_1().
double_int double_int::arshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Arithmetic shift A right by COUNT places keeping only PREC bits of result. Shift left if COUNT is negative.
int double_int::cmp | ( | double_int | b, |
bool | uns | ||
) | const |
double_int double_int::div | ( | double_int | b, |
bool | uns, | ||
unsigned | code | ||
) | const |
You must ensure that double_int::ext is called on the operands of the following operations, if the precision of the numbers is less than HOST_BITS_PER_DOUBLE_INT bits.
Returns A / B (computed as unsigned depending on UNS, and rounded as specified by CODE). CODE is enum tree_code in fact, but double_int.h must be included before tree.h.
Referenced by divmod_with_overflow().
double_int double_int::divmod | ( | double_int | b, |
bool | uns, | ||
unsigned | code, | ||
double_int * | mod | ||
) | const |
Referenced by operator-(), sub_with_overflow(), and udivmod().
double_int double_int::divmod_with_overflow | ( | double_int | b, |
bool | uns, | ||
unsigned | code, | ||
double_int * | mod, | ||
bool * | overflow | ||
) | const |
Returns A / B (computed as unsigned depending on UNS, and rounded as specified by CODE). CODE is enum tree_code in fact, but double_int.h must be included before tree.h. The remainder after the division is stored to MOD.
References div().
double_int double_int::ext | ( | unsigned | prec, |
bool | uns | ||
) | const |
Precision control functions.
Clears the bits of CST over the precision PREC. If UNS is false, the bits outside of the precision are set to the sign bit (i.e., the PREC-th one), otherwise they are set to zero. This corresponds to returning the value represented by PREC lowermost bits of CST, with the given signedness.
Referenced by bit_value_binop_1(), and double_int_to_tree().
bool double_int::fits_hwi | ( | bool | uns | ) | const |
bool double_int::fits_shwi | ( | ) | const |
Returns true if CST fits in signed HOST_WIDE_INT.
Referenced by fold_builtin_logarithm(), and replace_ref().
|
inline |
Conversion query functions.
Returns true if CST fits in unsigned HOST_WIDE_INT.
|
static |
Construct from a fuffer of length LEN. BUFFER will be read according to byte endianess and word endianess.
Construct from a buffer of length LEN. BUFFER will be read according to byte endianess and word endianess. Only the lower LEN bytes of the result are set; the remaining high bytes are cleared.
References high, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, low, and mask().
|
inlinestatic |
|
inlinestatic |
Constructors and conversions.
Constructs double_int from integer CST. The bits over the precision of HOST_WIDE_INT are filled with the sign bit.
Referenced by cgraph_create_function_alias(), fold_builtin_logarithm(), and vect_update_ivs_after_vectorizer().
|
inlinestatic |
Normally, we would define constructors to create instances. Two things prevent us from doing so. First, defining a constructor makes the class non-POD in C++03, and we certainly want double_int to be a POD. Second, the GCC conding conventions prefer explicit conversion, and explicit conversion operators are not available until C++11.
Constructs double_int from unsigned integer CST. The bits over the precision of HOST_WIDE_INT are filled with zeros.
Referenced by backtrace_base_for_ref(), fold_builtin_strcspn(), tree_fold_binomial(), and tree_to_aff_combination().
|
inline |
Returns true if CST is minus one.
Referenced by ncd_for_two_cands().
|
inline |
Returns true if CST is negative.
Referenced by build_function_type_list_1(), build_varargs_function_type_list(), dump_incr_vec(), get_inner_reference_aff(), ncd_of_cand_and_phis(), replace_conditional_candidate(), replace_ref(), and sle().
|
inline |
Returns true if CST is one.
Referenced by create_mul_ssa_cand(), fixed_address_object_p(), and ncd_for_two_cands().
|
inline |
Comparative functions.
The operands of the following comparison functions must be processed with double_int_ext, if their precision is less than HOST_BITS_PER_DOUBLE_INT bits.
Returns true if CST is zero.
Referenced by aff_combination_add_elt(), backtrace_base_for_ref(), double_int_constant_multiple_p(), free_name_expansion(), infer_loop_bounds_from_signedness(), ncd_for_two_cands(), register_edge_assert_for_2(), sle(), udivmod(), and vrp_intersect_ranges_1().
double_int double_int::llshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Logical shift A left by COUNT places keeping only PREC bits of result. Shift right if COUNT is negative.
Referenced by fixed_compare(), lshift(), and register_edge_assert_for_2().
double_int double_int::lrotate | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Rotate A left by COUNT places keeping only PREC bits of result. Rotate right if COUNT is negative.
Referenced by bit_value_unop_1(), and simplify_const_binary_operation().
double_int double_int::lrshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Logical shift A right by COUNT places keeping only PREC bits of result. Shift left if COUNT is negative.
Referenced by lshift().
double_int double_int::lshift | ( | HOST_WIDE_INT | count | ) | const |
Shift A left by COUNT places.
Shifting by the host word size is undefined according to the ANSI standard, so we must handle this as a special case.
References absu_hwi(), high, low, lshift_double(), and rshift_double().
Referenced by fixed_compare(), and fold_convert_const_int_from_int().
double_int double_int::lshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec, | ||
bool | arith | ||
) | const |
|
static |
No copy assignment operator or destructor to keep the type a POD.
There are some special value-creation static member functions.
Returns mask for PREC bits.
References sext(), and zext().
Referenced by build_method_type_directly(), from_buffer(), max_value(), number_of_iterations_ne_max(), and register_edge_assert_for_2().
double_int double_int::max | ( | double_int | b, |
bool | uns | ||
) |
Compares two values A and B. Returns max value. Signedness of the comparison is given by UNS.
|
static |
Returns a maximum value for signed or unsigned integer of precision PREC.
References HOST_BITS_PER_WIDE_INT, and mask().
double_int double_int::min | ( | double_int | b, |
bool | uns | ||
) |
Compares two values A and B. Returns mix value. Signedness of the comparison is given by UNS.
|
static |
Returns a minimum value for signed or unsigned integer of precision PREC.
References high, HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT.
double_int double_int::mod | ( | double_int | b, |
bool | uns, | ||
unsigned | code | ||
) | const |
Returns A % B (computed as unsigned depending on UNS, and rounded as specified by CODE). CODE is enum tree_code in fact, but double_int.h must be included before tree.h.
Referenced by operator-(), and sdivmod().
double_int double_int::mul_with_sign | ( | double_int | b, |
bool | unsigned_p, | ||
bool * | overflow | ||
) | const |
Returns A * B. If the operation overflows according to UNSIGNED_P, *OVERFLOW is set to nonzero.
References high, low, and neg_double().
Referenced by tree_fold_binomial().
bool double_int::multiple_of | ( | double_int | factor, |
bool | unsigned_p, | ||
double_int * | multiple | ||
) | const |
Arithmetic query operations.
Return TRUE iff PRODUCT is an integral multiple of FACTOR, and return the multiple in *MULTIPLE. Otherwise return FALSE and leave *MULTIPLE unchanged.
References high, HOST_BITS_PER_WIDE_INT, and low.
double_int double_int::neg_with_overflow | ( | bool * | overflow | ) | const |
Referenced by tree_unary_nonnegative_warnv_p().
|
inline |
Returns true if CST1 != CST2.
|
inline |
Returns A & B.
|
inline |
References HOST_WIDE_INT, and low.
double_int double_int::operator* | ( | double_int | b | ) | const |
double_int & double_int::operator*= | ( | double_int | b | ) |
Multiplies *this with B and returns a reference to *this.
References add_double_with_sign(), high, and low.
double_int double_int::operator+ | ( | double_int | b | ) | const |
Returns A + B.
References high, low, and neg_double().
|
inline |
The following functions are mutating operations.
double_int & double_int::operator+= | ( | double_int | b | ) |
Adds B to *this and returns a reference to *this.
References high, low, and neg_double().
double_int double_int::operator- | ( | double_int | b | ) | const |
Returns A - B.
double_int double_int::operator- | ( | ) | const |
|
inline |
double_int & double_int::operator-= | ( | double_int | b | ) |
Subtracts B from *this and returns a reference to *this.
|
inline |
Returns true if CST1 == CST2.
|
inline |
|
inline |
References low.
|
inline |
|
inline |
References high.
|
inline |
Logical operations.
Returns ~A.
|
inline |
Return number of set bits of CST.
double_int double_int::rrotate | ( | HOST_WIDE_INT | count, |
unsigned int | prec | ||
) | const |
Rotate A rigth by COUNT places keeping only PREC bits of result. Rotate right if COUNT is negative.
Referenced by simplify_const_binary_operation().
double_int double_int::rshift | ( | HOST_WIDE_INT | count | ) | const |
Shift A right by COUNT places.
Shifting by the host word size is undefined according to the ANSI standard, so we must handle this as a special case.
References absu_hwi(), high, low, lshift_double(), and rshift_double().
Referenced by fold_convert_const_int_from_int(), and simplify_const_binary_operation().
double_int double_int::rshift | ( | HOST_WIDE_INT | count, |
unsigned int | prec, | ||
bool | arith | ||
) | const |
Shift A right by COUNT places keeping only PREC bits of result. Shift left if COUNT is negative. ARITH true specifies arithmetic shifting; otherwise use logical shift.
int double_int::scmp | ( | double_int | b | ) | const |
Compares two signed values A and B. Returns -1 if A < B, 0 if A == B, and 1 if A > B.
Referenced by ult().
double_int double_int::sdiv | ( | double_int | b, |
unsigned | code | ||
) | const |
The same as double_int::div with UNS = false.
double_int double_int::sdivmod | ( | double_int | b, |
unsigned | code, | ||
double_int * | mod | ||
) | const |
The same as double_int::divmod with UNS = false.
References mod().
double_int double_int::set_bit | ( | unsigned | bitpos | ) | const |
Arithmetic operation functions.
The following operations perform arithmetics modulo 2^precision, so you do not need to call .ext between them, even if you are representing numbers with precision less than HOST_BITS_PER_DOUBLE_INT bits.
Set BITPOS bit in A.
Referenced by expand_abs().
double_int double_int::sext | ( | unsigned | prec | ) | const |
The same as double_int::ext with UNS = false.
Referenced by fixed_compare(), and mask().
bool double_int::sgt | ( | double_int | b | ) | const |
Compares two signed values A and B for greater-than.
bool double_int::sle | ( | double_int | b | ) | const |
Compares two signed values A and B for less-than or equal-to.
References is_negative(), and is_zero().
bool double_int::slt | ( | double_int | b | ) | const |
Compares two signed values A and B for less-than.
double_int double_int::smax | ( | double_int | b | ) |
Compares two signed values A and B. Returns max value.
double_int double_int::smin | ( | double_int | b | ) |
Compares two signed values A and B. Returns min value.
double_int double_int::smod | ( | double_int | b, |
unsigned | code | ||
) | const |
The same as double_int::mod with UNS = false.
double_int double_int::sub_with_overflow | ( | double_int | b, |
bool * | overflow | ||
) | const |
Returns A - B. If the operation overflows via inconsistent sign bits, *OVERFLOW is set to nonzero.
References divmod().
|
inline |
The following functions are non-mutating operations.
Conversion functions.
Returns value of CST as a signed number. CST must satisfy double_int::fits_signed.
Referenced by get_addr_base_and_unit_offset_1(), and replace_ref().
|
inline |
int double_int::trailing_zeros | ( | ) | const |
Attribute query functions.
Count trailing zeros in A.
References absu_hwi(), high, low, lshift_double(), and rshift_double().
int double_int::ucmp | ( | double_int | b | ) | const |
double_int double_int::udiv | ( | double_int | b, |
unsigned | code | ||
) | const |
The same as double_int::div with UNS = true.
References ctz_hwi(), high, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, and low.
Referenced by backtrace_base_for_ref().
double_int double_int::udivmod | ( | double_int | b, |
unsigned | code, | ||
double_int * | mod | ||
) | const |
bool double_int::ugt | ( | double_int | b | ) | const |
Compares two unsigned values A and B for greater-than.
Referenced by build_varargs_function_type_list().
bool double_int::ule | ( | double_int | b | ) | const |
Compares two unsigned values A and B for less-than or equal-to.
References cmp().
bool double_int::ult | ( | double_int | b | ) | const |
Compares two unsigned values A and B for less-than.
References scmp().
double_int double_int::umax | ( | double_int | b | ) |
Compares two unsigned values A and B. Returns max value.
References count.
double_int double_int::umin | ( | double_int | b | ) |
Compares two unsigned values A and B. Returns min value.
double_int double_int::umod | ( | double_int | b, |
unsigned | code | ||
) | const |
The same as double_int::mod with UNS = true.
References count, high, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, and low.
Referenced by backtrace_base_for_ref().
double_int double_int::wide_mul_with_sign | ( | double_int | b, |
bool | unsigned_p, | ||
double_int * | higher, | ||
bool * | overflow | ||
) | const |
References high, low, and neg_double().
Referenced by int_const_binop_1().
double_int double_int::zext | ( | unsigned | prec | ) | const |
The same as double_int::ext with UNS = true.
Referenced by mask(), and register_edge_assert_for_2().
HOST_WIDE_INT double_int::high |
Referenced by and_not(), cmp(), do_fixed_multiply(), fits_hwi(), from_buffer(), from_shwi(), get_addr_base_and_unit_offset_1(), lshift(), min_value(), mul_with_sign(), multiple_of(), operator*(), operator*=(), operator+(), operator+=(), operator^(), operator|(), operator|=(), reconstruct_complex_type(), rshift(), to_shwi(), to_uhwi(), trailing_zeros(), tree_expr_nonnegative_p(), ucmp(), udiv(), umod(), and wide_mul_with_sign().
unsigned HOST_WIDE_INT double_int::low |
Please migrate away from using these member variables publicly.
Referenced by and_not(), build_function_type_array_1(), cmp(), do_fixed_multiply(), fits_hwi(), fold_builtin_logarithm(), from_buffer(), from_shwi(), lshift(), mul_with_sign(), multiple_of(), operator&=(), operator*(), operator*=(), operator+(), operator+=(), operator^(), operator^=(), operator|(), reconstruct_complex_type(), rshift(), to_shwi(), to_uhwi(), trailing_zeros(), ucmp(), udiv(), umod(), and wide_mul_with_sign().