From: Eric Botcazou Date: Tue, 29 May 2018 09:36:34 +0000 (+0000) Subject: [Ada] Factor out worker procedure for -gnatR X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7883c42e3ffab6c1a87e22637384cf2c80193055;p=gcc.git [Ada] Factor out worker procedure for -gnatR This extracts a worker procedure for printing the layout of a single component from List_Record_Layout so as to make the next change more readable. 2018-05-29 Eric Botcazou gcc/ada/ * repinfo.adb (List_Component_Layout): New procedure extracted from... (List_Record_Layout): ...here. Invoke it. From-SVN: r260867 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cea7085988b..fdc940eef21 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-05-29 Eric Botcazou + + * repinfo.adb (List_Component_Layout): New procedure extracted from... + (List_Record_Layout): ...here. Invoke it. + 2018-05-29 Eric Botcazou * repinfo.adb (Write_Unknown_Val): New procedure. diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 737570d31d0..071abbb1830 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -891,6 +891,13 @@ package body Repinfo is Prefix_Length : Natural := 0); -- Internal recursive procedure to compute the max length + procedure List_Component_Layout + (Ent : Entity_Id; + Starting_Position : Uint := Uint_0; + Starting_First_Bit : Uint := Uint_0; + Prefix : String := ""); + -- Procedure to display the layout of a single component + procedure List_Record_Layout (Ent : Entity_Id; Starting_Position : Uint := Uint_0; @@ -1002,6 +1009,126 @@ package body Repinfo is end loop; end Compute_Max_Length; + --------------------------- + -- List_Component_Layout -- + --------------------------- + + procedure List_Component_Layout + (Ent : Entity_Id; + Starting_Position : Uint := Uint_0; + Starting_First_Bit : Uint := Uint_0; + Prefix : String := "") + is + Esiz : constant Uint := Esize (Ent); + Npos : constant Uint := Normalized_Position (Ent); + Fbit : constant Uint := Normalized_First_Bit (Ent); + Spos : Uint; + Sbit : Uint; + Lbit : Uint; + + begin + Write_Str (" "); + Write_Str (Prefix); + Write_Str (Name_Buffer (1 .. Name_Len)); + Spaces (Max_Name_Length - Prefix'Length - Name_Len); + Write_Str (" at "); + + if Known_Static_Normalized_Position (Ent) then + Spos := Starting_Position + Npos; + Sbit := Starting_First_Bit + Fbit; + + if Sbit >= SSU then + Spos := Spos + 1; + end if; + + UI_Image (Spos); + Spaces (Max_Spos_Length - UI_Image_Length); + Write_Str (UI_Image_Buffer (1 .. UI_Image_Length)); + + elsif Known_Normalized_Position (Ent) + and then List_Representation_Info = 3 + then + Spaces (Max_Spos_Length - 2); + + if Starting_Position /= Uint_0 then + UI_Write (Starting_Position); + Write_Str (" + "); + end if; + + Write_Val (Npos); + + else + Write_Unknown_Val; + end if; + + Write_Str (" range "); + Sbit := Starting_First_Bit + Fbit; + + if Sbit >= SSU then + Sbit := Sbit - SSU; + end if; + + UI_Write (Sbit); + Write_Str (" .. "); + + -- Allowing Uint_0 here is an annoying special case. Really + -- this should be a fine Esize value but currently it means + -- unknown, except that we know after gigi has back annotated + -- that a size of zero is real, since otherwise gigi back + -- annotates using No_Uint as the value to indicate unknown. + + if (Esize (Ent) = Uint_0 or else Known_Static_Esize (Ent)) + and then Known_Static_Normalized_First_Bit (Ent) + then + Lbit := Sbit + Esiz - 1; + + if Lbit < 10 then + Write_Char (' '); + end if; + + UI_Write (Lbit); + + -- The test for Esize (Ent) not Uint_0 here is an annoying + -- special case. Officially a value of zero for Esize means + -- unknown, but here we use the fact that we know that gigi + -- annotates Esize with No_Uint, not Uint_0. Really everyone + -- should use No_Uint??? + + elsif List_Representation_Info < 3 + or else (Esize (Ent) /= Uint_0 and then Unknown_Esize (Ent)) + then + Write_Unknown_Val; + + -- List_Representation >= 3 and Known_Esize (Ent) + + else + Write_Val (Esiz, Paren => True); + + -- If in front end layout mode, then dynamic size is stored + -- in storage units, so renormalize for output + + if not Back_End_Layout then + Write_Str (" * "); + Write_Int (SSU); + end if; + + -- Add appropriate first bit offset + + if Sbit = 0 then + Write_Str (" - 1"); + + elsif Sbit = 1 then + null; + + else + Write_Str (" + "); + Write_Int (UI_To_Int (Sbit) - 1); + end if; + end if; + + Write_Line (";"); + end List_Component_Layout; + ------------------------ -- List_Record_Layout -- ------------------------ @@ -1036,12 +1163,10 @@ package body Repinfo is declare Ctyp : constant Entity_Id := Underlying_Type (Etype (Comp)); - Esiz : constant Uint := Esize (Comp); Npos : constant Uint := Normalized_Position (Comp); Fbit : constant Uint := Normalized_First_Bit (Comp); Spos : Uint; Sbit : Uint; - Lbit : Uint; begin Get_Decoded_Name_String (Chars (Comp)); @@ -1069,121 +1194,8 @@ package body Repinfo is goto Continue; end if; - Write_Str (" "); - Write_Str (Prefix); - Write_Str (Name_Buffer (1 .. Name_Len)); - - for J in 1 .. Max_Name_Length - Prefix'Length - Name_Len loop - Write_Char (' '); - end loop; - - Write_Str (" at "); - - if Known_Static_Normalized_Position (Comp) then - Spos := Starting_Position + Npos; - Sbit := Starting_First_Bit + Fbit; - - if Sbit >= SSU then - Spos := Spos + 1; - end if; - - UI_Image (Spos); - Spaces (Max_Spos_Length - UI_Image_Length); - Write_Str (UI_Image_Buffer (1 .. UI_Image_Length)); - - elsif Known_Normalized_Position (Comp) - and then List_Representation_Info = 3 - then - Spaces (Max_Spos_Length - 2); - - if Starting_Position /= Uint_0 then - UI_Write (Starting_Position); - Write_Str (" + "); - end if; - - Write_Val (Npos); - - else - -- For the packed case, we don't know the bit positions if - -- we don't know the starting position. - - if Is_Packed (Ent) then - Write_Line ("?? range ? .. ??;"); - goto Continue; - - -- Otherwise we can continue - - else - Write_Unknown_Val; - end if; - end if; - - Write_Str (" range "); - Sbit := Starting_First_Bit + Fbit; - - if Sbit >= SSU then - Sbit := Sbit - SSU; - end if; - - UI_Write (Sbit); - Write_Str (" .. "); - - -- Allowing Uint_0 here is an annoying special case. Really - -- this should be a fine Esize value but currently it means - -- unknown, except that we know after gigi has back annotated - -- that a size of zero is real, since otherwise gigi back - -- annotates using No_Uint as the value to indicate unknown. - - if (Esize (Comp) = Uint_0 or else Known_Static_Esize (Comp)) - and then Known_Static_Normalized_First_Bit (Comp) - then - Lbit := Sbit + Esiz - 1; - - if Lbit < 10 then - Write_Char (' '); - end if; - - UI_Write (Lbit); - - -- The test for Esize (Comp) not Uint_0 here is an annoying - -- special case. Officially a value of zero for Esize means - -- unknown, but here we use the fact that we know that gigi - -- annotates Esize with No_Uint, not Uint_0. Really everyone - -- should use No_Uint??? - - elsif List_Representation_Info < 3 - or else (Esize (Comp) /= Uint_0 and then Unknown_Esize (Comp)) - then - Write_Unknown_Val; - - -- List_Representation >= 3 and Known_Esize (Comp) - - else - Write_Val (Esiz, Paren => True); - - -- If in front end layout mode, then dynamic size is stored - -- in storage units, so renormalize for output - - if not Back_End_Layout then - Write_Str (" * "); - Write_Int (SSU); - end if; - - -- Add appropriate first bit offset - - if Sbit = 0 then - Write_Str (" - 1"); - - elsif Sbit = 1 then - null; - - else - Write_Str (" + "); - Write_Int (UI_To_Int (Sbit) - 1); - end if; - end if; - - Write_Line (";"); + List_Component_Layout (Comp, + Starting_Position, Starting_First_Bit, Prefix); end; <>