comparison gcc/ada/layout.adb @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
4 -- -- 4 -- --
5 -- L A Y O U T -- 5 -- L A Y O U T --
6 -- -- 6 -- --
7 -- B o d y -- 7 -- B o d y --
8 -- -- 8 -- --
9 -- Copyright (C) 2001-2018, Free Software Foundation, Inc. -- 9 -- Copyright (C) 2001-2019, Free Software Foundation, Inc. --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
433 Set_Alignment (E, Alignment (PAT)); 433 Set_Alignment (E, Alignment (PAT));
434 end if; 434 end if;
435 end; 435 end;
436 end if; 436 end if;
437 437
438 -- If Esize is set, and RM_Size is not, RM_Size is copied from Esize. 438 -- For array base types, set the component size if object size of the
439 -- At least for now this seems reasonable, and is in any case needed
440 -- for compatibility with old versions of gigi.
441
442 if Known_Esize (E) and then Unknown_RM_Size (E) then
443 Set_RM_Size (E, Esize (E));
444 end if;
445
446 -- For array base types, set component size if object size of the
447 -- component type is known and is a small power of 2 (8, 16, 32, 64), 439 -- component type is known and is a small power of 2 (8, 16, 32, 64),
448 -- since this is what will always be used. 440 -- since this is what will always be used, except if a very large
441 -- alignment was specified and so Adjust_Esize_For_Alignment gave up
442 -- because, in this case, the object size is not a multiple of the
443 -- alignment and, therefore, cannot be the component size.
449 444
450 if Ekind (E) = E_Array_Type and then Unknown_Component_Size (E) then 445 if Ekind (E) = E_Array_Type and then Unknown_Component_Size (E) then
451 declare 446 declare
452 CT : constant Entity_Id := Component_Type (E); 447 CT : constant Entity_Id := Component_Type (E);
453 448
456 -- just do this for scalar types ??? 451 -- just do this for scalar types ???
457 452
458 if Present (CT) 453 if Present (CT)
459 and then Is_Scalar_Type (CT) 454 and then Is_Scalar_Type (CT)
460 and then Known_Static_Esize (CT) 455 and then Known_Static_Esize (CT)
456 and then not (Known_Alignment (CT)
457 and then Alignment_In_Bits (CT) >
458 Standard_Long_Long_Integer_Size)
461 then 459 then
462 declare 460 declare
463 S : constant Uint := Esize (CT); 461 S : constant Uint := Esize (CT);
464 begin 462 begin
465 if Addressable (S) then 463 if Addressable (S) then
756 then 754 then
757 Align := System_Word_Size / SSU; 755 Align := System_Word_Size / SSU;
758 end if; 756 end if;
759 757
760 -- Check components. If any component requires a higher alignment, 758 -- Check components. If any component requires a higher alignment,
761 -- then we set that higher alignment in any case. Don't do this if 759 -- then we set that higher alignment in any case. Don't do this if we
762 -- we have Optimize_Alignment set to Space. Note that that covers 760 -- have Optimize_Alignment set to Space. Note that covers the case of
763 -- the case of packed records, where we already set alignment to 1. 761 -- packed records, where we already set alignment to 1.
764 762
765 if not Optimize_Alignment_Space (E) then 763 if not Optimize_Alignment_Space (E) then
766 declare 764 declare
767 Comp : Entity_Id; 765 Comp : Entity_Id;
768 766