annotate gcc/ada/layout.ads @ 145:1830386684a0

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