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.8.0/gcc/ada/back_end.ads.~1~ 2011-08-04 10:33:14.000000000 +0200 +++ gcc-4.8.0/gcc/ada/back_end.ads 2013-03-23 17:17:20.772432317 +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.8.0/gcc/ada/cstand.adb.~1~ 2012-10-01 11:41:22.000000000 +0200 +++ gcc-4.8.0/gcc/ada/cstand.adb 2013-03-23 17:17:20.772432317 +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); @@ -2014,6 +2015,7 @@ package body CStand is Complex : Boolean; Count : Natural; Float_Rep : Float_Rep_Kind; + Prec : Positive; Size : Positive; Alignment : Natural) is @@ -2063,7 +2065,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; @@ -2100,7 +2102,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.8.0/gcc/ada/gcc-interface/gigi.h.~1~ 2013-02-06 14:19:20.000000000 +0100 +++ gcc-4.8.0/gcc/ada/gcc-interface/gigi.h 2013-03-23 17:17:20.772432317 +0100 @@ -1016,7 +1016,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.8.0/gcc/ada/gcc-interface/misc.c.~1~ 2013-01-02 11:45:00.000000000 +0100 +++ gcc-4.8.0/gcc/ada/gcc-interface/misc.c 2013-03-23 17:17:20.772432317 +0100 @@ -664,11 +664,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 }; @@ -751,9 +752,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; } } @@ -763,7 +766,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)); } }