public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Add GTY support for vrange.
@ 2023-04-18 16:24 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2023-04-18 16:24 UTC (permalink / raw)
  To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez

IPA currently puts *some* irange's in GC memory.  When I contribute
support for generic ranges in IPA, we'll need to change this to
vrange.  This patch adds GTY support for both vrange and frange.

gcc/ChangeLog:

	* value-range.cc (gt_ggc_mx): New.
	(gt_pch_nx): New.
	* value-range.h (class vrange): Add GTY marker.
	(class frange): Same.
	(gt_ggc_mx): Remove.
	(gt_pch_nx): Remove.
---
 gcc/value-range.cc | 85 ++++++++++++++++++++++++++++++++++++++++++++++
 gcc/value-range.h  | 51 ++++++++--------------------
 2 files changed, 99 insertions(+), 37 deletions(-)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 3b3102bc6d0..17f4e1b9f59 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -3252,6 +3252,91 @@ vrp_operand_equal_p (const_tree val1, const_tree val2)
   return true;
 }
 
+void
+gt_ggc_mx (irange *x)
+{
+  for (unsigned i = 0; i < x->m_num_ranges; ++i)
+    {
+      gt_ggc_mx (x->m_base[i * 2]);
+      gt_ggc_mx (x->m_base[i * 2 + 1]);
+    }
+  if (x->m_nonzero_mask)
+    gt_ggc_mx (x->m_nonzero_mask);
+}
+
+void
+gt_pch_nx (irange *x)
+{
+  for (unsigned i = 0; i < x->m_num_ranges; ++i)
+    {
+      gt_pch_nx (x->m_base[i * 2]);
+      gt_pch_nx (x->m_base[i * 2 + 1]);
+    }
+  if (x->m_nonzero_mask)
+    gt_pch_nx (x->m_nonzero_mask);
+}
+
+void
+gt_pch_nx (irange *x, gt_pointer_operator op, void *cookie)
+{
+  for (unsigned i = 0; i < x->m_num_ranges; ++i)
+    {
+      op (&x->m_base[i * 2], NULL, cookie);
+      op (&x->m_base[i * 2 + 1], NULL, cookie);
+    }
+  if (x->m_nonzero_mask)
+    op (&x->m_nonzero_mask, NULL, cookie);
+}
+
+void
+gt_ggc_mx (frange *x)
+{
+  gt_ggc_mx (x->m_type);
+}
+
+void
+gt_pch_nx (frange *x)
+{
+  gt_pch_nx (x->m_type);
+}
+
+void
+gt_pch_nx (frange *x, gt_pointer_operator op, void *cookie)
+{
+  op (&x->m_type, NULL, cookie);
+}
+
+void
+gt_ggc_mx (vrange *x)
+{
+  if (is_a <irange> (*x))
+    return gt_ggc_mx ((irange *) x);
+  if (is_a <frange> (*x))
+    return gt_ggc_mx ((frange *) x);
+  gcc_unreachable ();
+}
+
+void
+gt_pch_nx (vrange *x)
+{
+  if (is_a <irange> (*x))
+    return gt_pch_nx ((irange *) x);
+  if (is_a <frange> (*x))
+    return gt_pch_nx ((frange *) x);
+  gcc_unreachable ();
+}
+
+void
+gt_pch_nx (vrange *x, gt_pointer_operator op, void *cookie)
+{
+  if (is_a <irange> (*x))
+    gt_pch_nx ((irange *) x, op, cookie);
+  else if (is_a <frange> (*x))
+    gt_pch_nx ((frange *) x, op, cookie);
+  else
+    gcc_unreachable ();
+}
+
 // ?? These stubs are for ipa-prop.cc which use a value_range in a
 // hash_traits.  hash-traits.h defines an extern of gt_ggc_mx (T &)
 // instead of picking up the gt_ggc_mx (T *) version.
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 5545cce5024..0eeea79b322 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -72,7 +72,7 @@ enum value_range_discriminator
 //	if (f.supports_type_p (type)) ...
 //    }
 
-class vrange
+class GTY((user)) vrange
 {
   template <typename T> friend bool is_a (vrange &);
   friend class Value_Range;
@@ -329,10 +329,13 @@ nan_state::neg_p () const
 // The representation is a type with a couple of endpoints, unioned
 // with the set of { -NAN, +Nan }.
 
-class frange : public vrange
+class GTY((user)) frange : public vrange
 {
   friend class frange_storage_slot;
   friend class vrange_printer;
+  friend void gt_ggc_mx (frange *);
+  friend void gt_pch_nx (frange *);
+  friend void gt_pch_nx (frange *, gt_pointer_operator, void *);
 public:
   frange ();
   frange (const frange &);
@@ -827,41 +830,15 @@ range_includes_zero_p (const irange *vr)
   return vr->may_contain_p (build_zero_cst (vr->type ()));
 }
 
-inline void
-gt_ggc_mx (irange *x)
-{
-  for (unsigned i = 0; i < x->m_num_ranges; ++i)
-    {
-      gt_ggc_mx (x->m_base[i * 2]);
-      gt_ggc_mx (x->m_base[i * 2 + 1]);
-    }
-  if (x->m_nonzero_mask)
-    gt_ggc_mx (x->m_nonzero_mask);
-}
-
-inline void
-gt_pch_nx (irange *x)
-{
-  for (unsigned i = 0; i < x->m_num_ranges; ++i)
-    {
-      gt_pch_nx (x->m_base[i * 2]);
-      gt_pch_nx (x->m_base[i * 2 + 1]);
-    }
-  if (x->m_nonzero_mask)
-    gt_pch_nx (x->m_nonzero_mask);
-}
-
-inline void
-gt_pch_nx (irange *x, gt_pointer_operator op, void *cookie)
-{
-  for (unsigned i = 0; i < x->m_num_ranges; ++i)
-    {
-      op (&x->m_base[i * 2], NULL, cookie);
-      op (&x->m_base[i * 2 + 1], NULL, cookie);
-    }
-  if (x->m_nonzero_mask)
-    op (&x->m_nonzero_mask, NULL, cookie);
-}
+extern void gt_ggc_mx (vrange *);
+extern void gt_pch_nx (vrange *);
+extern void gt_pch_nx (vrange *, gt_pointer_operator, void *);
+extern void gt_ggc_mx (irange *);
+extern void gt_pch_nx (irange *);
+extern void gt_pch_nx (irange *, gt_pointer_operator, void *);
+extern void gt_ggc_mx (frange *);
+extern void gt_pch_nx (frange *);
+extern void gt_pch_nx (frange *, gt_pointer_operator, void *);
 
 template<unsigned N>
 inline void
-- 
2.39.2


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

only message in thread, other threads:[~2023-04-18 16:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 16:24 [COMMITTED] Add GTY support for vrange 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).