]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add function for printing a single OMP_CLAUSE
authorFrederik Harwath <frederik@codesourcery.com>
Tue, 16 Nov 2021 15:18:02 +0000 (16:18 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:50 +0000 (14:11 +0100)
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.

gcc/ChangeLog.omp
gcc/tree-pretty-print.cc
gcc/tree-pretty-print.h

index ec7d5e2c1cfa397a013a02cd243fada8de942fe7..04fd26f4129500a8b982b9f871a3b47f30763a6c 100644 (file)
@@ -1,3 +1,8 @@
+2021-11-16  Frederik Harwath <frederik@codesourcery.com>
+
+       * 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 <frederik@codesourcery.com>
 
        * omp-offload.cc (oacc_remove_unused_partitioning): New function
index d913f48e82d65834eb399e1650093d1501b47027..9e85b53493ed121199ac38cf8990e50cc8909bd9 100644 (file)
@@ -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.
 
index 7347878b95ad06f4dfd9ffcf3ddb9d82d8c647c3..27d202e27fc0623e19f2f4ef23d588500e6e74e3 100644 (file)
@@ -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,