https://gcc.gnu.org/g:c6375dc40866ab271e50a1fea89380a1dc8a80aa
commit c6375dc40866ab271e50a1fea89380a1dc8a80aa Author: Mikael Morin <[email protected]> Date: Wed Oct 29 12:56:03 2025 +0100 fortran: array descriptor: Move debug info generation function Regression tested on powerpc64le-unknown-linux-gnu. OK for master? -- >8 -- 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 preprocessor constants. (gfc_get_descriptor_offsets_for_info): Move function ... * trans-descriptor.cc (gfc_get_descriptor_offsets_for_info): ... to this file. * trans-array.h (gfc_get_descriptor_offsets_for_info): Move declaration ... * trans-descriptor.h (gfc_get_descriptor_offsets_for_info): ... to this file. * trans-types.cc: Include trans-descriptor.h. Diff: --- gcc/fortran/trans-array.cc | 56 ----------------------------------------- gcc/fortran/trans-array.h | 5 ---- gcc/fortran/trans-descriptor.cc | 35 ++++++++++++++++++++++++++ gcc/fortran/trans-descriptor.h | 5 ++++ gcc/fortran/trans-types.cc | 1 + 5 files changed, 41 insertions(+), 61 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 94e01dfc5e70..c7d86276cf90 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 - /* Build a null array descriptor constructor. */ tree @@ -283,51 +272,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 83297bccb134..6125301820f7 100644 --- a/gcc/fortran/trans-array.h +++ b/gcc/fortran/trans-array.h @@ -168,11 +168,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 649ff2415db2..b655767b7e64 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -347,6 +347,41 @@ gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree desc, } +/* Array descriptor higher level routines. + ******************************************************************************/ + +/* 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 142499f07ec9..db877ee402b6 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -46,4 +46,9 @@ void gfc_conv_descriptor_stride_set (stmtblock_t *, tree, tree, tree); void gfc_conv_descriptor_lbound_set (stmtblock_t *, tree, tree, tree); void gfc_conv_descriptor_ubound_set (stmtblock_t *, tree, tree, tree); +/* 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 */ diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index dfdac600c24d..108b481a4187 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-types.h" #include "trans-const.h" #include "trans-array.h" +#include "trans-descriptor.h" #include "dwarf2out.h" /* For struct array_descr_info. */ #include "attribs.h" #include "alias.h"
