https://gcc.gnu.org/g:516c5be20892a8f41a9a7fbe364a17c6da9755f5

commit 516c5be20892a8f41a9a7fbe364a17c6da9755f5
Author: Mikael Morin <[email protected]>
Date:   Tue Oct 28 16:34:34 2025 +0100

    fortran: array descriptor: Move debug info generation function
    
    Move the gfc_get_descriptor_offsets_for_info function, which is used
    to build debug info of array descriptors, to the trans-descriptor.cc
    file .
    
    gcc/fortran/ChangeLog:
    
            * trans-array.cc (DATA_FIELD, OFFSET_FIELD, DTYPE_FIELD, SPAN_FIELD,
            DIMENSION_FIELD, CAF_TOKEN_FIELD, STRIDE_SUBFIELD, LBOUND_SUBFIELD,
            UBOUND_SUBFIELD): Remove macro removal.
            (gfc_get_descriptor_offsets_for_info): Move ...
            * trans-descriptor.cc (gfc_get_descriptor_offsets_for_info): ...
            here.
            * trans-array.h (gfc_get_descriptor_offsets_for_info): Move
            declaration ...
            * trans-descriptor.h (gfc_get_descriptor_offsets_for_info): ...
            here.

Diff:
---
 gcc/fortran/trans-array.cc      | 56 -----------------------------------------
 gcc/fortran/trans-array.h       |  5 ----
 gcc/fortran/trans-descriptor.cc | 32 +++++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  5 ++++
 4 files changed, 37 insertions(+), 61 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index d40fbbc1d70a..ab419bbae0bf 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -214,17 +214,6 @@ gfc_get_cfi_dim_sm (tree desc, tree idx)
 #undef CFI_DIM_FIELD_SM
 
 
-#define DATA_FIELD 0
-#define OFFSET_FIELD 1
-#define DTYPE_FIELD 2
-#define SPAN_FIELD 3
-#define DIMENSION_FIELD 4
-#define CAF_TOKEN_FIELD 5
-
-#define STRIDE_SUBFIELD 0
-#define LBOUND_SUBFIELD 1
-#define UBOUND_SUBFIELD 2
-
 /* Modify a descriptor such that the lbound of a given dimension is the value
    specified.  This also updates ubound and offset accordingly.  */
 
@@ -262,51 +251,6 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree 
desc,
 }
 
 
-/* Obtain offsets for trans-types.cc(gfc_get_array_descr_info).  */
-
-void
-gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
-                                    tree *dtype_off, tree *span_off,
-                                    tree *dim_off, tree *dim_size,
-                                    tree *stride_suboff, tree *lower_suboff,
-                                    tree *upper_suboff)
-{
-  tree field;
-  tree type;
-
-  type = TYPE_MAIN_VARIANT (desc_type);
-  field = gfc_advance_chain (TYPE_FIELDS (type), DATA_FIELD);
-  *data_off = byte_position (field);
-  field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD);
-  *dtype_off = byte_position (field);
-  field = gfc_advance_chain (TYPE_FIELDS (type), SPAN_FIELD);
-  *span_off = byte_position (field);
-  field = gfc_advance_chain (TYPE_FIELDS (type), DIMENSION_FIELD);
-  *dim_off = byte_position (field);
-  type = TREE_TYPE (TREE_TYPE (field));
-  *dim_size = TYPE_SIZE_UNIT (type);
-  field = gfc_advance_chain (TYPE_FIELDS (type), STRIDE_SUBFIELD);
-  *stride_suboff = byte_position (field);
-  field = gfc_advance_chain (TYPE_FIELDS (type), LBOUND_SUBFIELD);
-  *lower_suboff = byte_position (field);
-  field = gfc_advance_chain (TYPE_FIELDS (type), UBOUND_SUBFIELD);
-  *upper_suboff = byte_position (field);
-}
-
-
-/* Cleanup those #defines.  */
-
-#undef DATA_FIELD
-#undef OFFSET_FIELD
-#undef DTYPE_FIELD
-#undef SPAN_FIELD
-#undef DIMENSION_FIELD
-#undef CAF_TOKEN_FIELD
-#undef STRIDE_SUBFIELD
-#undef LBOUND_SUBFIELD
-#undef UBOUND_SUBFIELD
-
-
 /* Mark a SS chain as used.  Flags specifies in which loops the SS is used.
    flags & 1 = Main loop body.
    flags & 2 = temp copy loop.  */
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index 79bb49ee1d86..7eb21dbb32dd 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -166,11 +166,6 @@ tree gfc_conv_array_ubound (tree, int);
 tree gfc_trans_array_bounds (tree, gfc_symbol *, tree *, stmtblock_t *);
 void gfc_trans_array_cobounds (tree, stmtblock_t *, const gfc_symbol *);
 
-/* Build expressions for accessing components of an array descriptor.  */
-void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *,
-                                         tree *, tree *, tree *, tree *,
-                                         tree *);
-
 /* CFI descriptor.  */
 tree gfc_get_cfi_desc_base_addr (tree);
 tree gfc_get_cfi_desc_elem_len (tree);
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index b34dd64b874e..d41de9668536 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -377,6 +377,38 @@ gfc_build_null_descriptor (tree type)
 }
 
 
+/* Obtain offsets for trans-types.cc(gfc_get_array_descr_info).  */
+
+void
+gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
+                                    tree *dtype_off, tree *span_off,
+                                    tree *dim_off, tree *dim_size,
+                                    tree *stride_suboff, tree *lower_suboff,
+                                    tree *upper_suboff)
+{
+  tree field;
+  tree type;
+
+  type = TYPE_MAIN_VARIANT (desc_type);
+  field = gfc_advance_chain (TYPE_FIELDS (type), DATA_FIELD);
+  *data_off = byte_position (field);
+  field = gfc_advance_chain (TYPE_FIELDS (type), DTYPE_FIELD);
+  *dtype_off = byte_position (field);
+  field = gfc_advance_chain (TYPE_FIELDS (type), SPAN_FIELD);
+  *span_off = byte_position (field);
+  field = gfc_advance_chain (TYPE_FIELDS (type), DIMENSION_FIELD);
+  *dim_off = byte_position (field);
+  type = TREE_TYPE (TREE_TYPE (field));
+  *dim_size = TYPE_SIZE_UNIT (type);
+  field = gfc_advance_chain (TYPE_FIELDS (type), STRIDE_SUBFIELD);
+  *stride_suboff = byte_position (field);
+  field = gfc_advance_chain (TYPE_FIELDS (type), LBOUND_SUBFIELD);
+  *lower_suboff = byte_position (field);
+  field = gfc_advance_chain (TYPE_FIELDS (type), UBOUND_SUBFIELD);
+  *upper_suboff = byte_position (field);
+}
+
+
 /* Cleanup those #defines.  */
 
 #undef DATA_FIELD
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index ac2e058b2732..180236fec6fe 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -52,4 +52,9 @@ void gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree 
desc, tree dim,
 /* Build a null array descriptor constructor.  */
 tree gfc_build_null_descriptor (tree type);
 
+/* Build expressions for accessing components of an array descriptor.  */
+void gfc_get_descriptor_offsets_for_info (const_tree, tree *, tree *, tree *,
+                                         tree *, tree *, tree *, tree *,
+                                         tree *);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */

Reply via email to