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