https://gcc.gnu.org/g:056ab994d950c8c19945d0adadb9f6ce44e4a45e
commit 056ab994d950c8c19945d0adadb9f6ce44e4a45e Author: Mikael Morin <mik...@gcc.gnu.org> Date: Wed Jul 23 16:36:42 2025 +0200 Déplacement gfc_descriptor_size Diff: --- gcc/fortran/trans-array.cc | 47 ----------------------------------------- gcc/fortran/trans-array.h | 2 -- gcc/fortran/trans-descriptor.cc | 47 +++++++++++++++++++++++++++++++++++++++++ gcc/fortran/trans-descriptor.h | 2 ++ 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 6d291d95df5a..b217f2695462 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -5678,53 +5678,6 @@ gfc_conv_array_extent_dim (tree lbound, tree ubound, tree* or_expr) } -/* For an array descriptor, get the total number of elements. This is just - the product of the extents along from_dim to to_dim. */ - -static tree -gfc_conv_descriptor_size_1 (tree desc, int from_dim, int to_dim) -{ - tree res; - int dim; - - res = gfc_index_one_node; - - for (dim = from_dim; dim < to_dim; ++dim) - { - tree lbound; - tree ubound; - tree extent; - - lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]); - ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]); - - extent = gfc_conv_array_extent_dim (lbound, ubound, NULL); - res = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - res, extent); - } - - return res; -} - - -/* Full size of an array. */ - -tree -gfc_conv_descriptor_size (tree desc, int rank) -{ - return gfc_conv_descriptor_size_1 (desc, 0, rank); -} - - -/* Size of a coarray for all dimensions but the last. */ - -tree -gfc_conv_descriptor_cosize (tree desc, int rank, int corank) -{ - return gfc_conv_descriptor_size_1 (desc, rank, rank + corank - 1); -} - - /* Fills in an array descriptor, and returns the size of the array. The size will be a simple_val, ie a variable or a constant. Also calculates the offset of the base. The pointer argument overflow, diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h index a7de99a5a4a4..30bae44a17ec 100644 --- a/gcc/fortran/trans-array.h +++ b/gcc/fortran/trans-array.h @@ -189,6 +189,4 @@ void gfc_trans_string_copy (stmtblock_t *, tree, tree, int, tree, tree, int); /* Calculate extent / size of an array. */ tree gfc_conv_array_extent_dim (tree, tree, tree*); -tree gfc_conv_descriptor_size (tree, int); -tree gfc_conv_descriptor_cosize (tree, int, int); diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 4a6cca9cc2bb..61752f087b59 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -732,6 +732,53 @@ gfc_nullify_descriptor (stmtblock_t *block, gfc_symbol *sym, gfc_expr *expr, gfc_conv_descriptor_dtype_set (block, descr, dtype); } + +/* For an array descriptor, get the total number of elements. This is just + the product of the extents along from_dim to to_dim. */ + +static tree +gfc_conv_descriptor_size_1 (tree desc, int from_dim, int to_dim) +{ + tree res; + int dim; + + res = gfc_index_one_node; + + for (dim = from_dim; dim < to_dim; ++dim) + { + tree lbound; + tree ubound; + tree extent; + + lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]); + ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]); + + extent = gfc_conv_array_extent_dim (lbound, ubound, NULL); + res = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, + res, extent); + } + + return res; +} + + +/* Full size of an array. */ + +tree +gfc_conv_descriptor_size (tree desc, int rank) +{ + return gfc_conv_descriptor_size_1 (desc, 0, rank); +} + + +/* Size of a coarray for all dimensions but the last. */ + +tree +gfc_conv_descriptor_cosize (tree desc, int rank, int corank) +{ + return gfc_conv_descriptor_size_1 (desc, rank, rank + corank - 1); +} + void gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, gfc_expr *expr, tree descr) diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h index e5643b310de0..ac7960589abb 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -82,6 +82,8 @@ void gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree desc, tree dim, tr void gfc_conv_descriptor_token_set (stmtblock_t *block, tree desc, tree value); tree gfc_build_null_descriptor (tree type); +tree gfc_conv_descriptor_size (tree, int); +tree gfc_conv_descriptor_cosize (tree, int, int); void gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,