diff options
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r-- | gcc/value-range.h | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h index f0075d0..43b231b 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -314,14 +314,10 @@ public: bool intersect (const frange_props &other); bool operator== (const frange_props &other) const; FP_PROP_ACCESSOR(nan) - FP_PROP_ACCESSOR(inf) - FP_PROP_ACCESSOR(ninf) private: union { struct { unsigned char nan : 2; - unsigned char inf : 2; - unsigned char ninf : 2; } bits; unsigned char bytes; } u; @@ -345,34 +341,62 @@ class frange : public vrange public: frange (); frange (const frange &); + frange (tree, tree, value_range_kind = VR_RANGE); + frange (tree type, const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max, + value_range_kind = VR_RANGE); static bool supports_p (const_tree type) { return SCALAR_FLOAT_TYPE_P (type); } virtual tree type () const override; virtual void set (tree, tree, value_range_kind = VR_RANGE) override; + void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &, + value_range_kind = VR_RANGE); virtual void set_varying (tree type) override; virtual void set_undefined () override; virtual bool union_ (const vrange &) override; virtual bool intersect (const vrange &) override; + virtual bool contains_p (tree) const override; + virtual bool singleton_p (tree *result = NULL) const override; virtual bool supports_type_p (const_tree type) const override; virtual void accept (const vrange_visitor &v) const override; + virtual bool zero_p () const; + virtual bool nonzero_p () const; + virtual void set_nonzero (tree type); + virtual void set_zero (tree type); + virtual void set_nonnegative (tree type); frange& operator= (const frange &); bool operator== (const frange &) const; bool operator!= (const frange &r) const { return !(*this == r); } + const REAL_VALUE_TYPE &lower_bound () const; + const REAL_VALUE_TYPE &upper_bound () const; // Each fp_prop can be accessed with get_PROP() and set_PROP(). FRANGE_PROP_ACCESSOR(nan) - FRANGE_PROP_ACCESSOR(inf) - FRANGE_PROP_ACCESSOR(ninf) private: void verify_range (); bool normalize_kind (); frange_props m_props; tree m_type; + REAL_VALUE_TYPE m_min; + REAL_VALUE_TYPE m_max; }; +inline const REAL_VALUE_TYPE & +frange::lower_bound () const +{ + gcc_checking_assert (!undefined_p ()); + return m_min; +} + +inline const REAL_VALUE_TYPE & +frange::upper_bound () const +{ + gcc_checking_assert (!undefined_p ()); + return m_max; +} + // is_a<> and as_a<> implementation for vrange. // Anything we haven't specialized is a hard fail. @@ -1050,10 +1074,9 @@ vrp_val_min (const_tree type) return build_zero_cst (const_cast<tree> (type)); if (frange::supports_p (type)) { - REAL_VALUE_TYPE real, real_ninf; - real_inf (&real); - real_ninf = real_value_negate (&real); - return build_real (const_cast <tree> (type), real_ninf); + REAL_VALUE_TYPE ninf; + real_inf (&ninf, 1); + return build_real (const_cast <tree> (type), ninf); } return NULL_TREE; } @@ -1096,6 +1119,26 @@ frange::frange (const frange &src) *this = src; } +// frange constructor from REAL_VALUE_TYPE endpoints. + +inline +frange::frange (tree type, + const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max, + value_range_kind kind) +{ + m_discriminator = VR_FRANGE; + set (type, min, max, kind); +} + +// frange constructor from trees. + +inline +frange::frange (tree min, tree max, value_range_kind kind) +{ + m_discriminator = VR_FRANGE; + set (min, max, kind); +} + inline tree frange::type () const { @@ -1107,6 +1150,8 @@ frange::set_varying (tree type) { m_kind = VR_VARYING; m_type = type; + real_inf (&m_min, 1); + real_inf (&m_max, 0); m_props.set_varying (); } @@ -1116,6 +1161,29 @@ frange::set_undefined () m_kind = VR_UNDEFINED; m_type = NULL; m_props.set_undefined (); + memset (&m_min, 0, sizeof (m_min)); + memset (&m_max, 0, sizeof (m_max)); +} + +// Set R to maximum representable value for TYPE. + +inline void +real_max_representable (REAL_VALUE_TYPE *r, tree type) +{ + char buf[128]; + get_max_float (REAL_MODE_FORMAT (TYPE_MODE (type)), + buf, sizeof (buf), false); + int res = real_from_string (r, buf); + gcc_checking_assert (!res); +} + +// Set R to minimum representable value for TYPE. + +inline void +real_min_representable (REAL_VALUE_TYPE *r, tree type) +{ + real_max_representable (r, type); + *r = real_value_negate (r); } #endif // GCC_VALUE_RANGE_H |