OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [exp_util.ads] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             E X P _ U T I L                              --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, 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
------------------------------------------------------------------------------
25
 
26
--  Package containing utility procedures used throughout the expander
27
 
28
with Exp_Tss; use Exp_Tss;
29
with Namet;   use Namet;
30
with Rtsfind; use Rtsfind;
31
with Sinfo;   use Sinfo;
32
with Types;   use Types;
33
 
34
package Exp_Util is
35
 
36
   -----------------------------------------------
37
   -- Handling of Actions Associated with Nodes --
38
   -----------------------------------------------
39
 
40
   --  The evaluation of certain expression nodes involves the elaboration
41
   --  of associated types and other declarations, and the execution of
42
   --  statement sequences. Expansion routines generating such actions must
43
   --  find an appropriate place in the tree to hang the actions so that
44
   --  they will be evaluated at the appropriate point.
45
 
46
   --  Some cases are simple:
47
 
48
   --    For an expression occurring in a simple statement that is in a list
49
   --    of statements, the actions are simply inserted into the list before
50
   --    the associated statement.
51
 
52
   --    For an expression occurring in a declaration (declarations always
53
   --    appear in lists), the actions are similarly inserted into the list
54
   --    just before the associated declaration.
55
 
56
   --  The following special cases arise:
57
 
58
   --    For actions associated with the right operand of a short circuit
59
   --    form, the actions are first stored in the short circuit form node
60
   --    in the Actions field. The expansion of these forms subsequently
61
   --    expands the short circuit forms into if statements which can then
62
   --    be moved as described above.
63
 
64
   --    For actions appearing in the Condition expression of a while loop,
65
   --    or an elsif clause, the actions are similarly temporarily stored in
66
   --    in the node (N_Elsif_Part or N_Iteration_Scheme) associated with
67
   --    the expression using the Condition_Actions field. Subsequently, the
68
   --    expansion of these nodes rewrites the control structures involved to
69
   --    reposition the actions in normal statement sequence.
70
 
71
   --    For actions appearing in the then or else expression of a conditional
72
   --    expression, these actions are similarly placed in the node, using the
73
   --    Then_Actions or Else_Actions field as appropriate. Once again the
74
   --    expansion of the N_Conditional_Expression node rewrites the node so
75
   --    that the actions can be normally positioned.
76
 
77
   --  Basically what we do is to climb up to the tree looking for the
78
   --  proper insertion point, as described by one of the above cases,
79
   --  and then insert the appropriate action or actions.
80
 
81
   --  Note if more than one insert call is made specifying the same
82
   --  Assoc_Node, then the actions are elaborated in the order of the
83
   --  calls, and this guarantee is preserved for the special cases above.
84
 
85
   procedure Insert_Action
86
     (Assoc_Node : Node_Id;
87
      Ins_Action : Node_Id);
88
   --  Insert the action Ins_Action at the appropriate point as described
89
   --  above. The action is analyzed using the default checks after it is
90
   --  inserted. Assoc_Node is the node with which the action is associated.
91
 
92
   procedure Insert_Action
93
     (Assoc_Node : Node_Id;
94
      Ins_Action : Node_Id;
95
      Suppress   : Check_Id);
96
   --  Insert the action Ins_Action at the appropriate point as described
97
   --  above. The action is analyzed using the default checks as modified
98
   --  by the given Suppress argument after it is inserted. Assoc_Node is
99
   --  the node with which the action is associated.
100
 
101
   procedure Insert_Actions
102
     (Assoc_Node  : Node_Id;
103
      Ins_Actions : List_Id);
104
   --  Insert the list of action Ins_Actions at the appropriate point as
105
   --  described above. The actions are analyzed using the default checks
106
   --  after they are inserted. Assoc_Node is the node with which the actions
107
   --  are associated. Ins_Actions may be No_List, in which case the call has
108
   --  no effect.
109
 
110
   procedure Insert_Actions
111
     (Assoc_Node  : Node_Id;
112
      Ins_Actions : List_Id;
113
      Suppress    : Check_Id);
114
   --  Insert the list of action Ins_Actions at the appropriate point as
115
   --  described above. The actions are analyzed using the default checks
116
   --  as modified by the given Suppress argument after they are inserted.
117
   --  Assoc_Node is the node with which the actions are associated.
118
   --  Ins_Actions may be No_List, in which case the call has no effect.
119
 
120
   procedure Insert_Actions_After
121
     (Assoc_Node  : Node_Id;
122
      Ins_Actions : List_Id);
