Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / s-auxdec.ads
blobf9529f1fc63a97918e1da152e90341e22b456194
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 -- --
10 -- Copyright (C) 1996-2001 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS For A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This package contains definitions that are designed to be compatible
36 -- with the extra definitions in package System for DEC Ada implementations.
38 -- These definitions can be used directly by withing this package, or merged
39 -- with System using pragma Extend_System (Aux_DEC)
41 with Unchecked_Conversion;
43 package System.Aux_DEC is
44 pragma Elaborate_Body (Aux_DEC);
46 type Integer_8 is range -2 ** (8 - 1) .. +2 ** (8 - 1) - 1;
47 for Integer_8'Size use 8;
49 type Integer_16 is range -2 ** (16 - 1) .. +2 ** (16 - 1) - 1;
50 for Integer_16'Size use 16;
52 type Integer_32 is range -2 ** (32 - 1) .. +2 ** (32 - 1) - 1;
53 for Integer_32'Size use 32;
55 type Integer_64 is range -2 ** (64 - 1) .. +2 ** (64 - 1) - 1;
56 for Integer_64'Size use 64;
58 type Largest_Integer is range Min_Int .. Max_Int;
60 type AST_Handler is limited private;
62 No_AST_Handler : constant AST_Handler;
64 type Type_Class is
65 (Type_Class_Enumeration,
66 Type_Class_Integer,
67 Type_Class_Fixed_Point,
68 Type_Class_Floating_Point,
69 Type_Class_Array,
70 Type_Class_Record,
71 Type_Class_Access,
72 Type_Class_Task, -- also in Ada 95 protected
73 Type_Class_Address);
75 function "not" (Left : Largest_Integer) return Largest_Integer;
76 function "and" (Left, Right : Largest_Integer) return Largest_Integer;
77 function "or" (Left, Right : Largest_Integer) return Largest_Integer;
78 function "xor" (Left, Right : Largest_Integer) return Largest_Integer;
80 Address_Zero : constant Address;
81 No_Addr : constant Address;
82 Address_Size : constant := Standard'Address_Size;
84 function "+" (Left : Address; Right : Integer) return Address;
85 function "+" (Left : Integer; Right : Address) return Address;
86 function "-" (Left : Address; Right : Address) return Integer;
87 function "-" (Left : Address; Right : Integer) return Address;
89 generic
90 type Target is private;
91 function Fetch_From_Address (A : Address) return Target;
93 generic
94 type Target is private;
95 procedure Assign_To_Address (A : Address; T : Target);
97 -- Floating point type declarations for VAX floating point data types
99 pragma Warnings (Off);
101 type F_Float is digits 6;
102 pragma Float_Representation (VAX_Float, F_Float);
104 type D_Float is digits 9;
105 pragma Float_Representation (Vax_Float, D_Float);
107 type G_Float is digits 15;
108 pragma Float_Representation (Vax_Float, G_Float);
110 -- Floating point type declarations for IEEE floating point data types
112 type IEEE_Single_Float is digits 6;
113 pragma Float_Representation (IEEE_Float, IEEE_Single_Float);
115 type IEEE_Double_Float is digits 15;
116 pragma Float_Representation (IEEE_Float, IEEE_Double_Float);
118 pragma Warnings (On);
120 Non_Ada_Error : exception;
122 -- Hardware-oriented types and functions
124 type Bit_Array is array (Integer range <>) of Boolean;
125 pragma Pack (Bit_Array);
127 subtype Bit_Array_8 is Bit_Array (0 .. 7);
128 subtype Bit_Array_16 is Bit_Array (0 .. 15);
129 subtype Bit_Array_32 is Bit_Array (0 .. 31);
130 subtype Bit_Array_64 is Bit_Array (0 .. 63);
132 type Unsigned_Byte is range 0 .. 255;
133 for Unsigned_Byte'Size use 8;
135 function "not" (Left : Unsigned_Byte) return Unsigned_Byte;
136 function "and" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
137 function "or" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
138 function "xor" (Left, Right : Unsigned_Byte) return Unsigned_Byte;
140 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte;
141 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8;
143 type Unsigned_Byte_Array is array (Integer range <>) of Unsigned_Byte;
145 type Unsigned_Word is range 0 .. 65535;
146 for Unsigned_Word'Size use 16;
148 function "not" (Left : Unsigned_Word) return Unsigned_Word;
149 function "and" (Left, Right : Unsigned_Word) return Unsigned_Word;
150 function "or" (Left, Right : Unsigned_Word) return Unsigned_Word;
151 function "xor" (Left, Right : Unsigned_Word) return Unsigned_Word;
153 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word;
154 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16;
156 type Unsigned_Word_Array is array (Integer range <>) of Unsigned_Word;
158 type Unsigned_Longword is range -2_147_483_648 .. 2_147_483_647;
159 for Unsigned_Longword'Size use 32;
161 function "not" (Left : Unsigned_Longword) return Unsigned_Longword;
162 function "and" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
163 function "or" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
164 function "xor" (Left, Right : Unsigned_Longword) return Unsigned_Longword;
166 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword;
167 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32;
169 type Unsigned_Longword_Array is
170 array (Integer range <>) of Unsigned_Longword;
172 type Unsigned_32 is range 0 .. 4_294_967_295;
173 for Unsigned_32'Size use 32;
175 function "not" (Left : Unsigned_32) return Unsigned_32;
176 function "and" (Left, Right : Unsigned_32) return Unsigned_32;
177 function "or" (Left, Right : Unsigned_32) return Unsigned_32;
178 function "xor" (Left, Right : Unsigned_32) return Unsigned_32;
180 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32;
181 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32;
183 type Unsigned_Quadword is record
184 L0 : Unsigned_Longword;
185 L1 : Unsigned_Longword;
186 end record;
188 for Unsigned_Quadword'Size use 64;
189 for Unsigned_Quadword'Alignment use
190 Integer'Min (8, Standard'Maximum_Alignment);
192 function "not" (Left : Unsigned_Quadword) return Unsigned_Quadword;
193 function "and" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
194 function "or" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
195 function "xor" (Left, Right : Unsigned_Quadword) return Unsigned_Quadword;
197 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword;
198 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64;
200 type Unsigned_Quadword_Array is
201 array (Integer range <>) of Unsigned_Quadword;
203 function To_Address (X : Integer) return Address;
204 pragma Pure_Function (To_Address);
206 function To_Address_Long (X : Unsigned_Longword) return Address;
207 pragma Pure_Function (To_Address_Long);
209 function To_Integer (X : Address) return Integer;
211 function To_Unsigned_Longword (X : Address) return Unsigned_Longword;
212 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword;
214 -- Conventional names for static subtypes of type UNSIGNED_LONGWORD
216 subtype Unsigned_1 is Unsigned_Longword range 0 .. 2** 1-1;
217 subtype Unsigned_2 is Unsigned_Longword range 0 .. 2** 2-1;
218 subtype Unsigned_3 is Unsigned_Longword range 0 .. 2** 3-1;
219 subtype Unsigned_4 is Unsigned_Longword range 0 .. 2** 4-1;
220 subtype Unsigned_5 is Unsigned_Longword range 0 .. 2** 5-1;
221 subtype Unsigned_6 is Unsigned_Longword range 0 .. 2** 6-1;
222 subtype Unsigned_7 is Unsigned_Longword range 0 .. 2** 7-1;
223 subtype Unsigned_8 is Unsigned_Longword range 0 .. 2** 8-1;
224 subtype Unsigned_9 is Unsigned_Longword range 0 .. 2** 9-1;
225 subtype Unsigned_10 is Unsigned_Longword range 0 .. 2**10-1;
226 subtype Unsigned_11 is Unsigned_Longword range 0 .. 2**11-1;
227 subtype Unsigned_12 is Unsigned_Longword range 0 .. 2**12-1;
228 subtype Unsigned_13 is Unsigned_Longword range 0 .. 2**13-1;
229 subtype Unsigned_14 is Unsigned_Longword range 0 .. 2**14-1;
230 subtype Unsigned_15 is Unsigned_Longword range 0 .. 2**15-1;
231 subtype Unsigned_16 is Unsigned_Longword range 0 .. 2**16-1;
232 subtype Unsigned_17 is Unsigned_Longword range 0 .. 2**17-1;
233 subtype Unsigned_18 is Unsigned_Longword range 0 .. 2**18-1;
234 subtype Unsigned_19 is Unsigned_Longword range 0 .. 2**19-1;
235 subtype Unsigned_20 is Unsigned_Longword range 0 .. 2**20-1;
236 subtype Unsigned_21 is Unsigned_Longword range 0 .. 2**21-1;
237 subtype Unsigned_22 is Unsigned_Longword range 0 .. 2**22-1;
238 subtype Unsigned_23 is Unsigned_Longword range 0 .. 2**23-1;
239 subtype Unsigned_24 is Unsigned_Longword range 0 .. 2**24-1;
240 subtype Unsigned_25 is Unsigned_Longword range 0 .. 2**25-1;
241 subtype Unsigned_26 is Unsigned_Longword range 0 .. 2**26-1;
242 subtype Unsigned_27 is Unsigned_Longword range 0 .. 2**27-1;
243 subtype Unsigned_28 is Unsigned_Longword range 0 .. 2**28-1;
244 subtype Unsigned_29 is Unsigned_Longword range 0 .. 2**29-1;
245 subtype Unsigned_30 is Unsigned_Longword range 0 .. 2**30-1;
246 subtype Unsigned_31 is Unsigned_Longword range 0 .. 2**31-1;
248 -- Function for obtaining global symbol values
250 function Import_Value (Symbol : String) return Unsigned_Longword;
251 function Import_Address (Symbol : String) return Address;
252 function Import_Largest_Value (Symbol : String) return Largest_Integer;
254 pragma Import (Intrinsic, Import_Value);
255 pragma Import (Intrinsic, Import_Address);
256 pragma Import (Intrinsic, Import_Largest_Value);
258 -- For the following declarations, note that the declaration without
259 -- a Retry_Count parameter means to retry infinitely. A value of zero
260 -- for the Retry_Count parameter means do not retry.
262 -- Interlocked-instruction procedures
264 procedure Clear_Interlocked
265 (Bit : in out Boolean;
266 Old_Value : out Boolean);
268 procedure Set_Interlocked
269 (Bit : in out Boolean;
270 Old_Value : out Boolean);
272 type Aligned_Word is record
273 Value : Short_Integer;
274 end record;
276 for Aligned_Word'Alignment use
277 Integer'Min (2, Standard'Maximum_Alignment);
279 procedure Clear_Interlocked
280 (Bit : in out Boolean;
281 Old_Value : out Boolean;
282 Retry_Count : in Natural;
283 Success_Flag : out Boolean);
285 procedure Set_Interlocked
286 (Bit : in out Boolean;
287 Old_Value : out Boolean;
288 Retry_Count : in Natural;
289 Success_Flag : out Boolean);
291 procedure Add_Interlocked
292 (Addend : in Short_Integer;
293 Augend : in out Aligned_Word;
294 Sign : out Integer);
296 type Aligned_Integer is record
297 Value : Integer;
298 end record;
300 for Aligned_Integer'Alignment use
301 Integer'Min (4, Standard'Maximum_Alignment);
303 type Aligned_Long_Integer is record
304 Value : Long_Integer;
305 end record;
307 for Aligned_Long_Integer'Alignment use
308 Integer'Min (8, Standard'Maximum_Alignment);
310 -- For the following declarations, note that the declaration without
311 -- a Retry_Count parameter mean to retry infinitely. A value of zero
312 -- for the Retry_Count means do not retry.
314 procedure Add_Atomic
315 (To : in out Aligned_Integer;
316 Amount : in Integer);
318 procedure Add_Atomic
319 (To : in out Aligned_Integer;
320 Amount : in Integer;
321 Retry_Count : in Natural;
322 Old_Value : out Integer;
323 Success_Flag : out Boolean);
325 procedure Add_Atomic
326 (To : in out Aligned_Long_Integer;
327 Amount : in Long_Integer);
329 procedure Add_Atomic
330 (To : in out Aligned_Long_Integer;
331 Amount : in Long_Integer;
332 Retry_Count : in Natural;
333 Old_Value : out Long_Integer;
334 Success_Flag : out Boolean);
336 procedure And_Atomic
337 (To : in out Aligned_Integer;
338 From : in Integer);
340 procedure And_Atomic
341 (To : in out Aligned_Integer;
342 From : in Integer;
343 Retry_Count : in Natural;
344 Old_Value : out Integer;
345 Success_Flag : out Boolean);
347 procedure And_Atomic
348 (To : in out Aligned_Long_Integer;
349 From : in Long_Integer);
351 procedure And_Atomic
352 (To : in out Aligned_Long_Integer;
353 From : in Long_Integer;
354 Retry_Count : in Natural;
355 Old_Value : out Long_Integer;
356 Success_Flag : out Boolean);
358 procedure Or_Atomic
359 (To : in out Aligned_Integer;
360 From : in Integer);
362 procedure Or_Atomic
363 (To : in out Aligned_Integer;
364 From : in Integer;
365 Retry_Count : in Natural;
366 Old_Value : out Integer;
367 Success_Flag : out Boolean);
369 procedure Or_Atomic
370 (To : in out Aligned_Long_Integer;
371 From : in Long_Integer);
373 procedure Or_Atomic
374 (To : in out Aligned_Long_Integer;
375 From : in Long_Integer;
376 Retry_Count : in Natural;
377 Old_Value : out Long_Integer;
378 Success_Flag : out Boolean);
380 type Insq_Status is
381 (Fail_No_Lock, OK_Not_First, OK_First);
383 for Insq_Status use
384 (Fail_No_Lock => -1,
385 OK_Not_First => 0,
386 OK_First => +1);
388 type Remq_Status is (
389 Fail_No_Lock,
390 Fail_Was_Empty,
391 OK_Not_Empty,
392 OK_Empty);
394 for Remq_Status use
395 (Fail_No_Lock => -1,
396 Fail_Was_Empty => 0,
397 OK_Not_Empty => +1,
398 OK_Empty => +2);
400 procedure Insqhi
401 (Item : in Address;
402 Header : in Address;
403 Status : out Insq_Status);
405 procedure Remqhi
406 (Header : in Address;
407 Item : out Address;
408 Status : out Remq_Status);
410 procedure Insqti
411 (Item : in Address;
412 Header : in Address;
413 Status : out Insq_Status);
415 procedure Remqti
416 (Header : in Address;
417 Item : out Address;
418 Status : out Remq_Status);
420 private
422 Address_Zero : constant Address := Null_Address;
423 No_Addr : constant Address := Null_Address;
425 -- An AST_Handler value is from a typing point of view simply a pointer
426 -- to a procedure taking a single 64bit parameter. However, this
427 -- is a bit misleading, because the data that this pointer references is
428 -- highly stylized. See body of System.AST_Handling for full details.
430 type AST_Handler is access procedure (Param : Long_Integer);
431 No_AST_Handler : constant AST_Handler := null;
433 -- Other operators have incorrect profiles. It would be nice to make
434 -- them intrinsic, since the backend can handle them, but the front
435 -- end is not prepared to deal with them, so at least inline them.
437 pragma Inline ("+");
438 pragma Inline ("-");
439 pragma Inline ("not");
440 pragma Inline ("and");
441 pragma Inline ("or");
442 pragma Inline ("xor");
444 -- Other inlined subprograms
446 pragma Inline (Fetch_From_Address);
447 pragma Inline (Assign_To_Address);
449 -- Provide proper unchecked conversion definitions for transfer
450 -- functions. Note that we need this level of indirection because
451 -- the formal parameter name is X and not Source (and this is indeed
452 -- detectable by a program)
454 function To_Unsigned_Byte_A is new
455 Unchecked_Conversion (Bit_Array_8, Unsigned_Byte);
457 function To_Unsigned_Byte (X : Bit_Array_8) return Unsigned_Byte
458 renames To_Unsigned_Byte_A;
460 function To_Bit_Array_8_A is new
461 Unchecked_Conversion (Unsigned_Byte, Bit_Array_8);
463 function To_Bit_Array_8 (X : Unsigned_Byte) return Bit_Array_8
464 renames To_Bit_Array_8_A;
466 function To_Unsigned_Word_A is new
467 Unchecked_Conversion (Bit_Array_16, Unsigned_Word);
469 function To_Unsigned_Word (X : Bit_Array_16) return Unsigned_Word
470 renames To_Unsigned_Word_A;
472 function To_Bit_Array_16_A is new
473 Unchecked_Conversion (Unsigned_Word, Bit_Array_16);
475 function To_Bit_Array_16 (X : Unsigned_Word) return Bit_Array_16
476 renames To_Bit_Array_16_A;
478 function To_Unsigned_Longword_A is new
479 Unchecked_Conversion (Bit_Array_32, Unsigned_Longword);
481 function To_Unsigned_Longword (X : Bit_Array_32) return Unsigned_Longword
482 renames To_Unsigned_Longword_A;
484 function To_Bit_Array_32_A is new
485 Unchecked_Conversion (Unsigned_Longword, Bit_Array_32);
487 function To_Bit_Array_32 (X : Unsigned_Longword) return Bit_Array_32
488 renames To_Bit_Array_32_A;
490 function To_Unsigned_32_A is new
491 Unchecked_Conversion (Bit_Array_32, Unsigned_32);
493 function To_Unsigned_32 (X : Bit_Array_32) return Unsigned_32
494 renames To_Unsigned_32_A;
496 function To_Bit_Array_32_A is new
497 Unchecked_Conversion (Unsigned_32, Bit_Array_32);
499 function To_Bit_Array_32 (X : Unsigned_32) return Bit_Array_32
500 renames To_Bit_Array_32_A;
502 function To_Unsigned_Quadword_A is new
503 Unchecked_Conversion (Bit_Array_64, Unsigned_Quadword);
505 function To_Unsigned_Quadword (X : Bit_Array_64) return Unsigned_Quadword
506 renames To_Unsigned_Quadword_A;
508 function To_Bit_Array_64_A is new
509 Unchecked_Conversion (Unsigned_Quadword, Bit_Array_64);
511 function To_Bit_Array_64 (X : Unsigned_Quadword) return Bit_Array_64
512 renames To_Bit_Array_64_A;
514 pragma Warnings (Off);
515 -- Turn warnings off. This is needed for systems with 64-bit integers,
516 -- where some of these operations are of dubious meaning, but we do not
517 -- want warnings when we compile on such systems.
519 function To_Address_A is new
520 Unchecked_Conversion (Integer, Address);
521 pragma Pure_Function (To_Address_A);
523 function To_Address (X : Integer) return Address
524 renames To_Address_A;
525 pragma Pure_Function (To_Address);
527 function To_Address_Long_A is new
528 Unchecked_Conversion (Unsigned_Longword, Address);
529 pragma Pure_Function (To_Address_Long_A);
531 function To_Address_Long (X : Unsigned_Longword) return Address
532 renames To_Address_Long_A;
533 pragma Pure_Function (To_Address_Long);
535 function To_Integer_A is new
536 Unchecked_Conversion (Address, Integer);
538 function To_Integer (X : Address) return Integer
539 renames To_Integer_A;
541 function To_Unsigned_Longword_A is new
542 Unchecked_Conversion (Address, Unsigned_Longword);
544 function To_Unsigned_Longword (X : Address) return Unsigned_Longword
545 renames To_Unsigned_Longword_A;
547 function To_Unsigned_Longword_A is new
548 Unchecked_Conversion (AST_Handler, Unsigned_Longword);
550 function To_Unsigned_Longword (X : AST_Handler) return Unsigned_Longword
551 renames To_Unsigned_Longword_A;
553 pragma Warnings (On);
555 end System.Aux_DEC;