From patchwork Wed Oct 18 17:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 827769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-464462-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LLhiUAiP"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yHJRR04Kcz9t5Q for ; Thu, 19 Oct 2017 04:08:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=nzYq2H9H1wZbTjdNx7ac4CMOZtDImJR7Tsa12uXJ0JIvcO mgl2TQ94EzUgB49Gs7q9E6XjtBtJ2nrbpVvuQnVtGRa+WD7b2Vqw4mgUza+0CtGp jcMUcT1OPN1ftuC0bTwbc9D7LuxQbVeVIZidqqGS+SkMV4p013S4OXRlFjoi8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=Ast+E6KgswNrBN55w6E2pw5WDk4=; b=LLhiUAiP84OTPwp1qN5z Idl5p5GN6R1QeL4VxwbqmjPlicwzW4gS+iQL6EfO/33FV50RK/aG0E12UPY80cU4 jQNa3fALCi5vx3jQTd90JKWyRz8PgkBJgpEosc8SMdycc5Wg0KuFktjBMrCYpK34 2Xo2X517F9aXD1kqXExoccw= Received: (qmail 52773 invoked by alias); 18 Oct 2017 17:08:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 52751 invoked by uid 89); 18 Oct 2017 17:08:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=our X-HELO: mail-oi0-f52.google.com Received: from mail-oi0-f52.google.com (HELO mail-oi0-f52.google.com) (209.85.218.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 17:08:07 +0000 Received: by mail-oi0-f52.google.com with SMTP id q4so10128444oic.7 for ; Wed, 18 Oct 2017 10:08:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=UOfJpzW9ahz/gRngG6Ee8YH8rUbloUdh1l1dLEfN5jU=; b=IlWFF1iOJYd81v1BcKM8W6i5GWZTFPngul4Z1WrTBmKIoS+YzTmqNNF8N1G28ARPn4 AnbP3wBNBkcLaKNNioaGUpn1/EAZggRz7/Wso1BzFJZru+Gu/l0UAp/U3LokApB7Meg+ X/GuQussioZsALVgv91JSmUf4Ey/Y1FGvKWE3n4jj9OdWv4niNoAlPp2y0fhAzv4VCXE dXIFl21c0LndAoTIx0QJdhJiao8qkDDwERPa8wrZzobNEDHopUaTbf3FBDCpVl6f1AKW mhAzSwPL8YM1seV9SVgq/1Et6UY0VAdImVIRapLjCJZmCfFxmWSfQshYPG1PlNhFEhJi JHoQ== X-Gm-Message-State: AMCzsaXXFCN1zLnu5cm4kNl4s9E1Ommwd07YZfxn0X3O+QjGS9xjkfI0 U/Fr0jq833ibhm5XPq9I3Nz4P8hp5ZZJ+RtRh0Gk9CYr X-Google-Smtp-Source: ABhQp+QRngklrD1ieFigyuLM1m0f05RuIz9MnxALjgpdbRXK/f7us4v/8sU56wyNaUEVu/0jAAQO+TWJb1kbJTV+qFQ= X-Received: by 10.202.74.17 with SMTP id x17mr8454262oia.163.1508346485498; Wed, 18 Oct 2017 10:08:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.18.241 with HTTP; Wed, 18 Oct 2017 10:08:05 -0700 (PDT) From: Aldy Hernandez Date: Wed, 18 Oct 2017 13:08:05 -0400 Message-ID: Subject: [patch] implement generic debug() functions for wide_int's To: gcc-patches X-IsSubscribed: yes It looks like the generic debug() function for wide_int's is missing. Instead, we have a wi->dump() method. I have implemented debug() for generic wide_int and for widest_int, which should cover the common cases. Anything else, can continue using the ->dump() method templated methods. Also, do we have a blessed way of specifying overloaded functions in ChangeLog's? I couldn't find anything in our GCC coding guidelines or in the GNU coding guidelines. For lack of direction, I'm doing the following: * wide-int.cc (debug) [const wide_int &]: New. (debug) [const wide_int *]: New. (debug) [const widest_int &]: New. (debug) [const widest_int *]: New. It seems appropriate, as that is the GNU way of changelogs for a conditional change to a function ???. OK for trunk? gcc/ * wide-int.cc (debug) [const wide_int &]: New. (debug) [const wide_int *]: New. (debug) [const widest_int &]: New. (debug) [const widest_int *]: New. diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc index 71e24ec22af..1a1a68c1943 100644 --- a/gcc/wide-int.cc +++ b/gcc/wide-int.cc @@ -2146,6 +2146,39 @@ template void generic_wide_int >::dump () const; template void offset_int::dump () const; template void widest_int::dump () const; +/* We could add all the above ::dump variants here, but wide_int and + widest_int should handle the common cases. Besides, you can always + call the dump method directly. */ + +DEBUG_FUNCTION void +debug (const wide_int &ref) +{ + ref.dump (); +} + +DEBUG_FUNCTION void +debug (const wide_int *ptr) +{ + if (ptr) + debug (*ptr); + else + fprintf (stderr, "\n"); +} + +DEBUG_FUNCTION void +debug (const widest_int &ref) +{ + ref.dump (); +} + +DEBUG_FUNCTION void +debug (const widest_int *ptr) +{ + if (ptr) + debug (*ptr); + else + fprintf (stderr, "\n"); +} #if CHECKING_P