aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-11-19 11:04:52 +0100
committerEric Botcazou <ebotcazou@adacore.com>2020-11-19 11:04:52 +0100
commit43a0debd527b75eb564cad6bd47f5d5bb301dfad (patch)
treeda21597c3e40f05e45153c7ba9c0bedfb42495d1 /gcc/ada/gcc-interface/decl.c
parent0d8290959ecf2c5f1dd062e57782b5e91be0f8f6 (diff)
downloadgcc-43a0debd527b75eb564cad6bd47f5d5bb301dfad.zip
gcc-43a0debd527b75eb564cad6bd47f5d5bb301dfad.tar.gz
gcc-43a0debd527b75eb564cad6bd47f5d5bb301dfad.tar.bz2
Enhance debug info for fixed-point types
The Ada language supports fixed-point types as first-class citizens so they need to be described as-is in the debug info. We devised the langhook get_fixed_point_type_info for this purpose a few years ago, but it comes with a limitation for the representation of the scale factor that we would need to lift in order to be able to represent more fixed-point types. gcc/ChangeLog: * dwarf2out.h (struct fixed_point_type_info) <scale_factor>: Turn numerator and denominator into a tree. * dwarf2out.c (base_type_die): In the case of a fixed-point type with arbitrary scale factor, call add_scalar_info on numerator and denominator to emit the appropriate attributes. gcc/ada/ChangeLog: * exp_dbug.adb (Is_Handled_Scale_Factor): Delete. (Get_Encoded_Name): Do not call it. * gcc-interface/decl.c (gnat_to_gnu_entity) <Fixed_Point_Type>: Tidy up and always use a meaningful description for arbitrary scale factors. * gcc-interface/misc.c (gnat_get_fixed_point_type_info): Remove obsolete block and adjust the description of the scale factor.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index fa17ad9..a0f17b1 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -1743,24 +1743,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_type = make_signed_type (esize);
- /* Try to decode the scale factor and to save it for the fixed-point
- types debug hook. */
-
- /* There are various ways to describe the scale factor, however there
- are cases where back-end internals cannot hold it. In such cases,
- we output invalid scale factor for such cases (i.e. the 0/0
- rational constant) but we expect GNAT to output GNAT encodings,
- then. Thus, keep this in sync with
- Exp_Dbug.Is_Handled_Scale_Factor. */
-
/* When encoded as 1/2**N or 1/10**N, describe the scale factor as a
binary or decimal scale: it is easier to read for humans. */
if (UI_Eq (Numerator (gnat_small_value), Uint_1)
&& (Rbase (gnat_small_value) == 2
|| Rbase (gnat_small_value) == 10))
{
- /* Given RM restrictions on 'Small values, we assume here that
- the denominator fits in an int. */
tree base
= build_int_cst (integer_type_node, Rbase (gnat_small_value));
tree exponent
@@ -1773,29 +1761,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
base, exponent));
}
- /* Default to arbitrary scale factors descriptions. */
- else
+ /* Use the arbitrary scale factor description. Note that we support
+ a Small_Value whose magnitude is larger than 64-bit even on 32-bit
+ platforms, so we unconditionally use a (dummy) 128-bit type. */
{
- const Uint num = Norm_Num (gnat_small_value);
- const Uint den = Norm_Den (gnat_small_value);
+ const Uint gnat_num = Norm_Num (gnat_small_value);
+ const Uint gnat_den = Norm_Den (gnat_small_value);
+ tree gnu_small_type = make_unsigned_type (128);
+ tree gnu_num = UI_To_gnu (gnat_num, gnu_small_type);
+ tree gnu_den = UI_To_gnu (gnat_den, gnu_small_type);
- if (UI_Is_In_Int_Range (num) && UI_Is_In_Int_Range (den))
- {
- tree gnu_num
- = build_int_cst (integer_type_node,
- UI_To_Int (Norm_Num (gnat_small_value)));
- tree gnu_den
- = build_int_cst (integer_type_node,
- UI_To_Int (Norm_Den (gnat_small_value)));
- scale_factor = build2 (RDIV_EXPR, integer_type_node,
- gnu_num, gnu_den);
- }
- else
- /* If compiler internals cannot represent arbitrary scale
- factors, output an invalid scale factor so that debugger
- don't try to handle them but so that we still have a type
- in the output. Note that GNAT */
- scale_factor = integer_zero_node;
+ scale_factor
+ = build2 (RDIV_EXPR, gnu_small_type, gnu_num, gnu_den);
}
TYPE_FIXED_POINT_P (gnu_type) = 1;