GCC Middle and Back End API Reference
int_range< N, RESIZABLE > Class Template Referenceabstract

#include <value-range.h>

Inheritance diagram for int_range< N, RESIZABLE >:
Collaboration diagram for int_range< N, RESIZABLE >:

Public Member Functions

 int_range ()
 
 int_range (tree type, const wide_int &, const wide_int &, value_range_kind=VR_RANGE)
 
 int_range (tree type)
 
 int_range (const int_range &)
 
 int_range (const irange &)
 
virtual ~int_range ()
 
int_rangeoperator= (const int_range &)
 
void set (tree type, const wide_int &, const wide_int &, value_range_kind=VR_RANGE)
 
virtual void set_nonzero (tree type) override
 
virtual void set_zero (tree type) override
 
virtual void set_nonnegative (tree type) override
 
virtual void set_varying (tree type) override
 
virtual void set_undefined () override
 
virtual bool supports_type_p (const_tree type) const override
 
virtual tree type () const override
 
unsigned num_pairs () const
 
wide_int lower_bound (unsigned=0) const
 
wide_int upper_bound (unsigned) const
 
wide_int upper_bound () const
 
virtual bool zero_p () const override
 
virtual bool nonzero_p () const override
 
virtual bool singleton_p (tree *result=NULL) const override
 
bool singleton_p (wide_int &) const
 
bool contains_p (const wide_int &) const
 
bool nonnegative_p () const
 
bool nonpositive_p () const
 
virtual bool union_ (const vrange &) override
 
virtual bool intersect (const vrange &) override
 
void invert ()
 
bool operator== (const irange &) const
 
bool operator== (const vrange &) const
 
bool operator!= (const irange &r) const
 
bool operator!= (const vrange &r) const
 
virtual bool fits_p (const vrange &r) const override
 
virtual void accept (const vrange_visitor &v) const override
 
virtual void accept (const class vrange_visitor &v) const =0
 
void update_bitmask (const irange_bitmask &)
 
irange_bitmask get_bitmask () const
 
wide_int get_nonzero_bits () const
 
void set_nonzero_bits (const wide_int &bits)
 
bool varying_p () const
 
bool undefined_p () const
 
void dump (FILE *) const
 

Static Public Member Functions

static bool supports_p (const_tree type)
 

Protected Member Functions

 int_range (tree, tree, value_range_kind=VR_RANGE)
 
virtual void set (tree, tree, value_range_kind=VR_RANGE) override
 
virtual bool contains_p (tree cst) const override
 
void maybe_resize (int needed)
 
bool irange_contains_p (const irange &) const
 
bool irange_single_pair_union (const irange &r)
 
void normalize_kind ()
 
void verify_range ()
 

Protected Attributes

wide_intm_base
 
enum value_range_kind m_kind: 8
 
enum value_range_discriminator m_discriminator: 4
 

Static Protected Attributes

static const int HARD_MAX_RANGES = 255
 

Private Member Functions

bool intersect (const wide_int &lb, const wide_int &ub)
 
bool varying_compatible_p () const
 
bool intersect_bitmask (const irange &r)
 
bool union_bitmask (const irange &r)
 
irange_bitmask get_bitmask_from_range () const
 
bool set_range_from_bitmask ()
 
bool union_append (const irange &r)
 

Private Attributes

wide_int m_ranges [N *2]
 
unsigned char m_num_ranges
 
bool m_resizable
 
unsigned char m_max_ranges
 
tree m_type
 
irange_bitmask m_bitmask
 

Constructor & Destructor Documentation

