aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-decl.cc')
-rw-r--r--gcc/c/c-decl.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index c701f07..bc407f9 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -10232,6 +10232,29 @@ temp_pop_parm_decls (void)
pop_scope ();
}
+/* Function passed to c_oacc_annotate_loop_in_kernels_regions to do
+ language-specific unwrapping of an initializer expression. */
+static tree
+c_unwrap_for_init (tree x)
+{
+ if (!x)
+ return NULL_TREE;
+
+ while (true)
+ switch (TREE_CODE (x))
+ {
+ case MODIFY_EXPR:
+ case VAR_DECL:
+ return x;
+
+ case DECL_EXPR:
+ x = TREE_OPERAND (x, 0);
+ break;
+
+ default:
+ return NULL_TREE;
+ }
+}
/* Finish up a function declaration and compile that function
all the way to assembler language output. Then free the storage
@@ -10334,6 +10357,11 @@ finish_function (location_t end_loc)
if (warn_unused_parameter)
do_warn_unused_parameter (fndecl);
+ /* If requested, automatically annotate suitable loops in OpenACC kernels
+ regions with OpenACC loop annotations to allow auto-parallelization. */
+ if (flag_openacc && flag_openacc_kernels_annotate_loops)
+ c_oacc_annotate_loops_in_kernels_regions (fndecl, c_unwrap_for_init);
+
/* Store the end of the function, so that we get good line number
info for the epilogue. */
cfun->function_end_locus = end_loc;