From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by sourceware.org (Postfix) with ESMTPS id 6BF613858C60 for ; Sun, 28 Apr 2024 19:06:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BF613858C60 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=localhost.redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BF613858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331169; cv=none; b=Hn9JMa0XOOJKwxROcmz4OWKnWjaDvi+ja9I/JX8dDqP3ZwAu6vzvtZg/OPOVKOtnqWK+R6E6ZyEvir1iV/xDtttkGBvZB9jFCxE1vhFwQU0QxomUtWLgvE7JbWyrVtW9Kbzkv8PYWNtyK7Q5WWtNcRLhThAdGnU8FS8hTvYK3cI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331169; c=relaxed/simple; bh=PLiPqLp2w9L9RnoObAa+lyAIdC7qRSH3buYQ4y+xAas=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=r2ygphvdV2BrMvWO5TDFKgBQ7duqX5PdDrmYAH8ho92k5jzuXPXd8uPxYJCqxSpKb+GvE1g2b8DXlEjASBjgwjGHP+L8gXoV6GrvurdJg3j7091g2+JqB7mJYPePw5kxUxsxsr8deYEbKbb9zBTQbdo+3VFiV+46EWdbSt5HRag= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714331165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mg7jKgEvyhXlABk6cA1pIhligfNeaV4wgFifz7CKzC4=; b=c34MLs7GaK8suf54toDN/Tm0o2tGYrq0BGKiccC/4SWUVuH4c0Oa0/Grt0NWTSsavImiuM RC6Hc87YhvdwFuBfykw+AmKbgOyuPgix0C0IroobZKL/TY+43xtz4cM+2+B5ijaqOTMae0 o+VwfnrleEP2pxaHVayxmghsq7GPWyA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-LcAjVE8fPDas-Zw3GggKwg-1; Sun, 28 Apr 2024 15:06:03 -0400 X-MC-Unique: LcAjVE8fPDas-Zw3GggKwg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33186830F7E for ; Sun, 28 Apr 2024 19:06:03 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0F2040BB24; Sun, 28 Apr 2024 19:06:02 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.2/8.17.1) with ESMTPS id 43SJ61wk1209692 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 28 Apr 2024 21:06:01 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.2/8.17.2/Submit) id 43SJ61xC1209691; Sun, 28 Apr 2024 21:06:01 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED 14/16] Move print_irange_* out of vrange_printer class. Date: Sun, 28 Apr 2024 21:05:52 +0200 Message-ID: <20240428190557.1209586-15-aldyh@redhat.com> In-Reply-To: <20240428190557.1209586-1-aldyh@redhat.com> References: <20240428190557.1209586-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; x-default=true X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NO_DNS_FOR_FROM,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Move some code out of the irange pretty printers so it can be shared with pointers. gcc/ChangeLog: =09* value-range-pretty-print.cc (print_int_bound): New. =09(print_irange_bitmasks): New. =09(vrange_printer::print_irange_bound): Remove. =09(vrange_printer::print_irange_bitmasks): Remove. =09* value-range-pretty-print.h: Remove print_irange_bitmasks and =09print_irange_bound --- 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" =20 +static void +print_int_bound (pretty_printer *pp, const wide_int &bound, tree type) +{ + wide_int type_min =3D wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (t= ype)); + wide_int type_max =3D wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (t= ype)); + + if (INTEGRAL_TYPE_P (type) + && !TYPE_UNSIGNED (type) + && bound =3D=3D type_min + && TYPE_PRECISION (type) !=3D 1) + pp_string (pp, "-INF"); + else if (bound =3D=3D type_max && TYPE_PRECISION (type) !=3D 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 =3D XALLOCAVEC (char, MAX (len_mask, len_val)); + else + p =3D 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 =3D 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) cons= t -{ - wide_int type_min =3D wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (t= ype)); - wide_int type_max =3D wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (t= ype)); - - if (INTEGRAL_TYPE_P (type) - && !TYPE_UNSIGNED (type) - && bound =3D=3D type_min - && TYPE_PRECISION (type) !=3D 1) - pp_string (pp, "-INF"); - else if (bound =3D=3D type_max && TYPE_PRECISION (type) !=3D 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 =3D 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 =3D XALLOCAVEC (char, MAX (len_mask, len_val)); - else - p =3D 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); } =20 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; =20 --=20 2.44.0