From d7b5bab3bb6269b34dca50e7cd6a0a47bee0fd18 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 13 Mar 2014 15:43:01 +0000 Subject: [PATCH] PR ada/51483 * back_end.ads (Register_Type_Proc): Add 'precision' parameter. * cstand.adb (Register_Float_Type): Add 'precision' parameter and use it to set the RM size. Use directly 'size' for the Esize. * gcc-interface/gigi.h (enumerate_modes): Add integer parameter. * gcc-interface/misc.c (enumerate_modes): Likewise. Do not register types for vector modes, pass the size in addition to the precision. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@208548 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/back_end.ads | 1 + gcc/ada/cstand.adb | 27 +++++++++++++++++++-------- gcc/ada/gcc-interface/gigi.h | 2 +- gcc/ada/gcc-interface/misc.c | 25 ++++++++++++------------- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e8b55eb77e3..25cf0ddbed3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2014-03-13 Eric Botcazou + + PR ada/51483 + * back_end.ads (Register_Type_Proc): Add 'precision' parameter. + * cstand.adb (Register_Float_Type): Add 'precision' parameter and use + it to set the RM size. Use directly 'size' for the Esize. + * gcc-interface/gigi.h (enumerate_modes): Add integer parameter. + * gcc-interface/misc.c (enumerate_modes): Likewise. Do not register + types for vector modes, pass the size in addition to the precision. + 2014-01-12 Eric Botcazou PR ada/59772 diff --git a/gcc/ada/back_end.ads b/gcc/ada/back_end.ads index bfa2eb5b440..9d92ce39c5c 100644 --- a/gcc/ada/back_end.ads +++ b/gcc/ada/back_end.ads @@ -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 + Precision : Positive; -- Precision of representation in bits Size : Positive; -- Size of representation in bits Alignment : Natural); -- Required alignment in bits pragma Convention (C, Register_Type_Proc); diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index c77afd2dc3c..5ec425cca49 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -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 + Precision : Positive; -- Precision of representation 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; + Precision : Positive; Size : Positive; Alignment : Natural) is @@ -2064,13 +2066,24 @@ package body CStand is else Write_Str ("mod 2**"); - Write_Int (Int (Size / Positive'Max (1, Count))); + Write_Int (Int (Precision / Positive'Max (1, Count))); Write_Line (";"); end if; - Write_Str ("for " & T & "'Size use "); - Write_Int (Int (Size)); - Write_Line (";"); + if Precision = Size then + Write_Str ("for " & T (1 .. Last) & "'Size use "); + Write_Int (Int (Size)); + Write_Line (";"); + + else + Write_Str ("for " & T (1 .. Last) & "'Value_Size use "); + Write_Int (Int (Precision)); + Write_Line (";"); + + Write_Str ("for " & T (1 .. Last) & "'Object_Size use "); + Write_Int (Int (Size)); + Write_Line (";"); + end if; Write_Str ("for " & T & "'Alignment use "); Write_Int (Int (Alignment / 8)); @@ -2093,15 +2106,13 @@ package body CStand is if Digs > 0 and then not Complex and then Count = 0 then declare Ent : constant Entity_Id := New_Standard_Entity; - Esize : constant Pos := Pos ((Size + Alignment - 1) - / Alignment * Alignment); begin Set_Defining_Identifier (New_Node (N_Full_Type_Declaration, Stloc), Ent); 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))); + Build_Float_Type (Ent, Int (Size), Float_Rep, Pos (Digs)); + Set_RM_Size (Ent, UI_From_Int (Int (Precision))); Set_Alignment (Ent, UI_From_Int (Int (Alignment / 8))); if No (Back_End_Float_Types) then diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 5a766b4515d..9651aea1ff1 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -992,7 +992,7 @@ extern Nat get_target_double_scalar_alignment (void); /* 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 } diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 08ca5bb92b3..d6296b46b28 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -632,7 +632,7 @@ must_pass_by_ref (tree gnu_type) /* This function is called by the front-end to enumerate all the supported modes for the machine, as well as some predefined C types. F is a function which is called back with the parameters as listed below, first a string, - then six ints. The name is any arbitrary null-terminated string and has + then seven ints. The name is any arbitrary null-terminated string and has no particular significance, except for the case of predefined C types, where it should be the name of the C type. For integer types, only signed types should be listed, unsigned versions are assumed. The order of types should @@ -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 - SIZE number of bits used to store data + PRECISION number of bits used to store data + SIZE number of bits occupied by the mode 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 }; @@ -726,28 +727,26 @@ enumerate_modes (void (*f) (const char *, int, int, int, int, int, int)) /* First register any C types for this mode that the front end may need to know about, unless the mode should be skipped. */ - - if (!skip_p) + if (!skip_p && !vector_p) for (nameloop = 0; nameloop < ARRAY_SIZE (c_types); nameloop++) { - tree typ = c_types[nameloop]; - const char *nam = c_names[nameloop]; + tree type = c_types[nameloop]; + const char *name = c_names[nameloop]; - if (TYPE_MODE (typ) == i) + if (TYPE_MODE (type) == i) { - f (nam, digs, complex_p, - vector_p ? GET_MODE_NUNITS (i) : 0, float_rep, - TYPE_PRECISION (typ), TYPE_ALIGN (typ)); + f (name, digs, complex_p, 0, float_rep, TYPE_PRECISION (type), + TREE_INT_CST_LOW (TYPE_SIZE (type)), TYPE_ALIGN (type)); skip_p = true; } } /* If no predefined C types were found, register the mode itself. */ - 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)); } } -- 2.11.0