gcc/ada/ 2012-01-28 Mikael Pettersson PR ada/51483 * gcc-interface/misc.c (enumerate_modes): Pass both precision and bitsize to callback function. Adjust prototype of callback function. gcc-interface/gigi.h (enumerate_modes): Likewise. back_end.ads (Register_Type_Proc): Likewise. cstand.adb (Register_Float_Type): Likewise. Use given precision rather than deriving it incorrectly from size. --- gcc-4.7-20120128/gcc/ada/back_end.ads.~1~ 2011-08-04 10:33:14.000000000 +0200 +++ gcc-4.7-20120128/gcc/ada/back_end.ads 2012-01-30 15:31:23.000000000 +0100 @@ -55,6 +55,7 @@ package Back_End is Complex : Boolean; -- True iff type has real and imaginary parts Count : Natural; -- Number of elements in vector, 0 otherwise Float_Rep : Float_Rep_Kind; -- Representation used for fpt type + Prec : Positive; -- Precision in bits Size : Positive; -- Size of representation in bits Alignment : Natural); -- Required alignment in bits pragma Convention (C, Register_Type_Proc); --- gcc-4.7-20120128/gcc/ada/cstand.adb.~1~ 2011-12-12 11:30:49.000000000 +0100 +++ gcc-4.7-20120128/gcc/ada/cstand.adb 2012-01-30 15:37:04.000000000 +0100 @@ -151,6 +151,7 @@ package body CStand is Complex : Boolean; -- True iff type has real and imaginary parts Count : Natural; -- Number of elements in vector, 0 otherwise Float_Rep : Float_Rep_Kind; -- Representation used for fpt type + Prec : Positive; -- Precision in bits Size : Positive; -- Size of representation in bits Alignment : Natural); -- Required alignment in bits pragma Convention (C, Register_Float_Type); @@ -2015,6 +2016,7 @@ package body CStand is Complex : Boolean; Count : Natural; Float_Rep : Float_Rep_Kind; + Prec : Positive; Size : Positive; Alignment : Natural) is @@ -2064,7 +2066,7 @@ package body CStand is else Write_Str ("mod 2**"); - Write_Int (Int (Size / Positive'Max (1, Count))); + Write_Int (Int (Prec / Positive'Max (1, Count))); Write_Line (";"); end if; @@ -2101,7 +2103,7 @@ package body CStand is Make_Name (Ent, T (1 .. Last)); Set_Scope (Ent, Standard_Standard); Build_Float_Type (Ent, Esize, Float_Rep, Pos (Digs)); - Set_RM_Size (Ent, UI_From_Int (Int (Size))); + Set_RM_Size (Ent, UI_From_Int (Int (Prec))); Set_Alignment (Ent, UI_From_Int (Int (Alignment / 8))); if No (Back_End_Float_Types) then --- gcc-4.7-20120128/gcc/ada/gcc-interface/gigi.h.~1~ 2012-01-27 10:22:36.000000000 +0100 +++ gcc-4.7-20120128/gcc/ada/gcc-interface/gigi.h 2012-01-30 15:14:21.000000000 +0100 @@ -992,7 +992,7 @@ extern Nat get_target_double_scalar_alig /* This function is called by the front-end to enumerate all the supported modes for the machine, as well as some predefined C types. */ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int, - int)); + int, int)); #ifdef __cplusplus } --- gcc-4.7-20120128/gcc/ada/gcc-interface/misc.c.~1~ 2011-10-26 22:45:09.000000000 +0200 +++ gcc-4.7-20120128/gcc/ada/gcc-interface/misc.c 2012-01-30 15:29:39.000000000 +0100 @@ -648,11 +648,12 @@ must_pass_by_ref (tree gnu_type) COMPLEX_P nonzero is this represents a complex mode COUNT count of number of items, nonzero for vector mode FLOAT_REP Float_Rep_Kind for FP, otherwise undefined + PREC number of bits of precision SIZE number of bits used to store data ALIGN number of bits to which mode is aligned. */ void -enumerate_modes (void (*f) (const char *, int, int, int, int, int, int)) +enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int)) { const tree c_types[] = { float_type_node, double_type_node, long_double_type_node }; @@ -735,9 +736,11 @@ enumerate_modes (void (*f) (const char * if (TYPE_MODE (typ) == i) { + int prec = TYPE_PRECISION (typ); + int size = float_p ? fp_prec_to_size (prec) : prec; f (nam, digs, complex_p, vector_p ? GET_MODE_NUNITS (i) : 0, float_rep, - TYPE_PRECISION (typ), TYPE_ALIGN (typ)); + prec, size, TYPE_ALIGN (typ)); skip_p = true; } } @@ -747,7 +750,7 @@ enumerate_modes (void (*f) (const char * if (!skip_p) f (GET_MODE_NAME (i), digs, complex_p, vector_p ? GET_MODE_NUNITS (i) : 0, float_rep, - GET_MODE_PRECISION (i), GET_MODE_ALIGNMENT (i)); + GET_MODE_PRECISION (i), GET_MODE_BITSIZE (i), GET_MODE_ALIGNMENT (i)); } }