| 1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
| 2 |
|
|
-- --
|
| 3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
| 4 |
|
|
-- --
|
| 5 |
|
|
-- L A Y O U T --
|
| 6 |
|
|
-- --
|
| 7 |
|
|
-- S p e c --
|
| 8 |
|
|
-- --
|
| 9 |
|
|
-- Copyright (C) 2000-2007, Free Software Foundation, Inc. --
|
| 10 |
|
|
-- --
|
| 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- --
|
| 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- --
|
| 15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
| 16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
| 17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
| 18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
| 19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
| 20 |
|
|
-- --
|
| 21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
| 22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
| 23 |
|
|
-- --
|
| 24 |
|
|
------------------------------------------------------------------------------
|
| 25 |
|
|
|
| 26 |
|
|
-- This package does front-end layout of types and objects. The result is
|
| 27 |
|
|
-- to annotate the tree with information on size and alignment of types
|
| 28 |
|
|
-- and objects. How much layout is performed depends on the setting of the
|
| 29 |
|
|
-- target dependent parameter Backend_Layout.
|
| 30 |
|
|
|
| 31 |
|
|
with Types; use Types;
|
| 32 |
|
|
|
| 33 |
|
|
package Layout is
|
| 34 |
|
|
|
| 35 |
|
|
-- The following procedures are called from Freeze, so all entities
|
| 36 |
|
|
-- for types and objects that get frozen (which should be all such
|
| 37 |
|
|
-- entities which are seen by the back end) will get layed out by one
|
| 38 |
|
|
-- of these two procedures.
|
| 39 |
|
|
|
| 40 |
|
|
procedure Layout_Type (E : Entity_Id);
|
| 41 |
|
|
-- This procedure may set or adjust the fields Esize, RM_Size and
|
| 42 |
|
|
-- Alignment in the non-generic type or subtype entity E. If the
|
| 43 |
|
|
-- Backend_Layout switch is False, then it is guaranteed that all
|
| 44 |
|
|
-- three fields will be properly set on return. Regardless of the
|
| 45 |
|
|
-- Backend_Layout value, it is guaranteed that all discrete types
|
| 46 |
|
|
-- will have both Esize and RM_Size fields set on return (since
|
| 47 |
|
|
-- these are static values). Note that Layout_Type is not called
|
| 48 |
|
|
-- for generic types, since these play no part in code generation,
|
| 49 |
|
|
-- and hence representation aspects are irrelevant.
|
| 50 |
|
|
|
| 51 |
|
|
procedure Layout_Object (E : Entity_Id);
|
| 52 |
|
|
-- E is either a variable (E_Variable), a constant (E_Constant),
|
| 53 |
|
|
-- a loop parameter (E_Loop_Parameter), or a formal parameter of
|
| 54 |
|
|
-- a non-generic subprogram (E_In_Parameter, E_In_Out_Parameter,
|
| 55 |
|
|
-- or E_Out_Parameter). This procedure may set or adjust the
|
| 56 |
|
|
-- Esize and Alignment fields of E. If Backend_Layout is False,
|
| 57 |
|
|
-- then it is guaranteed that both fields will be properly set
|
| 58 |
|
|
-- on return. If the Esize is still unknown in the latter case,
|
| 59 |
|
|
-- it means that the object must be allocated dynamically, since
|
| 60 |
|
|
-- its length is not known at compile time.
|
| 61 |
|
|
|
| 62 |
|
|
-- The following are utility routines, called from various places
|
| 63 |
|
|
|
| 64 |
|
|
procedure Adjust_Esize_Alignment (E : Entity_Id);
|
| 65 |
|
|
-- E is the entity for a type or object. This procedure checks that the
|
| 66 |
|
|
-- size and alignment are compatible, and if not either gives an error
|
| 67 |
|
|
-- message if they cannot be adjusted or else adjusts them appropriately.
|
| 68 |
|
|
|
| 69 |
|
|
procedure Set_Discrete_RM_Size (Def_Id : Entity_Id);
|
| 70 |
|
|
-- Set proper RM_Size for discrete size, this is normally the minimum
|
| 71 |
|
|
-- number of bits to accommodate the range given, except in the case
|
| 72 |
|
|
-- where the subtype statically matches the first subtype, in which
|
| 73 |
|
|
-- case the size must be copied from the first subtype. For generic
|
| 74 |
|
|
-- types, the RM_Size is simply set to zero. This routine also sets
|
| 75 |
|
|
-- the Is_Constrained flag in Def_Id.
|
| 76 |
|
|
|
| 77 |
|
|
procedure Set_Elem_Alignment (E : Entity_Id);
|
| 78 |
|
|
-- The front end always sets alignments for elementary types by calling
|
| 79 |
|
|
-- this procedure. Note that we have to do this for discrete types (since
|
| 80 |
|
|
-- the Alignment attribute is static), so we might as well do it for all
|
| 81 |
|
|
-- elementary types, since the processing is the same.
|
| 82 |
|
|
|
| 83 |
|
|
end Layout;
|