123
   --  Assoc_Node must be a node in a list. Same as Insert_Actions but
124
   --  actions will be inserted after N in a manner that is compatible with
125
   --  the transient scope mechanism. This procedure must be used instead
126
   --  of Insert_List_After if Assoc_Node may be in a transient scope.
127
   --
128
   --  Implementation limitation: Assoc_Node must be a statement. We can
129
   --  generalize to expressions if there is a need but this is tricky to
130
   --  implement because of short-circuits (among other things).???
131
 
132
   procedure Insert_Library_Level_Action (N : Node_Id);
133
   --  This procedure inserts and analyzes the node N as an action at the
134
   --  library level for the current unit (i.e. it is attached to the
135
   --  Actions field of the N_Compilation_Aux node for the main unit).
136
 
137
   procedure Insert_Library_Level_Actions (L : List_Id);
138
   --  Similar, but inserts a list of actions
139
 
140
   -----------------------
141
   -- Other Subprograms --
142
   -----------------------
143
 
144
   procedure Adjust_Condition (N : Node_Id);
145
   --  The node N is an expression whose root-type is Boolean, and which
146
   --  represents a boolean value used as a condition (i.e. a True/False
147
   --  value). This routine handles the case of C and Fortran convention
148
   --  boolean types, which have zero/non-zero semantics rather than the normal
149
   --  0/1 semantics, and also the case of an enumeration rep clause that
150
   --  specifies a non-standard representation. On return, node N always has
151
   --  the type Standard.Boolean, with a value that is a standard Boolean
152
   --  values of 0/1 for False/True. This procedure is used in two situations.
153
   --  First, the processing for a condition field always calls
154
   --  Adjust_Condition, so that the boolean value presented to the backend is
155
   --  a standard value. Second, for the code for boolean operations such as
156
   --  AND, Adjust_Condition is called on both operands, and then the operation
157
   --  is done in the domain of Standard_Boolean, then Adjust_Result_Type is
158
   --  called on the result to possibly reset the original type. This procedure
159
   --  also takes care of validity checking if Validity_Checks = Tests.
160
 
161
   procedure Adjust_Result_Type (N : Node_Id; T : Entity_Id);
162
   --  The processing of boolean operations like AND uses the procedure
163
   --  Adjust_Condition so that it can operate on Standard.Boolean, which is
164
   --  the only boolean type on which the backend needs to be able to implement
165
   --  such operators. This means that the result is also of type
166
   --  Standard.Boolean. In general the type must be reset back to the original
167
   --  type to get proper semantics, and that is the purpose of this procedure.
168
   --  N is the node (of type Standard.Boolean), and T is the desired type. As
169
   --  an optimization, this procedure leaves the type as Standard.Boolean in
170
   --  contexts where this is permissible (in particular for Condition fields,
171
   --  and for operands of other logical operations higher up the tree). The
172
   --  call to this procedure is completely ignored if the argument N is not of
173
   --  type Boolean.
174
 
175
   procedure Append_Freeze_Action (T : Entity_Id; N : Node_Id);
176
   --  Add a new freeze action for the given type. The freeze action is
177
   --  attached to the freeze node for the type. Actions will be elaborated in
178
   --  the order in which they are added. Note that the added node is not
179
   --  analyzed. The analyze call is found in Exp_Ch13.Expand_N_Freeze_Entity.
180
 
181
   procedure Append_Freeze_Actions (T : Entity_Id; L : List_Id);
182
   --  Adds the given list of freeze actions (declarations or statements) for
183
   --  the given type. The freeze actions are attached to the freeze node for
184
   --  the type. Actions will be elaborated in the order in which they are
185
   --  added, and the actions within the list will be elaborated in list order.
186
   --  Note that the added nodes are not analyzed. The analyze call is found in
187
   --  Exp_Ch13.Expand_N_Freeze_Entity.
188
 
189
   function Build_Runtime_Call (Loc : Source_Ptr; RE : RE_Id) return Node_Id;
190
   --  Build an N_Procedure_Call_Statement calling the given runtime entity.
191
   --  The call has no parameters. The first argument provides the location
192
   --  information for the tree and for error messages. The call node is not
193
   --  analyzed on return, the caller is responsible for analyzing it.
194
 
195
   function Build_Task_Image_Decls
196
     (Loc          : Source_Ptr;
197
      Id_Ref       : Node_Id;
198
      A_Type       : Entity_Id;
199
      In_Init_Proc : Boolean := False) return List_Id;
200
   --  Build declaration for a variable that holds an identifying string to be
