public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 1/5] Simplify dump_context by adding a dump_loc member function
Date: Tue, 31 Jul 2018 12:51:00 -0000	[thread overview]
Message-ID: <CAFiYyc0DXOjipyRs93+fA2SjsobNaaq_R5=M9ULACLR2h5JF8Q@mail.gmail.com> (raw)
In-Reply-To: <1532730752-10525-2-git-send-email-dmalcolm@redhat.com>

On Fri, Jul 27, 2018 at 11:48 PM David Malcolm <dmalcolm@redhat.com> wrote:
>
> This patch removes some duplicated code in dumpfile.c by
> reimplementing the various dump_foo_loc calls in terms of dump_foo.

OK.

Richard.

> gcc/ChangeLog:
>         * dump-context.h (dump_context::dump_loc): New decl.
>         * dumpfile.c (dump_context::dump_loc): New member function.
>         (dump_context::dump_gimple_stmt_loc): Reimplement using dump_loc
>         and dump_gimple_stmt.
>         (dump_context::dump_gimple_expr_loc): Likewise, using
>         dump_gimple_expr.
>         (dump_context::dump_generic_expr_loc): Likewise, using
>         dump_generic_expr.
>         (dump_context::dump_printf_loc_va): Likewise, using
>         dump_printf_va.
>         (dump_context::begin_scope): Explicitly using the global function
>         "dump_loc", rather than the member function.
> ---
>  gcc/dump-context.h |   2 +
>  gcc/dumpfile.c     | 119 ++++++++++++++---------------------------------------
>  2 files changed, 33 insertions(+), 88 deletions(-)
>
> diff --git a/gcc/dump-context.h b/gcc/dump-context.h
> index a191e3a..f6df0b4 100644
> --- a/gcc/dump-context.h
> +++ b/gcc/dump-context.h
> @@ -39,6 +39,8 @@ class dump_context
>
>    ~dump_context ();
>
> +  void dump_loc (dump_flags_t dump_kind, const dump_location_t &loc);
> +
>    void dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
>                          gimple *gs, int spc);
>
> diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
> index 176c9b8..3c8bc38 100644
> --- a/gcc/dumpfile.c
> +++ b/gcc/dumpfile.c
> @@ -474,6 +474,27 @@ dump_context::~dump_context ()
>    delete m_pending;
>  }
>
> +/* Print LOC to the appropriate dump destinations, given DUMP_KIND.
> +   If optinfos are enabled, begin a new optinfo.  */
> +
> +void
> +dump_context::dump_loc (dump_flags_t dump_kind, const dump_location_t &loc)
> +{
> +  location_t srcloc = loc.get_location_t ();
> +
> +  if (dump_file && (dump_kind & pflags))
> +    ::dump_loc (dump_kind, dump_file, srcloc);
> +
> +  if (alt_dump_file && (dump_kind & alt_flags))
> +    ::dump_loc (dump_kind, alt_dump_file, srcloc);
> +
> +  if (optinfo_enabled_p ())
> +    {
> +      optinfo &info = begin_next_optinfo (loc);
> +      info.handle_dump_file_kind (dump_kind);
> +    }
> +}
> +
>  /* Dump gimple statement GS with SPC indentation spaces and
>     EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
>
> @@ -504,25 +525,8 @@ dump_context::dump_gimple_stmt_loc (dump_flags_t dump_kind,
>                                     dump_flags_t extra_dump_flags,
>                                     gimple *gs, int spc)
>  {
> -  location_t srcloc = loc.get_location_t ();
> -  if (dump_file && (dump_kind & pflags))
> -    {
> -      dump_loc (dump_kind, dump_file, srcloc);
> -      print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (alt_dump_file && (dump_kind & alt_flags))
> -    {
> -      dump_loc (dump_kind, alt_dump_file, srcloc);
> -      print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (optinfo_enabled_p ())
> -    {
> -      optinfo &info = begin_next_optinfo (loc);
> -      info.handle_dump_file_kind (dump_kind);
> -      info.add_gimple_stmt (gs, spc, dump_flags | extra_dump_flags);
> -    }
> +  dump_loc (dump_kind, loc);
> +  dump_gimple_stmt (dump_kind, extra_dump_flags, gs, spc);
>  }
>
>  /* Dump gimple statement GS with SPC indentation spaces and
> @@ -557,25 +561,8 @@ dump_context::dump_gimple_expr_loc (dump_flags_t dump_kind,
>                                     gimple *gs,
>                                     int spc)
>  {
> -  location_t srcloc = loc.get_location_t ();
> -  if (dump_file && (dump_kind & pflags))
> -    {
> -      dump_loc (dump_kind, dump_file, srcloc);
> -      print_gimple_expr (dump_file, gs, spc, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (alt_dump_file && (dump_kind & alt_flags))
> -    {
> -      dump_loc (dump_kind, alt_dump_file, srcloc);
> -      print_gimple_expr (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (optinfo_enabled_p ())
> -    {
> -      optinfo &info = begin_next_optinfo (loc);
> -      info.handle_dump_file_kind (dump_kind);
> -      info.add_gimple_expr (gs, spc, dump_flags | extra_dump_flags);
> -    }
> +  dump_loc (dump_kind, loc);
> +  dump_gimple_expr (dump_kind, extra_dump_flags, gs, spc);
>  }
>
>
> @@ -611,25 +598,8 @@ dump_context::dump_generic_expr_loc (dump_flags_t dump_kind,
>                                      dump_flags_t extra_dump_flags,
>                                      tree t)
>  {
> -  location_t srcloc = loc.get_location_t ();
> -  if (dump_file && (dump_kind & pflags))
> -    {
> -      dump_loc (dump_kind, dump_file, srcloc);
> -      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (alt_dump_file && (dump_kind & alt_flags))
> -    {
> -      dump_loc (dump_kind, alt_dump_file, srcloc);
> -      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
> -    }
> -
> -  if (optinfo_enabled_p ())
> -    {
> -      optinfo &info = begin_next_optinfo (loc);
> -      info.handle_dump_file_kind (dump_kind);
> -      info.add_tree (t, dump_flags | extra_dump_flags);
> -    }
> +  dump_loc (dump_kind, loc);
> +  dump_generic_expr (dump_kind, extra_dump_flags, t);
>  }
>
>  /* Output a formatted message using FORMAT on appropriate dump streams.  */
> @@ -672,35 +642,8 @@ dump_context::dump_printf_loc_va (dump_flags_t dump_kind,
>                                   const dump_location_t &loc,
>                                   const char *format, va_list ap)
>  {
> -  location_t srcloc = loc.get_location_t ();
> -
> -  if (dump_file && (dump_kind & pflags))
> -    {
> -      dump_loc (dump_kind, dump_file, srcloc);
> -      va_list aq;
> -      va_copy (aq, ap);
> -      vfprintf (dump_file, format, aq);
> -      va_end (aq);
> -    }
> -
> -  if (alt_dump_file && (dump_kind & alt_flags))
> -    {
> -      dump_loc (dump_kind, alt_dump_file, srcloc);
> -      va_list aq;
> -      va_copy (aq, ap);
> -      vfprintf (alt_dump_file, format, aq);
> -      va_end (aq);
> -    }
> -
> -  if (optinfo_enabled_p ())
> -    {
> -      optinfo &info = begin_next_optinfo (loc);
> -      info.handle_dump_file_kind (dump_kind);
> -      va_list aq;
> -      va_copy (aq, ap);
> -      info.add_printf_va (format, aq);
> -      va_end (aq);
> -    }
> +  dump_loc (dump_kind, loc);
> +  dump_printf_va (dump_kind, format, ap);
>  }
>
>  /* Output VALUE in decimal to appropriate dump streams.  */
> @@ -767,13 +710,13 @@ dump_context::begin_scope (const char *name, const dump_location_t &loc)
>
>    if (dump_file)
>      {
> -      dump_loc (MSG_NOTE, dump_file, loc.get_location_t ());
> +      ::dump_loc (MSG_NOTE, dump_file, loc.get_location_t ());
>        fprintf (dump_file, "=== %s ===\n", name);
>      }
>
>    if (alt_dump_file)
>      {
> -      dump_loc (MSG_NOTE, alt_dump_file, loc.get_location_t ());
> +      ::dump_loc (MSG_NOTE, alt_dump_file, loc.get_location_t ());
>        fprintf (alt_dump_file, "=== %s ===\n", name);
>      }
>
> --
> 1.8.5.3
>

  reply	other threads:[~2018-07-31 12:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 21:47 [PATCH 0/5] dump_printf support for middle-end types David Malcolm
2018-07-27 21:47 ` [PATCH 2/5] dumpfile.c: eliminate special-casing of dump_file/alt_dump_file David Malcolm
2018-07-31 12:54   ` Richard Biener
2018-07-31 15:34     ` David Malcolm
2018-07-31 15:37       ` Richard Biener
2018-07-27 21:47 ` [PATCH 4/5] c-family: clean up the data tables in c-format.c David Malcolm
2018-07-31 12:56   ` Richard Biener
2018-07-31 13:08     ` Marek Polacek
2018-07-27 21:47 ` [PATCH 1/5] Simplify dump_context by adding a dump_loc member function David Malcolm
2018-07-31 12:51   ` Richard Biener [this message]
2018-07-27 21:47 ` [PATCH 5/5] Formatted printing for dump_* in the middle-end David Malcolm
2018-07-31 13:03   ` Richard Biener
2018-07-31 14:19     ` David Malcolm
2018-07-31 14:21       ` Richard Biener
2018-07-31 14:33         ` Richard Biener
2018-07-31 19:56       ` Joseph Myers
2018-08-02 17:09         ` [PATCH] v2: " David Malcolm
2018-08-09 22:11           ` Joseph Myers
2018-08-17  4:08           ` Jeff Law
2018-08-17 18:24             ` David Malcolm
2018-08-27  6:58           ` Jakub Jelinek
2018-08-27 23:46             ` [PATCH] Fix version check for ATTRIBUTE_GCC_DUMP_PRINTF David Malcolm
2018-08-28  6:44               ` Jakub Jelinek
2018-08-28 12:26                 ` Jakub Jelinek
2018-08-28 14:19                   ` David Malcolm
2018-07-27 21:47 ` [PATCH 3/5] C++: clean up cp_printer David Malcolm
2018-07-28 14:06   ` Jason Merrill
2018-07-31 12:50 ` [PATCH 0/5] dump_printf support for middle-end types Richard Biener
2018-07-31 14:01   ` David Malcolm

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='CAFiYyc0DXOjipyRs93+fA2SjsobNaaq_R5=M9ULACLR2h5JF8Q@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@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).