+ sum (remaining codimension offsets)
If offset is a pointer, we also need to multiply it by the size. */
static tree
-gfc_native_coarray_add_this_image_offset (tree offset, tree desc,
- gfc_array_ref *ar, int is_pointer,
- int subtract)
+cas_add_this_image_offset (tree offset, tree desc, gfc_array_ref *ar,
+ int is_pointer, int subtract)
{
tree tmp, off;
/* Calculate the actual offset. */
offset, off);
}
+/* Return the array ref of the coarray, NULL otherwise. */
+
+static gfc_ref *
+cas_array_ref (gfc_ref *ref)
+{
+ gcc_assert (flag_coarray = GFC_FCOARRAY_SHARED);
+
+ for (; ref; ref = ref->next)
+ {
+ if (ref->type == REF_ARRAY)
+ {
+ if (ref->u.ar.dimen_type[ref->u.ar.dimen + ref->u.ar.codimen - 1]
+ == DIMEN_THIS_IMAGE
+ && !ref->u.ar.shared_coarray_arg)
+ return ref;
+ else
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
/* Translate expressions for the descriptor and data pointer of a SS. */
/*GCC ARRAYS*/
/* If we have a native coarray with implied this_image (), add the
appropriate offset to the data pointer. */
ref = ss_info->expr->ref;
- if (flag_coarray == GFC_FCOARRAY_SHARED && ref && ref->type == REF_ARRAY
- && ref->u.ar.dimen_type[ref->u.ar.dimen + ref->u.ar.codimen - 1]
- == DIMEN_THIS_IMAGE)
- tmp = gfc_native_coarray_add_this_image_offset (tmp, se.expr, &ref->u.ar, 1, 1);
+ if (flag_coarray == GFC_FCOARRAY_SHARED)
+ {
+ gfc_ref *co_ref = cas_array_ref (ref);
+ if (co_ref)
+ tmp = cas_add_this_image_offset (tmp, se.expr,&co_ref->u.ar, 1, 1);
+ }
/* If this is a variable or address of a variable we use it directly.
Otherwise we must evaluate it now to avoid breaking dependency
analysis by pulling the expressions for elemental array indices
}
if (flag_coarray == GFC_FCOARRAY_SHARED && need_impl_this_image)
- offset = gfc_native_coarray_add_this_image_offset (offset, se->expr, ar, 0, 0);
+ offset = cas_add_this_image_offset (offset, se->expr, ar, 0, 0);
if (!integer_zerop (cst_offset))
offset = fold_build2_loc (input_location, PLUS_EXPR,
}
int
-gfc_native_coarray_get_allocation_type (gfc_symbol * sym)
+gfc_cas_get_allocation_type (gfc_symbol * sym)
{
bool is_lock_type, is_event_type;
is_lock_type = sym->ts.type == BT_DERIVED
}
void
-gfc_allocate_native_coarray (stmtblock_t *b, tree decl, tree size, int corank,
+gfc_allocate_shared_coarray (stmtblock_t *b, tree decl, tree size, int corank,
int alloc_type)
{
gfc_add_expr_to_block (b,
tree elem_size
= size_in_bytes (gfc_get_element_type (TREE_TYPE(se->expr)));
int alloc_type
- = gfc_native_coarray_get_allocation_type (expr->symtree->n.sym);
- gfc_allocate_native_coarray (&elseblock, se->expr, elem_size,
+ = gfc_cas_get_allocation_type (expr->symtree->n.sym);
+ gfc_allocate_shared_coarray (&elseblock, se->expr, elem_size,
ref->u.ar.as->corank, alloc_type);
}
/* The allocatable variant takes the old pointer as first argument. */
}
/* If it's a coarray with implicit this_image, add that to the offset. */
- ref = expr->ref;
- if (flag_coarray == GFC_FCOARRAY_SHARED && ref && ref->type == REF_ARRAY
- && ref->u.ar.dimen_type[ref->u.ar.dimen + ref->u.ar.codimen - 1]
- == DIMEN_THIS_IMAGE
- && !ref->u.ar.shared_coarray_arg)
- offset = gfc_native_coarray_add_this_image_offset (offset, desc,
- &ref->u.ar, 0, 1);
+ if (flag_coarray == GFC_FCOARRAY_SHARED)
+ {
+ gfc_ref *co_ref = cas_array_ref (expr->ref);
+ if (co_ref)
+ offset = cas_add_this_image_offset (offset, desc, &co_ref->u.ar, 0, 1);
+ }
tmp = build_array_ref (desc, offset, NULL, NULL);
ref = ref->next;
break;
}
- else if (flag_coarray == GFC_FCOARRAY_SHARED && ref->type == REF_ARRAY &&
- ref->u.ar.dimen_type[ref->u.ar.dimen +ref->u.ar.codimen -1]
- == DIMEN_THIS_IMAGE)
- tmp = gfc_native_coarray_add_this_image_offset (tmp, desc, &ref->u.ar, 0, 1);
- }
+ }
/* Calculate the offset for each subsequent subreference. */
for (; ref; ref = ref->next)
gfc_array_index_type, stride, itmp);
stride = gfc_evaluate_now (stride, block);
}
- if (flag_coarray == GFC_FCOARRAY_SHARED &&
- ref->u.ar.dimen_type[ref->u.ar.dimen + ref->u.ar.codimen -1]
- == DIMEN_THIS_IMAGE)
- tmp = gfc_native_coarray_add_this_image_offset (tmp, desc, &ref->u.ar, 0, 1);
+
/* Apply the index to obtain the array element. */
tmp = gfc_build_array_ref (tmp, index, NULL);
break;
void
-gfc_trans_native_coarray (stmtblock_t * init, stmtblock_t *cleanup, gfc_symbol * sym)
+gfc_trans_shared_coarray (stmtblock_t * init, stmtblock_t *cleanup, gfc_symbol * sym)
{
tree tmp, decl;
/* All unused, but needed as arguments. */
TREE_STATIC(decl) = 1;
/* Tell the library to handle arrays of locks and event types seperatly. */
- alloc_type = gfc_native_coarray_get_allocation_type (sym);
+ alloc_type = gfc_cas_get_allocation_type (sym);
if (init)
{
NULL_TREE, true, NULL, &element_size);
gfc_conv_descriptor_offset_set (init, decl, offset);
elem_size = size_in_bytes (gfc_get_element_type (TREE_TYPE(decl)));
- gfc_allocate_native_coarray (init, decl, elem_size, sym->as->corank,
+ gfc_allocate_shared_coarray (init, decl, elem_size, sym->as->corank,
alloc_type);
}
generate_coarray_constructor_function (tree *, tree *);
static void
-gfc_trans_native_coarray_static (gfc_symbol * sym)
+gfc_trans_shared_coarray_static (gfc_symbol * sym)
{
tree save_fn_decl, fndecl;
generate_coarray_constructor_function (&save_fn_decl, &fndecl);
- gfc_trans_native_coarray (&caf_init_block, NULL, sym);
+ gfc_trans_shared_coarray (&caf_init_block, NULL, sym);
finish_coarray_constructor_function (&save_fn_decl, &fndecl);
}
static void
-gfc_trans_native_coarray_inline (gfc_wrapped_block * block, gfc_symbol * sym)
+gfc_trans_shared_coarray_inline (gfc_wrapped_block * block, gfc_symbol * sym)
{
stmtblock_t init, cleanup;
gfc_init_block (&init);
gfc_init_block (&cleanup);
- gfc_trans_native_coarray (&init, &cleanup, sym);
+ gfc_trans_shared_coarray (&init, &cleanup, sym);
gfc_add_init_cleanup (block, gfc_finish_block (&init), gfc_finish_block (&cleanup));
}
else if (flag_coarray == GFC_FCOARRAY_SHARED
&& sym->attr.codimension)
{
- gfc_trans_native_coarray_inline (block, sym);
+ gfc_trans_shared_coarray_inline (block, sym);
}
else
{
if (flag_coarray == GFC_FCOARRAY_SHARED && sym->attr.codimension
&& !sym->attr.allocatable)
- gfc_trans_native_coarray_static (sym);
+ gfc_trans_shared_coarray_static (sym);
gfc_module_add_decl (cur_module, decl);