aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/dump-parse-tree.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2014-05-11 22:26:36 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2014-05-11 22:26:36 +0200
commitdd2fc5256e440377a3883a793af98b95f6ace957 (patch)
treec4f127aea63536dd03600145240bfabcf8433393 /gcc/fortran/dump-parse-tree.c
parent7588d8aae498ba0a9643858555ac44e97877d5cf (diff)
downloadgcc-dd2fc5256e440377a3883a793af98b95f6ace957.zip
gcc-dd2fc5256e440377a3883a793af98b95f6ace957.tar.gz
gcc-dd2fc5256e440377a3883a793af98b95f6ace957.tar.bz2
tree.h (OMP_CLAUSE_LINEAR_STMT): Define.
* tree.h (OMP_CLAUSE_LINEAR_STMT): Define. * tree.c (omp_clause_num_ops): Increase OMP_CLAUSE_LINEAR number of operands to 3. (walk_tree_1): Walk all operands of OMP_CLAUSE_LINEAR. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Handle OMP_CLAUSE_DEPEND. * gimplify.c (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_LINEAR_STMT. * omp-low.c (lower_rec_input_clauses): Fix typo. (maybe_add_implicit_barrier_cancel, lower_omp_1): Add cast between Fortran boolean_type_node and C _Bool if needed. gcc/fortran/ * gfortran.h (gfc_statement): Add ST_OMP_CANCEL, ST_OMP_CANCELLATION_POINT, ST_OMP_TASKGROUP, ST_OMP_END_TASKGROUP, ST_OMP_SIMD, ST_OMP_END_SIMD, ST_OMP_DO_SIMD, ST_OMP_END_DO_SIMD, ST_OMP_PARALLEL_DO_SIMD, ST_OMP_END_PARALLEL_DO_SIMD and ST_OMP_DECLARE_SIMD. (gfc_omp_namelist): New typedef. (gfc_get_omp_namelist): Define. (OMP_LIST_UNIFORM, OMP_LIST_ALIGNED, OMP_LIST_LINEAR, OMP_LIST_DEPEND_IN, OMP_LIST_DEPEND_OUT): New clause list kinds. (gfc_omp_proc_bind_kind, gfc_omp_cancel_kind): New enums. (gfc_omp_clauses): Change type of lists to gfc_omp_namelist *. Add inbranch, notinbranch, cancel, proc_bind, safelen_expr and simdlen_expr fields. (gfc_omp_declare_simd): New typedef. (gfc_get_omp_declare_simd): Define. (gfc_namespace): Add omp_declare_simd field. (gfc_exec_op): Add EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_TASKGROUP, EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD and EXEC_OMP_PARALLEL_DO_SIMD. (gfc_omp_atomic_op): Add GFC_OMP_ATOMIC_MASK, GFC_OMP_ATOMIC_SEQ_CST and GFC_OMP_ATOMIC_SWAP. (gfc_code): Change type of omp_namelist field to gfc_omp_namelist *. (gfc_free_omp_namelist, gfc_free_omp_declare_simd, gfc_free_omp_declare_simd_list, gfc_resolve_omp_declare_simd): New prototypes. * trans-stmt.h (gfc_trans_omp_declare_simd): New prototype. * symbol.c (gfc_free_namespace): Call gfc_free_omp_declare_simd. * openmp.c (gfc_free_omp_clauses): Free safelen_expr and simdlen_expr. Use gfc_free_omp_namelist instead of gfc_free_namelist. (gfc_free_omp_declare_simd, gfc_free_omp_declare_simd_list): New functions. (gfc_match_omp_variable_list): Add end_colon, headp and allow_sections arguments. Handle parsing of array sections. Use *omp_namelist* instead of *namelist* data structure and functions/macros. Allow termination at : character. (OMP_CLAUSE_ALIGNED, OMP_CLAUSE_DEPEND, OMP_CLAUSE_INBRANCH, OMP_CLAUSE_LINEAR, OMP_CLAUSE_NOTINBRANCH, OMP_CLAUSE_PROC_BIND, OMP_CLAUSE_SAFELEN, OMP_CLAUSE_SIMDLEN, OMP_CLAUSE_UNIFORM): Define. (gfc_match_omp_clauses): Change first and needs_space variables into arguments with default values. Parse inbranch, notinbranch, proc_bind, safelen, simdlen, uniform, linear, aligned and depend clauses. (OMP_PARALLEL_CLAUSES): Add OMP_CLAUSE_PROC_BIND. (OMP_DECLARE_SIMD_CLAUSES, OMP_SIMD_CLAUSES): Define. (OMP_TASK_CLAUSES): Add OMP_CLAUSE_DEPEND. (gfc_match_omp_do_simd): New function. (gfc_match_omp_flush): Use *omp_namelist* instead of *namelist* data structure and functions/macros. (gfc_match_omp_simd, gfc_match_omp_declare_simd, gfc_match_omp_parallel_do_simd): New functions. (gfc_match_omp_atomic): Handle seq_cst clause. Handle atomic swap. (gfc_match_omp_taskgroup, gfc_match_omp_cancel_kind, gfc_match_omp_cancel, gfc_match_omp_cancellation_point): New functions. (resolve_omp_clauses): Add where, omp_clauses and ns arguments. Use *omp_namelist* instead of *namelist* data structure and functions/macros. Resolve uniform, aligned, linear, depend, safelen and simdlen clauses. (resolve_omp_atomic): Adjust for GFC_OMP_ATOMIC_{MASK,SEQ_CST,SWAP} addition, recognize atomic swap. (gfc_resolve_omp_parallel_blocks): Use gfc_omp_namelist instead of gfc_namelist. Handle EXEC_OMP_PARALLEL_DO_SIMD the same as EXEC_OMP_PARALLEL_DO. (gfc_resolve_do_iterator): Use *omp_namelist* instead of *namelist* data structure and functions/macros. (resolve_omp_do): Likewise. Handle EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD. (gfc_resolve_omp_directive): Handle EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD and EXEC_OMP_CANCEL. Adjust resolve_omp_clauses caller. (gfc_resolve_omp_declare_simd): New function. * parse.c (decode_omp_directive): Parse cancellation point, cancel, declare simd, end do simd, end simd, end parallel do simd, end taskgroup, parallel do simd, simd and taskgroup directives. (case_executable): Add ST_OMP_CANCEL and ST_OMP_CANCELLATION_POINT. (case_exec_markers): Add ST_OMP_TASKGROUP, case ST_OMP_SIMD, ST_OMP_DO_SIMD and ST_OMP_PARALLEL_DO_SIMD. (case_decl): Add ST_OMP_DECLARE_SIMD. (gfc_ascii_statement): Handle ST_OMP_CANCEL, ST_OMP_CANCELLATION_POINT, ST_OMP_TASKGROUP, ST_OMP_END_TASKGROUP, ST_OMP_SIMD, ST_OMP_END_SIMD, ST_OMP_DO_SIMD, ST_OMP_END_DO_SIMD, ST_OMP_PARALLEL_DO_SIMD, ST_OMP_END_PARALLEL_DO_SIMD and ST_OMP_DECLARE_SIMD. (parse_omp_do): Handle ST_OMP_SIMD, ST_OMP_DO_SIMD and ST_OMP_PARALLEL_DO_SIMD. (parse_omp_atomic): Adjust for GFC_OMP_ATOMIC_* additions. (parse_omp_structured_block): Handle ST_OMP_TASKGROUP and ST_OMP_PARALLEL_DO_SIMD. (parse_executable): Handle ST_OMP_SIMD, ST_OMP_DO_SIMD, ST_OMP_PARALLEL_DO_SIMD and ST_OMP_TASKGROUP. * trans-decl.c (gfc_get_extern_function_decl, gfc_create_function_decl): Call gfc_trans_omp_declare_simd if needed. * frontend-passes.c (gfc_code_walker): Handle EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD and EXEC_OMP_PARALLEL_DO_SIMD. Walk safelen_expr and simdlen_expr. Walk expressions in gfc_omp_namelist of depend, aligned and linear clauses. * match.c (match_exit_cycle): Handle EXEC_OMP_SIMD, EXEC_OMP_DO_SIMD and EXEC_OMP_PARALLEL_DO_SIMD. (gfc_free_omp_namelist): New function. * dump-parse-tree.c (show_namelist): Removed. (show_omp_namelist): New function. (show_omp_node): Handle OpenMP 4.0 additions. (show_code_node): Handle EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. * match.h (gfc_match_omp_cancel, gfc_match_omp_cancellation_point, gfc_match_omp_declare_simd, gfc_match_omp_do_simd, gfc_match_omp_parallel_do_simd, gfc_match_omp_simd, gfc_match_omp_taskgroup): New prototypes. * trans-openmp.c (gfc_trans_omp_variable): Add declare_simd argument, handle it. Allow current_function_decl to be NULL. (gfc_trans_omp_variable_list): Add declare_simd argument, pass it through to gfc_trans_omp_variable and disregard whether sym is referenced if declare_simd is true. Work on gfc_omp_namelist instead of gfc_namelist. (gfc_trans_omp_reduction_list): Work on gfc_omp_namelist instead of gfc_namelist. Adjust gfc_trans_omp_variable caller. (gfc_trans_omp_clauses): Add declare_simd argument, pass it through to gfc_trans_omp_variable{,_list} callers. Work on gfc_omp_namelist instead of gfc_namelist. Handle inbranch, notinbranch, safelen, simdlen, depend, uniform, linear, proc_bind and aligned clauses. Handle cancel kind. (gfc_trans_omp_atomic): Handle seq_cst clause, handle atomic swap, adjust for GFC_OMP_ATOMIC_* changes. (gfc_trans_omp_cancel, gfc_trans_omp_cancellation_point): New functions. (gfc_trans_omp_do): Add op argument, handle simd translation into generic. (GFC_OMP_SPLIT_SIMD, GFC_OMP_SPLIT_DO, GFC_OMP_SPLIT_PARALLEL, GFC_OMP_SPLIT_NUM, GFC_OMP_MASK_SIMD, GFC_OMP_MASK_DO, GFC_OMP_MASK_PARALLEL): New. (gfc_split_omp_clauses, gfc_trans_omp_do_simd): New functions. (gfc_trans_omp_parallel_do): Rework to use gfc_split_omp_clauses. (gfc_trans_omp_parallel_do_simd, gfc_trans_omp_taskgroup): New functions. (gfc_trans_omp_directive): Handle EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. Adjust gfc_trans_omp_do caller. (gfc_trans_omp_declare_simd): New function. * st.c (gfc_free_statement): Handle EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. For EXEC_OMP_FLUSH call gfc_free_omp_namelist instead of gfc_free_namelist. * module.c (omp_declare_simd_clauses): New variable. (mio_omp_declare_simd): New function. (mio_symbol): Call it. * trans.c (trans_code): Handle EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. * resolve.c (gfc_resolve_blocks): Handle EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. (resolve_code): Handle EXEC_OMP_CANCEL, EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD, EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP. (resolve_types): Call gfc_resolve_omp_declare_simd. gcc/testsuite/ * gfortran.dg/gomp/affinity-1.f90: New test. libgomp/ * testsuite/libgomp.fortran/cancel-do-1.f90: New test. * testsuite/libgomp.fortran/cancel-do-2.f90: New test. * testsuite/libgomp.fortran/cancel-parallel-1.f90: New test. * testsuite/libgomp.fortran/cancel-parallel-3.f90: New test. * testsuite/libgomp.fortran/cancel-sections-1.f90: New test. * testsuite/libgomp.fortran/cancel-taskgroup-2.f90: New test. * testsuite/libgomp.fortran/declare-simd-1.f90: New test. * testsuite/libgomp.fortran/declare-simd-2.f90: New test. * testsuite/libgomp.fortran/declare-simd-3.f90: New test. * testsuite/libgomp.fortran/depend-1.f90: New test. * testsuite/libgomp.fortran/depend-2.f90: New test. * testsuite/libgomp.fortran/omp_atomic5.f90: New test. * testsuite/libgomp.fortran/simd1.f90: New test. * testsuite/libgomp.fortran/simd2.f90: New test. * testsuite/libgomp.fortran/simd3.f90: New test. * testsuite/libgomp.fortran/simd4.f90: New test. * testsuite/libgomp.fortran/taskgroup1.f90: New test. From-SVN: r210313
Diffstat (limited to 'gcc/fortran/dump-parse-tree.c')
-rw-r--r--gcc/fortran/dump-parse-tree.c100
1 files changed, 91 insertions, 9 deletions
diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index b1343bc..b5d2537 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -1016,11 +1016,19 @@ show_code (int level, gfc_code *c)
}
static void
-show_namelist (gfc_namelist *n)
+show_omp_namelist (gfc_omp_namelist *n)
{
- for (; n->next; n = n->next)
- fprintf (dumpfile, "%s,", n->sym->name);
- fprintf (dumpfile, "%s", n->sym->name);
+ for (; n; n = n->next)
+ {
+ fprintf (dumpfile, "%s", n->sym->name);
+ if (n->expr)
+ {
+ fputc (':', dumpfile);
+ show_expr (n->expr);
+ }
+ if (n->next)
+ fputc (',', dumpfile);
+ }
}
/* Show a single OpenMP directive node and everything underneath it
@@ -1036,18 +1044,24 @@ show_omp_node (int level, gfc_code *c)
{
case EXEC_OMP_ATOMIC: name = "ATOMIC"; break;
case EXEC_OMP_BARRIER: name = "BARRIER"; break;
+ case EXEC_OMP_CANCEL: name = "CANCEL"; break;
+ case EXEC_OMP_CANCELLATION_POINT: name = "CANCELLATION POINT"; break;
case EXEC_OMP_CRITICAL: name = "CRITICAL"; break;
case EXEC_OMP_FLUSH: name = "FLUSH"; break;
case EXEC_OMP_DO: name = "DO"; break;
+ case EXEC_OMP_DO_SIMD: name = "DO SIMD"; break;
case EXEC_OMP_MASTER: name = "MASTER"; break;
case EXEC_OMP_ORDERED: name = "ORDERED"; break;
case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break;
+ case EXEC_OMP_PARALLEL_DO_SIMD: name = "PARALLEL DO SIMD"; break;
case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break;
case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break;
case EXEC_OMP_SECTIONS: name = "SECTIONS"; break;
+ case EXEC_OMP_SIMD: name = "SIMD"; break;
case EXEC_OMP_SINGLE: name = "SINGLE"; break;
case EXEC_OMP_TASK: name = "TASK"; break;
+ case EXEC_OMP_TASKGROUP: name = "TASKGROUP"; break;
case EXEC_OMP_TASKWAIT: name = "TASKWAIT"; break;
case EXEC_OMP_TASKYIELD: name = "TASKYIELD"; break;
case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break;
@@ -1057,11 +1071,16 @@ show_omp_node (int level, gfc_code *c)
fprintf (dumpfile, "!$OMP %s", name);
switch (c->op)
{
+ case EXEC_OMP_CANCEL:
+ case EXEC_OMP_CANCELLATION_POINT:
case EXEC_OMP_DO:
+ case EXEC_OMP_DO_SIMD:
case EXEC_OMP_PARALLEL:
case EXEC_OMP_PARALLEL_DO:
+ case EXEC_OMP_PARALLEL_DO_SIMD:
case EXEC_OMP_PARALLEL_SECTIONS:
case EXEC_OMP_SECTIONS:
+ case EXEC_OMP_SIMD:
case EXEC_OMP_SINGLE:
case EXEC_OMP_WORKSHARE:
case EXEC_OMP_PARALLEL_WORKSHARE:
@@ -1076,7 +1095,7 @@ show_omp_node (int level, gfc_code *c)
if (c->ext.omp_namelist)
{
fputs (" (", dumpfile);
- show_namelist (c->ext.omp_namelist);
+ show_omp_namelist (c->ext.omp_namelist);
fputc (')', dumpfile);
}
return;
@@ -1091,6 +1110,23 @@ show_omp_node (int level, gfc_code *c)
{
int list_type;
+ switch (omp_clauses->cancel)
+ {
+ case OMP_CANCEL_UNKNOWN:
+ break;
+ case OMP_CANCEL_PARALLEL:
+ fputs (" PARALLEL", dumpfile);
+ break;
+ case OMP_CANCEL_SECTIONS:
+ fputs (" SECTIONS", dumpfile);
+ break;
+ case OMP_CANCEL_DO:
+ fputs (" DO", dumpfile);
+ break;
+ case OMP_CANCEL_TASKGROUP:
+ fputs (" TASKGROUP", dumpfile);
+ break;
+ }
if (omp_clauses->if_expr)
{
fputs (" IF(", dumpfile);
@@ -1156,7 +1192,7 @@ show_omp_node (int level, gfc_code *c)
if (omp_clauses->lists[list_type] != NULL
&& list_type != OMP_LIST_COPYPRIVATE)
{
- const char *type;
+ const char *type = NULL;
if (list_type >= OMP_LIST_REDUCTION_FIRST)
{
switch (list_type)
@@ -1187,14 +1223,53 @@ show_omp_node (int level, gfc_code *c)
case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
case OMP_LIST_SHARED: type = "SHARED"; break;
case OMP_LIST_COPYIN: type = "COPYIN"; break;
+ case OMP_LIST_UNIFORM: type = "UNIFORM"; break;
+ case OMP_LIST_ALIGNED: type = "ALIGNED"; break;
+ case OMP_LIST_LINEAR: type = "LINEAR"; break;
+ case OMP_LIST_DEPEND_IN:
+ fprintf (dumpfile, " DEPEND(IN:");
+ break;
+ case OMP_LIST_DEPEND_OUT:
+ fprintf (dumpfile, " DEPEND(OUT:");
+ break;
default:
gcc_unreachable ();
}
- fprintf (dumpfile, " %s(", type);
+ if (type)
+ fprintf (dumpfile, " %s(", type);
}
- show_namelist (omp_clauses->lists[list_type]);
+ show_omp_namelist (omp_clauses->lists[list_type]);
fputc (')', dumpfile);
}
+ if (omp_clauses->safelen_expr)
+ {
+ fputs (" SAFELEN(", dumpfile);
+ show_expr (omp_clauses->safelen_expr);
+ fputc (')', dumpfile);
+ }
+ if (omp_clauses->simdlen_expr)
+ {
+ fputs (" SIMDLEN(", dumpfile);
+ show_expr (omp_clauses->simdlen_expr);
+ fputc (')', dumpfile);
+ }
+ if (omp_clauses->inbranch)
+ fputs (" INBRANCH", dumpfile);
+ if (omp_clauses->notinbranch)
+ fputs (" NOTINBRANCH", dumpfile);
+ if (omp_clauses->proc_bind != OMP_PROC_BIND_UNKNOWN)
+ {
+ const char *type;
+ switch (omp_clauses->proc_bind)
+ {
+ case OMP_PROC_BIND_MASTER: type = "MASTER"; break;
+ case OMP_PROC_BIND_SPREAD: type = "SPREAD"; break;
+ case OMP_PROC_BIND_CLOSE: type = "CLOSE"; break;
+ default:
+ gcc_unreachable ();
+ }
+ fprintf (dumpfile, " PROC_BIND(%s)", type);
+ }
}
fputc ('\n', dumpfile);
if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
@@ -1214,6 +1289,7 @@ show_omp_node (int level, gfc_code *c)
show_code (level + 1, c->block->next);
if (c->op == EXEC_OMP_ATOMIC)
return;
+ fputc ('\n', dumpfile);
code_indent (level, 0);
fprintf (dumpfile, "!$OMP END %s", name);
if (omp_clauses != NULL)
@@ -1221,7 +1297,7 @@ show_omp_node (int level, gfc_code *c)
if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
{
fputs (" COPYPRIVATE(", dumpfile);
- show_namelist (omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
+ show_omp_namelist (omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
fputc (')', dumpfile);
}
else if (omp_clauses->nowait)
@@ -2195,19 +2271,25 @@ show_code_node (int level, gfc_code *c)
break;
case EXEC_OMP_ATOMIC:
+ case EXEC_OMP_CANCEL:
+ case EXEC_OMP_CANCELLATION_POINT:
case EXEC_OMP_BARRIER:
case EXEC_OMP_CRITICAL:
case EXEC_OMP_FLUSH:
case EXEC_OMP_DO:
+ case EXEC_OMP_DO_SIMD:
case EXEC_OMP_MASTER:
case EXEC_OMP_ORDERED:
case EXEC_OMP_PARALLEL:
case EXEC_OMP_PARALLEL_DO:
+ case EXEC_OMP_PARALLEL_DO_SIMD:
case EXEC_OMP_PARALLEL_SECTIONS:
case EXEC_OMP_PARALLEL_WORKSHARE:
case EXEC_OMP_SECTIONS:
+ case EXEC_OMP_SIMD:
case EXEC_OMP_SINGLE:
case EXEC_OMP_TASK:
+ case EXEC_OMP_TASKGROUP:
case EXEC_OMP_TASKWAIT:
case EXEC_OMP_TASKYIELD:
case EXEC_OMP_WORKSHARE: