aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2014-06-17 22:54:14 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2014-06-17 22:54:14 +0200
commitb511626828a636ed6310cd94c4fa78365450fb34 (patch)
tree96324659ad7bf83699d956687f06a317bffeb7e3 /gcc/fortran/resolve.c
parentdc3368d0f58b7385875a916689a1193e5716a14e (diff)
downloadgcc-b511626828a636ed6310cd94c4fa78365450fb34.zip
gcc-b511626828a636ed6310cd94c4fa78365450fb34.tar.gz
gcc-b511626828a636ed6310cd94c4fa78365450fb34.tar.bz2
check.c (gfc_check_atomic, [...]): Use argument for GFC_ISYM_CAF_GET.
gcc/fortran/ 2014-06-17 Tobias Burnus <burnus@net-b.de> * check.c (gfc_check_atomic, gfc_check_atomic_def): Use argument for GFC_ISYM_CAF_GET. * resolve.c (resolve_variable): Enable CAF_GET insertion. (resolve_lock_unlock): Remove GFC_ISYM_CAF_GET. (resolve_ordinary_assign): Enable CAF_SEND insertion. * trans-const.c (gfc_build_string_const, gfc_build_wide_string_const): Set TYPE_STRING_FLAG. * trans-decl.c (gfor_fndecl_caf_get, gfor_fndecl_caf_send, gfor_fndecl_caf_sendget): New global variables. (gfc_build_builtin_function_decls): Initialize them; update co_min/max/sum initialization. * trans-expr.c (gfc_get_tree_for_caf_expr): Renamed from get_tree_for_caf_expr and removed static. (gfc_conv_procedure_call): Update call. * trans-intrinsic.c (caf_get_image_index, conv_caf_vector_subscript_elem, conv_caf_vector_subscript, get_caf_token_offset, gfc_conv_intrinsic_caf_get, conv_caf_send): New. (gfc_conv_intrinsic_function, gfc_conv_intrinsic_subroutine, gfc_walk_intrinsic_function): Handle CAF_GET and CAF_SEND. (conv_co_minmaxsum): Update call for remove unused vector subscript. (conv_intrinsic_atomic_def, conv_intrinsic_atomic_ref): Skip a CAF_GET of the argument. * trans-types.c (gfc_get_caf_vector_type): New. * trans-types.h (gfc_get_caf_vector_type): New. * trans.h (gfor_fndecl_caf_get, gfor_fndecl_caf_send, gfor_fndecl_caf_sendget): New global variables. (gfc_get_tree_for_caf_expr): New prototypes. libgfortran/ 2014-06-17 Tobias Burnus <burnus@net-b.de> * caf/libcaf.h (gfc_descriptor_t): New typedef. (caf_vector_t): Update. (_gfortran_caf_co_sum, _gfortran_caf_co_max, _gfortran_caf_co_min): Remove vector-subscript argument. (_gfortran_caf_co_send, _gfortran_caf_co_get, _gfortran_caf_co_sendget): New. * caf/single.c (_gfortran_caf_co_sum, _gfortran_caf_co_max, _gfortran_caf_co_min): Remove vector-subscript argument. (_gfortran_caf_co_send, _gfortran_caf_co_get, _gfortran_caf_co_sendget): New. gcc/testsuite/ 2014-06-17 Tobias Burnus <burnus@net-b.de> Alessandro Fanfarillo <alessandro.fanfarillo@gmail.com> * gfortran.dg/coarray/send_array.f90: New. * gfortran.dg/coarray/get_array.f90: New. * gfortran.dg/coarray/sendget_array.f90: New. * gfortran.dg/coarray/collectives_1.f90: Correct subroutine names. * gfortran.dg/coarray/collectives_2.f90: New. Co-Authored-By: Alessandro Fanfarillo <alessandro.fanfarillo@gmail.com> From-SVN: r211748
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r--gcc/fortran/resolve.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index bc2db7d..7ea7c36 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4766,7 +4766,7 @@ remove_caf_get_intrinsic (gfc_expr *e)
gcc_assert (e->expr_type == EXPR_FUNCTION && e->value.function.isym
&& e->value.function.isym->id == GFC_ISYM_CAF_GET);
gfc_expr *e2 = e->value.function.actual->expr;
- e->value.function.actual->expr =NULL;
+ e->value.function.actual->expr = NULL;
gfc_free_actual_arglist (e->value.function.actual);
gfc_free_shape (&e->shape, e->rank);
*e = *e2;
@@ -5056,7 +5056,7 @@ resolve_procedure:
if (t)
expression_rank (e);
- if (0 && t && gfc_option.coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
+ if (t && gfc_option.coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
add_caf_get_intrinsic (e);
return t;
@@ -8424,6 +8424,11 @@ find_reachable_labels (gfc_code *block)
static void
resolve_lock_unlock (gfc_code *code)
{
+ if (code->expr1->expr_type == EXPR_FUNCTION
+ && code->expr1->value.function.isym
+ && code->expr1->value.function.isym->id == GFC_ISYM_CAF_GET)
+ remove_caf_get_intrinsic (code->expr1);
+
if (code->expr1->ts.type != BT_DERIVED
|| code->expr1->expr_type != EXPR_VARIABLE
|| code->expr1->ts.u.derived->from_intmod != INTMOD_ISO_FORTRAN_ENV
@@ -9276,8 +9281,22 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
gfc_check_assign (lhs, rhs, 1);
- if (0 && lhs_coindexed && gfc_option.coarray == GFC_FCOARRAY_LIB)
- {
+ /* Insert a GFC_ISYM_CAF_SEND intrinsic, when the LHS is a coindexed variable.
+ Additionally, insert this code when the RHS is a CAF as we then use the
+ GFC_ISYM_CAF_SEND intrinsic just to avoid a temporary; but do not do so if
+ the LHS is (re)allocatable or has a vector subscript. */
+ if (gfc_option.coarray == GFC_FCOARRAY_LIB
+ && (lhs_coindexed
+ || (code->expr2->expr_type == EXPR_FUNCTION
+ && code->expr2->value.function.isym
+ && code->expr2->value.function.isym->id == GFC_ISYM_CAF_GET
+ && !gfc_expr_attr (rhs).allocatable
+ && !gfc_has_vector_subscript (rhs))))
+ {
+ if (code->expr2->expr_type == EXPR_FUNCTION
+ && code->expr2->value.function.isym
+ && code->expr2->value.function.isym->id == GFC_ISYM_CAF_GET)
+ remove_caf_get_intrinsic (code->expr2);
code->op = EXEC_CALL;
gfc_get_sym_tree (GFC_PREFIX ("caf_send"), ns, &code->symtree, true);
code->resolved_sym = code->symtree->n.sym;
@@ -9919,6 +9938,8 @@ resolve_code (gfc_code *code, gfc_namespace *ns)
if (!t)
break;
+ /* Remove a GFC_ISYM_CAF_GET inserted for a coindexed variable on
+ the LHS. */
if (code->expr1->expr_type == EXPR_FUNCTION
&& code->expr1->value.function.isym
&& code->expr1->value.function.isym->id == GFC_ISYM_CAF_GET)