From: Mikael Morin <[email protected]>

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 (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.
---
 gcc/fortran/trans-array.cc      | 32 --------------------------------
 gcc/fortran/trans-array.h       |  5 -----
 gcc/fortran/trans-descriptor.cc | 32 ++++++++++++++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  5 +++++
 gcc/fortran/trans-types.cc      |  1 +
 5 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 94e01dfc5e7..d9d5759604e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -283,38 +283,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
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index 83297bccb13..6125301820f 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 649ff2415db..18603601663 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -347,6 +347,38 @@ gfc_conv_descriptor_ubound_set (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
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 142499f07ec..db877ee402b 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 dfdac600c24..108b481a418 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"
-- 
2.51.0

Reply via email to