From: Mikael Morin <[email protected]>

Regression tested on powerpc64le-unknown-linux-gnu.  OK for master?

-- >8 --

Move the gfc_conv_descriptor_size and gfc_conv_descriptor_cosize
functions from trans-array.cc to trans-descriptor.cc.

gcc/fortran/ChangeLog:

        * trans-array.cc: (gfc_conv_descriptor_size_1,
        gfc_conv_descriptor_size, gfc_conv_descriptor_cosize): Move
        functions ...
        * trans-descriptor.cc (gfc_conv_descriptor_size_1,
        gfc_conv_descriptor_size, gfc_conv_descriptor_cosize): ... to this
        file.
        * trans-array.h (gfc_conv_descriptor_size,
        gfc_conv_descriptor_cosize): Move ...
        * trans-descriptor.h (gfc_conv_descriptor_size,
        gfc_conv_descriptor_cosize): ... here.
---
 gcc/fortran/trans-array.cc      | 47 --------------------------------
 gcc/fortran/trans-array.h       |  2 --
 gcc/fortran/trans-descriptor.cc | 48 +++++++++++++++++++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  3 +++
 4 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index ab419bbae0b..6f79c0b1b4d 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -5888,53 +5888,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 7eb21dbb32d..f456532a47d 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -194,5 +194,3 @@ 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 75fb9206ae9..f872bb8c12a 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "trans.h"
 #include "trans-const.h"
 #include "trans-types.h"
+#include "trans-array.h"
 
 
 /* Array descriptor low level access routines.
@@ -414,3 +415,50 @@ gfc_build_null_descriptor (tree type)
 #undef STRIDE_SUBFIELD
 #undef LBOUND_SUBFIELD
 #undef UBOUND_SUBFIELD
+
+
+/* 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);
+}
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 44c8f6f1215..826a6ce8829 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -54,4 +54,7 @@ void gfc_get_descriptor_offsets_for_info (const_tree, tree *, 
tree *, tree *,
 /* Build a null array descriptor constructor.  */
 tree gfc_build_null_descriptor (tree type);
 
+tree gfc_conv_descriptor_size (tree, int);
+tree gfc_conv_descriptor_cosize (tree, int, int);
+
 #endif /* GFC_TRANS_DESCRIPTOR_H */
-- 
2.51.0

Reply via email to