201
   --  used as a task name. Id_Ref is an identifier if the task is a variable,
202
   --  and a selected or indexed component if the task is component of an
203
   --  object. If it is an indexed component, A_Type is the corresponding array
204
   --  type. Its index types are used to build the string as an image of the
205
   --  index values. For composite types, the result includes two declarations:
206
   --  one for a generated function that computes the image without using
207
   --  concatenation, and one for the variable that holds the result.
208
   --
209
   --  If In_Init_Proc is true, the call is part of the initialization of
210
   --  a component of a composite type, and the enclosing initialization
211
   --  procedure must be flagged as using the secondary stack. If In_Init_Proc
212
   --  is false, the call is for a stand-alone object, and the generated
213
   --  function itself must do its own cleanups.
214
 
215
   function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean;
216
   --  This function is in charge of detecting record components that may
217
   --  cause trouble in the back end if an attempt is made to assign the
218
   --  component. The back end can handle such assignments with no problem if
219
   --  the components involved are small (64-bits or less) records or scalar
220
   --  items (including bit-packed arrays represented with modular types) or
221
   --  are both aligned on a byte boundary (starting on a byte boundary, and
222
   --  occupying an integral number of bytes).
223
   --
224
   --  However, problems arise for records larger than 64 bits, or for arrays
225
   --  (other than bit-packed arrays represented with a modular type) if the
226
   --  component starts on a non-byte boundary, or does not occupy an integral
227
   --  number of bytes (i.e. there are some bits possibly shared with fields
228
   --  at the start or beginning of the component). The back end cannot handle
229
   --  loading and storing such components in a single operation.
230
   --
231
   --  This function is used to detect the troublesome situation. it is
232
   --  conservative in the sense that it produces True unless it knows for
233
   --  sure that the component is safe (as outlined in the first paragraph
234
   --  above). The code generation for record and array assignment checks for
235
   --  trouble using this function, and if so the assignment is generated
236
   --  component-wise, which the back end is required to handle correctly.
237
   --
238
   --  Note that in GNAT 3, the back end will reject such components anyway,
239
   --  so the hard work in checking for this case is wasted in GNAT 3, but
240
   --  it is harmless, so it is easier to do it in all cases, rather than
241
   --  conditionalize it in GNAT 5 or beyond.
242
 
243
   procedure Convert_To_Actual_Subtype (Exp : Node_Id);
244
   --  The Etype of an expression is the nominal type of the expression,
245
   --  not the actual subtype. Often these are the same, but not always.
246
   --  For example, a reference to a formal of unconstrained type has the
247
   --  unconstrained type as its Etype, but the actual subtype is obtained by
248
   --  applying the actual bounds. This routine is given an expression, Exp,
249
   --  and (if necessary), replaces it using Rewrite, with a conversion to
250
   --  the actual subtype, building the actual subtype if necessary. If the
251
   --  expression is already of the requested type, then it is unchanged.
252
 
253
   function Corresponding_Runtime_Package (Typ : Entity_Id) return RTU_Id;
254
   --  Return the id of the runtime package that will provide support for
255
   --  concurrent type Typ. Currently only protected types are supported,
256
   --  and the returned value is one of the following:
257
   --    System_Tasking_Protected_Objects
258
   --    System_Tasking_Protected_Objects_Entries
259
   --    System_Tasking_Protected_Objects_Single_Entry
260
 
261
   function Current_Sem_Unit_Declarations return List_Id;
262
   --  Return the place where it is fine to insert declarations for the
263
   --  current semantic unit. If the unit is a package body, return the
264
   --  visible declarations of the corresponding spec. For RCI stubs, this
265
   --  is necessary because the point at which they are generated may not
266
   --  be the earliest point at which they are used.
267
 
268
   function Duplicate_Subexpr
269
     (Exp      : Node_Id;
270
      Name_Req : Boolean := False) return Node_Id;
271
   --  Given the node for a subexpression, this function makes a logical copy
272
   --  of the subexpression, and returns it. This is intended for use when the
273
   --  expansion of an expression needs to repeat part of it. For example,
274
   --  replacing a**2 by a*a requires two references to a which may be a
275
   --  complex subexpression. Duplicate_Subexpr guarantees not to duplicate
276
   --  side effects. If necessary, it generates actions to save the expression
277
   --  value in a temporary, inserting these actions into the tree using
278
   --  Insert_Actions with Exp as the insertion location. The original
279
   --  expression and the returned result then become references to this saved
280
   --  value. Exp must be analyzed on entry. On return, Exp is analyzed, but
281
   --  the caller is responsible for analyzing the returned copy after it is
282
   --  attached to the tree. The Name_Req flag is set to ensure that the result
283
   --  is suitable for use in a context requiring name (e.g. the prefix of an
284
   --  attribute reference).
285
   --
286
   --  Note that if there are any run time checks in Exp, these same checks
287
   --  will be duplicated in the returned duplicated expression. The two
288
   --  following functions allow this behavior to be modified.
289
 
290
   function Duplicate_Subexpr_No_Checks
291
     (Exp      : Node_Id;
292
      Name_Req : Boolean := False) return Node_Id;
293
   --  Identical in effect to Duplicate_Subexpr, except that Remove_Checks
294
   --  is called on the result, so that the duplicated expression does not
295
   --  include checks. This is appropriate for use when Exp, the original
296
   --  expression is unconditionally elaborated before the duplicated
297
   --  expression, so that there is no need to repeat any checks.
298
 
299
   function Duplicate_Subexpr_Move_Checks
300
     (Exp      : Node_Id;
301
      Name_Req : Boolean := False) return Node_Id;
302
   --  Identical in effect to Duplicate_Subexpr, except that Remove_Checks is
303
   --  called on Exp after the duplication is complete, so that the original
304
   --  expression does not include checks. In this case the result returned
305
   --  (the duplicated expression) will retain the original checks. This is
306
   --  appropriate for use when the duplicated expression is sure to be
307
   --  elaborated before the original expression Exp, so that there is no need
308
   --  to repeat the checks.
309
 
310
   procedure Ensure_Defined (Typ : Entity_Id; N : Node_Id);
311
   --  This procedure ensures that type referenced by Typ is defined. For the
312
   --  case of a type other than an Itype, nothing needs to be done, since
313
   --  all such types have declaration nodes. For Itypes, an N_Itype_Reference
314
   --  node is generated and inserted at the given node N. This is typically
315
   --  used to ensure that an Itype is properly defined outside a conditional
316
   --  construct when it is referenced in more than one branch.
317
 
318
   function Entry_Names_OK return Boolean;
319
   --  Determine whether it is appropriate to dynamically allocate strings
320
   --  which represent entry [family member] names. These strings are created
321
   --  by the compiler and used by GDB.
322
 
323
   procedure Evolve_And_Then (Cond : in out Node_Id; Cond1 : Node_Id);
324
   --  Rewrites Cond with the expression: Cond and then Cond1. If Cond is
325
   --  Empty, then simply returns Cond1 (this allows the use of Empty to
326
   --  initialize a series of checks evolved by this routine, with a final
327
   --  result of Empty indicating that no checks were required). The Sloc field
328
   --  of the constructed N_And_Then node is copied from Cond1.
329
 
330
   procedure Evolve_Or_Else (Cond : in out Node_Id; Cond1 : Node_Id);
331
   --  Rewrites Cond with the expression: Cond or else Cond1. If Cond is Empty,
332
   --  then simply returns Cond1 (this allows the use of Empty to initialize a
333
   --  series of checks evolved by this routine, with a final result of Empty
334
   --  indicating that no checks were required). The Sloc field of the
335
   --  constructed N_Or_Else node is copied from Cond1.
336
 
337
   procedure Expand_Subtype_From_Expr
338
     (N             : Node_Id;
339
      Unc_Type      : Entity_Id;
340
      Subtype_Indic : Node_Id;
341
      Exp           : Node_Id);
342
   --  Build a constrained subtype from the initial value in object
343
   --  declarations and/or allocations when the type is indefinite (including
344
   --  class-wide).
345
 
346
   function Find_Init_Call
347
     (Var        : Entity_Id;
348
      Rep_Clause : Node_Id) return Node_Id;
349
   --  Look for init_proc call for variable Var, either among declarations
350
   --  between that of Var and a subsequent Rep_Clause applying to Var, or
351
   --  in the list of freeze actions associated with Var, and if found, return
352
   --  that call node.
353
 
354
   function Find_Interface_ADT
355
     (T     : Entity_Id;
356
      Iface : Entity_Id) return Elmt_Id;
357
   --  Ada 2005 (AI-251): Given a type T implementing the interface Iface,
358
   --  return the element of Access_Disp_Table containing the tag of the
359
   --  interface.
360
 
361
   function Find_Interface_Tag
362
     (T     : Entity_Id;
363
      Iface : Entity_Id) return Entity_Id;
364
   --  Ada 2005 (AI-251): Given a type T implementing the interface Iface,
