Complete information generated through the array descriptor language hook
authorPierre-Marie de Rodat <derodat@adacore.com>
Wed, 17 Dec 2014 16:25:21 +0000 (16:25 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 17 Dec 2014 16:25:21 +0000 (16:25 +0000)
gcc/
* dwarf2out.h (enum array_descr_ordering): New.
(array_descr_dimen): Add a bounds_type structure field.
(struct array_descr_info): Add a field to hold index type information
and another one to hold ordering information.
* dwarf2out.c (gen_type_die_with_usage): Get the main variant before
invoking the array descriptor language hook.  Initialize the
array_descr_info structure before calling the lang-hook.
(gen_descr_array_type_die): Use gen_type_die if not processing the main
type variant.  Replace Fortran-specific code with generic one using
this new field.  Add a GNAT descriptive type, if any.  Output type
information for the array bound subrange, if any.

gcc/fortran
* trans-types.c (gfc_get_array_descr_info): Describe all Fortran arrays
with column major ordering.

From-SVN: r218823

gcc/ChangeLog
gcc/dwarf2out.c
gcc/dwarf2out.h
gcc/fortran/ChangeLog
gcc/fortran/trans-types.c

index 34d74f9..bfa03b0 100644 (file)
@@ -1,3 +1,17 @@
+2014-12-17  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * dwarf2out.h (enum array_descr_ordering): New.
+       (array_descr_dimen): Add a bounds_type structure field.
+       (struct array_descr_info): Add a field to hold index type information
+       and another one to hold ordering information.
+       * dwarf2out.c (gen_type_die_with_usage): Get the main variant before
+       invoking the array descriptor language hook.  Initialize the
+       array_descr_info structure before calling the lang-hook.
+       (gen_descr_array_type_die): Use gen_type_die if not processing the main
+       type variant.  Replace Fortran-specific code with generic one using
+       this new field.  Add a GNAT descriptive type, if any.  Output type
+       information for the array bound subrange, if any.
+
 2014-12-17  H.J. Lu  <hongjiu.lu@intel.com>
            Jakub Jelinek  <jakub@redhat.com>
            Uros Bizjak  <ubizjak@gmail.com>
index 4c2ff8d..f92d31a 100644 (file)
@@ -17460,18 +17460,25 @@ static void
 gen_descr_array_type_die (tree type, struct array_descr_info *info,
                          dw_die_ref context_die)
 {
-  dw_die_ref scope_die = scope_die_for (type, context_die);
-  dw_die_ref array_die;
+  const dw_die_ref scope_die = scope_die_for (type, context_die);
+  const dw_die_ref array_die = new_die (DW_TAG_array_type, scope_die, type);
   int dim;
 
-  array_die = new_die (DW_TAG_array_type, scope_die, type);
   add_name_attribute (array_die, type_tag (type));
   equate_type_number_to_die (type, array_die);
 
-  /* For Fortran multidimensional arrays use DW_ORD_col_major ordering.  */
-  if (is_fortran ()
-      && info->ndimensions >= 2)
-    add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
+  if (info->ndimensions > 1)
+    switch (info->ordering)
+      {
+      case array_descr_ordering_row_major:
+       add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major);
+       break;
+      case array_descr_ordering_column_major:
+       add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
+       break;
+      default:
+       break;
+      }
 
   if (info->data_location)
     add_descr_info_field (array_die, DW_AT_data_location, info->data_location,
@@ -17483,11 +17490,17 @@ gen_descr_array_type_die (tree type, struct array_descr_info *info,
     add_descr_info_field (array_die, DW_AT_allocated, info->allocated,
                          info->base_decl);
 
+  add_gnat_descriptive_type_attribute (array_die, type, context_die);
+
   for (dim = 0; dim < info->ndimensions; dim++)
     {
       dw_die_ref subrange_die
        = new_die (DW_TAG_subrange_type, array_die, NULL);
 
+      if (info->dimen[dim].bounds_type)
+       add_type_attribute (subrange_die,
+                           info->dimen[dim].bounds_type, 0,
+                           context_die);
       if (info->dimen[dim].lower_bound)
        {
          /* If it is the default value, omit it.  */
@@ -20097,17 +20110,6 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
       return;
     }
 
-  /* If this is an array type with hidden descriptor, handle it first.  */
-  if (!TREE_ASM_WRITTEN (type)
-      && lang_hooks.types.get_array_descr_info
-      && lang_hooks.types.get_array_descr_info (type, &info)
-      && (dwarf_version >= 3 || !dwarf_strict))
-    {
-      gen_descr_array_type_die (type, &info, context_die);
-      TREE_ASM_WRITTEN (type) = 1;
-      return;
-    }
-
   /* We are going to output a DIE to represent the unqualified version
      of this type (i.e. without any const or volatile qualifiers) so
      get the main variant (i.e. the unqualified version) of this type
@@ -20116,6 +20118,20 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
   if (TREE_CODE (type) != VECTOR_TYPE)
     type = type_main_variant (type);
 
+  /* If this is an array type with hidden descriptor, handle it first.  */
+  if (!TREE_ASM_WRITTEN (type)
+      && lang_hooks.types.get_array_descr_info
+      && (dwarf_version >= 3 || !dwarf_strict))
+    {
+      memset (&info, 0, sizeof (info));
+      if (lang_hooks.types.get_array_descr_info (type, &info))
+       {
+         gen_descr_array_type_die (type, &info, context_die);
+         TREE_ASM_WRITTEN (type) = 1;
+         return;
+       }
+    }
+
   if (TREE_ASM_WRITTEN (type))
     return;
 
index a10cee8..a8d68bb 100644 (file)
@@ -261,9 +261,17 @@ extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
 extern void dwarf2out_vms_debug_main_pointer (void);
 #endif
 
+enum array_descr_ordering
+{
+  array_descr_ordering_default,
+  array_descr_ordering_row_major,
+  array_descr_ordering_column_major
+};
+
 struct array_descr_info
 {
   int ndimensions;
+  enum array_descr_ordering ordering;
   tree element_type;
   tree base_decl;
   tree data_location;
@@ -271,6 +279,10 @@ struct array_descr_info
   tree associated;
   struct array_descr_dimen
     {
+      /* GCC uses sizetype for array indices, so lower_bound and upper_bound
+        will likely be "sizetype" values. However, bounds may have another
+        type in the original source code.  */
+      tree bounds_type;
       tree lower_bound;
       tree upper_bound;
       tree stride;
index 3f20d0a..edbe42a 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-17  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * trans-types.c (gfc_get_array_descr_info): Describe all Fortran arrays
+       with column major ordering.
+
 2014-12-17  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54687
index 9bf0803..cdc5897 100644 (file)
@@ -3044,6 +3044,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
 
   memset (info, '\0', sizeof (*info));
   info->ndimensions = rank;
+  info->ordering = array_descr_ordering_column_major;
   info->element_type = etype;
   ptype = build_pointer_type (gfc_array_index_type);
   base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect);