]> 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)
committerFrederik Harwath <frederik@codesourcery.com>
Wed, 17 Nov 2021 07:50:54 +0000 (08:50 +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.c (print_omp_clause_to_str): Add new function.
        * tree-pretty-print.h (print_omp_clause_to_str): Add declaration.

gcc/tree-pretty-print.c
gcc/tree-pretty-print.h

index d769cd8f07c5f0da1b23ff84019a39ffc0673e0c..2e0255176c766554ef5a5c9d500bbba4b8ab1532 100644 (file)
@@ -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.
 
index cafe9aa95989c1761265c285f322b3388090c3de..3368cb9f1544b81f6b0d2679d32a86b383009a70 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,