|
|
8d374f |
2020-03-30 Jakub Jelinek <jakub@redhat.com>
|
|
|
8d374f |
|
|
|
8d374f |
Backported from mainline
|
|
|
8d374f |
2019-12-06 Jakub Jelinek <jakub@redhat.com>
|
|
|
8d374f |
|
|
|
8d374f |
PR fortran/92775
|
|
|
8d374f |
* trans.h (struct lang_type, struct lang_decl): Remove span member.
|
|
|
8d374f |
(GFC_DECL_SPAN, GFC_TYPE_ARRAY_SPAN): Remove macros.
|
|
|
8d374f |
* trans-array.h (gfc_get_descriptor_offsets_for_info): Add another
|
|
|
8d374f |
argument.
|
|
|
8d374f |
* trans-array.c (gfc_get_descriptor_offsets_for_info): Add SPAN_OFF
|
|
|
8d374f |
argument and initialize *SPAN_OFF to the offset of span field.
|
|
|
8d374f |
* trans-types.c (gfc_get_array_descr_info): Adjust
|
|
|
8d374f |
gfc_get_descriptor_offsets_for_info caller. Compute elem_size
|
|
|
8d374f |
as base->span instead of TYPE_SIZE_UNIT (etype) constant.
|
|
|
8d374f |
|
|
|
8d374f |
--- gcc/fortran/trans-array.c
|
|
|
8d374f |
+++ gcc/fortran/trans-array.c
|
|
|
8d374f |
@@ -503,9 +503,10 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc,
|
|
|
8d374f |
|
|
|
8d374f |
void
|
|
|
8d374f |
gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
|
|
|
8d374f |
- tree *dtype_off, tree *dim_off,
|
|
|
8d374f |
- tree *dim_size, tree *stride_suboff,
|
|
|
8d374f |
- tree *lower_suboff, tree *upper_suboff)
|
|
|
8d374f |
+ tree *dtype_off, tree *span_off,
|
|
|
8d374f |
+ tree *dim_off, tree *dim_size,
|
|
|
8d374f |
+ tree *stride_suboff, tree *lower_suboff,
|
|
|
8d374f |
+ tree *upper_suboff)
|
|
|
8d374f |
{
|
|
|
8d374f |
tree field;
|
|
|
8d374f |
tree type;
|
|
|
8d374f |
@@ -515,6 +516,8 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
|
|
|
8d374f |
*data_off = byte_position (field);
|
|
|
8d374f |
field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD);
|
|
|
8d374f |
*dtype_off = byte_position (field);
|
|
|
8d374f |
+ field = gfc_advance_chain (TYPE_FIELDS (type), SPAN_FIELD);
|
|
|
8d374f |
+ *span_off = byte_position (field);
|
|
|
8d374f |
field = gfc_advance_chain (TYPE_FIELDS (type), DIMENSION_FIELD);
|
|
|
8d374f |
*dim_off = byte_position (field);
|
|
|
8d374f |
type = TREE_TYPE (TREE_TYPE (field));
|
|
|
8d374f |
--- gcc/fortran/trans-array.h
|
|
|
8d374f |
+++ gcc/fortran/trans-array.h
|
|
|
8d374f |
@@ -159,7 +159,7 @@ void gfc_trans_array_cobounds (tree, stmtblock_t *, const gfc_symbol *);
|
|
|
8d374f |
|
|
|
8d374f |
/* Build expressions for accessing components of an array descriptor. */
|
|
|
8d374f |
void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *, tree *,
|
|
|
8d374f |
- tree *, tree *, tree *);
|
|
|
8d374f |
+ tree *, tree *, tree *, tree *);
|
|
|
8d374f |
|
|
|
8d374f |
tree gfc_conv_descriptor_data_get (tree);
|
|
|
8d374f |
tree gfc_conv_descriptor_data_addr (tree);
|
|
|
8d374f |
--- gcc/fortran/trans-types.c
|
|
|
8d374f |
+++ gcc/fortran/trans-types.c
|
|
|
8d374f |
@@ -3344,7 +3344,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
|
|
|
8d374f |
int rank, dim;
|
|
|
8d374f |
bool indirect = false;
|
|
|
8d374f |
tree etype, ptype, t, base_decl;
|
|
|
8d374f |
- tree data_off, dim_off, dtype_off, dim_size, elem_size;
|
|
|
8d374f |
+ tree data_off, span_off, dim_off, dtype_off, dim_size, elem_size;
|
|
|
8d374f |
tree lower_suboff, upper_suboff, stride_suboff;
|
|
|
8d374f |
tree dtype, field, rank_off;
|
|
|
8d374f |
|
|
|
8d374f |
@@ -3401,12 +3401,13 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
|
|
|
8d374f |
if (indirect)
|
|
|
8d374f |
base_decl = build1 (INDIRECT_REF, ptype, base_decl);
|
|
|
8d374f |
|
|
|
8d374f |
- elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype));
|
|
|
8d374f |
-
|
|
|
8d374f |
- gfc_get_descriptor_offsets_for_info (type, &data_off, &dtype_off, &dim_off,
|
|
|
8d374f |
- &dim_size, &stride_suboff,
|
|
|
8d374f |
+ gfc_get_descriptor_offsets_for_info (type, &data_off, &dtype_off, &span_off,
|
|
|
8d374f |
+ &dim_off, &dim_size, &stride_suboff,
|
|
|
8d374f |
&lower_suboff, &upper_suboff);
|
|
|
8d374f |
|
|
|
8d374f |
+ t = fold_build_pointer_plus (base_decl, span_off);
|
|
|
8d374f |
+ elem_size = build1 (INDIRECT_REF, gfc_array_index_type, t);
|
|
|
8d374f |
+
|
|
|
8d374f |
t = base_decl;
|
|
|
8d374f |
if (!integer_zerop (data_off))
|
|
|
8d374f |
t = fold_build_pointer_plus (t, data_off);
|
|
|
8d374f |
--- gcc/fortran/trans.h
|
|
|
8d374f |
+++ gcc/fortran/trans.h
|
|
|
8d374f |
@@ -953,7 +953,6 @@ struct GTY(()) lang_type {
|
|
|
8d374f |
tree offset;
|
|
|
8d374f |
tree dtype;
|
|
|
8d374f |
tree dataptr_type;
|
|
|
8d374f |
- tree span;
|
|
|
8d374f |
tree base_decl[2];
|
|
|
8d374f |
tree nonrestricted_type;
|
|
|
8d374f |
tree caf_token;
|
|
|
8d374f |
@@ -969,7 +968,6 @@ struct GTY(()) lang_decl {
|
|
|
8d374f |
address of target label. */
|
|
|
8d374f |
tree stringlen;
|
|
|
8d374f |
tree addr;
|
|
|
8d374f |
- tree span;
|
|
|
8d374f |
/* For assumed-shape coarrays. */
|
|
|
8d374f |
tree token, caf_offset;
|
|
|
8d374f |
unsigned int scalar_allocatable : 1;
|
|
|
8d374f |
@@ -979,7 +977,6 @@ struct GTY(()) lang_decl {
|
|
|
8d374f |
|
|
|
8d374f |
#define GFC_DECL_ASSIGN_ADDR(node) DECL_LANG_SPECIFIC(node)->addr
|
|
|
8d374f |
#define GFC_DECL_STRING_LEN(node) DECL_LANG_SPECIFIC(node)->stringlen
|
|
|
8d374f |
-#define GFC_DECL_SPAN(node) DECL_LANG_SPECIFIC(node)->span
|
|
|
8d374f |
#define GFC_DECL_TOKEN(node) DECL_LANG_SPECIFIC(node)->token
|
|
|
8d374f |
#define GFC_DECL_CAF_OFFSET(node) DECL_LANG_SPECIFIC(node)->caf_offset
|
|
|
8d374f |
#define GFC_DECL_SAVED_DESCRIPTOR(node) \
|
|
|
8d374f |
@@ -1028,7 +1025,6 @@ struct GTY(()) lang_decl {
|
|
|
8d374f |
#define GFC_TYPE_ARRAY_DTYPE(node) (TYPE_LANG_SPECIFIC(node)->dtype)
|
|
|
8d374f |
#define GFC_TYPE_ARRAY_DATAPTR_TYPE(node) \
|
|
|
8d374f |
(TYPE_LANG_SPECIFIC(node)->dataptr_type)
|
|
|
8d374f |
-#define GFC_TYPE_ARRAY_SPAN(node) (TYPE_LANG_SPECIFIC(node)->span)
|
|
|
8d374f |
#define GFC_TYPE_ARRAY_BASE_DECL(node, internal) \
|
|
|
8d374f |
(TYPE_LANG_SPECIFIC(node)->base_decl[(internal)])
|
|
|
8d374f |
|