* arm.c (FL_WBUF): Define.
[official-gcc.git] / gcc / ada / s-auxdec.ads
blobc3e16f502ca502fbf9ea0ef72d37c4a28acf0f37
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . A U X _ D E C --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1996-2004 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 -- 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 contains definitions that are designed to be compatible
35 -- with the extra definitions in package System for DEC Ada implementations.
37 -- These definitions can be used directly by withing this package, or merged
38 -- with System using pragma Extend_System (Aux_DEC)
40 with Unchecked_Conversion;
42 package System.Aux_DEC is
43 pragma Elaborate_Body (Aux_DEC);
45 subtype Short_Address is Address;
46 -- In some versions of System.Aux_DEC, notably that for VMS on the
47 -- ia64, there are two address types (64-bit and 32-bit), and the
48 -- name Short_Address is used for the short address form. To avoid
49 -- difficulties (in regression tests and elsewhere) with units that
50 -- reference Short_Address, it is provided for other targets as a
51 -- synonum for the normal Address type, and, as in the case where
52 -- the lengths are different, Address and Short_Address can be
53 -- freely inter-converted.
55 type Integer_8 is range -2 ** (8 - 1) .. +2 ** (8 - 1) - 1;
56 for Integer_8'Size use 8;
58 type Integer_16 is range -2 ** (16 - 1) .. +2 ** (16 - 1) - 1;
59 for Integer_16'Size use 16;
61 type Integer_32 is range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
62 for Integer_32'Size use 32;
64 type Integer_64 is range -2 ** (64 - 1) .. +2 ** (64 - 1) - 1;
65 for Integer_64'Size use 64;
67 type Largest_Integer is range Min_Int .. Max_Int;
69 type AST_Handler is limited private;
71 No_AST_Handler : constant AST_Handler;
73 type Type_Class is
74 (Type_Class_Enumeration,
75 Type_Class_Integer,
76 Type_Class_Fixed_Point,
77 Type_Class_Floating_Point,
78 Type_Class_Array,
79 Type_Class_Record,
80 Type_Class_Access,
81 Type_Class_Task, -- also in Ada 95 protected
82 Type_Class_Address);
84 function "not" (Left : Largest_Integer) return Largest_Integer;
85 function "and" (Left, Right : Largest_Integer) return Largest_Integer;
86 function "or" (Left, Right : Largest_Integer) return Largest_Integer;
87 function "xor" (Left, Right : Largest_Integer) return Largest_Integer;
89 Address_Zero : constant Address;
90 No_Addr : constant Address;
91 Address_Size : constant := Standard'Address_Size;
93 function "+" (Left : Address; Right : Integer) return Address;
94 function "+" (Left : Integer; Right : Address) return Address;
95 function "-" (Left : Address; Right : Address) return Integer;
96 function "-" (Left : Address; Right : Integer) return Address;
98 generic
99 type Target is private;
100 function Fetch_From_Address (A : Address) return Target;
102 generic
103 type Target is private;
104 procedure Assign_To_Address (A : Address; T : Target);
106 -- Floating point type declarations for VAX floating point data types
108 pragma Warnings (Off);
110 type F_Float is digits 6;
111 pragma Float_Representation (VAX_Float, F_Float);
113 type D_Float is digits 9;
114 pragma Float_Representation (Vax_Float, D_Float);
116 type G_Float is digits 15;
117 pragma Float_Representation (Vax_Float, G_Float);
119 -- Floating point type declarations for IEEE floating point data types
121 type IEEE_Single_Float is digits 6;
122 pragma Float_Representation (IEEE_Float, IEEE_Single_Float);
124 type IEEE_Double_Float is digits 15;
125 pragma Float_Representation (IEEE_Float, IEEE_Double_Float);
127 pragma Warnings (On);
129 Non_Ada_Error : exception;
131 -- Hardware-oriented types and functions
133 type Bit_Array is array (Integer range <>) of Boolean;
134 pragma Pack (Bit_Array);
136 subtype Bit_Array_8 is Bit_Array (0 .. 7);
137 subtype Bit_Array_16 is Bit_Array (0 .. 15);
138 subtype Bit_Array_32 is Bit_Array (0 .. 31);
139 subtype Bit_Array_64 is Bit_Array (0 .. 63);
141 type Unsigned_Byte is range 0 .. 255;
142 for Unsigned_Byte'Size use 8;
144 function "not" (Left : Unsigned_Byte) return Unsigned_Byte;
145 function "and" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
146 function "or" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
147 function "xor" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
149 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte;
150 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8;
152 type Unsigned_Byte_Array is array (Integer range <>) of Unsigned_Byte;
154 type Unsigned_Word is range 0 .. 65535;
155 for Unsigned_Word'Size use 16;
157 function "not" (Left : Unsigned_Word) return Unsigned_Word;
158 function "and" (Left, Right : Unsigned_Word) return Unsigned_Word;
159 function "or" (Left, Right : Unsigned_Word) return Unsigned_Word;
160 function "xor" (Left, Right : Unsigned_Word) return Unsigned_Word;
162 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word;
163 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16;
165 type Unsigned_Word_Array is array (Integer range <>) of Unsigned_Word;
167 type Unsigned_Longword is range -2_147_483_648 .. 2_147_483_647;
168 for Unsigned_Longword'Size use 32;
170 function "not" (Left : Unsigned_Longword) return Unsigned_Longword;
171 function "and" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
172 function "or" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
173 function "xor" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
175 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword;
176 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32;
178 type Unsigned_Longword_Array is
179 array (Integer range <>) of Unsigned_Longword;
181 type Unsigned_32 is range 0 .. 4_294_967_295;
182 for Unsigned_32'Size use 32;
184 function "not" (Left : Unsigned_32) return Unsigned_32;
185 function "and" (Left, Right : Unsigned_32) return Unsigned_32;
186 function "or" (Left, Right : Unsigned_32) return Unsigned_32;
187 function "xor" (Left, Right : Unsigned_32) return Unsigned_32;
189 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32;
190 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32;
192 type Unsigned_Quadword is record
193 L0 : Unsigned_Longword;
194 L1 : Unsigned_Longword;
195 end record;
197 for Unsigned_Quadword'Size use 64;
198 for Unsigned_Quadword'Alignment use
199 Integer'Min (8, Standard'Maximum_Alignment);
201 function "not" (Left : Unsigned_Quadword) return Unsigned_Quadword;
202 function "and" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
203 function "or" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
204 function "xor" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
206 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword;
207 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64;
209 type Unsigned_Quadword_Array is
210 array (Integer range <>) of Unsigned_Quadword;
212 function To_Address (X : Integer) return Address;
213 pragma Pure_Function (To_Address);
215 function To_Address_Long (X : Unsigned_Longword) return Address;
216 pragma Pure_Function (To_Address_Long);
218 function To_Integer (X : Address) return Integer;
220 function To_Unsigned_Longword (X : Address) return Unsigned_Longword;
221 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword;
223 -- Conventional names for static subtypes of type UNSIGNED_LONGWORD
225 subtype Unsigned_1 is Unsigned_Longword range 0 .. 2** 1-1;
226 subtype Unsigned_2 is Unsigned_Longword range 0 .. 2** 2-1;
227 subtype Unsigned_3 is Unsigned_Longword range 0 .. 2** 3-1;
228 subtype Unsigned_4 is Unsigned_Longword range 0 .. 2** 4-1;
229 subtype Unsigned_5 is Unsigned_Longword range 0 .. 2** 5-1;
230 subtype Unsigned_6 is Unsigned_Longword range 0 .. 2** 6-1;
231 subtype Unsigned_7 is Unsigned_Longword range 0 .. 2** 7-1;
232 subtype Unsigned_8 is Unsigned_Longword range 0 .. 2** 8-1;
233 subtype Unsigned_9 is Unsigned_Longword range 0 .. 2** 9-1;
234 subtype Unsigned_10 is Unsigned_Longword range 0 .. 2**10-1;
235 subtype Unsigned_11 is Unsigned_Longword range 0 .. 2**11-1;
236 subtype Unsigned_12 is Unsigned_Longword range 0 .. 2**12-1;
237 subtype Unsigned_13 is Unsigned_Longword range 0 .. 2**13-1;
238 subtype Unsigned_14 is Unsigned_Longword range 0 .. 2**14-1;
239 subtype Unsigned_15 is Unsigned_Longword range 0 .. 2**15-1;
240 subtype Unsigned_16 is Unsigned_Longword range 0 .. 2**16-1;
241 subtype Unsigned_17 is Unsigned_Longword range 0 .. 2**17-1;
242 subtype Unsigned_18 is Unsigned_Longword range 0 .. 2**18-1;
243 subtype Unsigned_19 is Unsigned_Longword range 0 .. 2**19-1;
244 subtype Unsigned_20 is Unsigned_Longword range 0 .. 2**20-1;
245 subtype Unsigned_21 is Unsigned_Longword range 0 .. 2**21-1;
246 subtype Unsigned_22 is Unsigned_Longword range 0 .. 2**22-1;
247 subtype Unsigned_23 is Unsigned_Longword range 0 .. 2**23-1;
248 subtype Unsigned_24 is Unsigned_Longword range 0 .. 2**24-1;
249 subtype Unsigned_25 is Unsigned_Longword range 0 .. 2**25-1;
250 subtype Unsigned_26 is Unsigned_Longword range 0 .. 2**26-1;
251 subtype Unsigned_27 is Unsigned_Longword range 0 .. 2**27-1;
252 subtype Unsigned_28 is Unsigned_Longword range 0 .. 2**28-1;
253 subtype Unsigned_29 is Unsigned_Longword range 0 .. 2**29-1;
254 subtype Unsigned_30 is Unsigned_Longword range 0 .. 2**30-1;
255 subtype Unsigned_31 is Unsigned_Longword range 0 .. 2**31-1;
257 -- Function for obtaining global symbol values
259 function Import_Value (Symbol : String) return Unsigned_Longword;
260 function Import_Address (Symbol : String) return Address;
261 function Import_Largest_Value (Symbol : String) return Largest_Integer;
263 pragma Import (Intrinsic, Import_Value);
264 pragma Import (Intrinsic, Import_Address);
265 pragma Import (Intrinsic, Import_Largest_Value);
267 -- For the following declarations, note that the declaration without
268 -- a Retry_Count parameter means to retry infinitely. A value of zero
269 -- for the Retry_Count parameter means do not retry.
271 -- Interlocked-instruction procedures
273 procedure Clear_Interlocked
274 (Bit : in out Boolean;
275 Old_Value : out Boolean);
277 procedure Set_Interlocked
278 (Bit : in out Boolean;
279 Old_Value : out Boolean);
281 type Aligned_Word is record
282 Value : Short_Integer;
283 end record;
285 for Aligned_Word'Alignment use
286 Integer'Min (2, Standard'Maximum_Alignment);
288 procedure Clear_Interlocked
289 (Bit : in out Boolean;
290 Old_Value : out Boolean;
291 Retry_Count : in Natural;
292 Success_Flag : out Boolean);
294 procedure Set_Interlocked
295 (Bit : in out Boolean;
296 Old_Value : out Boolean;
297 Retry_Count : in Natural;
298 Success_Flag : out Boolean);
300 procedure Add_Interlocked
301 (Addend : in Short_Integer;
302 Augend : in out Aligned_Word;
303 Sign : out Integer);
305 type Aligned_Integer is record
306 Value : Integer;
307 end record;
309 for Aligned_Integer'Alignment use
310 Integer'Min (4, Standard'Maximum_Alignment);
312 type Aligned_Long_Integer is record
313 Value : Long_Integer;
314 end record;
316 for Aligned_Long_Integer'Alignment use
317 Integer'Min (8, Standard'Maximum_Alignment);
319 -- For the following declarations, note that the declaration without
320 -- a Retry_Count parameter mean to retry infinitely. A value of zero
321 -- for the Retry_Count means do not retry.
323 procedure Add_Atomic
324 (To : in out Aligned_Integer;
325 Amount : in Integer);
327 procedure Add_Atomic
328 (To : in out Aligned_Integer;
329 Amount : in Integer;
330 Retry_Count : in Natural;
331 Old_Value : out Integer;
332 Success_Flag : out Boolean);
334 procedure Add_Atomic
335 (To : in out Aligned_Long_Integer;
336 Amount : in Long_Integer);
338 procedure Add_Atomic
339 (To : in out Aligned_Long_Integer;
340 Amount : in Long_Integer;
341 Retry_Count : in Natural;
342 Old_Value : out Long_Integer;
343 Success_Flag : out Boolean);
345 procedure And_Atomic
346 (To : in out Aligned_Integer;
347 From : in Integer);
349 procedure And_Atomic
350 (To : in out Aligned_Integer;
351 From : in Integer;
352 Retry_Count : in Natural;
353 Old_Value : out Integer;
354 Success_Flag : out Boolean);
356 procedure And_Atomic
357 (To : in out Aligned_Long_Integer;
358 From : in Long_Integer);
360 procedure And_Atomic
361 (To : in out Aligned_Long_Integer;
362 From : in Long_Integer;
363 Retry_Count : in Natural;
364 Old_Value : out Long_Integer;
365 Success_Flag : out Boolean);
367 procedure Or_Atomic
368 (To : in out Aligned_Integer;
369 From : in Integer);
371 procedure Or_Atomic
372 (To : in out Aligned_Integer;
373 From : in Integer;
374 Retry_Count : in Natural;
375 Old_Value : out Integer;
376 Success_Flag : out Boolean);
378 procedure Or_Atomic
379 (To : in out Aligned_Long_Integer;
380 From : in Long_Integer);
382 procedure Or_Atomic
383 (To : in out Aligned_Long_Integer;
384 From : in Long_Integer;
385 Retry_Count : in Natural;
386 Old_Value : out Long_Integer;
387 Success_Flag : out Boolean);
389 type Insq_Status is
390 (Fail_No_Lock, OK_Not_First, OK_First);
392 for Insq_Status use
393 (Fail_No_Lock => -1,
394 OK_Not_First => 0,
395 OK_First => +1);
397 type Remq_Status is (
398 Fail_No_Lock,
399 Fail_Was_Empty,
400 OK_Not_Empty,
401 OK_Empty);
403 for Remq_Status use
404 (Fail_No_Lock => -1,
405 Fail_Was_Empty => 0,
406 OK_Not_Empty => +1,
407 OK_Empty => +2);
409 procedure Insqhi
410 (Item : in Address;
411 Header : in Address;
412 Status : out Insq_Status);
414 procedure Remqhi
415 (Header : in Address;
416 Item : out Address;
417 Status : out Remq_Status);
419 procedure Insqti
420 (Item : in Address;
421 Header : in Address;
422 Status : out Insq_Status);
424 procedure Remqti
425 (Header : in Address;
426 Item : out Address;
427 Status : out Remq_Status);
429 private
431 Address_Zero : constant Address := Null_Address;
432 No_Addr : constant Address := Null_Address;
434 -- An AST_Handler value is from a typing point of view simply a pointer
435 -- to a procedure taking a single 64bit parameter. However, this
436 -- is a bit misleading, because the data that this pointer references is
437 -- highly stylized. See body of System.AST_Handling for full details.
439 type AST_Handler is access procedure (Param : Long_Integer);
440 No_AST_Handler : constant AST_Handler := null;
442 -- Other operators have incorrect profiles. It would be nice to make
443 -- them intrinsic, since the backend can handle them, but the front
444 -- end is not prepared to deal with them, so at least inline them.
446 pragma Inline_Always ("+");
447 pragma Inline_Always ("-");
448 pragma Inline_Always ("not");
449 pragma Inline_Always ("and");
450 pragma Inline_Always ("or");
451 pragma Inline_Always ("xor");
453 -- Other inlined subprograms
455 pragma Inline_Always (Fetch_From_Address);
456 pragma Inline_Always (Assign_To_Address);
458 -- Synchronization related subprograms. These are declared to have
459 -- convention C so that the critical parameters are passed by reference.
460 -- Without this, the parameters are passed by copy, creating load/store
461 -- race conditions. We also inline them, since this seems more in the
462 -- spirit of the original (hardware intrinsic) routines.
464 pragma Convention (C, Clear_Interlocked);
465 pragma Inline_Always (Clear_Interlocked);
467 pragma Convention (C, Set_Interlocked);
468 pragma Inline_Always (Set_Interlocked);
470 pragma Convention (C, Add_Interlocked);
471 pragma Inline_Always (Add_Interlocked);
473 pragma Convention (C, Add_Atomic);
474 pragma Inline_Always (Add_Atomic);
476 pragma Convention (C, And_Atomic);
477 pragma Inline_Always (And_Atomic);
479 pragma Convention (C, Or_Atomic);
480 pragma Inline_Always (Or_Atomic);
482 -- Provide proper unchecked conversion definitions for transfer
483 -- functions. Note that we need this level of indirection because
484 -- the formal parameter name is X and not Source (and this is indeed
485 -- detectable by a program)
487 function To_Unsigned_Byte_A is new
488 Unchecked_Conversion (Bit_Array_8, Unsigned_Byte);
490 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte
491 renames To_Unsigned_Byte_A;
493 function To_Bit_Array_8_A is new
494 Unchecked_Conversion (Unsigned_Byte, Bit_Array_8);
496 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8
497 renames To_Bit_Array_8_A;
499 function To_Unsigned_Word_A is new
500 Unchecked_Conversion (Bit_Array_16, Unsigned_Word);
502 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word
503 renames To_Unsigned_Word_A;
505 function To_Bit_Array_16_A is new
506 Unchecked_Conversion (Unsigned_Word, Bit_Array_16);
508 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16
509 renames To_Bit_Array_16_A;
511 function To_Unsigned_Longword_A is new
512 Unchecked_Conversion (Bit_Array_32, Unsigned_Longword);
514 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword
515 renames To_Unsigned_Longword_A;
517 function To_Bit_Array_32_A is new
518 Unchecked_Conversion (Unsigned_Longword, Bit_Array_32);
520 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32
521 renames To_Bit_Array_32_A;
523 function To_Unsigned_32_A is new
524 Unchecked_Conversion (Bit_Array_32, Unsigned_32);
526 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32
527 renames To_Unsigned_32_A;
529 function To_Bit_Array_32_A is new
530 Unchecked_Conversion (Unsigned_32, Bit_Array_32);
532 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32
533 renames To_Bit_Array_32_A;
535 function To_Unsigned_Quadword_A is new
536 Unchecked_Conversion (Bit_Array_64, Unsigned_Quadword);
538 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword
539 renames To_Unsigned_Quadword_A;
541 function To_Bit_Array_64_A is new
542 Unchecked_Conversion (Unsigned_Quadword, Bit_Array_64);
544 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64
545 renames To_Bit_Array_64_A;
547 pragma Warnings (Off);
548 -- Turn warnings off. This is needed for systems with 64-bit integers,
549 -- where some of these operations are of dubious meaning, but we do not
550 -- want warnings when we compile on such systems.
552 function To_Address_A is new
553 Unchecked_Conversion (Integer, Address);
554 pragma Pure_Function (To_Address_A);
556 function To_Address (X : Integer) return Address
557 renames To_Address_A;
558 pragma Pure_Function (To_Address);
560 function To_Address_Long_A is new
561 Unchecked_Conversion (Unsigned_Longword, Address);
562 pragma Pure_Function (To_Address_Long_A);
564 function To_Address_Long (X : Unsigned_Longword) return Address
565 renames To_Address_Long_A;
566 pragma Pure_Function (To_Address_Long);
568 function To_Integer_A is new
569 Unchecked_Conversion (Address, Integer);
571 function To_Integer (X : Address) return Integer
572 renames To_Integer_A;
574 function To_Unsigned_Longword_A is new
575 Unchecked_Conversion (Address, Unsigned_Longword);
577 function To_Unsigned_Longword (X : Address) return Unsigned_Longword
578 renames To_Unsigned_Longword_A;
580 function To_Unsigned_Longword_A is new
581 Unchecked_Conversion (AST_Handler, Unsigned_Longword);
583 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword
584 renames To_Unsigned_Longword_A;
586 pragma Warnings (On);
588 end System.Aux_DEC;