Commit 616743a8 by Pierre-Marie de Rodat Committed by Pierre-Marie de Rodat

Complete information generated through the array descriptor language hook

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
parent b86d271e
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> 2014-12-17 H.J. Lu <hongjiu.lu@intel.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
Uros Bizjak <ubizjak@gmail.com> Uros Bizjak <ubizjak@gmail.com>
...@@ -17460,18 +17460,25 @@ static void ...@@ -17460,18 +17460,25 @@ static void
gen_descr_array_type_die (tree type, struct array_descr_info *info, gen_descr_array_type_die (tree type, struct array_descr_info *info,
dw_die_ref context_die) dw_die_ref context_die)
{ {
dw_die_ref scope_die = scope_die_for (type, context_die); const dw_die_ref scope_die = scope_die_for (type, context_die);
dw_die_ref array_die; const dw_die_ref array_die = new_die (DW_TAG_array_type, scope_die, type);
int dim; int dim;
array_die = new_die (DW_TAG_array_type, scope_die, type);
add_name_attribute (array_die, type_tag (type)); add_name_attribute (array_die, type_tag (type));
equate_type_number_to_die (type, array_die); equate_type_number_to_die (type, array_die);
/* For Fortran multidimensional arrays use DW_ORD_col_major ordering. */ if (info->ndimensions > 1)
if (is_fortran () switch (info->ordering)
&& info->ndimensions >= 2) {
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); add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
break;
default:
break;
}
if (info->data_location) if (info->data_location)
add_descr_info_field (array_die, DW_AT_data_location, 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, ...@@ -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, add_descr_info_field (array_die, DW_AT_allocated, info->allocated,
info->base_decl); info->base_decl);
add_gnat_descriptive_type_attribute (array_die, type, context_die);
for (dim = 0; dim < info->ndimensions; dim++) for (dim = 0; dim < info->ndimensions; dim++)
{ {
dw_die_ref subrange_die dw_die_ref subrange_die
= new_die (DW_TAG_subrange_type, array_die, NULL); = 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 (info->dimen[dim].lower_bound)
{ {
/* If it is the default value, omit it. */ /* If it is the default value, omit it. */
...@@ -20097,24 +20110,27 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die, ...@@ -20097,24 +20110,27 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
return; 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
now. (Vectors are special because the debugging info is in the
cloned type itself). */
if (TREE_CODE (type) != VECTOR_TYPE)
type = type_main_variant (type);
/* If this is an array type with hidden descriptor, handle it first. */ /* If this is an array type with hidden descriptor, handle it first. */
if (!TREE_ASM_WRITTEN (type) if (!TREE_ASM_WRITTEN (type)
&& lang_hooks.types.get_array_descr_info && lang_hooks.types.get_array_descr_info
&& lang_hooks.types.get_array_descr_info (type, &info)
&& (dwarf_version >= 3 || !dwarf_strict)) && (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); gen_descr_array_type_die (type, &info, context_die);
TREE_ASM_WRITTEN (type) = 1; TREE_ASM_WRITTEN (type) = 1;
return; 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
now. (Vectors are special because the debugging info is in the
cloned type itself). */
if (TREE_CODE (type) != VECTOR_TYPE)
type = type_main_variant (type);
if (TREE_ASM_WRITTEN (type)) if (TREE_ASM_WRITTEN (type))
return; return;
......
...@@ -261,9 +261,17 @@ extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *)); ...@@ -261,9 +261,17 @@ extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
extern void dwarf2out_vms_debug_main_pointer (void); extern void dwarf2out_vms_debug_main_pointer (void);
#endif #endif
enum array_descr_ordering
{
array_descr_ordering_default,
array_descr_ordering_row_major,
array_descr_ordering_column_major
};
struct array_descr_info struct array_descr_info
{ {
int ndimensions; int ndimensions;
enum array_descr_ordering ordering;
tree element_type; tree element_type;
tree base_decl; tree base_decl;
tree data_location; tree data_location;
...@@ -271,6 +279,10 @@ struct array_descr_info ...@@ -271,6 +279,10 @@ struct array_descr_info
tree associated; tree associated;
struct array_descr_dimen 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 lower_bound;
tree upper_bound; tree upper_bound;
tree stride; tree stride;
......
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> 2014-12-17 Tobias Burnus <burnus@net-b.de>
PR fortran/54687 PR fortran/54687
......
...@@ -3044,6 +3044,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info) ...@@ -3044,6 +3044,7 @@ gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
memset (info, '\0', sizeof (*info)); memset (info, '\0', sizeof (*info));
info->ndimensions = rank; info->ndimensions = rank;
info->ordering = array_descr_ordering_column_major;
info->element_type = etype; info->element_type = etype;
ptype = build_pointer_type (gfc_array_index_type); ptype = build_pointer_type (gfc_array_index_type);
base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect); base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment