Implement -mmemcpy-strategy= and -mmemset-strategy= options
[official-gcc.git] / gcc / ada / exp_ch6.ads
blobf9829f52b34b8e338da408ae6d82bf876148f7de
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ C H 6 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2013, 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 -- Expand routines for chapter 6 constructs
28 with Types; use Types;
30 package Exp_Ch6 is
32 procedure Expand_N_Extended_Return_Statement (N : Node_Id);
33 procedure Expand_N_Function_Call (N : Node_Id);
34 procedure Expand_N_Procedure_Call_Statement (N : Node_Id);
35 procedure Expand_N_Simple_Return_Statement (N : Node_Id);
36 procedure Expand_N_Subprogram_Body (N : Node_Id);
37 procedure Expand_N_Subprogram_Body_Stub (N : Node_Id);
38 procedure Expand_N_Subprogram_Declaration (N : Node_Id);
40 procedure Expand_Actuals (N : Node_Id; Subp : Entity_Id);
41 -- For each actual of an in-out or out parameter which is a numeric
42 -- (view) conversion of the form T (A), where A denotes a variable,
43 -- we insert the declaration:
45 -- Temp : T[ := T (A)];
47 -- prior to the call. Then we replace the actual with a reference to Temp,
48 -- and append the assignment:
50 -- A := TypeA (Temp);
52 -- after the call. Here TypeA is the actual type of variable A. For out
53 -- parameters, the initial declaration has no expression. If A is not an
54 -- entity name, we generate instead:
56 -- Var : TypeA renames A;
57 -- Temp : T := Var; -- omitting expression for out parameter.
58 -- ...
59 -- Var := TypeA (Temp);
61 -- For other in-out parameters, we emit the required constraint checks
62 -- before and/or after the call.
64 -- For all parameter modes, actuals that denote components and slices of
65 -- packed arrays are expanded into suitable temporaries.
67 -- For non-scalar objects that are possibly unaligned, add call by copy
68 -- code (copy in for IN and IN OUT, copy out for OUT and IN OUT).
70 procedure Expand_Call (N : Node_Id);
71 -- This procedure contains common processing for Expand_N_Function_Call,
72 -- Expand_N_Procedure_Statement, and Expand_N_Entry_Call.
74 procedure Expand_Contract_Cases
75 (CCs : Node_Id;
76 Subp_Id : Entity_Id;
77 Decls : List_Id;
78 Stmts : in out List_Id);
79 -- Given pragma Contract_Cases CCs, create the circuitry needed to evaluate
80 -- case guards and trigger consequence expressions. Subp_Id is the related
81 -- subprogram for which the pragma applies. Decls are the declarations of
82 -- Subp_Id's body. All generated code is added to list Stmts. If Stmts is
83 -- empty, a new list is created.
85 procedure Freeze_Subprogram (N : Node_Id);
86 -- generate the appropriate expansions related to Subprogram freeze
87 -- nodes (e.g. the filling of the corresponding Dispatch Table for
88 -- Primitive Operations)
90 -- The following type defines the various forms of allocation used for the
91 -- results of build-in-place function calls.
93 type BIP_Allocation_Form is
94 (Unspecified,
95 Caller_Allocation,
96 Secondary_Stack,
97 Global_Heap,
98 User_Storage_Pool);
100 type BIP_Formal_Kind is
101 -- Ada 2005 (AI-318-02): This type defines the kinds of implicit extra
102 -- formals created for build-in-place functions. The order of these
103 -- enumeration literals matches the order in which the formals are
104 -- declared. See Sem_Ch6.Create_Extra_Formals.
106 (BIP_Alloc_Form,
107 -- Present if result subtype is unconstrained or tagged. Indicates
108 -- whether the return object is allocated by the caller or callee, and
109 -- if the callee, whether to use the secondary stack or the heap. See
110 -- Create_Extra_Formals.
112 BIP_Storage_Pool,
113 -- Present if result subtype is unconstrained or tagged. If
114 -- BIP_Alloc_Form = User_Storage_Pool, this is a pointer to the pool
115 -- (of type access to Root_Storage_Pool'Class). Otherwise null.
117 BIP_Finalization_Master,
118 -- Present if result type needs finalization. Pointer to caller's
119 -- finalization master.
121 BIP_Task_Master,
122 -- Present if result type contains tasks. Master associated with
123 -- calling context.
125 BIP_Activation_Chain,
126 -- Present if result type contains tasks. Caller's activation chain
128 BIP_Object_Access);
129 -- Present for all build-in-place functions. Address at which to place
130 -- the return object, or null if BIP_Alloc_Form indicates allocated by
131 -- callee.
133 -- ??? We might also need to be able to pass in a constrained flag.
135 function BIP_Formal_Suffix (Kind : BIP_Formal_Kind) return String;
136 -- Ada 2005 (AI-318-02): Returns a string to be used as the suffix of names
137 -- for build-in-place formal parameters of the given kind.
139 function Build_In_Place_Formal
140 (Func : Entity_Id;
141 Kind : BIP_Formal_Kind) return Entity_Id;
142 -- Ada 2005 (AI-318-02): Locates and returns the entity for the implicit
143 -- build-in-place formal parameter of the given kind associated with the
144 -- function Func, and returns its Entity_Id. It is a bug if not found; the
145 -- caller should ensure this is called only when the extra formal exists.
147 function Is_Build_In_Place_Function (E : Entity_Id) return Boolean;
148 -- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic
149 -- function, or access-to-function type whose result must be built in
150 -- place; otherwise returns False. For Ada 2005, this is currently
151 -- restricted to the set of functions whose result subtype is an inherently
152 -- limited type. In Ada 95, this must be False for inherently limited
153 -- result types (but currently returns False for all Ada 95 functions).
154 -- Eventually we plan to support build-in-place for nonlimited types.
155 -- Build-in-place is usually more efficient for large things, and less
156 -- efficient for small things. However, we never use build-in-place if the
157 -- convention is other than Ada, because that would disturb mixed-language
158 -- programs. Note that for the non-inherently-limited cases, we must make
159 -- the same decision for Ada 95 and 2005, so that mixed-dialect programs
160 -- will work.
162 function Is_Build_In_Place_Function_Call (N : Node_Id) return Boolean;
163 -- Ada 2005 (AI-318-02): Returns True if N denotes a call to a function
164 -- that requires handling as a build-in-place call or is a qualified
165 -- expression applied to such a call; otherwise returns False.
167 function Is_Null_Procedure (Subp : Entity_Id) return Boolean;
168 -- Predicate to recognize stubbed procedures and null procedures, which
169 -- can be inlined unconditionally in all cases.
171 procedure List_Inlining_Info;
172 -- Generate listing of calls inlined by the frontend plus listing of
173 -- calls to inline subprograms passed to the backend.
175 procedure Make_Build_In_Place_Call_In_Allocator
176 (Allocator : Node_Id;
177 Function_Call : Node_Id);
178 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
179 -- occurs as the expression initializing an allocator, by passing access
180 -- to the allocated object as an additional parameter of the function call.
181 -- A new access object is declared that is initialized to the result of the
182 -- allocator, passed to the function, and the allocator is rewritten to
183 -- refer to that access object. Function_Call must denote either an
184 -- N_Function_Call node for which Is_Build_In_Place_Call is True, or else
185 -- an N_Qualified_Expression node applied to such a function call.
187 procedure Make_Build_In_Place_Call_In_Anonymous_Context
188 (Function_Call : Node_Id);
189 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
190 -- occurs in a context that does not provide a separate object. A temporary
191 -- object is created to act as the return object and an access to the
192 -- temporary is passed as an additional parameter of the call. This occurs
193 -- in contexts such as subprogram call actuals and object renamings.
194 -- Function_Call must denote either an N_Function_Call node for which
195 -- Is_Build_In_Place_Call is True, or else an N_Qualified_Expression node
196 -- applied to such a function call.
198 procedure Make_Build_In_Place_Call_In_Assignment
199 (Assign : Node_Id;
200 Function_Call : Node_Id);
201 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
202 -- occurs as the right-hand side of an assignment statement by passing
203 -- access to the left-hand side as an additional parameter of the function
204 -- call. Assign must denote a N_Assignment_Statement. Function_Call must
205 -- denote either an N_Function_Call node for which Is_Build_In_Place_Call
206 -- is True, or an N_Qualified_Expression node applied to such a function
207 -- call.
209 procedure Make_Build_In_Place_Call_In_Object_Declaration
210 (Object_Decl : Node_Id;
211 Function_Call : Node_Id);
212 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
213 -- occurs as the expression initializing an object declaration by
214 -- passing access to the declared object as an additional parameter of the
215 -- function call. Function_Call must denote either an N_Function_Call node
216 -- for which Is_Build_In_Place_Call is True, or an N_Qualified_Expression
217 -- node applied to such a function call.
219 procedure Make_CPP_Constructor_Call_In_Allocator
220 (Allocator : Node_Id;
221 Function_Call : Node_Id);
222 -- Handle a call to a CPP constructor that occurs as the expression that
223 -- initializes an allocator, by passing access to the allocated object as
224 -- an additional parameter of the constructor call. A new access object is
225 -- declared that is initialized to the result of the allocator, passed to
226 -- the constructor, and the allocator is rewritten to refer to that access
227 -- object. Function_Call must denote a call to a CPP_Constructor function.
229 function Needs_BIP_Alloc_Form (Func_Id : Entity_Id) return Boolean;
230 -- Ada 2005 (AI-318-02): Return True if the function needs an implicit
231 -- BIP_Alloc_Form parameter (see type BIP_Formal_Kind).
233 function Needs_BIP_Finalization_Master (Func_Id : Entity_Id) return Boolean;
234 -- Ada 2005 (AI-318-02): Return True if the result subtype of function
235 -- Func_Id needs finalization actions.
237 function Needs_Result_Accessibility_Level
238 (Func_Id : Entity_Id) return Boolean;
239 -- Ada 2012 (AI05-0234): Return True if the function needs an implicit
240 -- parameter to identify the accessibility level of the function result
241 -- "determined by the point of call".
243 procedure Add_Extra_Actual_To_Call
244 (Subprogram_Call : Node_Id;
245 Extra_Formal : Entity_Id;
246 Extra_Actual : Node_Id);
247 -- Adds Extra_Actual as a named parameter association for the formal
248 -- Extra_Formal in Subprogram_Call.
250 end Exp_Ch6;