Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / targparm.ads
blob4255b508d2a789ad88ad9a355af84431b2a8e44f
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-2007, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This package obtains parameters from the target runtime version of System,
35 -- to indicate parameters relevant to the target environment.
37 -- Is it right for this to be modified GPL???
39 -- Conceptually, these parameters could be obtained using rtsfind, but
40 -- we do not do this for four reasons:
42 -- 1. Compiling System for every compilation wastes time
44 -- 2. This compilation impedes debugging by adding extra compile steps
46 -- 3. There are recursion problems coming from compiling System itself
47 -- or any of its children.
49 -- 4. The binder also needs the parameters, and we do not want to have
50 -- to drag a lot of front end stuff into the binder.
52 -- For all these reasons, we read in the source of System, and then scan
53 -- it at the text level to extract the parameter values.
55 -- Note however, that later on, when the ali file is written, we make sure
56 -- that the System file is at least parsed, so that the checksum is properly
57 -- computed and set in the ali file. This partially negates points 1 and 2
58 -- above although just parsing is quick and does not impact debugging much.
60 -- The parameters acquired by this routine from system.ads fall into four
61 -- categories:
63 -- 1. Configuration pragmas, that must appear at the start of the file.
64 -- Any such pragmas automatically apply to any unit compiled in the
65 -- presence of this system file. Only a limited set of such pragmas
66 -- may appear as documented in the corresponding section below,
68 -- 2. Target parameters. These are boolean constants that are defined
69 -- in the private part of the package giving fixed information
70 -- about the target architecture, and the capabilities of the
71 -- code generator and run-time library.
73 -- 3. Identification information. This is an optional string constant
74 -- that gives the name of the run-time library configuration. This
75 -- line may be ommitted for a version of system.ads to be used with
76 -- the full Ada 95 run time.
78 -- 4. Other characterisitics of package System. At the current time the
79 -- only item in this category is whether type Address is private.
81 with Rident; use Rident;
82 with Namet; use Namet;
83 with Types; use Types;
85 package Targparm is
87 ---------------------------
88 -- Configuration Pragmas --
89 ---------------------------
91 -- The following switches get set if the corresponding configuration
92 -- pragma is scanned from the source of system.ads. No other pragmas
93 -- are permitted to appear at the start of the system.ads source file.
95 -- If a pragma Discard_Names appears, then Opt.Global_Discard_Names is
96 -- set to True to indicate that all units must be compiled in this mode.
98 -- If a pragma Locking_Policy appears, then Opt.Locking_Policy is set
99 -- to the first character of the policy name, and Opt.Locking_Policy_Sloc
100 -- is set to System_Location.
102 -- If a pragma Normalize_Scalars appears, then Opt.Normalize_Scalars
103 -- is set True, as well as Opt.Init_Or_Norm_Scalars.
105 -- If a pragma Queuing_Policy appears, then Opt.Queuing_Policy is set
106 -- to the first character of the policy name, and Opt.Queuing_Policy_Sloc
107 -- is set to System_Location.
109 -- If a pragma Task_Dispatching_Policy appears, then the flag
110 -- Opt.Task_Dispatching_Policy is set to the first character of the
111 -- policy name, and Opt.Task_Dispatching_Policy_Sloc is set to
112 -- System_Location.
114 -- If a pragma Polling (On) appears, then the flag Opt.Polling_Required
115 -- is set to True.
117 -- If a pragma Detect_Blocking appears, then the flag Opt.Detect_Blocking
118 -- is set to True.
120 -- if a pragma Suppress_Exception_Locations appears, then the flag
121 -- Opt.Exception_Locations_Suppressed is set to True.
123 -- If a pragma Profile with a valid profile argument appears, then
124 -- the appropriate restrictions and policy flags are set.
126 -- The only other pragma allowed is a pragma Restrictions that specifies
127 -- a restriction that will be imposed on all units in the partition. Note
128 -- that in this context, only one restriction can be specified in a single
129 -- pragma, and the pragma must appear on its own on a single source line.
131 -- If package System contains exactly the line "type Address is private;"
132 -- then the flag Opt.Address_Is_Private is set True, otherwise this flag
133 -- is set False.
135 Restrictions_On_Target : Restrictions_Info := No_Restrictions;
136 -- Records restrictions specified by system.ads. Only the Set and Value
137 -- members are modified. The Violated and Count fields are never modified.
138 -- Note that entries can be set either by a pragma Restrictions or by
139 -- a pragma Profile.
141 -------------------
142 -- Run Time Name --
143 -------------------
145 -- This parameter should be regarded as read only by all clients of
146 -- of package. The only way they get modified is by calling the
147 -- Get_Target_Parameters routine which reads the values from a provided
148 -- text buffer containing the source of the system package.
150 -- The corresponding string constant is placed immediately at the start
151 -- of the private part of system.ads if is present, e.g. in the form:
153 -- Run_Time_Name : constant String := "Zero Footprint Run Time";
155 -- the corresponding messages will look something like
157 -- xxx not supported (Zero Footprint Run Time)
159 Run_Time_Name_On_Target : Name_Id := No_Name;
160 -- Set to appropriate names table entry Id value if a Run_Time_Name
161 -- string constant is defined in system.ads. This name is used only
162 -- for the configurable run-time case, and is used to parametrize
163 -- messages that complain about non-supported run-time features.
164 -- The name should contain only letters A-Z, digits 1-9, spaces,
165 -- and underscores.
167 --------------------------
168 -- Executable Extension --
169 --------------------------
171 Executable_Extension_On_Target : Name_Id := No_Name;
172 -- Executable extension on the target. This name is useful for setting
173 -- the executable extension in a dynamic way, e.g. depending on the
174 -- run time used, rather than using a configure-time macro as done by
175 -- Get_Target_Executable_Suffix. If not set (No_Name), instead use
176 -- System.OS_Lib.Get_Target_Executable_Suffix.
178 -----------------------
179 -- Target Parameters --
180 -----------------------
182 -- The following parameters correspond to the variables defined in the
183 -- private part of System (without the terminating _On_Target). Note
184 -- that it is required that all parameters defined here be specified
185 -- in the target specific version of system.ads. Thus, to add a new
186 -- parameter, add it to all system*.ads files. (There is a defaulting
187 -- mechanism, but we don't normally take advantage of it, as explained
188 -- below.)
190 -- The default values here are used if no value is found in system.ads.
191 -- This should normally happen if the special version of system.ads used
192 -- by the compiler itself is in use or if the value is only relevant to
193 -- a particular target (e.g. OpenVMS, AAMP). The default values are
194 -- suitable for use in normal environments. This approach allows the
195 -- possibility of new versions of the compiler (possibly with new system
196 -- parameters added) being used to compile older versions of the compiler
197 -- sources, as well as avoiding duplicating values in all system-*.ads
198 -- files for flags that are used on a few platforms only.
200 -- All these parameters should be regarded as read only by all clients
201 -- of the package. The only way they get modified is by calling the
202 -- Get_Target_Parameters routine which reads the values from a provided
203 -- text buffer containing the source of the system package.
205 ----------------------------
206 -- Special Target Control --
207 ----------------------------
209 -- The great majority of GNAT ports are based on GCC. The switches in
210 -- This section indicate the use of some non-standard target back end
211 -- or other special targetting requirements.
213 AAMP_On_Target : Boolean := False;
214 -- Set to True if target is AAMP
216 OpenVMS_On_Target : Boolean := False;
217 -- Set to True if target is OpenVMS
219 type Virtual_Machine_Kind is (No_VM, JVM_Target, CLI_Target);
220 VM_Target : Virtual_Machine_Kind := No_VM;
221 -- Kind of virtual machine targetted
223 -------------------------------
224 -- Backend Arithmetic Checks --
225 -------------------------------
227 -- Divide and overflow checks are either done in the front end or
228 -- back end. The front end will generate checks when required unless
229 -- the corresponding parameter here is set to indicate that the back
230 -- end will generate the required checks (or that the checks are
231 -- automatically performed by the hardware in an appropriate form).
233 Backend_Divide_Checks_On_Target : Boolean := False;
234 -- Set True if the back end generates divide checks, or if the hardware
235 -- checks automatically. Set False if the front end must generate the
236 -- required tests using explicit expanded code.
238 Backend_Overflow_Checks_On_Target : Boolean := False;
239 -- Set True if the back end generates arithmetic overflow checks, or if
240 -- the hardware checks automatically. Set False if the front end must
241 -- generate the required tests using explicit expanded code.
243 -----------------------------------
244 -- Control of Exception Handling --
245 -----------------------------------
247 -- GNAT implements three methods of implementing exceptions:
249 -- Front-End Longjmp/Setjmp Exceptions
251 -- This approach uses longjmp/setjmp to handle exceptions. It
252 -- uses less storage, and can often propagate exceptions faster,
253 -- at the expense of (sometimes considerable) overhead in setting
254 -- up an exception handler. This approach is available on all
255 -- targets, and is the default where it is the only approach.
257 -- The generation of the setjmp and longjmp calls is handled by
258 -- the front end of the compiler (this includes gigi in the case
259 -- of the standard GCC back end). It does not use any back end
260 -- suport (such as the GCC3 exception handling mechanism). When
261 -- this approach is used, the compiler generates special exception
262 -- handlers for handling cleanups when an exception is raised.
264 -- Front-End Zero Cost Exceptions
266 -- This approach uses separate exception tables. These use extra
267 -- storage, and exception propagation can be quite slow, but there
268 -- is no overhead in setting up an exception handler (it is to this
269 -- latter operation that the phrase zero-cost refers). This approach
270 -- is only available on some targets, and is the default where it is
271 -- available.
273 -- The generation of the exception tables is handled by the front
274 -- end of the compiler. It does not use any back end support (such
275 -- as the GCC3 exception handling mechanism). When this approach
276 -- is used, the compiler generates special exception handlers for
277 -- handling cleanups when an exception is raised.
279 -- Back-End Zero Cost Exceptions
281 -- With this approach, the back end handles the generation and
282 -- handling of exceptions. For example, the GCC3 exception handling
283 -- mechanisms are used in this mode. The front end simply generates
284 -- code for explicit exception handlers, and AT END cleanup handlers
285 -- are simply passed unchanged to the backend for generating cleanups
286 -- both in the exceptional and non-exceptional cases.
288 -- As the name implies, this approach generally uses a zero-cost
289 -- mechanism with tables, but the tables are generated by the back
290 -- end. However, since the back-end is entirely responsible for the
291 -- handling of exceptions, another mechanism might be used. In the
292 -- case of GCC3 for instance, it might be the case that the compiler
293 -- is configured for setjmp/longjmp handling, then everything will
294 -- work correctly. However, it is definitely preferred that the
295 -- back end provide zero cost exception handling.
297 -- Controlling the selection of methods
299 -- On most implementations, back-end zero-cost exceptions are used.
300 -- Otherwise, Front-End Longjmp/Setjmp approach is used.
301 -- Note that there is a requirement that all Ada units in a partition
302 -- be compiled with the same exception model.
304 -- Control of Available Methods and Defaults
306 -- The following switches specify whether ZCX is available, and
307 -- whether it is enabled by default.
309 ZCX_By_Default_On_Target : Boolean := False;
310 -- Indicates if zero cost exceptions are active by default. If this
311 -- variable is False, then the only possible exception method is the
312 -- front-end setjmp/longjmp approach, and this is the default. If
313 -- this variable is True, then GCC ZCX is used.
315 GCC_ZCX_Support_On_Target : Boolean := False;
316 -- Indicates that the target supports GCC Exceptions
318 ------------------------------------
319 -- Run-Time Library Configuration --
320 ------------------------------------
322 -- In configurable run-time mode, the system run-time may not support
323 -- the full Ada language. The effect of setting this switch is to let
324 -- the compiler know that it is not surprising (i.e. the system is not
325 -- misconfigured) if run-time library units or entities within units are
326 -- not present in the run-time.
328 Configurable_Run_Time_On_Target : Boolean := False;
329 -- Indicates that the system.ads file is for a configurable run-time
331 -- This has some specific effects as follows
333 -- The binder generates the gnat_argc/argv/envp variables in the
334 -- binder file instead of being imported from the run-time library.
335 -- If Command_Line_Args_On_Target is set to False, then the
336 -- generation of these variables is suppressed completely.
338 -- The binder generates the gnat_exit_status variable in the binder
339 -- file instead of being imported from the run-time library. If
340 -- Exit_Status_Supported_On_Target is set to False, then the
341 -- generation of this variable is suppressed entirely.
343 -- The routine __gnat_break_start is defined within the binder file
344 -- instead of being imported from the run-time library.
346 -- The variable __gnat_exit_status is generated within the binder file
347 -- instead of being imported from the run-time library.
349 Suppress_Standard_Library_On_Target : Boolean := False;
350 -- If this flag is True, then the standard library is not included by
351 -- default in the executable (see unit System.Standard_Library in file
352 -- s-stalib.ads for details of what this includes). This is for example
353 -- set True for the zero foot print case, where these files should not
354 -- be included by default.
356 -- This flag has some other related effects:
358 -- The generation of global variables in the bind file is suppressed,
359 -- with the exception of the priority of the environment task, which
360 -- is needed by the Ravenscar run-time.
362 -- The calls to __gnat_initialize and __gnat_finalize are omitted
364 -- All finalization and initialization (controlled types) is omitted
366 -- The routine __gnat_handler_installed is not imported
368 Preallocated_Stacks_On_Target : Boolean := False;
369 -- If this flag is True, then the expander preallocates all task stacks
370 -- at compile time. If the flag is False, then task stacks are not pre-
371 -- allocated, and task stack allocation is the responsibility of the
372 -- run-time (which typically delegates the task to the underlying
373 -- operating system environment).
375 ---------------------
376 -- Duration Format --
377 ---------------------
379 -- By default, type Duration is a 64-bit fixed-point type with a delta
380 -- and small of 10**(-9) (i.e. it is a count in nanoseconds. This flag
381 -- allows that standard format to be modified.
383 Duration_32_Bits_On_Target : Boolean := False;
384 -- If True, then Duration is represented in 32 bits and the delta and
385 -- small values are set to 20.0*(10**(-3)) (i.e. it is a count in units
386 -- of 20 milliseconds.
388 ------------------------------------
389 -- Back-End Code Generation Flags --
390 ------------------------------------
392 -- These flags indicate possible limitations in what the code generator
393 -- can handle. They will all be True for a full run-time, but one or more
394 -- of these may be false for a configurable run-time, and if a feature is
395 -- used at the source level, and the corresponding flag is false, then an
396 -- error message will be issued saying the feature is not supported.
398 Support_64_Bit_Divides_On_Target : Boolean := True;
399 -- If True, the back end supports 64-bit divide operations. If False, then
400 -- the source program may not contain 64-bit divide operations. This is
401 -- specifically useful in the zero foot-print case, where the issue is
402 -- whether there is a hardware divide instruction for 64-bits so that
403 -- no run-time support is required. It should always be set True if the
404 -- necessary run-time support is present.
406 Support_Aggregates_On_Target : Boolean := True;
407 -- In the general case, the use of aggregates may generate calls
408 -- to run-time routines in the C library, including memset, memcpy,
409 -- memmove, and bcopy. This flag is set to True if these routines
410 -- are available. If any of these routines is not available, then
411 -- this flag is False, and the use of aggregates is not permitted.
413 Support_Composite_Assign_On_Target : Boolean := True;
414 -- The assignment of composite objects other than small records and
415 -- arrays whose size is 64-bits or less and is set by an explicit
416 -- size clause may generate calls to memcpy, memmove, and bcopy.
417 -- If versions of all these routines are available, then this flag
418 -- is set to True. If any of these routines is not available, then
419 -- the flag is set False, and composite assignments are not allowed.
421 Support_Composite_Compare_On_Target : Boolean := True;
422 -- If this flag is True, then the back end supports bit-wise comparison
423 -- of composite objects for equality, either generating inline code or
424 -- calling appropriate (and available) run-time routines. If this flag
425 -- is False, then the back end does not provide this support, and the
426 -- front end uses component by component comparison for composites.
428 Support_Long_Shifts_On_Target : Boolean := True;
429 -- If True, the back end supports 64-bit shift operations. If False, then
430 -- the source program may not contain explicit 64-bit shifts. In addition,
431 -- the code generated for packed arrays will avoid the use of long shifts.
433 --------------------
434 -- Indirect Calls --
435 --------------------
437 Always_Compatible_Rep_On_Target : Boolean := True;
438 -- If True, the Can_Use_Internal_Rep flag (see Einfo) is set to False in
439 -- all cases. This corresponds to the traditional code generation
440 -- strategy. False allows the front end to choose a policy that partly or
441 -- entirely eliminates dynamically generated trampolines.
443 -------------------------------
444 -- Control of Stack Checking --
445 -------------------------------
447 -- GNAT provides two methods of implementing exceptions:
449 -- GCC Probing Mechanism
451 -- This approach uses the standard GCC mechanism for
452 -- stack checking. The method assumes that accessing
453 -- storage immediately beyond the end of the stack
454 -- will result in a trap that is converted to a storage
455 -- error by the runtime system. This mechanism has
456 -- minimal overhead, but requires complex hardware,
457 -- operating system and run-time support. Probing is
458 -- the default method where it is available. The stack
459 -- size for the environment task depends on the operating
460 -- system and cannot be set in a system-independent way.
462 -- GCC Stack-limit Mechanism
464 -- This approach uses the GCC stack limits mechanism.
465 -- It relies on comparing the stack pointer with the
466 -- values of a global symbol. If the check fails, a
467 -- trap is explicitly generated. The advantage is
468 -- that the mechanism requires no memory protection,
469 -- but operating system and run-time support are
470 -- needed to manage the per-task values of the symbol.
471 -- This is the default method after probing where it
472 -- is available.
474 -- GNAT Stack-limit Checking
476 -- This method relies on comparing the stack pointer
477 -- with per-task stack limits. If the check fails, an
478 -- exception is explicitly raised. The advantage is
479 -- that the method requires no extra system dependent
480 -- runtime support and can be used on systems without
481 -- memory protection as well, but at the cost of more
482 -- overhead for doing the check. This is the fallback
483 -- method if the above two are not supported.
485 Stack_Check_Probes_On_Target : Boolean := False;
486 -- Indicates if the GCC probing mechanism is used
488 Stack_Check_Limits_On_Target : Boolean := False;
489 -- Indicates if the GCC stack-limit mechanism is used
491 -- Both flags cannot be simultaneously set to True. If neither
492 -- is, the target independent fallback method is used.
494 Stack_Check_Default_On_Target : Boolean := False;
495 -- Indicates if stack checking is on by default
497 ----------------------------
498 -- Command Line Arguments --
499 ----------------------------
501 -- For most ports of GNAT, command line arguments are supported. The
502 -- following flag is set to False for targets that do not support
503 -- command line arguments (VxWorks and AAMP). Note that support of
504 -- command line arguments is not required on such targets (RM A.15(13)).
506 Command_Line_Args_On_Target : Boolean := True;
507 -- Set False if no command line arguments on target. Note that if this
508 -- is False in with Configurable_Run_Time_On_Target set to True, then
509 -- this causes suppression of generation of the argv/argc variables
510 -- used to record command line arguments.
512 -- Similarly, most ports support the use of an exit status, but AAMP
513 -- is an exception (as allowed by RM A.15(18-20))
515 Exit_Status_Supported_On_Target : Boolean := True;
516 -- Set False if returning of an exit status is not supported on target.
517 -- Note that if this False in with Configurable_Run_Time_On_Target
518 -- set to True, then this causes suppression of the gnat_exit_status
519 -- variable used to record the exit status.
521 -----------------------
522 -- Main Program Name --
523 -----------------------
525 -- When the binder generates the main program to be used to create the
526 -- executable, the main program name is main by default (to match the
527 -- usual Unix practice). If this parameter is set to True, then the
528 -- name is instead by default taken from the actual Ada main program
529 -- name (just the name of the child if the main program is a child unit).
530 -- In either case, this value can be overridden using -M name.
532 Use_Ada_Main_Program_Name_On_Target : Boolean := False;
533 -- Set True to use the Ada main program name as the main name
535 ----------------------------------------------
536 -- Boolean-Valued Floating-Point Attributes --
537 ----------------------------------------------
539 -- The constants below give the values for representation oriented
540 -- floating-point attributes that are the same for all float types
541 -- on the target. These are all boolean values.
543 -- A value is only True if the target reliably supports the corresponding
544 -- feature. Reliably here means that support is guaranteed for all
545 -- possible settings of the relevant compiler switches (like -mieee),
546 -- since we cannot control the user setting of those switches.
548 -- The attributes cannot dependent on the current setting of compiler
549 -- switches, since the values must be static and consistent throughout
550 -- the partition. We probably should add such consistency checks in future,
551 -- but for now we don't do this.
553 -- Note: the compiler itself does not use floating-point, so the
554 -- settings of the defaults here are not really relevant.
556 -- Note: in some cases, proper support of some of these floating point
557 -- features may require a specific switch (e.g. -mieee on the Alpha)
558 -- to be used to obtain full RM compliant support.
560 Denorm_On_Target : Boolean := False;
561 -- Set to False on targets that do not reliably support denormals
563 Machine_Rounds_On_Target : Boolean := True;
564 -- Set to False for targets where S'Machine_Rounds is False
566 Machine_Overflows_On_Target : Boolean := False;
567 -- Set to True for targets where S'Machine_Overflows is True
569 Signed_Zeros_On_Target : Boolean := True;
570 -- Set to False on targets that do not reliably support signed zeros
572 -------------------------------------------
573 -- Boolean-Valued Fixed-Point Attributes --
574 -------------------------------------------
576 Fractional_Fixed_Ops_On_Target : Boolean := False;
577 -- Set to True for targets that support fixed-by-fixed multiplication
578 -- and division for fixed-point types with a small value equal to
579 -- 2 ** (-(T'Object_Size - 1)) and whose values have an absolute
580 -- value less than 1.0.
582 -----------------
583 -- Data Layout --
584 -----------------
586 -- Normally when using the GCC backend, Gigi and GCC perform much of the
587 -- data layout using the standard layout capabilities of GCC. If the
588 -- parameter Backend_Layout is set to False, then the front end must
589 -- perform all data layout. For further details see the package Layout.
591 Frontend_Layout_On_Target : Boolean := False;
592 -- Set True if front end does layout
594 -----------------
595 -- Subprograms --
596 -----------------
598 -- These subprograms are used to initialize the target parameter values
599 -- from the system.ads file. Note that this is only done once, so if more
600 -- than one call is made to either routine, the second and subsequent
601 -- calls are ignored.
603 procedure Get_Target_Parameters
604 (System_Text : Source_Buffer_Ptr;
605 Source_First : Source_Ptr;
606 Source_Last : Source_Ptr);
607 -- Called at the start of execution to obtain target parameters from
608 -- the source of package System. The parameters provide the source
609 -- text to be scanned (in System_Text (Source_First .. Source_Last)).
611 procedure Get_Target_Parameters;
612 -- This version reads in system.ads using Osint. The idea is that the
613 -- caller uses the first version if they have to read system.ads anyway
614 -- (e.g. the compiler) and uses this simpler interface if system.ads is
615 -- not otherwise needed.
617 end Targparm;