2005-12-29 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / ada / s-auxdec-vms_64.ads
blob3bf7a5b69b5b33c6fad405fefb543bae8bd338f1
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-2005 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 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 -- This is the IPF VMS 64 bit version.
42 with Unchecked_Conversion;
44 package System.Aux_DEC is
45 pragma Preelaborate;
47 subtype Short_Address is Address
48 range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
49 for Short_Address'Object_Size use 32;
50 -- This subtype allows addresses to be converted from 64 bits to 32 bits
51 -- with an appropriate range check. Note that since this is a subtype of
52 -- type System.Address, the same limitations apply to this subtype. Namely
53 -- there are no visible arithmetic operations, and integer literals are
54 -- not available.
56 Short_Memory_Size : constant := 2 ** 32;
57 -- Defined for convenience of porting.
59 type Integer_8 is range -2 ** (8 - 1) .. +2 ** (8 - 1) - 1;
60 for Integer_8'Size use 8;
62 type Integer_16 is range -2 ** (16 - 1) .. +2 ** (16 - 1) - 1;
63 for Integer_16'Size use 16;
65 type Integer_32 is range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
66 for Integer_32'Size use 32;
68 type Integer_64 is range -2 ** (64 - 1) .. +2 ** (64 - 1) - 1;
69 for Integer_64'Size use 64;
71 type Largest_Integer is range Min_Int .. Max_Int;
73 type AST_Handler is limited private;
75 No_AST_Handler : constant AST_Handler;
77 type Type_Class is
78 (Type_Class_Enumeration,
79 Type_Class_Integer,
80 Type_Class_Fixed_Point,
81 Type_Class_Floating_Point,
82 Type_Class_Array,
83 Type_Class_Record,
84 Type_Class_Access,
85 Type_Class_Task, -- also in Ada 95 protected
86 Type_Class_Address);
88 function "not" (Left : Largest_Integer) return Largest_Integer;
89 function "and" (Left, Right : Largest_Integer) return Largest_Integer;
90 function "or" (Left, Right : Largest_Integer) return Largest_Integer;
91 function "xor" (Left, Right : Largest_Integer) return Largest_Integer;
93 Address_Zero : constant Address;
94 No_Addr : constant Address;
95 Address_Size : constant := Standard'Address_Size;
97 function "+" (Left : Address; Right : Integer) return Address;
98 function "+" (Left : Integer; Right : Address) return Address;
99 function "-" (Left : Address; Right : Address) return Integer;
100 function "-" (Left : Address; Right : Integer) return Address;
102 generic
103 type Target is private;
104 function Fetch_From_Address (A : Address) return Target;
106 generic
107 type Target is private;
108 procedure Assign_To_Address (A : Address; T : Target);
110 -- Floating point type declarations for VAX floating point data types
112 pragma Warnings (Off);
114 type F_Float is digits 6;
115 pragma Float_Representation (VAX_Float, F_Float);
117 type D_Float is digits 9;
118 pragma Float_Representation (Vax_Float, D_Float);
120 type G_Float is digits 15;
121 pragma Float_Representation (Vax_Float, G_Float);
123 -- Floating point type declarations for IEEE floating point data types
125 type IEEE_Single_Float is digits 6;
126 pragma Float_Representation (IEEE_Float, IEEE_Single_Float);
128 type IEEE_Double_Float is digits 15;
129 pragma Float_Representation (IEEE_Float, IEEE_Double_Float);
131 pragma Warnings (On);
133 Non_Ada_Error : exception;
135 -- Hardware-oriented types and functions
137 type Bit_Array is array (Integer range <>) of Boolean;
138 pragma Pack (Bit_Array);
140 subtype Bit_Array_8 is Bit_Array (0 .. 7);
141 subtype Bit_Array_16 is Bit_Array (0 .. 15);
142 subtype Bit_Array_32 is Bit_Array (0 .. 31);
143 subtype Bit_Array_64 is Bit_Array (0 .. 63);
145 type Unsigned_Byte is range 0 .. 255;
146 for Unsigned_Byte'Size use 8;
148 function "not" (Left : Unsigned_Byte) return Unsigned_Byte;
149 function "and" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
150 function "or" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
151 function "xor" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
153 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte;
154 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8;
156 type Unsigned_Byte_Array is array (Integer range <>) of Unsigned_Byte;
158 type Unsigned_Word is range 0 .. 65535;
159 for Unsigned_Word'Size use 16;
161 function "not" (Left : Unsigned_Word) return Unsigned_Word;
162 function "and" (Left, Right : Unsigned_Word) return Unsigned_Word;
163 function "or" (Left, Right : Unsigned_Word) return Unsigned_Word;
164 function "xor" (Left, Right : Unsigned_Word) return Unsigned_Word;
166 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word;
167 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16;
169 type Unsigned_Word_Array is array (Integer range <>) of Unsigned_Word;
171 type Unsigned_Longword is range -2_147_483_648 .. 2_147_483_647;
172 for Unsigned_Longword'Size use 32;
174 function "not" (Left : Unsigned_Longword) return Unsigned_Longword;
175 function "and" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
176 function "or" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
177 function "xor" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
179 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword;
180 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32;
182 type Unsigned_Longword_Array is
183 array (Integer range <>) of Unsigned_Longword;
185 type Unsigned_32 is range 0 .. 4_294_967_295;
186 for Unsigned_32'Size use 32;
188 function "not" (Left : Unsigned_32) return Unsigned_32;
189 function "and" (Left, Right : Unsigned_32) return Unsigned_32;
190 function "or" (Left, Right : Unsigned_32) return Unsigned_32;
191 function "xor" (Left, Right : Unsigned_32) return Unsigned_32;
193 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32;
194 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32;
196 type Unsigned_Quadword is record
197 L0 : Unsigned_Longword;
198 L1 : Unsigned_Longword;
199 end record;
201 for Unsigned_Quadword'Size use 64;
202 for Unsigned_Quadword'Alignment use
203 Integer'Min (8, Standard'Maximum_Alignment);
205 function "not" (Left : Unsigned_Quadword) return Unsigned_Quadword;
206 function "and" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
207 function "or" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
208 function "xor" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
210 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword;
211 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64;
213 type Unsigned_Quadword_Array is
214 array (Integer range <>) of Unsigned_Quadword;
216 function To_Address (X : Integer) return Address;
217 pragma Pure_Function (To_Address);
219 function To_Address_Long (X : Unsigned_Longword) return Address;
220 pragma Pure_Function (To_Address_Long);
222 function To_Integer (X : Address) return Integer;
224 function To_Unsigned_Longword (X : Address) return Unsigned_Longword;
225 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword;
227 -- Conventional names for static subtypes of type UNSIGNED_LONGWORD
229 subtype Unsigned_1 is Unsigned_Longword range 0 .. 2** 1-1;
230 subtype Unsigned_2 is Unsigned_Longword range 0 .. 2** 2-1;
231 subtype Unsigned_3 is Unsigned_Longword range 0 .. 2** 3-1;
232 subtype Unsigned_4 is Unsigned_Longword range 0 .. 2** 4-1;
233 subtype Unsigned_5 is Unsigned_Longword range 0 .. 2** 5-1;
234 subtype Unsigned_6 is Unsigned_Longword range 0 .. 2** 6-1;
235 subtype Unsigned_7 is Unsigned_Longword range 0 .. 2** 7-1;
236 subtype Unsigned_8 is Unsigned_Longword range 0 .. 2** 8-1;
237 subtype Unsigned_9 is Unsigned_Longword range 0 .. 2** 9-1;
238 subtype Unsigned_10 is Unsigned_Longword range 0 .. 2**10-1;
239 subtype Unsigned_11 is Unsigned_Longword range 0 .. 2**11-1;
240 subtype Unsigned_12 is Unsigned_Longword range 0 .. 2**12-1;
241 subtype Unsigned_13 is Unsigned_Longword range 0 .. 2**13-1;
242 subtype Unsigned_14 is Unsigned_Longword range 0 .. 2**14-1;
243 subtype Unsigned_15 is Unsigned_Longword range 0 .. 2**15-1;
244 subtype Unsigned_16 is Unsigned_Longword range 0 .. 2**16-1;
245 subtype Unsigned_17 is Unsigned_Longword range 0 .. 2**17-1;
246 subtype Unsigned_18 is Unsigned_Longword range 0 .. 2**18-1;
247 subtype Unsigned_19 is Unsigned_Longword range 0 .. 2**19-1;
248 subtype Unsigned_20 is Unsigned_Longword range 0 .. 2**20-1;
249 subtype Unsigned_21 is Unsigned_Longword range 0 .. 2**21-1;
250 subtype Unsigned_22 is Unsigned_Longword range 0 .. 2**22-1;
251 subtype Unsigned_23 is Unsigned_Longword range 0 .. 2**23-1;
252 subtype Unsigned_24 is Unsigned_Longword range 0 .. 2**24-1;
253 subtype Unsigned_25 is Unsigned_Longword range 0 .. 2**25-1;
254 subtype Unsigned_26 is Unsigned_Longword range 0 .. 2**26-1;
255 subtype Unsigned_27 is Unsigned_Longword range 0 .. 2**27-1;
256 subtype Unsigned_28 is Unsigned_Longword range 0 .. 2**28-1;
257 subtype Unsigned_29 is Unsigned_Longword range 0 .. 2**29-1;
258 subtype Unsigned_30 is Unsigned_Longword range 0 .. 2**30-1;
259 subtype Unsigned_31 is Unsigned_Longword range 0 .. 2**31-1;
261 -- Function for obtaining global symbol values
263 function Import_Value (Symbol : String) return Unsigned_Longword;
264 function Import_Address (Symbol : String) return Address;
265 function Import_Largest_Value (Symbol : String) return Largest_Integer;
267 pragma Import (Intrinsic, Import_Value);
268 pragma Import (Intrinsic, Import_Address);
269 pragma Import (Intrinsic, Import_Largest_Value);
271 -- For the following declarations, note that the declaration without
272 -- a Retry_Count parameter means to retry infinitely. A value of zero
273 -- for the Retry_Count parameter means do not retry.
275 -- Interlocked-instruction procedures
277 procedure Clear_Interlocked
278 (Bit : in out Boolean;
279 Old_Value : out Boolean);
281 procedure Set_Interlocked
282 (Bit : in out Boolean;
283 Old_Value : out Boolean);
285 type Aligned_Word is record
286 Value : Short_Integer;
287 end record;
289 for Aligned_Word'Alignment use
290 Integer'Min (2, Standard'Maximum_Alignment);
292 procedure Clear_Interlocked
293 (Bit : in out Boolean;
294 Old_Value : out Boolean;
295 Retry_Count : in Natural;
296 Success_Flag : out Boolean);
298 procedure Set_Interlocked
299 (Bit : in out Boolean;
300 Old_Value : out Boolean;
301 Retry_Count : in Natural;
302 Success_Flag : out Boolean);
304 procedure Add_Interlocked
305 (Addend : in Short_Integer;
306 Augend : in out Aligned_Word;
307 Sign : out Integer);
309 type Aligned_Integer is record
310 Value : Integer;
311 end record;
313 for Aligned_Integer'Alignment use
314 Integer'Min (4, Standard'Maximum_Alignment);
316 type Aligned_Long_Integer is record
317 Value : Long_Integer;
318 end record;
320 for Aligned_Long_Integer'Alignment use
321 Integer'Min (8, Standard'Maximum_Alignment);
323 -- For the following declarations, note that the declaration without
324 -- a Retry_Count parameter mean to retry infinitely. A value of zero
325 -- for the Retry_Count means do not retry.
327 procedure Add_Atomic
328 (To : in out Aligned_Integer;
329 Amount : in Integer);
331 procedure Add_Atomic
332 (To : in out Aligned_Integer;
333 Amount : in Integer;
334 Retry_Count : in Natural;
335 Old_Value : out Integer;
336 Success_Flag : out Boolean);
338 procedure Add_Atomic
339 (To : in out Aligned_Long_Integer;
340 Amount : in Long_Integer);
342 procedure Add_Atomic
343 (To : in out Aligned_Long_Integer;
344 Amount : in Long_Integer;
345 Retry_Count : in Natural;
346 Old_Value : out Long_Integer;
347 Success_Flag : out Boolean);
349 procedure And_Atomic
350 (To : in out Aligned_Integer;
351 From : in Integer);
353 procedure And_Atomic
354 (To : in out Aligned_Integer;
355 From : in Integer;
356 Retry_Count : in Natural;
357 Old_Value : out Integer;
358 Success_Flag : out Boolean);
360 procedure And_Atomic
361 (To : in out Aligned_Long_Integer;
362 From : in Long_Integer);
364 procedure And_Atomic
365 (To : in out Aligned_Long_Integer;
366 From : in Long_Integer;
367 Retry_Count : in Natural;
368 Old_Value : out Long_Integer;
369 Success_Flag : out Boolean);
371 procedure Or_Atomic
372 (To : in out Aligned_Integer;
373 From : in Integer);
375 procedure Or_Atomic
376 (To : in out Aligned_Integer;
377 From : in Integer;
378 Retry_Count : in Natural;
379 Old_Value : out Integer;
380 Success_Flag : out Boolean);
382 procedure Or_Atomic
383 (To : in out Aligned_Long_Integer;
384 From : in Long_Integer);
386 procedure Or_Atomic
387 (To : in out Aligned_Long_Integer;
388 From : in Long_Integer;
389 Retry_Count : in Natural;
390 Old_Value : out Long_Integer;
391 Success_Flag : out Boolean);
393 type Insq_Status is
394 (Fail_No_Lock, OK_Not_First, OK_First);
396 for Insq_Status use
397 (Fail_No_Lock => -1,
398 OK_Not_First => 0,
399 OK_First => +1);
401 type Remq_Status is (
402 Fail_No_Lock,
403 Fail_Was_Empty,
404 OK_Not_Empty,
405 OK_Empty);
407 for Remq_Status use
408 (Fail_No_Lock => -1,
409 Fail_Was_Empty => 0,
410 OK_Not_Empty => +1,
411 OK_Empty => +2);
413 procedure Insqhi
414 (Item : in Address;
415 Header : in Address;
416 Status : out Insq_Status);
418 procedure Remqhi
419 (Header : in Address;
420 Item : out Address;
421 Status : out Remq_Status);
423 procedure Insqti
424 (Item : in Address;
425 Header : in Address;
426 Status : out Insq_Status);
428 procedure Remqti
429 (Header : in Address;
430 Item : out Address;
431 Status : out Remq_Status);
433 private
435 Address_Zero : constant Address := Null_Address;
436 No_Addr : constant Address := Null_Address;
438 -- An AST_Handler value is from a typing point of view simply a pointer
439 -- to a procedure taking a single 64bit parameter. However, this
440 -- is a bit misleading, because the data that this pointer references is
441 -- highly stylized. See body of System.AST_Handling for full details.
443 type AST_Handler is access procedure (Param : Long_Integer);
444 No_AST_Handler : constant AST_Handler := null;
446 -- Other operators have incorrect profiles. It would be nice to make
447 -- them intrinsic, since the backend can handle them, but the front
448 -- end is not prepared to deal with them, so at least inline them.
450 pragma Inline_Always ("+");
451 pragma Inline_Always ("-");
452 pragma Inline_Always ("not");
453 pragma Inline_Always ("and");
454 pragma Inline_Always ("or");
455 pragma Inline_Always ("xor");
457 -- Other inlined subprograms
459 pragma Inline_Always (Fetch_From_Address);
460 pragma Inline_Always (Assign_To_Address);
462 -- Synchronization related subprograms. These are declared to have
463 -- convention C so that the critical parameters are passed by reference.
464 -- Without this, the parameters are passed by copy, creating load/store
465 -- race conditions. We also inline them, since this seems more in the
466 -- spirit of the original (hardware intrinsic) routines.
468 pragma Convention (C, Clear_Interlocked);
469 pragma Inline_Always (Clear_Interlocked);
471 pragma Convention (C, Set_Interlocked);
472 pragma Inline_Always (Set_Interlocked);
474 pragma Convention (C, Add_Interlocked);
475 pragma Inline_Always (Add_Interlocked);
477 pragma Convention (C, Add_Atomic);
478 pragma Inline_Always (Add_Atomic);
480 pragma Convention (C, And_Atomic);
481 pragma Inline_Always (And_Atomic);
483 pragma Convention (C, Or_Atomic);
484 pragma Inline_Always (Or_Atomic);
486 -- Provide proper unchecked conversion definitions for transfer
487 -- functions. Note that we need this level of indirection because
488 -- the formal parameter name is X and not Source (and this is indeed
489 -- detectable by a program)
491 function To_Unsigned_Byte_A is new
492 Unchecked_Conversion (Bit_Array_8, Unsigned_Byte);
494 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte
495 renames To_Unsigned_Byte_A;
497 function To_Bit_Array_8_A is new
498 Unchecked_Conversion (Unsigned_Byte, Bit_Array_8);
500 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8
501 renames To_Bit_Array_8_A;
503 function To_Unsigned_Word_A is new
504 Unchecked_Conversion (Bit_Array_16, Unsigned_Word);
506 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word
507 renames To_Unsigned_Word_A;
509 function To_Bit_Array_16_A is new
510 Unchecked_Conversion (Unsigned_Word, Bit_Array_16);
512 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16
513 renames To_Bit_Array_16_A;
515 function To_Unsigned_Longword_A is new
516 Unchecked_Conversion (Bit_Array_32, Unsigned_Longword);
518 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword
519 renames To_Unsigned_Longword_A;
521 function To_Bit_Array_32_A is new
522 Unchecked_Conversion (Unsigned_Longword, Bit_Array_32);
524 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32
525 renames To_Bit_Array_32_A;
527 function To_Unsigned_32_A is new
528 Unchecked_Conversion (Bit_Array_32, Unsigned_32);
530 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32
531 renames To_Unsigned_32_A;
533 function To_Bit_Array_32_A is new
534 Unchecked_Conversion (Unsigned_32, Bit_Array_32);
536 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32
537 renames To_Bit_Array_32_A;
539 function To_Unsigned_Quadword_A is new
540 Unchecked_Conversion (Bit_Array_64, Unsigned_Quadword);
542 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword
543 renames To_Unsigned_Quadword_A;
545 function To_Bit_Array_64_A is new
546 Unchecked_Conversion (Unsigned_Quadword, Bit_Array_64);
548 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64
549 renames To_Bit_Array_64_A;
551 pragma Warnings (Off);
552 -- Turn warnings off. This is needed for systems with 64-bit integers,
553 -- where some of these operations are of dubious meaning, but we do not
554 -- want warnings when we compile on such systems.
556 function To_Address_A is new
557 Unchecked_Conversion (Integer, Address);
558 pragma Pure_Function (To_Address_A);
560 function To_Address (X : Integer) return Address
561 renames To_Address_A;
562 pragma Pure_Function (To_Address);
564 function To_Address_Long_A is new
565 Unchecked_Conversion (Unsigned_Longword, Address);
566 pragma Pure_Function (To_Address_Long_A);
568 function To_Address_Long (X : Unsigned_Longword) return Address
569 renames To_Address_Long_A;
570 pragma Pure_Function (To_Address_Long);
572 function To_Integer_A is new
573 Unchecked_Conversion (Address, Integer);
575 function To_Integer (X : Address) return Integer
576 renames To_Integer_A;
578 function To_Unsigned_Longword_A is new
579 Unchecked_Conversion (Address, Unsigned_Longword);
581 function To_Unsigned_Longword (X : Address) return Unsigned_Longword
582 renames To_Unsigned_Longword_A;
584 function To_Unsigned_Longword_A is new
585 Unchecked_Conversion (AST_Handler, Unsigned_Longword);
587 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword
588 renames To_Unsigned_Longword_A;
590 pragma Warnings (On);
592 end System.Aux_DEC;