From patchwork Mon Oct 23 17:02:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116751 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4867075qgn; Mon, 23 Oct 2017 10:02:27 -0700 (PDT) X-Received: by 10.84.231.193 with SMTP id g1mr10630026pln.407.1508778147274; Mon, 23 Oct 2017 10:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778147; cv=none; d=google.com; s=arc-20160816; b=A0v+gcNnNVk0pIsye4esbN+wSkYG2DFbzhtMmxEuDkhJzqzZrBVDrTgFFJRm6qtden H/ynZSaL6gJ9WWEYvgqswplUI8uHUKaaJ9X4mO76Je8hNpf4Y6vn4agO/NwCW/WacmFo Qp9PwYrn1ZpgUjIU3G5DkEO/+VUfmXDVAdAzJuiRo0faLsPQpXkYFuMieYDHlnLZQr7x wkzOeFh4PMfOWjvg5fGb3zKVq3pxDjn1nNuVpb2LjpQi7Q1iyOqGlmdAfX3EmQ1FC9dH trk637w8omHqzw8Lbg05OeaijOqZjxNu4wtB34b93Y61bLrcKekBHXY5ydocdxcWYAn1 GVUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=mUG4I3oAiGQkDFL0xsX7QaqEuxOXF2F75DrYQSjIMqI=; b=DK3U32Ybn1+XXZ/ckCA6NLeK3+CEsyRifPdvXjtvvZB+uYdsqLeKlqs6z9x3o4rNtK 5lESKosjnuIUO/c4d/0Rv7K/s1lRa/qgla10P+iLhAgk8Wmn4hvC+Ann+/Mam6pDqnSM 2YG5h0g7tOqMalTwt3Spf96ErUQk3S32rl/bakvIVgXrfeXXH5UQX93v0r/1JMiRVtpN QMyC5qOmnlw/vBz1qvdUN/1/0tkUObLWShVM5znuaBYH57zfRHS4QAcdyo0EpCttZh3J z/op9DhDhUjQhAfYcm51+9yFdi3ylkQZYZn1NMzzVizLK/kqrviUtTEIWZ1W8vhvpIBd CvLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZilLwPZa; spf=pass (google.com: domain of gcc-patches-return-464782-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464782-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f4si4244272plm.686.2017.10.23.10.02.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464782-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZilLwPZa; spf=pass (google.com: domain of gcc-patches-return-464782-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464782-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=vIPEt8Gv8U2Mf9qK4z2Oz64s8EbUW 48Rs1noIdeowBJXa7OgW8PvpKaFQszkx/+BrbMFlmBxD+Kua98RKDZF2oko3ub52 Zm5wSvd7RBLGuy/lWCJ9yWEYNCgX+6gheI1gEmkFN9MIpllfurhHnDe62SgHwpXD 4jpvwHEUs2etzg= 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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=VJ87diWMmRsmvuDj3BQius6cXaw=; b=Zil LwPZatuGe8qedHmeyOgnBY6OVM2FnYbgEiOb1Yq7Vz37KtFwBfdDPreJH9YimLYF 6ZnZ1fz7SwyJJ4ImLLLs450NcLuLZ5BiGewBofp7HOV7FyEIb0dWzfYB+72TZsqW DuTt0SdQbn4hl48+ZQvgK8Dkzbn//ro7XlKzf0js= Received: (qmail 103574 invoked by alias); 23 Oct 2017 17:02:14 -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 103561 invoked by uid 89); 23 Oct 2017 17:02:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=flush, 007 X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:02:07 +0000 Received: by mail-wm0-f52.google.com with SMTP id b9so5448884wmh.0 for ; Mon, 23 Oct 2017 10:02: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:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=mUG4I3oAiGQkDFL0xsX7QaqEuxOXF2F75DrYQSjIMqI=; b=fWvC+9DPwM5ZEHLMlU1NwEsVyA1Og1238xLj4RLNhrZc1Yx6lYSY0S0lCtVDURKLHD sFdZQzP1++VU0DSRlj1IY83pXDgjx/nHJK1HiY2m81M3iA/VkmbCIT9FPpwAs6wPOKM5 DuKIC09DvDdzg/z1THrDwkklofH+8tvQH4estjTm0V7+RaEvQW0j4GZyvKO9pDywSEnT O4pz1k2DahiEh6U1W2G1phc2DZXrvYVChMLOKkUan0uep+0TU63V7Lf0kfxFbogWOLfX PnsQ0X6aj/AoS8JnOAkI/56doUAEcz89GEf1q7HJQbfUNlx+lqkdFEBC+z1GUA5pscoZ lLTg== X-Gm-Message-State: AMCzsaXKBeOebNfmk6pSql8E04UdoxeO5gvEdBSKTy5m/izJs6/EYZuR 3ndji22d9b6QQqVqiq+DGSwmiOgVDPg= X-Google-Smtp-Source: ABhQp+RyD+x5/buPDvCJtbL5bJEHHTfWzEHzRa8RUKoFLB6IpI97HXMzjStnVsq7RAi2S4uJccwcPQ== X-Received: by 10.28.145.13 with SMTP id t13mr4772790wmd.40.1508778125351; Mon, 23 Oct 2017 10:02:05 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id j27sm6306282wrd.42.2017.10.23.10.02.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:02:04 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [007/nnn] poly_int: dump routines References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:02:04 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <874lqpu7ar.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Add poly_int routines for the dumpfile.h and pretty-print.h frameworks. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * dumpfile.h (dump_dec): Declare. * dumpfile.c (dump_dec): New function. * pretty-print.h (pp_wide_integer): Turn into a function and declare a poly_int version. * pretty-print.c (pp_wide_integer): New function for poly_ints. Index: gcc/dumpfile.h =================================================================== --- gcc/dumpfile.h 2017-10-23 16:52:20.417686430 +0100 +++ gcc/dumpfile.h 2017-10-23 17:01:00.431554440 +0100 @@ -174,6 +174,9 @@ extern void dump_gimple_stmt (dump_flags extern void print_combine_total_stats (void); extern bool enable_rtl_dump_file (void); +template +void dump_dec (int, const poly_int &); + /* In tree-dump.c */ extern void dump_node (const_tree, dump_flags_t, FILE *); Index: gcc/dumpfile.c =================================================================== --- gcc/dumpfile.c 2017-10-23 16:52:20.417686430 +0100 +++ gcc/dumpfile.c 2017-10-23 17:01:00.431554440 +0100 @@ -473,6 +473,27 @@ dump_printf_loc (dump_flags_t dump_kind, } } +/* Output VALUE in decimal to appropriate dump streams. */ + +template +void +dump_dec (int dump_kind, const poly_int &value) +{ + STATIC_ASSERT (poly_coeff_traits::signedness >= 0); + signop sgn = poly_coeff_traits::signedness ? SIGNED : UNSIGNED; + if (dump_file && (dump_kind & pflags)) + print_dec (value, dump_file, sgn); + + if (alt_dump_file && (dump_kind & alt_flags)) + print_dec (value, alt_dump_file, sgn); +} + +template void dump_dec (int, const poly_uint16 &); +template void dump_dec (int, const poly_int64 &); +template void dump_dec (int, const poly_uint64 &); +template void dump_dec (int, const poly_offset_int &); +template void dump_dec (int, const poly_widest_int &); + /* Start a dump for PHASE. Store user-supplied dump flags in *FLAG_PTR. Return the number of streams opened. Set globals DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and Index: gcc/pretty-print.h =================================================================== --- gcc/pretty-print.h 2017-10-23 16:52:20.417686430 +0100 +++ gcc/pretty-print.h 2017-10-23 17:01:00.431554440 +0100 @@ -328,8 +328,6 @@ #define pp_wide_int(PP, W, SGN) \ pp_string (PP, pp_buffer (PP)->digit_buffer); \ } \ while (0) -#define pp_wide_integer(PP, I) \ - pp_scalar (PP, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) I) #define pp_pointer(PP, P) pp_scalar (PP, "%p", P) #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \ @@ -401,4 +399,15 @@ extern const char *identifier_to_locale extern void *(*identifier_to_locale_alloc) (size_t); extern void (*identifier_to_locale_free) (void *); +/* Print I to PP in decimal. */ + +inline void +pp_wide_integer (pretty_printer *pp, HOST_WIDE_INT i) +{ + pp_scalar (pp, HOST_WIDE_INT_PRINT_DEC, i); +} + +template +void pp_wide_integer (pretty_printer *pp, const poly_int_pod &); + #endif /* GCC_PRETTY_PRINT_H */ Index: gcc/pretty-print.c =================================================================== --- gcc/pretty-print.c 2017-10-23 16:52:20.417686430 +0100 +++ gcc/pretty-print.c 2017-10-23 17:01:00.431554440 +0100 @@ -795,6 +795,30 @@ pp_clear_state (pretty_printer *pp) pp_indentation (pp) = 0; } +/* Print X to PP in decimal. */ +template +void +pp_wide_integer (pretty_printer *pp, const poly_int_pod &x) +{ + if (x.is_constant ()) + pp_wide_integer (pp, x.coeffs[0]); + else + { + pp_left_bracket (pp); + for (unsigned int i = 0; i < N; ++i) + { + if (i != 0) + pp_comma (pp); + pp_wide_integer (pp, x.coeffs[i]); + } + pp_right_bracket (pp); + } +} + +template void pp_wide_integer (pretty_printer *, const poly_uint16_pod &); +template void pp_wide_integer (pretty_printer *, const poly_int64_pod &); +template void pp_wide_integer (pretty_printer *, const poly_uint64_pod &); + /* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */ void pp_write_text_to_stream (pretty_printer *pp)