aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2015-12-17 14:09:55 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2015-12-17 14:09:55 +0000
commit2971780e404ebe8f3094c4d014b258b5c337959d (patch)
tree95d7a868396094336050add983f43966dd2afabf /gcc/dwarf2out.c
parenteb59e42800b805e0bcced98ad2383c66a5839acc (diff)
downloadgcc-2971780e404ebe8f3094c4d014b258b5c337959d.zip
gcc-2971780e404ebe8f3094c4d014b258b5c337959d.tar.gz
gcc-2971780e404ebe8f3094c4d014b258b5c337959d.tar.bz2
DWARF: add a language hook for fixed-point types
Support for fixed-point types in GCC is not powerful enough for Ada fixed-point types: GNAT uses regular scalar types to implement them. This new language hook makes it possible to output the desired debugging information anyway. gcc/ada/ChangeLog: * gcc-interface/ada-tree.def (POWER_EXPR): New binary operation. * gcc-interface/ada-tree.h (TYPE_FIXED_POINT_P): New macro. (TYPE_IS_FIXED_POINT_P): New macro. (TYPE_SCALE_FACTOR): New macro. (SET_TYPE_SCALE_FACTOR): New macro. * gcc-interface/decl.c: Include urealp.h (gnat_to_gnu_entity): Attach trees to encode scale factors to fixed-point types. * gcc-interface/misc.c (gnat_print_type): Print scale factors for fixed-point types. (gnat_get_fixed_point_type_info): New. (gnat_init_ts): Initialize data for the POWER_EXPR binary operation. (LANG_HOOKS_GET_FIXED_POINT_INFO): Redefine macro to implement the get_fixed_point_type_info language hook. gcc/ChangeLog: * langhooks.h (struct lang_hooks_for_types): Add a get_fixed_point_type_info field. * langhooks-def.h (LANG_HOOKS_GET_FIXED_POINT_TYPE_INFO): New macro. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Initialize the get_fixed_point_type_info field. * dwarf2out.h (enum fixed_point_scale_factor): New. (struct fixed_point_type_info): New. * dwarf2out.c (base_type_die): In DWARFv3 or non-strict DWARF mode, get fixed-point type information using the debugging hook and describe it in DWARF, if any. From-SVN: r231764
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 800f283..538b76d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10807,6 +10807,8 @@ base_type_die (tree type)
{
dw_die_ref base_type_result;
enum dwarf_type encoding;
+ bool fpt_used = false;
+ struct fixed_point_type_info fpt_info;
if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE)
return 0;
@@ -10833,6 +10835,19 @@ base_type_die (tree type)
break;
}
}
+ if ((dwarf_version >= 3 || !dwarf_strict)
+ && lang_hooks.types.get_fixed_point_type_info)
+ {
+ memset (&fpt_info, 0, sizeof (fpt_info));
+ if (lang_hooks.types.get_fixed_point_type_info (type, &fpt_info))
+ {
+ fpt_used = true;
+ encoding = ((TYPE_UNSIGNED (type))
+ ? DW_ATE_unsigned_fixed
+ : DW_ATE_signed_fixed);
+ break;
+ }
+ }
if (TYPE_STRING_FLAG (type))
{
if (TYPE_UNSIGNED (type))
@@ -10891,6 +10906,43 @@ base_type_die (tree type)
add_AT_unsigned (base_type_result, DW_AT_byte_size,
int_size_in_bytes (type));
add_AT_unsigned (base_type_result, DW_AT_encoding, encoding);
+
+ if (fpt_used)
+ {
+ switch (fpt_info.scale_factor_kind)
+ {
+ case fixed_point_scale_factor_binary:
+ add_AT_int (base_type_result, DW_AT_binary_scale,
+ fpt_info.scale_factor.binary);
+ break;
+
+ case fixed_point_scale_factor_decimal:
+ add_AT_int (base_type_result, DW_AT_decimal_scale,
+ fpt_info.scale_factor.decimal);
+ break;
+
+ case fixed_point_scale_factor_arbitrary:
+ /* Arbitrary scale factors cannot be described in standard DWARF,
+ yet. */
+ if (!dwarf_strict)
+ {
+ /* Describe the scale factor as a rational constant. */
+ const dw_die_ref scale_factor
+ = new_die (DW_TAG_constant, comp_unit_die (), type);
+
+ add_AT_unsigned (scale_factor, DW_AT_GNU_numerator,
+ fpt_info.scale_factor.arbitrary.numerator);
+ add_AT_int (scale_factor, DW_AT_GNU_denominator,
+ fpt_info.scale_factor.arbitrary.denominator);
+
+ add_AT_die_ref (base_type_result, DW_AT_small, scale_factor);
+ }
+ break;
+
+ default:
+ gcc_unreachable ();
+ }
+ }
add_pubtype (type, base_type_result);
return base_type_result;