diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
commit | a926878ddbd5a98b272c22171ce58663fc04c3e0 (patch) | |
tree | 86af256e5d9a9c06263c00adc90e5fe348008c43 /gcc/ada/gcc-interface/misc.c | |
parent | 542730f087133690b47e036dfd43eb0db8a650ce (diff) | |
parent | 07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff) | |
download | gcc-devel/autopar_devel.zip gcc-devel/autopar_devel.tar.gz gcc-devel/autopar_devel.tar.bz2 |
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r-- | gcc/ada/gcc-interface/misc.c | 153 |
1 files changed, 54 insertions, 99 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index d68b373..3999f9c 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2019, Free Software Foundation, Inc. * + * Copyright (C) 1992-2020, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -47,6 +47,7 @@ #include "atree.h" #include "namet.h" #include "nlists.h" +#include "snames.h" #include "uintp.h" #include "fe.h" #include "sinfo.h" @@ -164,7 +165,6 @@ gnat_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, /* These are handled by the front-end. */ break; - case OPT_fopenacc: case OPT_fshort_enums: case OPT_fsigned_char: case OPT_funsigned_char: @@ -417,7 +417,8 @@ gnat_init_gcc_eh (void) } else { - flag_non_call_exceptions = 1; + if (!global_options_set.x_flag_non_call_exceptions) + flag_non_call_exceptions = 1; flag_aggressive_loop_optimizations = 0; warn_aggressive_loop_optimizations = 0; } @@ -466,9 +467,6 @@ gnat_print_decl (FILE *file, tree node, int indent) if (DECL_LOOP_PARM_P (node)) print_node (file, "induction var", DECL_INDUCTION_VAR (node), indent + 4); - else - print_node (file, "renamed object", DECL_RENAMED_OBJECT (node), - indent + 4); break; default: @@ -601,20 +599,10 @@ gnat_enum_underlying_base_type (const_tree) static tree gnat_get_debug_type (const_tree type) { - if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type)) - { - type = TYPE_DEBUG_TYPE (type); - - /* ??? The get_debug_type language hook is processed after the array - descriptor language hook, so if there is an array behind this type, - the latter is supposed to handle it. Still, we can get here with - a type we are not supposed to handle (e.g. when the DWARF back-end - processes the type of a variable), so keep this guard. */ - if (type && TYPE_CAN_HAVE_DEBUG_TYPE_P (type)) - return const_cast<tree> (type); - } - - return NULL_TREE; + if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type)) + return TYPE_DEBUG_TYPE (type); + else + return NULL_TREE; } /* Provide information in INFO for debugging output about the TYPE fixed-point @@ -649,14 +637,14 @@ gnat_get_fixed_point_type_info (const_tree type, if (TREE_CODE (scale_factor) == RDIV_EXPR) { - const tree num = TREE_OPERAND (scale_factor, 0); - const tree den = TREE_OPERAND (scale_factor, 1); + tree num = TREE_OPERAND (scale_factor, 0); + tree den = TREE_OPERAND (scale_factor, 1); /* See if we have a binary or decimal scale. */ if (TREE_CODE (den) == POWER_EXPR) { - const tree base = TREE_OPERAND (den, 0); - const tree exponent = TREE_OPERAND (den, 1); + tree base = TREE_OPERAND (den, 0); + tree exponent = TREE_OPERAND (den, 1); /* We expect the scale factor to be 1 / 2 ** N or 1 / 10 ** N. */ gcc_assert (num == integer_one_node @@ -785,14 +773,9 @@ static bool gnat_get_array_descr_info (const_tree const_type, struct array_descr_info *info) { - bool convention_fortran_p; - bool is_array = false; - bool is_fat_ptr = false; - bool is_packed_array = false; tree type = const_cast<tree> (const_type); - const_tree first_dimen = NULL_TREE; - const_tree last_dimen = NULL_TREE; - const_tree dimen; + tree first_dimen, dimen; + bool is_packed_array, is_array; int i; /* Temporaries created in the first pass and used in the second one for thin @@ -802,9 +785,6 @@ gnat_get_array_descr_info (const_tree const_type, tree thinptr_template_expr = NULL_TREE; tree thinptr_bound_field = NULL_TREE; - /* ??? See gnat_get_debug_type. */ - type = maybe_debug_type (type); - /* If we have an implementation type for a packed array, get the orignial array type. */ if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type)) @@ -812,6 +792,8 @@ gnat_get_array_descr_info (const_tree const_type, type = TYPE_ORIGINAL_PACKED_ARRAY (type); is_packed_array = true; } + else + is_packed_array = false; /* First pass: gather all information about this array except everything related to dimensions. */ @@ -823,54 +805,27 @@ gnat_get_array_descr_info (const_tree const_type, { is_array = true; first_dimen = type; - info->data_location = NULL_TREE; - } - - else if (TYPE_IS_FAT_POINTER_P (type) - && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) - { - const tree ua_type = TYPE_UNCONSTRAINED_ARRAY (type); - - /* This will be our base object address. */ - const tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type); - - /* We assume below that maybe_unconstrained_array returns an INDIRECT_REF - node. */ - const tree ua_val - = maybe_unconstrained_array (build_unary_op (INDIRECT_REF, - ua_type, - placeholder_expr)); - - is_fat_ptr = true; - first_dimen = TREE_TYPE (ua_val); - - /* Get the *address* of the array, not the array itself. */ - info->data_location = TREE_OPERAND (ua_val, 0); } - /* Unlike fat pointers (which appear for unconstrained arrays passed in - argument), thin pointers are used only for array access types, so we want - them to appear in the debug info as pointers to an array type. That's why - we match only the RECORD_TYPE here instead of the POINTER_TYPE with the - TYPE_IS_THIN_POINTER_P predicate. */ + /* As well as array types embedded in a record type with their bounds. */ else if (TREE_CODE (type) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (type) && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) { /* This will be our base object address. Note that we assume that - pointers to these will actually point to the array field (thin + pointers to this will actually point to the array field (thin pointers are shifted). */ - const tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type); - const tree placeholder_addr - = build_unary_op (ADDR_EXPR, NULL_TREE, placeholder_expr); + tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type); + tree placeholder_addr + = build_unary_op (ADDR_EXPR, NULL_TREE, placeholder_expr); - const tree bounds_field = TYPE_FIELDS (type); - const tree bounds_type = TREE_TYPE (bounds_field); - const tree array_field = DECL_CHAIN (bounds_field); - const tree array_type = TREE_TYPE (array_field); + tree bounds_field = TYPE_FIELDS (type); + tree bounds_type = TREE_TYPE (bounds_field); + tree array_field = DECL_CHAIN (bounds_field); + tree array_type = TREE_TYPE (array_field); - /* Shift the thin pointer address to get the address of the template. */ - const tree shift_amount + /* Shift back the address to get the address of the template. */ + tree shift_amount = fold_build1 (NEGATE_EXPR, sizetype, byte_position (array_field)); tree template_addr = build_binary_op (POINTER_PLUS_EXPR, TREE_TYPE (placeholder_addr), @@ -878,46 +833,44 @@ gnat_get_array_descr_info (const_tree const_type, template_addr = fold_convert (TYPE_POINTER_TO (bounds_type), template_addr); - first_dimen = array_type; - - /* The thin pointer is already the pointer to the array data, so there's - no need for a specific "data location" expression. */ - info->data_location = NULL_TREE; - - thinptr_template_expr = build_unary_op (INDIRECT_REF, - bounds_type, - template_addr); + thinptr_template_expr + = build_unary_op (INDIRECT_REF, NULL_TREE, template_addr); thinptr_bound_field = TYPE_FIELDS (bounds_type); + + is_array = false; + first_dimen = array_type; } + else return false; /* Second pass: compute the remaining information: dimensions and corresponding bounds. */ - if (TYPE_PACKED (first_dimen)) - is_packed_array = true; /* If this array has fortran convention, it's arranged in column-major order, so our view here has reversed dimensions. */ - convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen); + const bool convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen); + + if (TYPE_PACKED (first_dimen)) + is_packed_array = true; + /* ??? For row major ordering, we probably want to emit nothing and instead specify it as the default in Dw_TAG_compile_unit. */ info->ordering = (convention_fortran_p ? array_descr_ordering_column_major : array_descr_ordering_row_major); + info->rank = NULL_TREE; - /* Count how many dimensions this array has. */ - for (i = 0, dimen = first_dimen; ; ++i, dimen = TREE_TYPE (dimen)) + /* Count the number of dimensions and determine the element type. */ + i = 1; + dimen = TREE_TYPE (first_dimen); + while (TREE_CODE (dimen) == ARRAY_TYPE && TYPE_MULTI_ARRAY_P (dimen)) { - if (i > 0 - && (TREE_CODE (dimen) != ARRAY_TYPE - || !TYPE_MULTI_ARRAY_P (dimen))) - break; - last_dimen = dimen; + i++; + dimen = TREE_TYPE (dimen); } - info->ndimensions = i; - info->rank = NULL_TREE; + info->element_type = dimen; /* Too many dimensions? Give up generating proper description: yield instead nested arrays. Note that in this case, this hook is invoked once on each @@ -927,12 +880,10 @@ gnat_get_array_descr_info (const_tree const_type, || TYPE_MULTI_ARRAY_P (first_dimen)) { info->ndimensions = 1; - last_dimen = first_dimen; + info->element_type = TREE_TYPE (first_dimen); } - info->element_type = TREE_TYPE (last_dimen); - - /* Now iterate over all dimensions in source-order and fill the info + /* Now iterate over all dimensions in source order and fill the info structure. */ for (i = (convention_fortran_p ? info->ndimensions - 1 : 0), dimen = first_dimen; @@ -943,7 +894,7 @@ gnat_get_array_descr_info (const_tree const_type, /* We are interested in the stored bounds for the debug info. */ tree index_type = TYPE_INDEX_TYPE (TYPE_DOMAIN (dimen)); - if (is_array || is_fat_ptr) + if (is_array) { /* GDB does not handle very well the self-referencial bound expressions we are able to generate here for XUA types (they are @@ -994,6 +945,7 @@ gnat_get_array_descr_info (const_tree const_type, /* These are Fortran-specific fields. They make no sense here. */ info->allocated = NULL_TREE; info->associated = NULL_TREE; + info->data_location = NULL_TREE; if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL) { @@ -1048,6 +1000,9 @@ get_array_bit_stride (tree comp_type) if (INTEGRAL_TYPE_P (comp_type)) return TYPE_RM_SIZE (comp_type); + /* The gnat_get_array_descr_info debug hook expects a debug tyoe. */ + comp_type = maybe_debug_type (comp_type); + /* Otherwise, see if this is an array we can analyze; if it's not, punt. */ memset (&info, 0, sizeof (info)); if (!gnat_get_array_descr_info (comp_type, &info) || !info.stride) @@ -1185,7 +1140,7 @@ must_pass_by_ref (tree gnu_type) void enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int)) { - const tree c_types[] + tree const c_types[] = { float_type_node, double_type_node, long_double_type_node }; const char *const c_names[] = { "float", "double", "long double" }; |