OSDN Git Service

Delete all lines containing "$Revision:".
[pf3gnuchains/gcc-fork.git] / gcc / ada / inline.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               I N L I N E                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- GNAT was originally developed  by the GNAT team at  New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
25 --                                                                          --
26 ------------------------------------------------------------------------------
27
28 --  This module handles two kinds of inlining activity:
29
30 --  a) Instantiation of generic bodies. This is done unconditionally, after
31 --  analysis and expansion of the main unit.
32
33 --  b) Compilation of unit bodies that contain the bodies of inlined sub-
34 --  programs. This is done only if inlining is enabled (-gnatn). Full inlining
35 --  requires that a) an b) be mutually recursive, because each step may
36 --  generate another generic expansion and further inlined calls. For now each
37 --  of them uses a workpile algorithm, but they are called independently from
38 --  Frontend, and thus are not mutually recursive.
39
40 with Alloc;
41 with Table;
42 with Types;  use Types;
43
44 package Inline is
45
46    --------------------------------
47    -- Generic Body Instantiation --
48    --------------------------------
49
50    --  The bodies of generic instantiations are built after semantic analysis
51    --  of the main unit is complete. Generic instantiations are saved in a
52    --  global data structure, and the bodies constructed by means of a separate
53    --  analysis and expansion step.
54
55    --  See full description in body of Sem_Ch12 for details
56
57    type Pending_Body_Info is record
58       Inst_Node : Node_Id;
59       --  Node for instantiation that requires the body
60
61       Act_Decl : Node_Id;
62       --  Declaration for package or subprogram spec for instantiation
63
64       Expander_Status : Boolean;
65       --  If the body is instantiated only for semantic checking, expansion
66       --  must be inhibited.
67
68       Current_Sem_Unit : Unit_Number_Type;
69       --  The semantic unit within which the instantiation is found. Must
70       --  be restored when compiling the body, to insure that internal enti-
71       --  ties use the same counter and are unique over spec and body.
72    end record;
73
74    package Pending_Instantiations is new Table.Table (
75      Table_Component_Type => Pending_Body_Info,
76      Table_Index_Type     => Int,
77      Table_Low_Bound      => 0,
78      Table_Initial        => Alloc.Pending_Instantiations_Initial,
79      Table_Increment      => Alloc.Pending_Instantiations_Increment,
80      Table_Name           => "Pending_Instantiations");
81
82    --  The following table records subprograms and packages for which
83    --  generation of subprogram descriptors must be delayed.
84
85    package Pending_Descriptor is new Table.Table (
86      Table_Component_Type => Entity_Id,
87      Table_Index_Type     => Int,
88      Table_Low_Bound      => 0,
89      Table_Initial        => Alloc.Pending_Instantiations_Initial,
90      Table_Increment      => Alloc.Pending_Instantiations_Increment,
91      Table_Name           => "Pending_Descriptor");
92
93    Analyzing_Inlined_Bodies : Boolean;
94    --  This flag is set False by the call to Initialize, and then is set
95    --  True by the call to Analyze_Inlined_Bodies. It is used to suppress
96    --  generation of subprogram descriptors for inlined bodies.
97
98    -----------------
99    -- Subprograms --
100    -----------------
101
102    procedure Initialize;
103    --  Initialize internal tables
104
105    procedure Lock;
106    --  Lock internal tables before calling backend
107
108    procedure Instantiate_Bodies;
109    --  This procedure is called after semantic analysis is complete, to
110    --  instantiate the bodies of generic instantiations that appear in the
111    --  compilation unit.
112
113    procedure Add_Inlined_Body (E : Entity_Id);
114    --  E is an inlined subprogram appearing in a call, either explicitly, or
115    --  a discriminant check for which gigi builds a call.  Add E's enclosing
116    --  unit to Inlined_Bodies so that body of E can be subsequently retrieved
117    --  and analyzed.
118
119    procedure Analyze_Inlined_Bodies;
120    --  At end of compilation, analyze the bodies of all units that contain
121    --  inlined subprograms that are actually called.
122
123    procedure Check_Body_For_Inlining (N : Node_Id; P : Entity_Id);
124    --  If front-end inlining is enabled and a package declaration contains
125    --  inlined subprograms, load and compile the package body to collect the
126    --  bodies of these subprograms, so they are available to inline calls.
127    --  N is the compilation unit for the package.
128
129    procedure Remove_Dead_Instance (N : Node_Id);
130    --  If an instantiation appears in unreachable code, delete the pending
131    --  body instance.
132
133 end Inline;