365
   --  return the record component containing the tag of Iface.
366
 
367
   function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id;
368
   --  Find the first primitive operation of type T whose name is 'Name'.
369
   --  This function allows the use of a primitive operation which is not
370
   --  directly visible. If T is a class wide type, then the reference is
371
   --  to an operation of the corresponding root type. Raises Program_Error
372
   --  exception if no primitive operation is found. This is normally an
373
   --  internal error, but in some cases is an expected consequence of
374
   --  illegalities elsewhere.
375
 
376
   function Find_Prim_Op
377
     (T    : Entity_Id;
378
      Name : TSS_Name_Type) return Entity_Id;
379
   --  Find the first primitive operation of type T whose name has the form
380
   --  indicated by the name parameter (i.e. is a type support subprogram
381
   --  with the indicated suffix). This function allows use of a primitive
382
   --  operation which is not directly visible. If T is a class wide type,
383
   --  then the reference is to an operation of the corresponding root type.
384
   --  Raises Program_Error exception if no primitive operation is found.
385
   --  This is normally an internal error, but in some cases is an expected
386
   --  consequence of illegalities elsewhere.
387
 
388
   function Find_Protection_Object (Scop : Entity_Id) return Entity_Id;
389
   --  Traverse the scope stack starting from Scop and look for an entry,
390
   --  entry family, or a subprogram that has a Protection_Object and return
391
   --  it. Raises Program_Error if no such entity is found since the context
392
   --  in which this routine is invoked should always have a protection
393
   --  object.
394
 
395
   procedure Force_Evaluation
396
     (Exp      : Node_Id;
397
      Name_Req : Boolean := False);
398
   --  Force the evaluation of the expression right away. Similar behavior
399
   --  to Remove_Side_Effects when Variable_Ref is set to TRUE. That is to
400
   --  say, it removes the side-effects and captures the values of the
401
   --  variables. Remove_Side_Effects guarantees that multiple evaluations
402
   --  of the same expression won't generate multiple side effects, whereas
403
   --  Force_Evaluation further guarantees that all evaluations will yield
404
   --  the same result.
405
 
406
   procedure Generate_Poll_Call (N : Node_Id);
407
   --  If polling is active, then a call to the Poll routine is built,
408
   --  and then inserted before the given node N and analyzed.
409
 
410
   procedure Get_Current_Value_Condition
411
     (Var : Node_Id;
412
      Op  : out Node_Kind;
413
      Val : out Node_Id);
414
   --  This routine processes the Current_Value field of the variable Var. If
415
   --  the Current_Value field is null or if it represents a known value, then
416
   --  on return Cond is set to N_Empty, and Val is set to Empty.
417
   --
418
   --  The other case is when Current_Value points to an N_If_Statement or an
419
   --  N_Elsif_Part or a N_Iteration_Scheme node (see description in Einfo for
420
   --  exact details). In this case, Get_Current_Condition digs out the
421
   --  condition, and then checks if the condition is known false, known true,
422
   --  or not known at all. In the first two cases, Get_Current_Condition will
423
   --  return with Op set to the appropriate conditional operator (inverted if
424
   --  the condition is known false), and Val set to the constant value. If the
425
   --  condition is not known, then Op and Val are set for the empty case
426
   --  (N_Empty and Empty).
427
   --
428
   --  The check for whether the condition is true/false unknown depends
429
   --  on the case:
430
   --
431
   --     For an IF, the condition is known true in the THEN part, known false
432
   --     in any ELSIF or ELSE part, and not known outside the IF statement in
433
   --     question.
434
   --
435
   --     For an ELSIF, the condition is known true in the ELSIF part, known
436
   --     FALSE in any subsequent ELSIF, or ELSE part, and not known before the
437
   --     ELSIF, or after the end of the IF statement.
438
   --
439
   --  The caller can use this result to determine the value (for the case of
440
   --  N_Op_Eq), or to determine the result of some other test in other cases
441
   --  (e.g. no access check required if N_Op_Ne Null).
442
 
443
   function Has_Controlled_Coextensions (Typ : Entity_Id) return Boolean;
444
   --  Determine whether a record type has anonymous access discriminants with
445
   --  a controlled designated type.
446
 
447
   function Homonym_Number (Subp : Entity_Id) return Nat;
448
   --  Here subp is the entity for a subprogram. This routine returns the
449
   --  homonym number used to disambiguate overloaded subprograms in the same
450
   --  scope (the number is used as part of constructed names to make sure that
451
   --  they are unique). The number is the ordinal position on the Homonym
