aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-06-01 16:58:36 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-06-03 10:31:01 +0200
commit89b0276d3fafdd254e17beee3c86ec00edcf28a2 (patch)
tree5fcc6c8fd7dbae658f1376faae0ce1bbd7140f14 /gcc/value-range.h
parenta9058b08381cd76e8d21364f0f5ccddb3777c3fd (diff)
downloadgcc-89b0276d3fafdd254e17beee3c86ec00edcf28a2.zip
gcc-89b0276d3fafdd254e17beee3c86ec00edcf28a2.tar.gz
gcc-89b0276d3fafdd254e17beee3c86ec00edcf28a2.tar.bz2
Flesh out unsupported_range.
It's cleaner to have the unsupported_range fully fleshed out, instead of trapping on every operation. It can also serve as the basis for the default vrange methods that frange and prange will inherit. This patch implements most methods, including union and intersect, to handle an UNDEFINED and a VARYING range. Since this can serve as the basis for other classes, I have moved everything into the vrange class, making the unsupported_range trivial. Note that vrange is still an abstract class, as I have purposely left the dump() method abstract. Also, I have made the unsupported range in the temporary class (Value_Range) a method field, instead of a static member. This way the temporary can set UNDEFINED and VARYING as needed. Tested on x86-64 Linux. gcc/ChangeLog: * value-range.cc (vrange::contains_p): Implement. (vrange::type): Return void. (vrange::supports_type_p): Implement. (irange::fits_p): Same. (vrange::set_undefined): Same. (irange::set_nonnegative): Same. (vrange::set_varying): Same. (vrange::union_): Same. (unsupported_range::set): Move to vrange. (unsupported_range::type): Move to vrange. (vrange::intersect): Implement for varying and undefined. (vrange::zero_p): Implement. (unsupported_range::supports_type_p): Move to vrange. (vrange::nonzero_p): Implement. (unsupported_range::set_undefined): Move to vrange. (unsupported_range::set_varying): Same. (unsupported_range::dump): Same. (unsupported_range::union_): Same. Implement for varying and undefined. (unsupported_range::intersect): Move to vrange. (unsupported_range::zero_p): Same. (unsupported_range::nonzero_p): Same. (unsupported_range::set_nonzero): Same. (unsupported_range::set_zero): Same. (unsupported_range::set_nonnegative): Same. (unsupported_range::fits_p): Same. * value-range.h (class vrange): Remove abstract markers for most methods. (class unsupported_range): Remove most methods as they will now be inherited from vrange.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r--gcc/value-range.h44
1 files changed, 15 insertions, 29 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 69cf6c3..61e6a18 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -73,22 +73,22 @@ class vrange
template <typename T> friend bool is_a (vrange &);
friend class Value_Range;
public:
- virtual void set (tree, tree, value_range_kind = VR_RANGE) = 0;
- virtual tree type () const = 0;
- virtual bool supports_type_p (tree type) const = 0;
- virtual void set_varying (tree type) = 0;
- virtual void set_undefined () = 0;
+ virtual void set (tree, tree, value_range_kind = VR_RANGE);
+ virtual tree type () const;
+ virtual bool supports_type_p (tree type) const;
+ virtual void set_varying (tree type);
+ virtual void set_undefined ();
virtual void dump (FILE * = stderr) const = 0;
- virtual bool union_ (const vrange &) = 0;
- virtual bool intersect (const vrange &) = 0;
+ virtual bool union_ (const vrange &);
+ virtual bool intersect (const vrange &);
virtual bool singleton_p (tree *result = NULL) const;
virtual bool contains_p (tree cst) const;
- virtual bool zero_p () const = 0;
- virtual bool nonzero_p () const = 0;
- virtual void set_nonzero (tree type) = 0;
- virtual void set_zero (tree type) = 0;
- virtual void set_nonnegative (tree type) = 0;
- virtual bool fits_p (const vrange &r) const = 0;
+ 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);
+ virtual bool fits_p (const vrange &r) const;
bool varying_p () const;
bool undefined_p () const;
@@ -236,27 +236,13 @@ private:
};
// Unsupported temporaries may be created by ranger before it's known
-// they're unsupported, or by vr_values::get_value_range. All
-// operations except construction cause a trap.
+// they're unsupported, or by vr_values::get_value_range.
class unsupported_range : public vrange
{
public:
unsupported_range ();
- virtual void set (tree, tree, value_range_kind) override;
- virtual tree type () const override;
- virtual bool supports_type_p (tree type) const override;
- virtual void set_varying (tree type) override;
- virtual void set_undefined () override;
virtual void dump (FILE *) const override;
- virtual bool union_ (const vrange &) override;
- virtual bool intersect (const vrange &) override;
- virtual bool zero_p () const override;
- virtual bool nonzero_p () const override;
- virtual void set_nonzero (tree) override;
- virtual void set_zero (tree) override;
- virtual void set_nonnegative (tree) override;
- virtual bool fits_p (const vrange &) const override;
};
// Traits to implement vrange is_a<> and as_a<>.
@@ -369,7 +355,7 @@ public:
wide_int upper_bound () const; // For irange/prange compatability.
private:
void init (tree type);
- static unsupported_range m_unsupported;
+ unsupported_range m_unsupported;
vrange *m_vrange;
int_range_max m_irange;
DISABLE_COPY_AND_ASSIGN (Value_Range);