OSDN Git Service

More improvements to sparc VIS vec_init code generation.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-rident.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                         S Y S T E M . R I D E N T                        --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2011, 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.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- GNAT was originally developed  by the GNAT team at  New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
29 --                                                                          --
30 ------------------------------------------------------------------------------
31
32 --  This package defines the set of restriction identifiers. It is a generic
33 --  package that is instantiated by the compiler/binder in package Rident, and
34 --  is instantiated in package System.Restrictions for use at run-time.
35
36 --  The reason that we make this a generic package is so that in the case of
37 --  the instantiation in Rident for use at compile time and bind time, we can
38 --  generate normal image tables for the enumeration types, which are needed
39 --  for diagnostic and informational messages. At run-time we really do not
40 --  want to waste the space for these image tables, and they are not needed,
41 --  so we can do the instantiation under control of Discard_Names to remove
42 --  the tables.
43
44 pragma Compiler_Unit;
45
46 generic
47 package System.Rident is
48    pragma Preelaborate;
49
50    --  The following enumeration type defines the set of restriction
51    --  identifiers that are implemented in GNAT.
52
53    --  To add a new restriction identifier, add an entry with the name to be
54    --  used in the pragma, and add calls to the Restrict.Check_Restriction
55    --  routine as appropriate.
56
57    type Restriction_Id is
58
59       --  The following cases are checked for consistency in the binder. The
60       --  binder will check that every unit either has the restriction set, or
61       --  does not violate the restriction.
62
63      (Simple_Barriers,                         -- GNAT (Ravenscar)
64       No_Abort_Statements,                     -- (RM D.7(5), H.4(3))
65       No_Access_Subprograms,                   -- (RM H.4(17))
66       No_Allocators,                           -- (RM H.4(7))
67       No_Allocators_After_Elaboration,         -- Ada 2012 (RM D.7(19.1/2))
68       No_Anonymous_Allocators,                 -- Ada 2012 (RM H.4(8/1))
69       No_Asynchronous_Control,                 -- (RM D.7(10))
70       No_Calendar,                             -- GNAT
71       No_Default_Stream_Attributes,            -- Ada 2012 (RM 13.12.1(4/2))
72       No_Delay,                                -- (RM H.4(21))
73       No_Direct_Boolean_Operators,             -- GNAT
74       No_Dispatch,                             -- (RM H.4(19))
75       No_Dispatching_Calls,                    -- GNAT
76       No_Dynamic_Attachment,                   -- GNAT
77       No_Dynamic_Priorities,                   -- (RM D.9(9))
78       No_Enumeration_Maps,                     -- GNAT
79       No_Entry_Calls_In_Elaboration_Code,      -- GNAT
80       No_Entry_Queue,                          -- GNAT (Ravenscar)
81       No_Exception_Handlers,                   -- GNAT
82       No_Exception_Propagation,                -- GNAT
83       No_Exception_Registration,               -- GNAT
84       No_Exceptions,                           -- (RM H.4(12))
85       No_Finalization,                         -- GNAT
86       No_Fixed_Point,                          -- (RM H.4(15))
87       No_Floating_Point,                       -- (RM H.4(14))
88       No_IO,                                   -- (RM H.4(20))
89       No_Implicit_Conditionals,                -- GNAT
90       No_Implicit_Dynamic_Code,                -- GNAT
91       No_Implicit_Heap_Allocations,            -- (RM D.8(8), H.4(3))
92       No_Implicit_Loops,                       -- GNAT
93       No_Initialize_Scalars,                   -- GNAT
94       No_Local_Allocators,                     -- (RM H.4(8))
95       No_Local_Timing_Events,                  -- (RM D.7(10.2/2))
96       No_Local_Protected_Objects,              -- GNAT
97       No_Nested_Finalization,                  -- (RM D.7(4))
98       No_Protected_Type_Allocators,            -- GNAT
99       No_Protected_Types,                      -- (RM H.4(5))
100       No_Recursion,                            -- (RM H.4(22))
101       No_Reentrancy,                           -- (RM H.4(23))
102       No_Relative_Delay,                       -- GNAT (Ravenscar)
103       No_Requeue_Statements,                   -- GNAT
104       No_Secondary_Stack,                      -- GNAT
105       No_Select_Statements,                    -- GNAT (Ravenscar)
106       No_Specific_Termination_Handlers,        -- (RM D.7(10.7/2))
107       No_Standard_Storage_Pools,               -- GNAT
108       No_Stream_Optimizations,                 -- GNAT
109       No_Streams,                              -- GNAT
110       No_Task_Allocators,                      -- (RM D.7(7))
111       No_Task_Attributes_Package,              -- GNAT
112       No_Task_Hierarchy,                       -- (RM D.7(3), H.4(3))
113       No_Task_Termination,                     -- GNAT (Ravenscar)
114       No_Tasking,                              -- GNAT
115       No_Terminate_Alternatives,               -- (RM D.7(6))
116       No_Unchecked_Access,                     -- (RM H.4(18))
117       No_Unchecked_Conversion,                 -- (RM H.4(16))
118       No_Unchecked_Deallocation,               -- (RM H.4(9))
119       Static_Priorities,                       -- GNAT
120       Static_Storage_Size,                     -- GNAT
121
122       --  The following require consistency checking with special rules. See
123       --  individual routines in unit Bcheck for details of what is required.
124
125       No_Default_Initialization,               -- GNAT
126
127       --  The following cases do not require consistency checking
128
129       Immediate_Reclamation,                   -- (RM H.4(10))
130       No_Implementation_Aspect_Specifications, -- Ada 2012 AI-241
131       No_Implementation_Attributes,            -- Ada 2005 AI-257
132       No_Implementation_Identifiers,           -- Ada 2012 AI-246
133       No_Implementation_Pragmas,               -- Ada 2005 AI-257
134       No_Implementation_Restrictions,          -- GNAT
135       No_Implementation_Units,                 -- Ada 2012 AI-242
136       No_Implicit_Aliasing,                    -- GNAT
137       No_Elaboration_Code,                     -- GNAT
138       No_Obsolescent_Features,                 -- Ada 2005 AI-368
139       No_Wide_Characters,                      -- GNAT
140       SPARK,                                   -- GNAT
141
142       --  The following cases require a parameter value
143
144       --  The following entries are fully checked at compile/bind time, which
145       --  means that the compiler can in general tell the minimum value which
146       --  could be used with a restrictions pragma. The binder can deduce the
147       --  appropriate minimum value for the partition by taking the maximum
148       --  value required by any unit.
149
150       Max_Protected_Entries,                   -- (RM D.7(14))
151       Max_Select_Alternatives,                 -- (RM D.7(12))
152       Max_Task_Entries,                        -- (RM D.7(13), H.4(3))
153
154       --  The following entries are also fully checked at compile/bind time,
155       --  and the compiler can also at least in some cases tell the minimum
156       --  value which could be used with a restriction pragma. The difference
157       --  is that the contributions are additive, so the binder deduces this
158       --  value by adding the unit contributions.
159
160       Max_Tasks,                               -- (RM D.7(19), H.4(3))
161
162       --  The following entries are checked at compile time only for zero/
163       --  nonzero entries. This means that the compiler can tell at compile
164       --  time if a restriction value of zero is (would be) violated, but that
165       --  the compiler cannot distinguish between different non-zero values.
166
167       Max_Asynchronous_Select_Nesting,         -- (RM D.7(18), H.4(3))
168       Max_Entry_Queue_Length,                  -- GNAT
169
170       --  The remaining entries are not checked at compile/bind time
171
172       Max_Storage_At_Blocking,                 -- (RM D.7(17))
173
174       Not_A_Restriction_Id);
175
176    --  Synonyms permitted for historical purposes of compatibility.
177    --  Must be coordinated with Restrict.Process_Restriction_Synonym.
178
179    Boolean_Entry_Barriers : Restriction_Id renames Simple_Barriers;
180    Max_Entry_Queue_Depth  : Restriction_Id renames Max_Entry_Queue_Length;
181    No_Dynamic_Interrupts  : Restriction_Id renames No_Dynamic_Attachment;
182    No_Requeue             : Restriction_Id renames No_Requeue_Statements;
183    No_Task_Attributes     : Restriction_Id renames No_Task_Attributes_Package;
184
185    subtype All_Restrictions is Restriction_Id range
186      Simple_Barriers .. Max_Storage_At_Blocking;
187    --  All restrictions (excluding only Not_A_Restriction_Id)
188
189    subtype All_Boolean_Restrictions is Restriction_Id range
190      Simple_Barriers .. SPARK;
191    --  All restrictions which do not take a parameter
192
193    subtype Partition_Boolean_Restrictions is All_Boolean_Restrictions range
194      Simple_Barriers .. Static_Storage_Size;
195    --  Boolean restrictions that are checked for partition consistency.
196    --  Note that all parameter restrictions are checked for partition
197    --  consistency by default, so this distinction is only needed in the
198    --  case of Boolean restrictions.
199
200    subtype Cunit_Boolean_Restrictions is All_Boolean_Restrictions range
201      Immediate_Reclamation .. SPARK;
202    --  Boolean restrictions that are not checked for partition consistency
203    --  and that thus apply only to the current unit. Note that for these
204    --  restrictions, the compiler does not apply restrictions found in
205    --  with'ed units, parent specs etc. to the main unit.
206
207    subtype All_Parameter_Restrictions is
208      Restriction_Id range
209        Max_Protected_Entries .. Max_Storage_At_Blocking;
210    --  All restrictions that take a parameter
211
212    subtype Checked_Parameter_Restrictions is
213      All_Parameter_Restrictions range
214        Max_Protected_Entries .. Max_Entry_Queue_Length;
215    --  These are the parameter restrictions that can be at least partially
216    --  checked at compile/binder time. Minimally, the compiler can detect
217    --  violations of a restriction pragma with a value of zero reliably.
218
219    subtype Checked_Max_Parameter_Restrictions is
220      Checked_Parameter_Restrictions range
221        Max_Protected_Entries .. Max_Task_Entries;
222    --  Restrictions with parameters that can be checked in some cases by
223    --  maximizing among statically detected instances where the compiler
224    --  can determine the count.
225
226    subtype Checked_Add_Parameter_Restrictions is
227      Checked_Parameter_Restrictions range
228        Max_Tasks .. Max_Tasks;
229    --  Restrictions with parameters that can be checked in some cases by
230    --  summing the statically detected instances where the compiler can
231    --  determine the count.
232
233    subtype Checked_Val_Parameter_Restrictions is
234      Checked_Parameter_Restrictions range
235        Max_Protected_Entries .. Max_Tasks;
236    --  Restrictions with parameter where the count is known at least in some
237    --  cases by the compiler/binder.
238
239    subtype Checked_Zero_Parameter_Restrictions is
240      Checked_Parameter_Restrictions range
241        Max_Asynchronous_Select_Nesting .. Max_Entry_Queue_Length;
242    --  Restrictions with parameters where the compiler can detect the use of
243    --  the feature, and hence violations of a restriction specifying a value
244    --  of zero, but cannot detect specific values other than zero/nonzero.
245
246    subtype Unchecked_Parameter_Restrictions is
247      All_Parameter_Restrictions range
248        Max_Storage_At_Blocking .. Max_Storage_At_Blocking;
249    --  Restrictions with parameters where the compiler cannot ever detect
250    --  corresponding compile time usage, so the binder and compiler never
251    --  detect violations of any restriction.
252
253    -------------------------------------
254    -- Restriction Status Declarations --
255    -------------------------------------
256
257    --  The following declarations are used to record the current status or
258    --  restrictions (for the current unit, or related units, at compile time,
259    --  and for all units in a partition at bind time or run time).
260
261    type Restriction_Flags  is array (All_Restrictions)           of Boolean;
262    type Restriction_Values is array (All_Parameter_Restrictions) of Natural;
263    type Parameter_Flags    is array (All_Parameter_Restrictions) of Boolean;
264
265    type Restrictions_Info is record
266       Set : Restriction_Flags;
267       --  An entry is True in the Set array if a restrictions pragma has been
268       --  encountered for the given restriction. If the value is True for a
269       --  parameter restriction, then the corresponding entry in the Value
270       --  array gives the minimum value encountered for any such restriction.
271
272       Value : Restriction_Values;
273       --  If the entry for a parameter restriction in Set is True (i.e. a
274       --  restrictions pragma for the restriction has been encountered), then
275       --  the corresponding entry in the Value array is the minimum value
276       --  specified by any such restrictions pragma. Note that a restrictions
277       --  pragma specifying a value greater than Int'Last is simply ignored.
278
279       Violated : Restriction_Flags;
280       --  An entry is True in the violations array if the compiler has detected
281       --  a violation of the restriction. For a parameter restriction, the
282       --  Count and Unknown arrays have additional information.
283
284       Count : Restriction_Values;
285       --  If an entry for a parameter restriction is True in Violated, the
286       --  corresponding entry in the Count array may record additional
287       --  information. If the actual minimum count is known (by taking
288       --  maximums, or sums, depending on the restriction), it will be
289       --  recorded in this array. If not, then the value will remain zero.
290       --  The value is also zero for a non-violated restriction.
291
292       Unknown : Parameter_Flags;
293       --  If an entry for a parameter restriction is True in Violated, the
294       --  corresponding entry in the Unknown array may record additional
295       --  information. If the actual count is not known by the compiler (but
296       --  is known to be non-zero), then the entry in Unknown will be True.
297       --  This indicates that the value in Count is not known to be exact,
298       --  and the actual violation count may be higher.
299
300       --  Note: If Violated (K) is True, then either Count (K) > 0 or
301       --  Unknown (K) = True. It is possible for both these to be set.
302       --  For example, if Count (K) = 3 and Unknown (K) is True, it means
303       --  that the actual violation count is at least 3 but might be higher.
304    end record;
305
306    No_Restrictions : constant Restrictions_Info :=
307      (Set      => (others => False),
308       Value    => (others => 0),
309       Violated => (others => False),
310       Count    => (others => 0),
311       Unknown  => (others => False));
312    --  Used to initialize Restrictions_Info variables
313
314    ----------------------------------
315    -- Profile Definitions and Data --
316    ----------------------------------
317
318    --  Note: to add a profile, modify the following declarations appropriately,
319    --  add Name_xxx to Snames, and add a branch to the conditions for pragmas
320    --  Profile and Profile_Warnings in the body of Sem_Prag.
321
322    type Profile_Name is
323      (No_Profile,
324       No_Implementation_Extensions,
325       Ravenscar,
326       Restricted);
327    --  Names of recognized profiles. No_Profile is used to indicate that a
328    --  restriction came from pragma Restrictions[_Warning], as opposed to
329    --  pragma Profile[_Warning].
330
331    subtype Profile_Name_Actual is Profile_Name
332      range No_Implementation_Extensions .. Restricted;
333    --  Actual used profile names
334
335    type Profile_Data is record
336       Set : Restriction_Flags;
337       --  Set to True if given restriction must be set for the profile, and
338       --  False if it need not be set (False does not mean that it must not be
339       --  set, just that it need not be set). If the flag is True for a
340       --  parameter restriction, then the Value array gives the maximum value
341       --  permitted by the profile.
342
343       Value : Restriction_Values;
344       --  An entry in this array is meaningful only if the corresponding flag
345       --  in Set is True. In that case, the value in this array is the maximum
346       --  value of the parameter permitted by the profile.
347    end record;
348
349    Profile_Info : constant array (Profile_Name_Actual) of Profile_Data :=
350
351                     (No_Implementation_Extensions =>
352                         --  Restrictions for Restricted profile
353
354                        (Set   =>
355                           (No_Implementation_Aspect_Specifications => True,
356                            No_Implementation_Attributes            => True,
357                            No_Implementation_Identifiers           => True,
358                            No_Implementation_Pragmas               => True,
359                            No_Implementation_Units                 => True,
360                            others                                  => False),
361
362                         --  Value settings for Restricted profile (none
363
364                         Value =>
365                           (others                          => 0)),
366
367                      --  Restricted Profile
368
369                      Restricted =>
370
371                         --  Restrictions for Restricted profile
372
373                        (Set   =>
374                           (No_Abort_Statements             => True,
375                            No_Asynchronous_Control         => True,
376                            No_Dynamic_Attachment           => True,
377                            No_Dynamic_Priorities           => True,
378                            No_Entry_Queue                  => True,
379                            No_Local_Protected_Objects      => True,
380                            No_Protected_Type_Allocators    => True,
381                            No_Requeue_Statements           => True,
382                            No_Task_Allocators              => True,
383                            No_Task_Attributes_Package      => True,
384                            No_Task_Hierarchy               => True,
385                            No_Terminate_Alternatives       => True,
386                            Max_Asynchronous_Select_Nesting => True,
387                            Max_Protected_Entries           => True,
388                            Max_Select_Alternatives         => True,
389                            Max_Task_Entries                => True,
390                            others                          => False),
391
392                         --  Value settings for Restricted profile
393
394                         Value =>
395                           (Max_Asynchronous_Select_Nesting => 0,
396                            Max_Protected_Entries           => 1,
397                            Max_Select_Alternatives         => 0,
398                            Max_Task_Entries                => 0,
399                            others                          => 0)),
400
401                      --  Ravenscar Profile
402
403                      --  Note: the table entries here only represent the
404                      --  required restriction profile for Ravenscar. The
405                      --  full Ravenscar profile also requires:
406
407                      --    pragma Dispatching_Policy (FIFO_Within_Priorities);
408                      --    pragma Locking_Policy (Ceiling_Locking);
409                      --    pragma Detect_Blocking
410
411                      Ravenscar  =>
412
413                      --  Restrictions for Ravenscar = Restricted profile ..
414
415                        (Set   =>
416                           (No_Abort_Statements             => True,
417                            No_Asynchronous_Control         => True,
418                            No_Dynamic_Attachment           => True,
419                            No_Dynamic_Priorities           => True,
420                            No_Entry_Queue                  => True,
421                            No_Local_Protected_Objects      => True,
422                            No_Protected_Type_Allocators    => True,
423                            No_Requeue_Statements           => True,
424                            No_Task_Allocators              => True,
425                            No_Task_Attributes_Package      => True,
426                            No_Task_Hierarchy               => True,
427                            No_Terminate_Alternatives       => True,
428                            Max_Asynchronous_Select_Nesting => True,
429                            Max_Protected_Entries           => True,
430                            Max_Select_Alternatives         => True,
431                            Max_Task_Entries                => True,
432
433                            --  plus these additional restrictions:
434
435                            No_Calendar                     => True,
436                            No_Implicit_Heap_Allocations    => True,
437                            No_Relative_Delay               => True,
438                            No_Select_Statements            => True,
439                            No_Task_Termination             => True,
440                            Simple_Barriers                 => True,
441                            others                          => False),
442
443                         --  Value settings for Ravenscar (same as Restricted)
444
445                         Value =>
446                           (Max_Asynchronous_Select_Nesting => 0,
447                            Max_Protected_Entries           => 1,
448                            Max_Select_Alternatives         => 0,
449                            Max_Task_Entries                => 0,
450                            others                          => 0)));
451
452 end System.Rident;