From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1729) id A4969384D1A2; Wed, 29 Jun 2022 14:42:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4969384D1A2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Kwok Yeung To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] Add function for printing a single OMP_CLAUSE X-Act-Checkin: gcc X-Git-Author: Frederik Harwath X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 22e26296ce66bf33b512adb5d9c0f1da621037c0 X-Git-Newrev: cbc7e47d439f024ed828cc31441218f1ec5ce235 Message-Id: <20220629144217.A4969384D1A2@sourceware.org> Date: Wed, 29 Jun 2022 14:42:17 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 14:42:17 -0000 https://gcc.gnu.org/g:cbc7e47d439f024ed828cc31441218f1ec5ce235 commit cbc7e47d439f024ed828cc31441218f1ec5ce235 Author: Frederik Harwath 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.cc (print_omp_clause_to_str): Add new function. * tree-pretty-print.h (print_omp_clause_to_str): Add declaration. Diff: --- gcc/ChangeLog.omp | 5 +++++ gcc/tree-pretty-print.cc | 11 +++++++++++ gcc/tree-pretty-print.h | 1 + 3 files changed, 17 insertions(+) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index ec7d5e2c1cf..04fd26f4129 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,8 @@ +2021-11-16 Frederik Harwath + + * tree-pretty-print.cc (print_omp_clause_to_str): Add new function. + * tree-pretty-print.h (print_omp_clause_to_str): Add declaration. + 2021-11-16 Frederik Harwath * omp-offload.cc (oacc_remove_unused_partitioning): New function diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index d913f48e82d..9e85b53493e 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -1420,6 +1420,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 7347878b95a..27d202e27fc 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,