◆ int_range() [1/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( )
inline

◆ int_range() [2/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( tree type,
const wide_int & wmin,
const wide_int & wmax,
value_range_kind kind = VR_RANGE )

References ggc_alloc(), and irange::set().

◆ int_range() [3/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( tree type)

References irange::set_varying().

◆ int_range() [4/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( const int_range< N, RESIZABLE > & other)

References irange::operator=().

◆ int_range() [5/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( const irange & other)

References irange::operator=().

◆ ~int_range()

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::~int_range ( )
inlinevirtual

References ggc_alloc().

◆ int_range() [6/6]

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE >::int_range ( tree min,
tree max,
value_range_kind kind = VR_RANGE )
protected

References irange::set().

Member Function Documentation

◆ accept() [1/2]

virtual void vrange::accept ( const class vrange_visitor & v) const
pure virtualinherited

◆ accept() [2/2]

void irange::accept ( const vrange_visitor & v) const
overridevirtualinherited
Support routines for value ranges.
   Copyright (C) 2019-2024 Free Software Foundation, Inc.
   Major hacks by Aldy Hernandez <aldyh@redhat.com> and
   Andrew MacLeod <amacleod@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   

References vrange_visitor::visit().

◆ contains_p() [1/2]

bool irange::contains_p ( const wide_int & cst) const
inherited
Return 1 if CST is inside value range.
       0 if CST is not inside value range.

Benchmark compile/20001226-1.c compilation time after changing this
function.   

References wi::bit_and(), irange_bitmask::get_nonzero_bits(), ggc_alloc(), wi::le_p(), irange::lower_bound(), wi::lt_p(), irange::m_bitmask, irange::m_num_ranges, r, TYPE_SIGN, vrange::undefined_p(), irange_bitmask::unknown_p(), and irange::upper_bound().

Referenced by irange::contains_p(), expr_not_equal_to(), cfn_signbit::op1_range(), range_includes_zero_p(), and irange::set_range_from_bitmask().

◆ contains_p() [2/2]

bool irange::contains_p ( tree cst) const
inlineoverrideprotectedvirtualinherited

Reimplemented from vrange.

References irange::contains_p(), ggc_alloc(), and wi::to_wide().

◆ dump()

◆ fits_p()

bool irange::fits_p ( const vrange & r) const
overridevirtualinherited

Reimplemented from vrange.

References ggc_alloc(), irange::m_max_ranges, and r.

◆ get_bitmask()

◆ get_bitmask_from_range()

irange_bitmask irange::get_bitmask_from_range ( ) const
privateinherited

◆ get_nonzero_bits()

◆ intersect() [1/2]

◆ intersect() [2/2]

◆ intersect_bitmask()

◆ invert()

◆ irange_contains_p()

◆ irange_single_pair_union()

◆ lower_bound()

wide_int irange::lower_bound ( unsigned pair = 0) const
inlineinherited

References gcc_checking_assert, irange::m_base, irange::m_num_ranges, and irange::num_pairs().

Referenced by compare_nonzero_chars(), irange::contains_p(), strlen_pass::count_nonzero_bytes_addr(), dr_step_indicator(), expr_to_aff_combination(), operator_cast::fold_pair(), operator_equal::fold_range(), operator_not_equal::fold_range(), operator_lt::fold_range(), operator_le::fold_range(), operator_gt::fold_range(), operator_ge::fold_range(), irange::get_bitmask_from_range(), get_range_strlen_dynamic(), get_ref_base_and_extent(), handle_printf_call(), irange::intersect(), operator_plus::lhs_op1_relation(), operator_rshift::lhs_op1_relation(), operator_bitwise_and::lhs_op1_relation(), irange::nonnegative_p(), operator_bitwise_and::op1_range(), operator_trunc_mod::op1_range(), operator_abs::op1_range(), operator_not_equal::op1_range(), operator_lt::op1_range(), operator_le::op1_range(), operator_gt::op1_range(), operator_ge::op1_range(), operator_equal::op1_range(), operator_trunc_mod::op2_range(), operator_lt::op2_range(), operator_le::op2_range(), operator_gt::op2_range(), operator_ge::op2_range(), irange::operator==(), range_fits_type_p(), phi_group::refine_using_relation(), operator_bitwise_and::simple_op1_range_solver(), simplify_conversion_using_ranges(), simplify_using_ranges::simplify_div_or_mod_using_ranges(), irange::singleton_p(), irange::singleton_p(), test_for_singularity(), simplify_using_ranges::two_valued_val_range_p(), irange::verify_range(), vr_set_zero_nonzero_bits(), and irange::zero_p().

◆ maybe_resize()

◆ nonnegative_p()

bool irange::nonnegative_p ( ) const
inherited

◆ nonpositive_p()

bool irange::nonpositive_p ( ) const
inherited

◆ nonzero_p()

bool irange::nonzero_p ( ) const
inlineoverridevirtualinherited

Reimplemented from vrange.

References TYPE_PRECISION, vrange::undefined_p(), VR_ANTI_RANGE, and wi::zero().

Referenced by find_what_p_points_to().

◆ normalize_kind()

◆ num_pairs()

◆ operator!=() [1/2]

bool irange::operator!= ( const irange & r) const
inlineinherited

References r.

◆ operator!=() [2/2]

bool vrange::operator!= ( const vrange & r) const
inlineinherited

References r.

◆ operator=()

template<unsigned N, bool RESIZABLE>
int_range< N, RESIZABLE > & int_range< N, RESIZABLE >::operator= ( const int_range< N, RESIZABLE > & src)

References irange::operator=().

◆ operator==() [1/2]

◆ operator==() [2/2]

bool vrange::operator== ( const vrange & src) const
inherited

◆ set() [1/2]

void irange::set ( tree type,
const wide_int & min,
const wide_int & max,
value_range_kind kind = VR_RANGE )
inherited
Set value range to the canonical form of {VRTYPE, MIN, MAX, EQUIV}.
This means adjusting VRTYPE, MIN and MAX representing the case of a
wrapping range with MAX < MIN covering [MIN, type_max] U [type_min, MAX]
as anti-rage ~[MAX+1, MIN-1].  Likewise for wrapping anti-ranges.
In corner cases where MAX+1 or MIN-1 wraps this will fall back
to varying.
This routine exists to ease canonicalization in the case where we
extract ranges from var + CST op limit.   

References wi::add(), gcc_checking_assert, ggc_alloc(), irange::m_base, irange::m_bitmask, vrange::m_kind, irange::m_max_ranges, irange::m_num_ranges, irange::m_type, wi::max_value(), wi::min_value(), irange_bitmask::set_unknown(), SIGNED, wi::sub(), irange::type(), TYPE_PRECISION, TYPE_SIGN, irange::verify_range(), VR_ANTI_RANGE, VR_RANGE, VR_UNDEFINED, and VR_VARYING.

Referenced by int_range< N, RESIZABLE >::int_range(), int_range< N, RESIZABLE >::int_range(), phi_group::refine_using_relation(), irange::set(), irange::set_nonnegative(), irange::set_nonzero(), irange::set_range_from_bitmask(), and irange::set_zero().

◆ set() [2/2]

void irange::set ( tree min,
tree max,
value_range_kind kind = VR_RANGE )
overrideprotectedvirtualinherited

◆ set_nonnegative()

void irange::set_nonnegative ( tree type)
overridevirtualinherited

Reimplemented from vrange.

References irange::set(), wi::to_wide(), TYPE_MAX_VALUE, TYPE_PRECISION, and wi::zero().

◆ set_nonzero()

◆ set_nonzero_bits()

void irange::set_nonzero_bits ( const wide_int & bits)
inherited

◆ set_range_from_bitmask()

◆ set_undefined()

◆ set_varying()

◆ set_zero()

void irange::set_zero ( tree type)
inlineoverridevirtualinherited

Reimplemented from vrange.

References irange::set(), TYPE_PRECISION, and wi::zero().

Referenced by irange::set_range_from_bitmask().

◆ singleton_p() [1/2]

◆ singleton_p() [2/2]

bool irange::singleton_p ( wide_int & w) const
inherited

◆ supports_p()

◆ supports_type_p()

bool irange::supports_type_p ( const_tree type) const
overridevirtualinherited

Reimplemented from vrange.

References irange::supports_p().

◆ type()

◆ undefined_p()

bool vrange::undefined_p ( ) const
inlineinherited

References vrange::m_kind, and VR_UNDEFINED.

Referenced by inchash::add_vrange(), adjust_equivalence_range(), array_bounds_checker::check_array_ref(), frange::clear_nan(), frange::combine_zeros(), compare_nonzero_chars(), gori_compute::compute_operand_range(), gori_compute::compute_operand_range_switch(), frange::contains_p(), irange::contains_p(), strlen_pass::count_nonzero_bytes_addr(), dr_step_indicator(), empty_range_varying(), expr_not_equal_to(), expr_to_aff_combination(), find_case_label_ranges(), find_range_for_lhs(), frange::flush_denormals_to_zero(), operator_lshift::fold_range(), operator_rshift::fold_range(), irange::get_bitmask(), get_bool_state(), irange::get_nonzero_bits(), get_range_strlen_dynamic(), get_ref_base_and_extent(), get_shift_range(), get_size_range(), handle_printf_call(), vrange::intersect(), irange::intersect(), frange::intersect(), irange::intersect(), irange::intersect_bitmask(), irange::invert(), irange::irange_contains_p(), irange::irange_single_pair_union(), frange::known_isfinite(), operator_identity::lhs_op1_relation(), operator_plus::lhs_op1_relation(), operator_minus::lhs_op1_relation(), operator_rshift::lhs_op1_relation(), operator_cast::lhs_op1_relation(), operator_bitwise_and::lhs_op1_relation(), frange::lower_bound(), frange::maybe_isinf(), frange::maybe_isnan(), frange::maybe_isnan(), frange::nan_signbit_p(), irange::nonzero_p(), operator_equal::op1_op2_relation(), operator_not_equal::op1_op2_relation(), operator_lt::op1_op2_relation(), operator_le::op1_op2_relation(), operator_gt::op1_op2_relation(), operator_ge::op1_op2_relation(), operator_equal::op1_op2_relation(), operator_not_equal::op1_op2_relation(), operator_lt::op1_op2_relation(), operator_le::op1_op2_relation(), operator_gt::op1_op2_relation(), operator_ge::op1_op2_relation(), foperator_div::op1_range(), operator_plus::op1_range(), operator_minus::op1_range(), operator_mult::op1_range(), operator_le::op1_range(), foperator_unordered_lt::op1_range(), foperator_unordered_le::op1_range(), foperator_unordered_gt::op1_range(), foperator_unordered_ge::op1_range(), operator_lt::op1_range(), operator_gt::op1_range(), operator_ge::op1_range(), operator_rshift::op1_range(), pointer_or_operator::op1_range(), operator_cast::op1_range(), operator_addr_expr::op1_range(), operator_bitwise_not::op1_range(), operator_bitwise_xor::op1_range(), operator_lshift::op1_range(), operator_bitwise_and::op1_range(), operator_bitwise_or::op1_range(), operator_exact_divide::op1_range(), operator_trunc_mod::op1_range(), operator_plus::op1_range(), operator_minus::op1_range(), operator_mult::op1_range(), operator_not_equal::op1_range(), operator_lt::op1_range(), operator_le::op1_range(), operator_gt::op1_range(), operator_ge::op1_range(), operator_equal::op1_range(), range_op_handler::op1_range(), foperator_div::op2_range(), operator_minus::op2_range(), operator_le::op2_range(), foperator_unordered_lt::op2_range(), foperator_unordered_le::op2_range(), foperator_unordered_gt::op2_range(), foperator_unordered_ge::op2_range(), operator_lt::op2_range(), operator_gt::op2_range(), operator_ge::op2_range(), operator_trunc_mod::op2_range(), operator_minus::op2_range(), operator_lt::op2_range(), operator_le::op2_range(), operator_gt::op2_range(), operator_ge::op2_range(), range_op_handler::op2_range(), frange::operator==(), range_fits_type_p(), range_includes_zero_p(), irange::set_nonzero_bits(), set_nonzero_range_from_mask(), irange::set_range_from_bitmask(), set_switch_stmt_execution_predicate(), frange::signbit_p(), simplify_using_ranges::simplify(), simplify_using_ranges::simplify_casted_compare(), simplify_using_ranges::simplify_compare_using_ranges_1(), simplify_conversion_using_ranges(), simplify_using_ranges::simplify_div_or_mod_using_ranges(), simplify_using_ranges::simplify_float_conversion_using_ranges(), simplify_using_ranges::simplify_switch_using_ranges(), size_must_be_zero_p(), split_constant_offset(), simplify_using_ranges::two_valued_val_range_p(), frange::type(), Value_Range::undefined_p(), vrange::union_(), irange::union_(), frange::union_(), irange::union_bitmask(), unswitch_predicate::unswitch_predicate(), irange::update_bitmask(), frange::update_nan(), frange::update_nan(), frange::update_nan(), frange::upper_bound(), relation_oracle::validate_relation(), vect_get_range_info(), frange::verify_range(), and vr_set_zero_nonzero_bits().

◆ union_()

◆ union_append()

◆ union_bitmask()

◆ update_bitmask()

◆ upper_bound() [1/2]

◆ upper_bound() [2/2]

◆ varying_compatible_p()

◆ varying_p()

◆ verify_range()

◆ zero_p()

Field Documentation

◆ HARD_MAX_RANGES

const int irange::HARD_MAX_RANGES = 255
staticprotectedinherited

Referenced by irange::maybe_resize().

◆ m_base

◆ m_bitmask

◆ m_discriminator

◆ m_kind

◆ m_max_ranges

◆ m_num_ranges

◆ m_ranges

template<unsigned N, bool RESIZABLE = false>
wide_int int_range< N, RESIZABLE >::m_ranges[N *2]
private

◆ m_resizable

bool irange::m_resizable
privateinherited

Referenced by irange::maybe_resize().

◆ m_type


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