public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-35] Accept a vrange in get_legacy_range.
@ 2024-04-28 19:04 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2024-04-28 19:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9a2f0d152d98dd55efc9accd07ea507b929c3516

commit r15-35-g9a2f0d152d98dd55efc9accd07ea507b929c3516
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Mar 19 17:17:53 2024 +0100

    Accept a vrange in get_legacy_range.
    
    In preparation for prange, make get_legacy_range take a generic
    vrange, not just an irange.
    
    gcc/ChangeLog:
    
            * value-range.cc (get_legacy_range): Make static and add another
            version of get_legacy_range that takes a vrange.
            * value-range.h (class irange): Remove unnecessary friendship with
            get_legacy_range.
            (get_legacy_range): Accept a vrange.

Diff:
---
 gcc/value-range.cc | 17 ++++++++++++++++-
 gcc/value-range.h  |  3 +--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index b901c864a7b..44929b210aa 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1004,7 +1004,7 @@ irange::operator= (const irange &src)
   return *this;
 }
 
-value_range_kind
+static value_range_kind
 get_legacy_range (const irange &r, tree &min, tree &max)
 {
   if (r.undefined_p ())
@@ -1041,6 +1041,21 @@ get_legacy_range (const irange &r, tree &min, tree &max)
   return VR_RANGE;
 }
 
+// Given a range in V, return an old-style legacy range consisting of
+// a value_range_kind with a MIN/MAX.  This is to maintain
+// compatibility with passes that still depend on VR_ANTI_RANGE, and
+// only works for integers and pointers.
+
+value_range_kind
+get_legacy_range (const vrange &v, tree &min, tree &max)
+{
+  if (is_a <irange> (v))
+    return get_legacy_range (as_a <irange> (v), min, max);
+
+  gcc_unreachable ();
+  return VR_UNDEFINED;
+}
+
 /* 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]
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 62f123e2a4b..d2e8fd5a4d9 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -281,7 +281,6 @@ irange_bitmask::intersect (const irange_bitmask &orig_src)
 
 class irange : public vrange
 {
-  friend value_range_kind get_legacy_range (const irange &, tree &, tree &);
   friend class irange_storage;
   friend class vrange_printer;
 public:
@@ -886,7 +885,7 @@ Value_Range::supports_type_p (const_tree type)
   return irange::supports_p (type) || frange::supports_p (type);
 }
 
-extern value_range_kind get_legacy_range (const irange &, tree &min, tree &max);
+extern value_range_kind get_legacy_range (const vrange &, tree &min, tree &max);
 extern void dump_value_range (FILE *, const vrange *);
 extern bool vrp_operand_equal_p (const_tree, const_tree);
 inline REAL_VALUE_TYPE frange_val_min (const_tree type);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-28 19:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-28 19:04 [gcc r15-35] Accept a vrange in get_legacy_range Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).