]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/51483 (cstand.adb:Register_Float_Type makes invalid assumption about FP...
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 13 Mar 2014 15:43:01 +0000 (15:43 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 13 Mar 2014 15:43:01 +0000 (15:43 +0000)
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.

From-SVN: r208548

gcc/ada/ChangeLog
gcc/ada/back_end.ads
gcc/ada/cstand.adb
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/misc.c

index e8b55eb77e314ac76aa77874b9b468831ace8447..25cf0ddbed3b1876e636e972c9bfd58c4798d831 100644 (file)
@@ -1,3 +1,13 @@
+2014-03-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       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  <ebotcazou@adacore.com>
 
        PR ada/59772
index bfa2eb5b440da98a642cd75de3d3cef91d819b0a..9d92ce39c5ceb3a7f0c92e0f3da97150e1381f7c 100644 (file)
@@ -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);
index c77afd2dc3c3bfe4a41fe681e33a062d0039b4aa..5ec425cca49b19340dac4daabcc3a7d70fde4a3e 100644 (file)
@@ -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
index 5a766b4515d33f2c6f5dc391b06f90f5fc890e6a..9651aea1ff11762a052e2c58da6dd2c58baa9419 100644 (file)
@@ -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
 }
index 08ca5bb92b33df693332bb2fc021e47243b6accd..d6296b46b282053a127c1815387276cccbf25490 100644 (file)
@@ -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));
     }
 }