public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r15-39] Move print_irange_* out of vrange_printer class.
Date: Sun, 28 Apr 2024 19:04:47 +0000 (GMT)	[thread overview]
Message-ID: <20240428190447.BE4853858D3C@sourceware.org> (raw)

https://gcc.gnu.org/g:df6a1bc59a355c9fee10d29f54c9dca81612afb6

commit r15-39-gdf6a1bc59a355c9fee10d29f54c9dca81612afb6
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Mar 19 20:26:27 2024 +0100

    Move print_irange_* out of vrange_printer class.
    
    Move some code out of the irange pretty printers so it can be shared
    with pointers.
    
    gcc/ChangeLog:
    
            * value-range-pretty-print.cc (print_int_bound): New.
            (print_irange_bitmasks): New.
            (vrange_printer::print_irange_bound): Remove.
            (vrange_printer::print_irange_bitmasks): Remove.
            * value-range-pretty-print.h: Remove print_irange_bitmasks and
            print_irange_bound

Diff:
---
 gcc/value-range-pretty-print.cc | 83 ++++++++++++++++++++---------------------
 gcc/value-range-pretty-print.h  |  2 -
 2 files changed, 41 insertions(+), 44 deletions(-)

diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc
index c75cbea3955..b6d23dce6d2 100644
--- a/gcc/value-range-pretty-print.cc
+++ b/gcc/value-range-pretty-print.cc
@@ -30,6 +30,44 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-range.h"
 #include "value-range-pretty-print.h"
 
+static void
+print_int_bound (pretty_printer *pp, const wide_int &bound, tree type)
+{
+  wide_int type_min = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
+  wide_int type_max = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
+
+  if (INTEGRAL_TYPE_P (type)
+      && !TYPE_UNSIGNED (type)
+      && bound == type_min
+      && TYPE_PRECISION (type) != 1)
+    pp_string (pp, "-INF");
+  else if (bound == type_max && TYPE_PRECISION (type) != 1)
+    pp_string (pp, "+INF");
+  else
+    pp_wide_int (pp, bound, TYPE_SIGN (type));
+}
+
+static void
+print_irange_bitmasks (pretty_printer *pp, const irange_bitmask &bm)
+{
+  if (bm.unknown_p ())
+    return;
+
+  pp_string (pp, " MASK ");
+  char buf[WIDE_INT_PRINT_BUFFER_SIZE], *p;
+  unsigned len_mask, len_val;
+  if (print_hex_buf_size (bm.mask (), &len_mask)
+      | print_hex_buf_size (bm.value (), &len_val))
+    p = XALLOCAVEC (char, MAX (len_mask, len_val));
+  else
+    p = buf;
+  print_hex (bm.mask (), p);
+  pp_string (pp, p);
+  pp_string (pp, " VALUE ");
+  print_hex (bm.value (), p);
+  pp_string (pp, p);
+}
+
 void
 vrange_printer::visit (const unsupported_range &r) const
 {
@@ -66,51 +104,12 @@ vrange_printer::visit (const irange &r) const
   for (unsigned i = 0; i < r.num_pairs (); ++i)
     {
       pp_character (pp, '[');
-      print_irange_bound (r.lower_bound (i), r.type ());
+      print_int_bound (pp, r.lower_bound (i), r.type ());
       pp_string (pp, ", ");
-      print_irange_bound (r.upper_bound (i), r.type ());
+      print_int_bound (pp, r.upper_bound (i), r.type ());
       pp_character (pp, ']');
     }
- print_irange_bitmasks (r);
-}
-
-void
-vrange_printer::print_irange_bound (const wide_int &bound, tree type) const
-{
-  wide_int type_min = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
-  wide_int type_max = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
-
-  if (INTEGRAL_TYPE_P (type)
-      && !TYPE_UNSIGNED (type)
-      && bound == type_min
-      && TYPE_PRECISION (type) != 1)
-    pp_string (pp, "-INF");
-  else if (bound == type_max && TYPE_PRECISION (type) != 1)
-    pp_string (pp, "+INF");
-  else
-    pp_wide_int (pp, bound, TYPE_SIGN (type));
-}
-
-void
-vrange_printer::print_irange_bitmasks (const irange &r) const
-{
-  irange_bitmask bm = r.m_bitmask;
-  if (bm.unknown_p ())
-    return;
-
-  pp_string (pp, " MASK ");
-  char buf[WIDE_INT_PRINT_BUFFER_SIZE], *p;
-  unsigned len_mask, len_val;
-  if (print_hex_buf_size (bm.mask (), &len_mask)
-      | print_hex_buf_size (bm.value (), &len_val))
-    p = XALLOCAVEC (char, MAX (len_mask, len_val));
-  else
-    p = buf;
-  print_hex (bm.mask (), p);
-  pp_string (pp, p);
-  pp_string (pp, " VALUE ");
-  print_hex (bm.value (), p);
-  pp_string (pp, p);
+  print_irange_bitmasks (pp, r.m_bitmask);
 }
 
 void
diff --git a/gcc/value-range-pretty-print.h b/gcc/value-range-pretty-print.h
index ca85fd6157c..44cd6e81298 100644
--- a/gcc/value-range-pretty-print.h
+++ b/gcc/value-range-pretty-print.h
@@ -29,8 +29,6 @@ public:
   void visit (const irange &) const override;
   void visit (const frange &) const override;
 private:
-  void print_irange_bound (const wide_int &w, tree type) const;
-  void print_irange_bitmasks (const irange &) const;
   void print_frange_nan (const frange &) const;
   void print_real_value (tree type, const REAL_VALUE_TYPE &r) const;

                 reply	other threads:[~2024-04-28 19:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240428190447.BE4853858D3C@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).