452
   --  chain, counting only entries in the current scope. If an entity is not
453
   --  overloaded, the returned number will be one.
454
 
455
   function Inside_Init_Proc return Boolean;
456
   --  Returns True if current scope is within an init proc
457
 
458
   function In_Unconditional_Context (Node : Node_Id) return Boolean;
459
   --  Node is the node for a statement or a component of a statement. This
460
   --  function determines if the statement appears in a context that is
461
   --  unconditionally executed, i.e. it is not within a loop or a conditional
462
   --  or a case statement etc.
463
 
464
   function Is_All_Null_Statements (L : List_Id) return Boolean;
465
   --  Return True if all the items of the list are N_Null_Statement nodes.
466
   --  False otherwise. True for an empty list. It is an error to call this
467
   --  routine with No_List as the argument.
468
 
469
   function Is_Fully_Repped_Tagged_Type (T : Entity_Id) return Boolean;
470
   --  Tests given type T, and returns True if T is a non-discriminated tagged
471
   --  type which has a record representation clause that specifies the layout
472
   --  of all the components, including recursively components in all parent
473
   --  types. We exclude discriminated types for convenience, it is extremely
474
   --  unlikely that the special processing associated with the use of this
475
   --  routine is useful for the case of a discriminated type, and testing for
476
   --  component overlap would be a pain.
477
 
478
   function Is_Library_Level_Tagged_Type (Typ : Entity_Id) return Boolean;
479
   --  Return True if Typ is a library level tagged type. Currently we use
480
   --  this information to build statically allocated dispatch tables.
481
 
482
   function Is_Ref_To_Bit_Packed_Array (N : Node_Id) return Boolean;
483
   --  Determine whether the node P is a reference to a bit packed array, i.e.
484
   --  whether the designated object is a component of a bit packed array, or a
485
   --  subcomponent of such a component. If so, then all subscripts in P are
486
   --  evaluated with a call to Force_Evaluation, and True is returned.
487
   --  Otherwise False is returned, and P is not affected.
488
 
489
   function Is_Ref_To_Bit_Packed_Slice (N : Node_Id) return Boolean;
490
   --  Determine whether the node P is a reference to a bit packed slice, i.e.
491
   --  whether the designated object is bit packed slice or a component of a
492
   --  bit packed slice. Return True if so.
493
 
494
   function Is_Possibly_Unaligned_Slice (N : Node_Id) return Boolean;
495
   --  Determine whether the node P is a slice of an array where the slice
496
   --  result may cause alignment problems because it has an alignment that
497
   --  is not compatible with the type. Return True if so.
498
 
499
   function Is_Possibly_Unaligned_Object (N : Node_Id) return Boolean;
500
   --  Node N is an object reference. This function returns True if it is
501
   --  possible that the object may not be aligned according to the normal
502
   --  default alignment requirement for its type (e.g. if it appears in a
503
   --  packed record, or as part of a component that has a component clause.)
504
 
505
   function Is_Renamed_Object (N : Node_Id) return Boolean;
506
   --  Returns True if the node N is a renamed object. An expression is
507
   --  considered to be a renamed object if either it is the Name of an object
508
   --  renaming declaration, or is the prefix of a name which is a renamed
509
   --  object. For example, in:
510
   --
511
   --     x : r renames a (1 .. 2) (1);
512
   --
513
   --  We consider that a (1 .. 2) is a renamed object since it is the prefix
514
   --  of the name in the renaming declaration.
515
 
516
   function Is_Untagged_Derivation (T : Entity_Id) return Boolean;
517
   --  Returns true if type T is not tagged and is a derived type,
518
   --  or is a private type whose completion is such a type.
519
 
520
   function Is_Volatile_Reference (N : Node_Id) return Boolean;
521
   --  Checks if the node N represents a volatile reference, which can be
522
   --  either a direct reference to a variable treated as volatile, or an
523
   --  indexed/selected component where the prefix is treated as volatile,
524
   --  or has Volatile_Components set. A slice of a volatile variable is
525
   --  also volatile.
526
 
527
   procedure Kill_Dead_Code (N : Node_Id; Warn : Boolean := False);
528
   --  N represents a node for a section of code that is known to be dead. Any
529
   --  exception handler references and warning messages relating to this code
530
   --  are removed. If Warn is True, a warning will be output at the start of N
531
   --  indicating the deletion of the code. Note that the tree for the deleted
532
   --  code is left intact so that e.g. cross-reference data is still valid.
533
 
534
   procedure Kill_Dead_Code (L : List_Id; Warn : Boolean := False);
