Merge from mainline (160224:163495).
[official-gcc/graphite-test-results.git] / gcc / ada / inline.ads
blob04cb3234400795184bd050dda881220c036c5664
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I N L I N E --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2010, 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 ------------------------------------------------------------------------------
26 -- This module handles two kinds of inlining activity:
28 -- a) Instantiation of generic bodies. This is done unconditionally, after
29 -- analysis and expansion of the main unit.
31 -- b) Compilation of unit bodies that contain the bodies of inlined sub-
32 -- programs. This is done only if inlining is enabled (-gnatn). Full inlining
33 -- requires that a) an b) be mutually recursive, because each step may
34 -- generate another generic expansion and further inlined calls. For now each
35 -- of them uses a workpile algorithm, but they are called independently from
36 -- Frontend, and thus are not mutually recursive.
38 with Alloc;
39 with Opt; use Opt;
40 with Sem; use Sem;
41 with Table;
42 with Types; use Types;
44 package Inline is
46 --------------------------------
47 -- Generic Body Instantiation --
48 --------------------------------
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.
55 -- See full description in body of Sem_Ch12 for more details
57 type Pending_Body_Info is record
58 Inst_Node : Node_Id;
59 -- Node for instantiation that requires the body
61 Act_Decl : Node_Id;
62 -- Declaration for package or subprogram spec for instantiation
64 Expander_Status : Boolean;
65 -- If the body is instantiated only for semantic checking, expansion
66 -- must be inhibited.
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.
73 Scope_Suppress : Suppress_Array;
74 Local_Suppress_Stack_Top : Suppress_Stack_Entry_Ptr;
75 -- Save suppress information at the point of instantiation. Used to
76 -- properly inherit check status active at this point (see RM 11.5
77 -- (7.2/2), AI95-00224-01):
79 -- "If a checking pragma applies to a generic instantiation, then the
80 -- checking pragma also applies to the instance. If a checking pragma
81 -- applies to a call to a subprogram that has a pragma Inline applied
82 -- to it, then the checking pragma also applies to the inlined
83 -- subprogram body".
85 -- This means we have to capture this information from the current scope
86 -- at the point of instantiation.
88 Version : Ada_Version_Type;
89 -- The body must be compiled with the same language version as the
90 -- spec. The version may be set by a configuration pragma in a separate
91 -- file or in the current file, and may differ from body to body.
92 end record;
94 package Pending_Instantiations is new Table.Table (
95 Table_Component_Type => Pending_Body_Info,
96 Table_Index_Type => Int,
97 Table_Low_Bound => 0,
98 Table_Initial => Alloc.Pending_Instantiations_Initial,
99 Table_Increment => Alloc.Pending_Instantiations_Increment,
100 Table_Name => "Pending_Instantiations");
102 -- The following table records subprograms and packages for which
103 -- generation of subprogram descriptors must be delayed.
105 package Pending_Descriptor is new Table.Table (
106 Table_Component_Type => Entity_Id,
107 Table_Index_Type => Int,
108 Table_Low_Bound => 0,
109 Table_Initial => Alloc.Pending_Instantiations_Initial,
110 Table_Increment => Alloc.Pending_Instantiations_Increment,
111 Table_Name => "Pending_Descriptor");
113 Analyzing_Inlined_Bodies : Boolean;
114 -- This flag is set False by the call to Initialize, and then is set
115 -- True by the call to Analyze_Inlined_Bodies. It is used to suppress
116 -- generation of subprogram descriptors for inlined bodies.
118 -----------------
119 -- Subprograms --
120 -----------------
122 procedure Initialize;
123 -- Initialize internal tables
125 procedure Lock;
126 -- Lock internal tables before calling backend
128 procedure Instantiate_Bodies;
129 -- This procedure is called after semantic analysis is complete, to
130 -- instantiate the bodies of generic instantiations that appear in the
131 -- compilation unit.
133 procedure Add_Inlined_Body (E : Entity_Id);
134 -- E is an inlined subprogram appearing in a call, either explicitly, or
135 -- a discriminant check for which gigi builds a call. Add E's enclosing
136 -- unit to Inlined_Bodies so that body of E can be subsequently retrieved
137 -- and analyzed.
139 procedure Analyze_Inlined_Bodies;
140 -- At end of compilation, analyze the bodies of all units that contain
141 -- inlined subprograms that are actually called.
143 procedure Check_Body_For_Inlining (N : Node_Id; P : Entity_Id);
144 -- If front-end inlining is enabled and a package declaration contains
145 -- inlined subprograms, load and compile the package body to collect the
146 -- bodies of these subprograms, so they are available to inline calls.
147 -- N is the compilation unit for the package.
149 procedure Remove_Dead_Instance (N : Node_Id);
150 -- If an instantiation appears in unreachable code, delete the pending
151 -- body instance.
153 end Inline;