[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Modification ordre argument gfc_build_array_ref
Mikael Morin
mikael@gcc.gnu.org
Sat Sep 27 19:04:31 GMT 2025
https://gcc.gnu.org/g:eb91e421b6ceaa78e6df0dc954e532a936e3a74f
commit eb91e421b6ceaa78e6df0dc954e532a936e3a74f
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Tue Sep 16 11:14:28 2025 +0200
Modification ordre argument gfc_build_array_ref
Diff:
---
gcc/fortran/trans-array.cc | 22 ++++++++++------------
gcc/fortran/trans-descriptor.cc | 4 ++--
gcc/fortran/trans-expr.cc | 6 +++---
gcc/fortran/trans-intrinsic.cc | 13 ++++++-------
gcc/fortran/trans-io.cc | 2 +-
gcc/fortran/trans-openmp.cc | 8 ++++----
gcc/fortran/trans-stmt.cc | 36 ++++++++++++++++++------------------
gcc/fortran/trans.cc | 4 ++--
gcc/fortran/trans.h | 5 ++---
9 files changed, 48 insertions(+), 52 deletions(-)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 502901ae83d8..c5654ea59185 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -1426,7 +1426,7 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
/* The offset may change, so get its value now and use that to free memory.
*/
offset_eval = gfc_evaluate_now (offset, &se->pre);
- tmp = gfc_build_array_ref (tmp, offset_eval, NULL);
+ tmp = gfc_build_array_ref (tmp, offset_eval);
if (expr->expr_type == EXPR_FUNCTION && expr->ts.type == BT_DERIVED
&& expr->ts.u.derived->attr.alloc_comp)
@@ -1757,7 +1757,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock,
tmp = gfc_conv_descriptor_data_get (desc);
tmp = build_fold_indirect_ref_loc (input_location,
tmp);
- tmp = gfc_build_array_ref (tmp, *poffset, NULL);
+ tmp = gfc_build_array_ref (tmp, *poffset);
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
init = gfc_build_addr_expr (NULL_TREE, init);
@@ -3507,7 +3507,7 @@ conv_array_index_offset (gfc_se * se, gfc_ss * ss, int dim, int i,
/* Read the vector to get an index into info->descriptor. */
data = build_fold_indirect_ref_loc (input_location,
gfc_conv_array_data (desc));
- index = gfc_build_array_ref (data, index, NULL);
+ index = gfc_build_array_ref (data, index);
index = gfc_evaluate_now (index, &se->pre);
index = fold_convert (gfc_array_index_type, index);
@@ -3741,8 +3741,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar,
bool non_negative_stride = tmp_array
|| non_negative_strides_array_p (info->descriptor);
- se->expr = gfc_build_array_ref (base, index, decl,
- non_negative_stride);
+ se->expr = gfc_build_array_ref (base, index, non_negative_stride, decl);
}
@@ -3804,9 +3803,8 @@ build_array_ref (tree desc, tree offset, tree decl, tree vptr)
tmp = gfc_conv_array_data (desc);
tmp = build_fold_indirect_ref_loc (input_location, tmp);
- tmp = gfc_build_array_ref (tmp, offset, decl,
- non_negative_strides_array_p (desc),
- vptr);
+ tmp = gfc_build_array_ref (tmp, offset, non_negative_strides_array_p (desc),
+ decl, vptr);
return tmp;
}
@@ -7099,7 +7097,7 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, tree offset,
gfc_init_se (&start, NULL);
gfc_conv_expr_type (&start, ref->u.ss.start, gfc_charlen_type_node);
gfc_add_block_to_block (block, &start.pre);
- tmp = gfc_build_array_ref (tmp, start.expr, NULL);
+ tmp = gfc_build_array_ref (tmp, start.expr);
break;
case REF_ARRAY:
@@ -7144,7 +7142,7 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, tree offset,
}
/* Apply the index to obtain the array element. */
- tmp = gfc_build_array_ref (tmp, index, NULL);
+ tmp = gfc_build_array_ref (tmp, index);
break;
case REF_INQUIRY:
@@ -8984,13 +8982,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tree dest,
/* Build the body of the loop. */
gfc_init_block (&loopbody);
- vref = gfc_build_array_ref (var, index, NULL);
+ vref = gfc_build_array_ref (var, index);
if (purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP)
{
tmp = build_fold_indirect_ref_loc (input_location,
gfc_conv_array_data (dest));
- dref = gfc_build_array_ref (tmp, index, NULL);
+ dref = gfc_build_array_ref (tmp, index);
tmp = structure_alloc_comps (der_type, vref, dref, rank,
COPY_ALLOC_COMP, caf_mode, args,
no_finalization);
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index a12f8e79d50f..f04bf69d237e 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -102,7 +102,7 @@ static tree
gfc_get_cfi_dim_item (tree desc, tree idx, unsigned field_idx)
{
tree tmp = gfc_get_cfi_descriptor_field (desc, CFI_FIELD_DIM);
- tmp = gfc_build_array_ref (tmp, idx, NULL_TREE, true);
+ tmp = gfc_build_array_ref (tmp, idx, true);
tree field = gfc_advance_chain (TYPE_FIELDS (TREE_TYPE (tmp)), field_idx);
gcc_assert (field != NULL_TREE);
return fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field),
@@ -462,7 +462,7 @@ get_descriptor_dimension (tree desc, tree dim)
tmp = gfc_get_descriptor_dimension (desc);
- return gfc_build_array_ref (tmp, dim, NULL_TREE, true);
+ return gfc_build_array_ref (tmp, dim, true);
}
tree
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index dae41a0818d8..395160a60579 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1578,7 +1578,7 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems, bool unlimited)
tmp = gfc_conv_array_data (to);
tmp = build_fold_indirect_ref_loc (input_location, tmp);
to_ref = gfc_build_addr_expr (NULL_TREE,
- gfc_build_array_ref (tmp, index, to));
+ gfc_build_array_ref (tmp, index, false, to));
}
vec_safe_push (args, to_ref);
@@ -2734,7 +2734,7 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
/* For BIND(C), a BT_CHARACTER is not an ARRAY_TYPE. */
if (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
{
- tmp = gfc_build_array_ref (tmp, start.expr, NULL_TREE, true);
+ tmp = gfc_build_array_ref (tmp, start.expr, true);
se->expr = gfc_build_addr_expr (type, tmp);
}
else if (POINTER_TYPE_P (TREE_TYPE (tmp)))
@@ -5566,7 +5566,7 @@ gfc_conv_subref_array_arg (gfc_se *se, gfc_expr * expr, int g77,
/* Now use the offset for the reference. */
tmp = build_fold_indirect_ref_loc (input_location,
info->data);
- rse.expr = gfc_build_array_ref (tmp, tmp_index, NULL);
+ rse.expr = gfc_build_array_ref (tmp, tmp_index);
if (expr->ts.type == BT_CHARACTER)
rse.string_length = expr->ts.u.cl->backend_decl;
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 88b8b17892dc..ddbd644309b2 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -2161,7 +2161,7 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
thus we need explicitly check this - and return 0 if they are exceeded. */
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[rank+corank-1]);
- tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[corank-1], NULL);
+ tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[corank-1]);
invalid_bound = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
fold_convert (gfc_array_index_type, tmp),
lbound);
@@ -2170,7 +2170,7 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
{
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[codim]);
ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[codim]);
- tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[codim-rank], NULL);
+ tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[codim-rank]);
cond = fold_build2_loc (input_location, LT_EXPR, logical_type_node,
fold_convert (gfc_array_index_type, tmp),
lbound);
@@ -2189,8 +2189,8 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
/* coindex = sub(corank) - lcobound(n). */
coindex = fold_convert (gfc_array_index_type,
- gfc_build_array_ref (subdesc, gfc_rank_cst[corank-1],
- NULL));
+ gfc_build_array_ref (subdesc,
+ gfc_rank_cst[corank-1]));
lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[rank+corank-1]);
coindex = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
fold_convert (gfc_array_index_type, coindex),
@@ -2208,7 +2208,7 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
gfc_array_index_type, coindex, extent);
/* coindex += sub(codim). */
- tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[codim-rank], NULL);
+ tmp = gfc_build_array_ref (subdesc, gfc_rank_cst[codim-rank]);
coindex = fold_build2_loc (input_location, PLUS_EXPR,
gfc_array_index_type, coindex,
fold_convert (gfc_array_index_type, tmp));
@@ -5613,8 +5613,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op)
for (int i = 0; i < arrayexpr->rank; i++)
{
tree res_idx = build_int_cst (gfc_array_index_type, i);
- tree res_arr_ref = gfc_build_array_ref (result_var, res_idx,
- NULL_TREE, true);
+ tree res_arr_ref = gfc_build_array_ref (result_var, res_idx, true);
tree value = convert (type, pos[i]);
gfc_add_modify (&se->pre, res_arr_ref, value);
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index 1f284931cff3..2ee60a7b1439 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -1657,7 +1657,7 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c,
tmp = gfc_build_addr_expr (NULL_TREE, tmp);
if (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
- tmp = gfc_build_array_ref (tmp, gfc_index_zero_node, NULL);
+ tmp = gfc_build_array_ref (tmp, gfc_index_zero_node);
if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
tmp = build_fold_indirect_ref_loc (input_location,
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 07e3649914fb..d1229a749102 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -644,13 +644,13 @@ gfc_walk_alloc_comps (tree decl, tree dest, tree var,
gfc_init_block (&tmpblock);
tem = gfc_conv_array_data (decl);
tree declvar = build_fold_indirect_ref_loc (input_location, tem);
- tree declvref = gfc_build_array_ref (declvar, index, NULL);
+ tree declvref = gfc_build_array_ref (declvar, index);
tree destvar, destvref = NULL_TREE;
if (dest)
{
tem = gfc_conv_array_data (dest);
destvar = build_fold_indirect_ref_loc (input_location, tem);
- destvref = gfc_build_array_ref (destvar, index, NULL);
+ destvref = gfc_build_array_ref (destvar, index);
}
gfc_add_expr_to_block (&tmpblock,
gfc_walk_alloc_comps (declvref, destvref,
@@ -1276,8 +1276,8 @@ gfc_omp_linear_clause_add_loop (stmtblock_t *block, tree dest, tree src,
gfc_init_block (&tmpblock);
if (TREE_CODE (TREE_TYPE (dest)) == ARRAY_TYPE)
{
- desta = gfc_build_array_ref (dest, index, NULL);
- srca = gfc_build_array_ref (src, index, NULL);
+ desta = gfc_build_array_ref (dest, index);
+ srca = gfc_build_array_ref (src, index);
}
else
{
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index a8fccb60058b..a26491839b39 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -576,7 +576,7 @@ gfc_trans_call (gfc_code * code, bool dependency_check,
{
/* Form the mask expression according to the mask. */
index = count1;
- maskexpr = gfc_build_array_ref (mask, index, NULL);
+ maskexpr = gfc_build_array_ref (mask, index);
if (invert)
maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (maskexpr), maskexpr);
@@ -4434,7 +4434,7 @@ gfc_trans_nested_forall_loop (forall_info * nested_forall_info, tree body,
/* If a mask was specified make the assignment conditional. */
if (mask)
{
- tmp = gfc_build_array_ref (mask, maskindex, NULL);
+ tmp = gfc_build_array_ref (mask, maskindex);
body = build3_v (COND_EXPR, tmp, body,
build_empty_stmt (input_location));
}
@@ -4511,7 +4511,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
{
gfc_init_block (&body1);
gfc_conv_expr (&lse, expr);
- rse.expr = gfc_build_array_ref (tmp1, count1, NULL);
+ rse.expr = gfc_build_array_ref (tmp1, count1);
}
else
{
@@ -4534,7 +4534,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
gfc_conv_expr (&lse, expr);
/* Form the expression of the temporary. */
- rse.expr = gfc_build_array_ref (tmp1, count1, NULL);
+ rse.expr = gfc_build_array_ref (tmp1, count1);
}
/* Use the scalar assignment. */
@@ -4545,7 +4545,7 @@ generate_loop_for_temp_to_lhs (gfc_expr *expr, tree tmp1, tree count3,
/* Form the mask expression according to the mask tree list. */
if (wheremask)
{
- wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL);
+ wheremaskexpr = gfc_build_array_ref (wheremask, count3);
if (invert)
wheremaskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (wheremaskexpr),
@@ -4616,7 +4616,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
{
gfc_init_block (&body1);
gfc_conv_expr (&rse, expr2);
- lse.expr = gfc_build_array_ref (tmp1, count1, NULL);
+ lse.expr = gfc_build_array_ref (tmp1, count1);
}
else
{
@@ -4640,7 +4640,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
gfc_conv_expr (&rse, expr2);
/* Form the expression of the temporary. */
- lse.expr = gfc_build_array_ref (tmp1, count1, NULL);
+ lse.expr = gfc_build_array_ref (tmp1, count1);
}
/* Use the scalar assignment. */
@@ -4651,7 +4651,7 @@ generate_loop_for_rhs_to_temp (gfc_expr *expr2, tree tmp1, tree count3,
/* Form the mask expression according to the mask tree list. */
if (wheremask)
{
- wheremaskexpr = gfc_build_array_ref (wheremask, count3, NULL);
+ wheremaskexpr = gfc_build_array_ref (wheremask, count3);
if (invert)
wheremaskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (wheremaskexpr),
@@ -5057,7 +5057,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
inner_size, NULL, block, &ptemp1);
gfc_start_block (&body);
gfc_init_se (&lse, NULL);
- lse.expr = gfc_build_array_ref (tmp1, count, NULL);
+ lse.expr = gfc_build_array_ref (tmp1, count);
gfc_init_se (&rse, NULL);
rse.want_pointer = 1;
gfc_conv_expr (&rse, expr2);
@@ -5084,7 +5084,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
gfc_start_block (&body);
gfc_init_se (&lse, NULL);
gfc_init_se (&rse, NULL);
- rse.expr = gfc_build_array_ref (tmp1, count, NULL);
+ rse.expr = gfc_build_array_ref (tmp1, count);
lse.want_pointer = 1;
gfc_conv_expr (&lse, expr1);
gfc_add_block_to_block (&body, &lse.pre);
@@ -5127,7 +5127,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
inner_size, NULL, block, &ptemp1);
gfc_start_block (&body);
gfc_init_se (&lse, NULL);
- lse.expr = gfc_build_array_ref (tmp1, count, NULL);
+ lse.expr = gfc_build_array_ref (tmp1, count);
lse.direct_byref = 1;
gfc_conv_expr_descriptor (&lse, expr2);
@@ -5149,7 +5149,7 @@ gfc_trans_pointer_assign_need_temp (gfc_expr * expr1, gfc_expr * expr2,
/* Reset count. */
gfc_add_modify (block, count, gfc_index_zero_node);
- parm = gfc_build_array_ref (tmp1, count, NULL);
+ parm = gfc_build_array_ref (tmp1, count);
gfc_init_se (&lse, NULL);
gfc_conv_expr_descriptor (&lse, expr1);
gfc_add_modify (&lse.pre, lse.expr, parm);
@@ -5543,7 +5543,7 @@ gfc_trans_forall_1 (gfc_code * code, forall_info * nested_forall_info)
/* Store the mask. */
se.expr = convert (mask_type, se.expr);
- tmp = gfc_build_array_ref (mask, maskindex, NULL);
+ tmp = gfc_build_array_ref (mask, maskindex);
gfc_add_modify (&body, tmp, se.expr);
/* Advance to the next mask element. */
@@ -5805,7 +5805,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
if (mask && (cmask || pmask))
{
- tmp = gfc_build_array_ref (mask, count, NULL);
+ tmp = gfc_build_array_ref (mask, count);
if (invert)
tmp = fold_build1_loc (input_location, TRUTH_NOT_EXPR, mask_type, tmp);
gfc_add_modify (&body1, mtmp, tmp);
@@ -5813,7 +5813,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
if (cmask)
{
- tmp1 = gfc_build_array_ref (cmask, count, NULL);
+ tmp1 = gfc_build_array_ref (cmask, count);
tmp = cond;
if (mask)
tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR, mask_type,
@@ -5823,7 +5823,7 @@ gfc_evaluate_where_mask (gfc_expr * me, forall_info * nested_forall_info,
if (pmask)
{
- tmp1 = gfc_build_array_ref (pmask, count, NULL);
+ tmp1 = gfc_build_array_ref (pmask, count);
tmp = fold_build1_loc (input_location, TRUTH_NOT_EXPR, mask_type, cond);
if (mask)
tmp = fold_build2_loc (input_location, TRUTH_AND_EXPR, mask_type, mtmp,
@@ -5982,7 +5982,7 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
/* Form the mask expression according to the mask. */
index = count1;
- maskexpr = gfc_build_array_ref (mask, index, NULL);
+ maskexpr = gfc_build_array_ref (mask, index);
if (invert)
maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (maskexpr), maskexpr);
@@ -6036,7 +6036,7 @@ gfc_trans_where_assign (gfc_expr *expr1, gfc_expr *expr2,
/* Form the mask expression according to the mask tree list. */
index = count2;
- maskexpr = gfc_build_array_ref (mask, index, NULL);
+ maskexpr = gfc_build_array_ref (mask, index);
if (invert)
maskexpr = fold_build1_loc (input_location, TRUTH_NOT_EXPR,
TREE_TYPE (maskexpr), maskexpr);
diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index bd249ae2f87c..66c0bf28f06b 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -487,8 +487,8 @@ gfc_build_spanned_array_ref (tree base, tree offset, tree span)
have to play it safe and use pointer arithmetic. */
tree
-gfc_build_array_ref (tree base, tree offset, tree decl,
- bool non_negative_offset, tree vptr)
+gfc_build_array_ref (tree base, tree offset, bool non_negative_offset,
+ tree decl, tree vptr)
{
tree type = TREE_TYPE (base);
tree span = NULL_TREE;
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 74def76fe384..f3c79db7f54e 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -636,9 +636,8 @@ tree gfc_get_extern_function_decl (gfc_symbol *,
tree gfc_build_addr_expr (tree, tree);
/* Build an ARRAY_REF. */
-tree gfc_build_array_ref (tree, tree, tree,
- bool non_negative_offset = false,
- tree vptr = NULL_TREE);
+tree gfc_build_array_ref (tree, tree, bool non_negative_offset = false,
+ tree decl = NULL_TREE, tree vptr = NULL_TREE);
/* Build an array ref using pointer arithmetic. */
tree gfc_build_spanned_array_ref (tree base, tree offset, tree span);
More information about the Gcc-cvs
mailing list