public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Frederik Harwath <frederik@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] Add function for printing a single OMP_CLAUSE
Date: Wed, 17 Nov 2021 08:18:15 +0000 (GMT)	[thread overview]
Message-ID: <20211117081815.96D7C385AC30@sourceware.org> (raw)

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

commit d53d3fd9435bbe0e51357b0645820b787c06f53d
Author: Frederik Harwath <frederik@codesourcery.com>
Date:   Tue Nov 16 16:18:02 2021 +0100

    Add function for printing a single OMP_CLAUSE
    
    Commit 89f4f339130c ("For 'OMP_CLAUSE' in 'dump_generic_node', dump
    the whole OMP clause chain") changed the dumping behavior for
    OMP_CLAUSEs.  The old behavior is required for a follow-up
    commit ("openacc: Add data optimization pass") that optimizes single
    OMP_CLAUSEs.
    
    gcc/ChangeLog:
    
            * tree-pretty-print.c (print_omp_clause_to_str): Add new function.
            * tree-pretty-print.h (print_omp_clause_to_str): Add declaration.

Diff:
---
 gcc/tree-pretty-print.c | 11 +++++++++++
 gcc/tree-pretty-print.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index d769cd8f07c..2e0255176c7 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1402,6 +1402,17 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
     }
 }
 
+/* Print the single clause at the top of the clause chain C to a string and
+   return it. Note that print_generic_expr_to_str prints the whole clause chain
+   instead. The caller must free the returned memory. */
+
+char *
+print_omp_clause_to_str (tree c)
+{
+  pretty_printer pp;
+  dump_omp_clause (&pp, c, 0, TDF_VOPS|TDF_MEMSYMS);
+  return xstrdup (pp_formatted_text (&pp));
+}
 
 /* Dump chain of OMP clauses.
 
diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h
index cafe9aa9598..3368cb9f154 100644
--- a/gcc/tree-pretty-print.h
+++ b/gcc/tree-pretty-print.h
@@ -41,6 +41,7 @@ extern void print_generic_expr (FILE *, tree, dump_flags_t = TDF_NONE);
 extern char *print_generic_expr_to_str (tree);
 extern void dump_omp_clauses (pretty_printer *, tree, int, dump_flags_t,
 			      bool = true);
+extern char *print_omp_clause_to_str (tree);
 extern void dump_omp_atomic_memory_order (pretty_printer *,
 					  enum omp_memory_order);
 extern void dump_omp_loop_non_rect_expr (pretty_printer *, tree, int,


                 reply	other threads:[~2021-11-17  8:18 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=20211117081815.96D7C385AC30@sourceware.org \
    --to=frederik@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).