535
   --  Like the above procedure, but applies to every element in the given
536
   --  list. If Warn is True, a warning will be output at the start of N
537
   --  indicating the deletion of the code.
538
 
539
   function Known_Non_Negative (Opnd : Node_Id) return Boolean;
540
   --  Given a node for a subexpression, determines if it represents a value
541
   --  that cannot possibly be negative, and if so returns True. A value of
542
   --  False means that it is not known if the value is positive or negative.
543
 
544
   function Known_Non_Null (N : Node_Id) return Boolean;
545
   --  Given a node N for a subexpression of an access type, determines if
546
   --  this subexpression yields a value that is known at compile time to
547
   --  be non-null and returns True if so. Returns False otherwise. It is
548
   --  an error to call this function if N is not of an access type.
549
 
550
   function Known_Null (N : Node_Id) return Boolean;
551
   --  Given a node N for a subexpression of an access type, determines if this
552
   --  subexpression yields a value that is known at compile time to be null
553
   --  and returns True if so. Returns False otherwise. It is an error to call
554
   --  this function if N is not of an access type.
555
 
556
   function Make_Subtype_From_Expr
557
     (E       : Node_Id;
558
      Unc_Typ : Entity_Id) return Node_Id;
559
   --  Returns a subtype indication corresponding to the actual type of an
560
   --  expression E. Unc_Typ is an unconstrained array or record, or
561
   --  a classwide type.
562
 
563
   function May_Generate_Large_Temp (Typ : Entity_Id) return Boolean;
564
   --  Determines if the given type, Typ, may require a large temporary of the
565
   --  kind that causes back-end trouble if stack checking is enabled. The
566
   --  result is True only the size of the type is known at compile time and
567
   --  large, where large is defined heuristically by the body of this routine.
568
   --  The purpose of this routine is to help avoid generating troublesome
569
   --  temporaries that interfere with stack checking mechanism. Note that the
570
   --  caller has to check whether stack checking is actually enabled in order
571
   --  to guide the expansion (typically of a function call).
572
 
573
   function Non_Limited_Designated_Type (T : Entity_Id) return Entity_Id;
574
   --  An anonymous access type may designate a limited view. Check whether
575
   --  non-limited view is available during expansion, to examine components
576
   --  or other characteristics of the full type.
577
 
578
   function OK_To_Do_Constant_Replacement (E : Entity_Id) return Boolean;
579
   --  This function is used when testing whether or not to replace a reference
580
   --  to entity E by a known constant value. Such replacement must be done
581
   --  only in a scope known to be safe for such replacements. In particular,
582
   --  if we are within a subprogram and the entity E is declared outside the
583
   --  subprogram then we cannot do the replacement, since we do not attempt to
584
   --  trace subprogram call flow. It is also unsafe to replace statically
585
   --  allocated values (since they can be modified outside the scope), and we
586
   --  also inhibit replacement of Volatile or aliased objects since their
587
   --  address might be captured in a way we do not detect. A value of True is
588
   --  returned only if the replacement is safe.
589
 
590
   function Possible_Bit_Aligned_Component (N : Node_Id) return Boolean;
591
   --  This function is used during processing the assignment of a record or
592
   --  indexed component. The argument N is either the left hand or right hand
593
   --  side of an assignment, and this function determines if there is a record
594
   --  component reference where the record may be bit aligned in a manner that
595
   --  causes trouble for the back end (see Component_May_Be_Bit_Aligned for
596
   --  further details).
597
 
598
   procedure Remove_Side_Effects
599
     (Exp          : Node_Id;
600
      Name_Req     : Boolean := False;
601
      Variable_Ref : Boolean := False);
602
   --  Given the node for a subexpression, this function replaces the node if
603
   --  necessary by an equivalent subexpression that is guaranteed to be side
604
   --  effect free. This is done by extracting any actions that could cause
605
   --  side effects, and inserting them using Insert_Actions into the tree to
606
   --  which Exp is attached. Exp must be analyzed and resolved before the call
607
   --  and is analyzed and resolved on return. The Name_Req may only be set to
608
   --  True if Exp has the form of a name, and the effect is to guarantee that
609
   --  any replacement maintains the form of name. If Variable_Ref is set to
610
   --  TRUE, a variable is considered as side effect (used in implementing
611
   --  Force_Evaluation). Note: after call to Remove_Side_Effects, it is safe
612
   --  to call New_Copy_Tree to obtain a copy of the resulting expression.
613
 
614
   function Represented_As_Scalar (T : Entity_Id) return Boolean;
