summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-stmt.c
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-10 17:58:01 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-10 17:58:01 +0000
commit71cf3ae65aaccc07caf3f89476930174705d9e3d (patch)
tree3b81e10f4b9ef07bf487371bb8be9be05d418397 /gcc/fortran/trans-stmt.c
parent993a9cacbaacc6a2c72d8b21808e76fbdad2fb2e (diff)
downloadgcc-71cf3ae65aaccc07caf3f89476930174705d9e3d.tar.gz
2015-03-10 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Tobias Burnus <burnus@net-b.de> * trans.h (caf_sync_memory): New function decl tree. * trans-decl.c (gfc_build_builtin_function_decls): Define it. (create_main_function): Don't call sync_synchronize and leave it to the CAF library. * trans-stmt.c (gfc_trans_stop): Ditto. (gfc_trans_sync): Ditto; add call library call for sync memory. * gfortran.dg/coarray_sync_memory.f90: New. * caf/libcaf.h (_gfortran_caf_sync_memory): New prototype. * caf/single.c (_gfortran_caf_sync_memory): Implement. (_gfortran_caf_sync_all, _gfortran_caf_sync_image): Add __asm__ __volatile___ ("":::"memory"). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221329 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-stmt.c')
-rw-r--r--gcc/fortran/trans-stmt.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 505f9052cf6..6450a0ecec2 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -639,17 +639,6 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
gfc_init_se (&se, NULL);
gfc_start_block (&se.pre);
- if (flag_coarray == GFC_FCOARRAY_LIB && !error_stop)
- {
- /* Per F2008, 8.5.1 STOP implies a SYNC MEMORY. */
- tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE);
- tmp = build_call_expr_loc (input_location, tmp, 0);
- gfc_add_expr_to_block (&se.pre, tmp);
-
- tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_finalize, 0);
- gfc_add_expr_to_block (&se.pre, tmp);
- }
-
if (code->expr1 == NULL)
{
tmp = build_int_cst (gfc_int4_type_node, 0);
@@ -768,8 +757,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
else
stat = null_pointer_node;
- if (code->expr3 && flag_coarray == GFC_FCOARRAY_LIB
- && type != EXEC_SYNC_MEMORY)
+ if (code->expr3 && flag_coarray == GFC_FCOARRAY_LIB)
{
gcc_assert (code->expr3->expr_type == EXPR_VARIABLE);
gfc_init_se (&argse, NULL);
@@ -778,7 +766,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
errmsg = gfc_build_addr_expr (NULL, argse.expr);
errmsglen = argse.string_length;
}
- else if (flag_coarray == GFC_FCOARRAY_LIB && type != EXEC_SYNC_MEMORY)
+ else if (flag_coarray == GFC_FCOARRAY_LIB)
{
errmsg = null_pointer_node;
errmsglen = build_int_cst (integer_type_node, 0);
@@ -813,22 +801,13 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
fold_convert (integer_type_node, images));
}
- /* Per F2008, 8.5.1, a SYNC MEMORY is implied by calling the
- image control statements SYNC IMAGES and SYNC ALL. */
- if (flag_coarray == GFC_FCOARRAY_LIB)
- {
- tmp = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE);
- tmp = build_call_expr_loc (input_location, tmp, 0);
- gfc_add_expr_to_block (&se.pre, tmp);
- }
-
- if (flag_coarray != GFC_FCOARRAY_LIB || type == EXEC_SYNC_MEMORY)
+ if (flag_coarray != GFC_FCOARRAY_LIB)
{
/* Set STAT to zero. */
if (code->expr2)
gfc_add_modify (&se.pre, stat, build_int_cst (TREE_TYPE (stat), 0));
}
- else if (type == EXEC_SYNC_ALL)
+ else if (type == EXEC_SYNC_ALL || type == EXEC_SYNC_MEMORY)
{
/* SYNC ALL => stat == null_pointer_node
SYNC ALL(stat=s) => stat has an integer type
@@ -840,8 +819,13 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
if (TREE_TYPE (stat) == integer_type_node)
stat = gfc_build_addr_expr (NULL, stat);
- tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all,
- 3, stat, errmsg, errmsglen);
+ if(type == EXEC_SYNC_MEMORY)
+ tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_memory,
+ 3, stat, errmsg, errmsglen);
+ else
+ tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all,
+ 3, stat, errmsg, errmsglen);
+
gfc_add_expr_to_block (&se.pre, tmp);
}
else