[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Déplacement copy_descriptor
Mikael Morin
mikael@gcc.gnu.org
Wed Sep 10 19:57:03 GMT 2025
https://gcc.gnu.org/g:2888c8afb2a8cb6a9517e696ff99770b205727b4
commit 2888c8afb2a8cb6a9517e696ff99770b205727b4
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Thu Jul 31 20:48:05 2025 +0200
Déplacement copy_descriptor
Diff:
---
gcc/fortran/trans-descriptor.cc | 42 +++++++++++++++++++++++++++++++++++++
gcc/fortran/trans-descriptor.h | 1 +
gcc/fortran/trans-stmt.cc | 46 ++---------------------------------------
3 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 66fa9d57b725..43aa236acfb7 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1329,6 +1329,48 @@ gfc_copy_descriptor (stmtblock_t *block, tree dest, tree src, bool lhs_type)
}
+void
+gfc_copy_descriptor (stmtblock_t *block, tree dst, tree src, int rank)
+{
+ int n;
+ tree dim;
+ tree tmp;
+ tree tmp2;
+ tree size;
+ tree offset;
+
+ offset = gfc_index_zero_node;
+
+ /* Use memcpy to copy the descriptor. The size is the minimum of
+ the sizes of 'src' and 'dst'. This avoids a non-trivial conversion. */
+ tmp = TYPE_SIZE_UNIT (TREE_TYPE (src));
+ tmp2 = TYPE_SIZE_UNIT (TREE_TYPE (dst));
+ size = fold_build2_loc (input_location, MIN_EXPR,
+ TREE_TYPE (tmp), tmp, tmp2);
+ tmp = builtin_decl_explicit (BUILT_IN_MEMCPY);
+ tmp = build_call_expr_loc (input_location, tmp, 3,
+ gfc_build_addr_expr (NULL_TREE, dst),
+ gfc_build_addr_expr (NULL_TREE, src),
+ fold_convert (size_type_node, size));
+ gfc_add_expr_to_block (block, tmp);
+
+ /* Set the offset correctly. */
+ for (n = 0; n < rank; n++)
+ {
+ dim = gfc_rank_cst[n];
+ tmp = gfc_conv_descriptor_lbound_get (src, dim);
+ tmp2 = gfc_conv_descriptor_stride_get (src, dim);
+ tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
+ tmp, tmp2);
+ offset = fold_build2_loc (input_location, MINUS_EXPR,
+ TREE_TYPE (offset), offset, tmp);
+ offset = gfc_evaluate_now (offset, block);
+ }
+
+ gfc_conv_descriptor_offset_set (block, dst, offset);
+}
+
+
void
gfc_copy_descriptor (stmtblock_t *block, tree dest, tree src, tree ptr,
int rank, gfc_ss *ss)
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 44f6d51dc6cd..f445a76aef09 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -111,6 +111,7 @@ void gfc_copy_sequence_descriptor (stmtblock_t *, tree, tree, int);
void gfc_copy_descriptor (stmtblock_t *, tree, tree, gfc_expr *, bool);
void gfc_copy_descriptor (stmtblock_t *, tree, tree, tree, int, gfc_ss *);
void gfc_copy_descriptor (stmtblock_t *, tree, tree, bool);
+void gfc_copy_descriptor (stmtblock_t *, tree, tree, int);
void gfc_set_descriptor_from_scalar_class (stmtblock_t *, tree, tree, gfc_expr *);
void gfc_set_descriptor_from_scalar (stmtblock_t *, tree, tree, symbol_attribute,
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 57ca11e1bafb..b525c4348916 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -1825,48 +1825,6 @@ class_has_len_component (gfc_symbol *sym)
}
-static void
-copy_descriptor (stmtblock_t *block, tree dst, tree src, int rank)
-{
- int n;
- tree dim;
- tree tmp;
- tree tmp2;
- tree size;
- tree offset;
-
- offset = gfc_index_zero_node;
-
- /* Use memcpy to copy the descriptor. The size is the minimum of
- the sizes of 'src' and 'dst'. This avoids a non-trivial conversion. */
- tmp = TYPE_SIZE_UNIT (TREE_TYPE (src));
- tmp2 = TYPE_SIZE_UNIT (TREE_TYPE (dst));
- size = fold_build2_loc (input_location, MIN_EXPR,
- TREE_TYPE (tmp), tmp, tmp2);
- tmp = builtin_decl_explicit (BUILT_IN_MEMCPY);
- tmp = build_call_expr_loc (input_location, tmp, 3,
- gfc_build_addr_expr (NULL_TREE, dst),
- gfc_build_addr_expr (NULL_TREE, src),
- fold_convert (size_type_node, size));
- gfc_add_expr_to_block (block, tmp);
-
- /* Set the offset correctly. */
- for (n = 0; n < rank; n++)
- {
- dim = gfc_rank_cst[n];
- tmp = gfc_conv_descriptor_lbound_get (src, dim);
- tmp2 = gfc_conv_descriptor_stride_get (src, dim);
- tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
- tmp, tmp2);
- offset = fold_build2_loc (input_location, MINUS_EXPR,
- TREE_TYPE (offset), offset, tmp);
- offset = gfc_evaluate_now (offset, block);
- }
-
- gfc_conv_descriptor_offset_set (block, dst, offset);
-}
-
-
/* Do proper initialization for ASSOCIATE names. */
static void
@@ -1995,7 +1953,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
attributes so the selector descriptor must be copied in and
copied out. */
if (rank > 0)
- copy_descriptor (&se.pre, desc, se.expr, rank);
+ gfc_copy_descriptor (&se.pre, desc, se.expr, rank);
else
{
tmp = gfc_conv_descriptor_data_get (se.expr);
@@ -2024,7 +1982,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
|| CLASS_DATA (sym)->attr.pointer)))
{
if (rank > 0)
- copy_descriptor (&se.post, se.expr, desc, rank);
+ gfc_copy_descriptor (&se.post, se.expr, desc, rank);
else
gfc_conv_descriptor_data_set (&se.post, se.expr, desc);
More information about the Gcc-cvs
mailing list