2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / targparm.ads
blob942b501af182e4a9f5adb44e2639ea8eee85cc07
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- T A R G P A R M --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1999-2003 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- This package obtains parameters from the target runtime version of
28 -- System, to indicate parameters relevant to the target environment.
30 -- Conceptually, these parameters could be obtained using rtsfind, but
31 -- we do not do this for four reasons:
33 -- 1. Compiling System for every compilation wastes time
35 -- 2. This compilation impedes debugging by adding extra compile steps
37 -- 3. There are recursion problems coming from compiling System itself
38 -- or any of its children.
40 -- 4. The binder also needs the parameters, and we do not want to have
41 -- to drag a lot of front end stuff into the binder.
43 -- For all these reasons, we read in the source of System, and then scan
44 -- it at the text level to extract the parameter values.
46 -- Note however, that later on, when the ali file is written, we make sure
47 -- that the System file is at least parsed, so that the checksum is properly
48 -- computed and set in the ali file. This partially negates points 1 and 2
49 -- above although just parsing is quick and does not impact debugging much.
51 -- The parameters acquired by this routine from system.ads fall into three
52 -- categories:
54 -- 1. Configuration pragmas, that must appear at the start of the file.
55 -- Any such pragmas automatically apply to any unit compiled in the
56 -- presence of this system file. Only a limited set of such pragmas
57 -- may appear as documented in the corresponding section below,
59 -- 2. Target parameters. These are boolean constants that are defined
60 -- in the private part of the package giving fixed information
61 -- about the target architecture, and the capabilities of the
62 -- code generator and run-time library.
64 -- 3. Identification information. This is an optional string constant
65 -- that gives the name of the run-time library configuration. This
66 -- line may be ommitted for a version of system.ads to be used with
67 -- the full Ada 95 run time.
69 with Rident; use Rident;
70 with Types; use Types;
71 with Uintp; use Uintp;
73 package Targparm is
75 ---------------------------
76 -- Configuration Pragmas --
77 ---------------------------
79 -- The following switches get set if the corresponding configuration
80 -- pragma is scanned from the source of system.ads. No other pragmas
81 -- are permitted to appear at the start of the system.ads source file.
83 -- If a pragma Discard_Names appears, then Opt.Global_Discard_Names is
84 -- set to True to indicate that all units must be compiled in this mode.
86 -- If a pragma Locking_Policy appears, then Opt.Locking_Policy is set
87 -- to the first character of the policy name, and Opt.Locking_Policy_Sloc
88 -- is set to System_Location.
90 -- If a pragma Normalize_Scalars appears, then Opt.Normalize_Scalars
91 -- is set True, as well as Opt.Init_Or_Norm_Scalars.
93 -- If a pragma Queuing_Policy appears, then Opt.Queuing_Policy is set
94 -- to the first character of the policy name, and Opt.Queuing_Policy_Sloc
95 -- is set to System_Location.
97 -- If a pragma Task_Dispatching_Policy appears, then the flag
98 -- Opt.Task_Dispatching_Policy is set to the first character of the
99 -- policy name, and Opt.Task_Dispatching_Policy_Sloc is set to
100 -- System_Location.
102 -- If a pragma Polling (On) appears, then the flag Opt.Polling_Required
103 -- is set to True.
105 -- if a pragma Suppress_Exception_Locations appears, then the flag
106 -- Opt.Exception_Locations_Suppressed is set to True.
108 -- The only other pragma allowed is a pragma Restrictions that gives the
109 -- simple name of a restriction for which partition consistency is always
110 -- required (see definition of Rident.Partition_Restrictions).
112 Restrictions_On_Target :
113 array (Partition_Restrictions) of Boolean := (others => False);
114 -- Element is set True if a pragma Restrictions for the corresponding
115 -- identifier appears in system.ads. Note that only partition restriction
116 -- identifiers are permitted as arguments for pragma Restrictions for
117 -- pragmas appearing at the start of system.ads.
119 Restriction_Parameters_On_Target :
120 array (Restriction_Parameter_Id) of Uint := (others => No_Uint);
121 -- Element is set to specified value if a pragma Restrictions for the
122 -- corresponding restriction parameter value is set.
124 -------------------
125 -- Run Time Name --
126 -------------------
128 -- This parameter should be regarded as read only by all clients of
129 -- of package. The only way they get modified is by calling the
130 -- Get_Target_Parameters routine which reads the values from a provided
131 -- text buffer containing the source of the system package.
133 -- The corresponding string constant is placed immediately at the start
134 -- of the private part of system.ads if is present, e.g. in the form:
136 -- Run_Time_Name : constant String := "Zero Footprint Run Time";
138 -- the corresponding messages will look something like
140 -- xxx not supported (Zero Footprint Run Time)
142 Run_Time_Name_On_Target : Name_Id := No_Name;
143 -- Set to appropriate names table entry Id value if a Run_Time_Name
144 -- string constant is defined in system.ads. This name is used only
145 -- for the configurable run-time case, and is used to parametrize
146 -- messages that complain about non-supported run-time features.
147 -- The name should contain only letters A-Z, digits 1-9, spaces,
148 -- and underscores.
150 -----------------------
151 -- Target Parameters --
152 -----------------------
154 -- The following parameters correspond to the variables defined in the
155 -- private part of System (without the terminating _On_Target). Note
156 -- that it is required that all parameters defined here be specified
157 -- in the target specific version of system.ads (there are no defaults).
159 -- All these parameters should be regarded as read only by all clients
160 -- of the package. The only way they get modified is by calling the
161 -- Get_Target_Parameters routine which reads the values from a provided
162 -- text buffer containing the source of the system package.
164 ----------------------------
165 -- Special Target Control --
166 ----------------------------
168 -- The great majority of GNAT ports are based on GCC. The switches in
169 -- This section indicate the use of some non-standard target back end.
171 AAMP_On_Target : Boolean;
172 -- Set to True if target is AAMP.
174 -------------------------------
175 -- Backend Arithmetic Checks --
176 -------------------------------
178 -- Divide and overflow checks are either done in the front end or
179 -- back end. The front end will generate checks when required unless
180 -- the corresponding parameter here is set to indicate that the back
181 -- end will generate the required checks (or that the checks are
182 -- automatically performed by the hardware in an appropriate form).
184 Backend_Divide_Checks_On_Target : Boolean;
185 -- Set True if the back end generates divide checks, or if the hardware
186 -- checks automatically. Set False if the front end must generate the
187 -- required tests using explicit expanded code.
189 Backend_Overflow_Checks_On_Target : Boolean;
190 -- Set True if the back end generates arithmetic overflow checks, or if
191 -- the hardware checks automatically. Set False if the front end must
192 -- generate the required tests using explicit expanded code.
194 -----------------------------------
195 -- Control of Exception Handling --
196 -----------------------------------
198 -- GNAT implements three methods of implementing exceptions:
200 -- Front-End Longjmp/Setjmp Exceptions
202 -- This approach uses longjmp/setjmp to handle exceptions. It
203 -- uses less storage, and can often propagate exceptions faster,
204 -- at the expense of (sometimes considerable) overhead in setting
205 -- up an exception handler. This approach is available on all
206 -- targets, and is the default where it is the only approach.
208 -- The generation of the setjmp and longjmp calls is handled by
209 -- the front end of the compiler (this includes gigi in the case
210 -- of the standard GCC back end). It does not use any back end
211 -- suport (such as the GCC3 exception handling mechanism). When
212 -- this approach is used, the compiler generates special exception
213 -- handlers for handling cleanups when an exception is raised.
215 -- Front-End Zero Cost Exceptions
217 -- This approach uses separate exception tables. These use extra
218 -- storage, and exception propagation can be quite slow, but there
219 -- is no overhead in setting up an exception handler (it is to this
220 -- latter operation that the phrase zero-cost refers). This approach
221 -- is only available on some targets, and is the default where it is
222 -- available.
224 -- The generation of the exception tables is handled by the front
225 -- end of the compiler. It does not use any back end support (such
226 -- as the GCC3 exception handling mechanism). When this approach
227 -- is used, the compiler generates special exception handlers for
228 -- handling cleanups when an exception is raised.
230 -- Back-End Zero Cost Exceptions
232 -- With this approach, the back end handles the generation and
233 -- handling of exceptions. For example, the GCC3 exception handling
234 -- mechanisms are used in this mode. The front end simply generates
235 -- code for explicit exception handlers, and AT END cleanup handlers
236 -- are simply passed unchanged to the backend for generating cleanups
237 -- both in the exceptional and non-exceptional cases.
239 -- As the name implies, this approach generally uses a zero-cost
240 -- mechanism with tables, but the tables are generated by the back
241 -- end. However, since the back-end is entirely responsible for the
242 -- handling of exceptions, another mechanism might be used. In the
243 -- case of GCC3 for instance, it might be the case that the compiler
244 -- is configured for setjmp/longjmp handling, then everything will
245 -- work correctly. However, it is definitely preferred that the
246 -- back end provide zero cost exception handling.
248 -- Controlling the selection of methods
250 -- The Front-End Longjmp/Setjmp approach is always available in
251 -- all implementations. If it is not the default method, then it
252 -- may be explicitly specified by the use of -gnatL. Note however
253 -- that there is a requirement that all Ada units in a partition
254 -- be compiled with this overriding option if it is not the default.
256 -- On some, but not all, implementations of GNAT, one of the two
257 -- ZCX approaches (but not both) is implemented. If this is the
258 -- case, and ZCX is not the default mechanism, then ZCX handling
259 -- (front-end or back-end according to the implementation) may be
260 -- specified by use of the -gnatZ switch. Again, this switch must
261 -- be used to compile all Ada units in a partition. The use of
262 -- the -gnatZ switch will cause termination with a fatal error.
264 -- Finally the debug option -gnatdX can be used to force the
265 -- compiler to operate in front-end ZCX exception mode and force
266 -- the front end to generate exception tables. This is only useful
267 -- for debugging purposes for implementations which do not provide
268 -- the possibility of front-end ZCX mode. The resulting object file
269 -- is unusable, but this debug switch may still be useful (e.g. in
270 -- conjunction with -gnatG) for front-end debugging purposes.
272 -- Control of Available Methods and Defaults
274 -- The following switches specify which of the two ZCX methods
275 -- (if any) is available in an implementation, and which method
276 -- is the default method.
278 ZCX_By_Default_On_Target : Boolean;
279 -- Indicates if zero cost exceptions are active by default. If this
280 -- variable is False, then the only possible exception method is the
281 -- front-end setjmp/longjmp approach, and this is the default. If
282 -- this variable is True, then one of the following two flags must
283 -- be True, and represents the method to be used by default.
285 GCC_ZCX_Support_On_Target : Boolean;
286 -- Indicates that when ZCX is active, the mechanism to be used is the
287 -- back-end ZCX exception approach. If this variable is set to True,
288 -- then Front_End_ZCX_Support_On_Target must be False.
290 Front_End_ZCX_Support_On_Target : Boolean;
291 -- Indicates that when ZCX is active, the mechanism to be used is the
292 -- front-end ZCX exception approach. If this variable is set to True,
293 -- then GCC_ZCX_Support_On_Target must be False.
295 --------------------------------
296 -- Configurable Run-Time Mode --
297 --------------------------------
299 -- In configurable run-time mode, the system run-time may not support
300 -- the full Ada language. The effect of setting this switch is to let
301 -- the compiler know that it is not surprising (i.e. the system is not
302 -- misconfigured) if run-time library units or entities within units are
303 -- not present in the run-time.
305 Configurable_Run_Time_On_Target : Boolean;
306 -- Indicates that the system.ads file is for a configurable run-time
308 -- This has some specific effects as follows
310 -- The binder generates the gnat_argc/argv/envp variables in the
311 -- binder file instead of being imported from the run-time library.
312 -- If Command_Line_Args_On_Target is set to False, then the
313 -- generation of these variables is suppressed completely.
315 -- The binder generates the gnat_exit_status variable in the binder
316 -- file instead of being imported from the run-time library. If
317 -- Exit_Status_Supported_On_Target is set to False, then the
318 -- generation of this variable is suppressed entirely.
320 -- The routine __gnat_break_start is defined within the binder file
321 -- instead of being imported from the run-time library.
323 -- The variable __gnat_exit_status is generated within the binder file
324 -- instead of being imported from the run-time library.
326 Suppress_Standard_Library_On_Target : Boolean;
327 -- If this flag is True, then the standard library is not included by
328 -- default in the executable (see unit System.Standard_Library in file
329 -- s-stalib.ads for details of what this includes). This is for example
330 -- set True for the zero foot print case, where these files should not
331 -- be included by default.
333 -- This flag has some other related effects:
335 -- The generation of global variables in the bind file is suppressed,
336 -- with the exception of the priority of the environment task, which
337 -- is needed by the Ravenscar run-time.
339 -- The generation of exception tables is suppressed for front end
340 -- ZCX exception handling (since we assume no exception handling).
342 -- The calls to __gnat_initialize and __gnat_finalize are omitted
344 -- All finalization and initialization (controlled types) is omitted
346 -- The routine __gnat_handler_installed is not imported
348 ---------------------
349 -- Duration Format --
350 ---------------------
352 -- By default, type Duration is a 64-bit fixed-point type with a delta
353 -- and small of 10**(-9) (i.e. it is a count in nanoseconds. This flag
354 -- allows that standard format to be modified.
356 Duration_32_Bits_On_Target : Boolean;
357 -- If True, then Duration is represented in 32 bits and the delta and
358 -- small values are set to 20.0*(10**(-3)) (i.e. it is a count in units
359 -- of 20 milliseconds.
361 ------------------------------------
362 -- Back-End Code Generation Flags --
363 ------------------------------------
365 -- These flags indicate possible limitations in what the code generator
366 -- can handle. They will all be True for a full run-time, but one or more
367 -- of these may be false for a configurable run-time, and if a feature is
368 -- used at the source level, and the corresponding flag is false, then an
369 -- error message will be issued saying the feature is not supported.
371 Support_64_Bit_Divides_On_Target : Boolean;
372 -- If True, the back end supports 64-bit divide operations. If False, then
373 -- the source program may not contain 64-bit divide operations. This is
374 -- specifically useful in the zero foot-print case, where the issue is
375 -- whether there is a hardware divide instruction for 64-bits so that
376 -- no run-time support is required. It should always be set True if the
377 -- necessary run-time support is present.
379 Support_Aggregates_On_Target : Boolean;
380 -- In the general case, the use of aggregates may generate calls
381 -- to run-time routines in the C library, including memset, memcpy,
382 -- memmove, and bcopy. This flag is set to True if these routines
383 -- are available. If any of these routines is not available, then
384 -- this flag is False, and the use of aggregates is not permitted.
386 Support_Composite_Assign_On_Target : Boolean;
387 -- The assignment of composite objects other than small records and
388 -- arrays whose size is 64-bits or less and is set by an explicit
389 -- size clause may generate calls to memcpy, memmove, and bcopy.
390 -- If versions of all these routines are available, then this flag
391 -- is set to True. If any of these routines is not available, then
392 -- the flag is set False, and composite assignments are not allowed.
394 Support_Composite_Compare_On_Target : Boolean;
395 -- If this flag is True, then the back end supports bit-wise comparison
396 -- of composite objects for equality, either generating inline code or
397 -- calling appropriate (and available) run-time routines. If this flag
398 -- is False, then the back end does not provide this support, and the
399 -- front end uses component by component comparison for composites.
401 Support_Long_Shifts_On_Target : Boolean;
402 -- If True, the back end supports 64-bit shift operations. If False, then
403 -- the source program may not contain explicit 64-bit shifts. In addition,
404 -- the code generated for packed arrays will avoid the use of long shifts.
406 -------------------------------
407 -- Control of Stack Checking --
408 -------------------------------
410 -- GNAT provides two methods of implementing exceptions:
412 -- GCC Probing Mechanism
414 -- This approach uses the standard GCC mechanism for
415 -- stack checking. The method assumes that accessing
416 -- storage immediately beyond the end of the stack
417 -- will result in a trap that is converted to a storage
418 -- error by the runtime system. This mechanism has
419 -- minimal overhead, but requires complex hardware,
420 -- operating system and run-time support. Probing is
421 -- the default method where it is available. The stack
422 -- size for the environment task depends on the operating
423 -- system and cannot be set in a system-independent way.
425 -- GNAT Stack-limit Checking
427 -- This method relies on comparing the stack pointer
428 -- with per-task stack limits. If the check fails, an
429 -- exception is explicitly raised. The advantage is
430 -- that the method requires no extra system dependent
431 -- runtime support and can be used on systems without
432 -- memory protection as well, but at the cost of more
433 -- overhead for doing the check. This method is the
434 -- default on systems that lack complete support for
435 -- probing.
437 Stack_Check_Probes_On_Target : Boolean;
438 -- Indicates if stack check probes are used, as opposed to the standard
439 -- target independent comparison method.
441 Stack_Check_Default_On_Target : Boolean;
442 -- Indicates if stack checking is on by default
444 ----------------------------
445 -- Command Line Arguments --
446 ----------------------------
448 -- For most ports of GNAT, command line arguments are supported. The
449 -- following flag is set to False for targets that do not support
450 -- command line arguments (VxWorks and AAMP). Note that support of
451 -- command line arguments is not required on such targets (RM A.15(13)).
453 Command_Line_Args_On_Target : Boolean;
454 -- Set False if no command line arguments on target. Note that if this
455 -- is False in with Configurable_Run_Time_On_Target set to True, then
456 -- this causes suppression of generation of the argv/argc variables
457 -- used to record command line arguments.
459 -- Similarly, most ports support the use of an exit status, but AAMP
460 -- is an exception (as allowed by RM A.15(18-20))
462 Exit_Status_Supported_On_Target : Boolean;
463 -- Set False if returning of an exit status is not supported on target.
464 -- Note that if this False in with Configurable_Run_Time_On_Target
465 -- set to True, then this causes suppression of the gnat_exit_status
466 -- variable used to recod the exit status.
468 -----------------------
469 -- Main Program Name --
470 -----------------------
472 -- When the binder generates the main program to be used to create the
473 -- executable, the main program name is main by default (to match the
474 -- usual Unix practice). If this parameter is set to True, then the
475 -- name is instead by default taken from the actual Ada main program
476 -- name (just the name of the child if the main program is a child unit).
477 -- In either case, this value can be overridden using -M name.
479 Use_Ada_Main_Program_Name_On_Target : Boolean;
480 -- Set True to use the Ada main program name as the main name
482 ----------------------------------------------
483 -- Boolean-Valued Floating-Point Attributes --
484 ----------------------------------------------
486 -- The constants below give the values for representation oriented
487 -- floating-point attributes that are the same for all float types
488 -- on the target. These are all boolean values.
490 -- A value is only True if the target reliably supports the corresponding
491 -- feature. Reliably here means that support is guaranteed for all
492 -- possible settings of the relevant compiler switches (like -mieee),
493 -- since we cannot control the user setting of those switches.
495 -- The attributes cannot dependent on the current setting of compiler
496 -- switches, since the values must be static and consistent throughout
497 -- the partition. We probably should add such consistency checks in future,
498 -- but for now we don't do this.
500 Denorm_On_Target : Boolean;
501 -- Set to False on targets that do not reliably support denormals.
502 -- Reliably here means for all settings of the relevant -m flag, so
503 -- for example, this is False on the Alpha where denormals are not
504 -- supported unless -mieee is used.
506 Machine_Rounds_On_Target : Boolean;
507 -- Set to False for targets where S'Machine_Rounds is False
509 Machine_Overflows_On_Target : Boolean;
510 -- Set to True for targets where S'Machine_Overflows is True
512 Signed_Zeros_On_Target : Boolean;
513 -- Set to False on targets that do not reliably support signed zeros.
515 OpenVMS_On_Target : Boolean;
516 -- Set to True if target is OpenVMS.
518 -------------------------------------------
519 -- Boolean-Valued Fixed-Point Attributes --
520 -------------------------------------------
522 Fractional_Fixed_Ops_On_Target : Boolean;
523 -- Set to True for targets that support fixed-by-fixed multiplication
524 -- and division for fixed-point types with a small value equal to
525 -- 2 ** (-(T'Object_Size - 1)) and whose values have an absolute
526 -- value less than 1.0.
528 --------------------------------------------------------------
529 -- Handling of Unconstrained Values Returned from Functions --
530 --------------------------------------------------------------
532 -- Functions that return variable length objects, notably unconstrained
533 -- arrays are a special case, because there is no simple obvious way of
534 -- implementing this feature. Furthermore, this capability is not present
535 -- in C++ or C, so typically the system ABI does not handle this case.
537 -- GNAT uses two different approaches
539 -- The Secondary Stack
541 -- The secondary stack is a special storage pool that is used for
542 -- this purpose. The called function places the result on the
543 -- secondary stack, and the caller uses or copies the value from
544 -- the secondary stack, and pops the secondary stack after the
545 -- value is consumed. The secondary stack is outside the system
546 -- ABI, and the important point is that although generally it is
547 -- handled in a stack like manner corresponding to the subprogram
548 -- call structure, a return from a function does NOT pop the stack.
550 -- DSP (Depressed Stack Pointer)
552 -- Some targets permit the implementation of a function call/return
553 -- protocol in which the function does not pop the main stack pointer
554 -- on return, but rather returns with the stack pointer depressed.
555 -- This is not generally permitted by any ABI, but for at least some
556 -- targets, the implementation of alloca provides a model for this
557 -- approach. If return-with-DSP is implemented, then functions that
558 -- return variable length objects do it by returning with the stack
559 -- pointer depressed, and the returned object is a pointer to the
560 -- area within the stack frame of the called procedure that contains
561 -- the returned value. The caller must then pop the main stack when
562 -- this value is consumed.
564 Functions_Return_By_DSP_On_Target : Boolean;
565 -- Set to True if target permits functions to return with using the
566 -- DSP (depressed stack pointer) approach.
568 -----------------
569 -- Data Layout --
570 -----------------
572 -- Normally when using the GCC backend, Gigi and GCC perform much of the
573 -- data layout using the standard layout capabilities of GCC. If the
574 -- parameter Backend_Layout is set to False, then the front end must
575 -- perform all data layout. For further details see the package Layout.
577 Frontend_Layout_On_Target : Boolean;
578 -- Set True if front end does layout
580 -----------------
581 -- Subprograms --
582 -----------------
584 -- These subprograms are used to initialize the target parameter values
585 -- from the system.ads file. Note that this is only done once, so if more
586 -- than one call is made to either routine, the second and subsequent
587 -- calls are ignored.
589 procedure Get_Target_Parameters
590 (System_Text : Source_Buffer_Ptr;
591 Source_First : Source_Ptr;
592 Source_Last : Source_Ptr);
593 -- Called at the start of execution to obtain target parameters from
594 -- the source of package System. The parameters provide the source
595 -- text to be scanned (in System_Text (Source_First .. Source_Last)).
597 procedure Get_Target_Parameters;
598 -- This version reads in system.ads using Osint. The idea is that the
599 -- caller uses the first version if they have to read system.ads anyway
600 -- (e.g. the compiler) and uses this simpler interface if system.ads is
601 -- not otherwise needed.
603 end Targparm;