615
   --  Returns True iff the implementation of this type in code generation
616
   --  terms is scalar. This is true for scalars in the Ada sense, and for
617
   --  packed arrays which are represented by a scalar (modular) type.
618
 
619
   function Safe_Unchecked_Type_Conversion (Exp : Node_Id) return Boolean;
620
   --  Given the node for an N_Unchecked_Type_Conversion, return True if this
621
   --  is an unchecked conversion that Gigi can handle directly. Otherwise
622
   --  return False if it is one for which the front end must provide a
623
   --  temporary. Note that the node need not be analyzed, and thus the Etype
624
   --  field may not be set, but in that case it must be the case that the
625
   --  Subtype_Mark field of the node is set/analyzed.
626
 
627
   procedure Set_Current_Value_Condition (Cnode : Node_Id);
628
   --  Cnode is N_If_Statement, N_Elsif_Part, or N_Iteration_Scheme (the latter
629
   --  when a WHILE condition is present). This call checks whether Condition
630
   --  (Cnode) has embedded expressions of a form that should result in setting
631
   --  the Current_Value field of one or more entities, and if so sets these
632
   --  fields to point to Cnode.
633
 
634
   procedure Set_Elaboration_Flag (N : Node_Id; Spec_Id : Entity_Id);
635
   --  N is the node for a subprogram or generic body, and Spec_Id is the
636
   --  entity for the corresponding spec. If an elaboration entity is defined,
637
   --  then this procedure generates an assignment statement to set it True,
638
   --  immediately after the body is elaborated. However, no assignment is
639
   --  generated in the case of library level procedures, since the setting of
640
   --  the flag in this case is generated in the binder. We do that so that we
641
   --  can detect cases where this is the only elaboration action that is
642
   --  required.
643
 
644
   procedure Set_Renamed_Subprogram (N : Node_Id; E : Entity_Id);
645
   --  N is an node which is an entity name that represents the name of a
646
   --  renamed subprogram. The node is rewritten to be an identifier that
647
   --  refers directly to the renamed subprogram, given by entity E.
648
 
649
   procedure Silly_Boolean_Array_Not_Test (N : Node_Id; T : Entity_Id);
650
   --  N is the node for a boolean array NOT operation, and T is the type of
651
   --  the array. This routine deals with the silly case where the subtype of
652
   --  the boolean array is False..False or True..True, where it is required
653
   --  that a Constraint_Error exception be raised (RM 4.5.6(6)).
654
 
655
   procedure Silly_Boolean_Array_Xor_Test (N : Node_Id; T : Entity_Id);
656
   --  N is the node for a boolean array XOR operation, and T is the type of
657
   --  the array. This routine deals with the silly case where the subtype of
658
   --  the boolean array is True..True, where a raise of a Constraint_Error
659
   --  exception is required (RM 4.5.6(6)).
660
 
661
   function Target_Has_Fixed_Ops
662
     (Left_Typ   : Entity_Id;
663
      Right_Typ  : Entity_Id;
664
      Result_Typ : Entity_Id) return Boolean;
665
   --  Returns True if and only if the target machine has direct support
666
   --  for fixed-by-fixed multiplications and divisions for the given
667
   --  operand and result types. This is called in package Exp_Fixd to
668
   --  determine whether to expand such operations.
669
 
670
   function Type_May_Have_Bit_Aligned_Components
671
     (Typ : Entity_Id) return Boolean;
672
   --  Determines if Typ is a composite type that has within it (looking down
673
   --  recursively at any subcomponents), a record type which has component
674
   --  that may be bit aligned (see Possible_Bit_Aligned_Component). The result
675
   --  is conservative, in that a result of False is decisive. A result of True
676
   --  means that such a component may or may not be present.
677
 
678
   procedure Wrap_Cleanup_Procedure (N : Node_Id);
679
   --  Given an N_Subprogram_Body node, this procedure adds an Abort_Defer call
680
   --  at the start of the statement sequence, and an Abort_Undefer call at the
681
   --  end of the statement sequence. All cleanup routines (i.e. those that are
682
   --  called from "at end" handlers) must defer abort on entry and undefer
683
   --  abort on exit. Note that it is assumed that the code for the procedure
684
   --  does not contain any return statements which would allow the flow of
685
   --  control to escape doing the undefer call.
686
 
687
private
688
   pragma Inline (Duplicate_Subexpr);
689
   pragma Inline (Force_Evaluation);
690
   pragma Inline (Is_Library_Level_Tagged_Type);
691
end Exp_Util;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.