compiler: don't generate stubs for ambiguous direct interface methods
[official-gcc.git] / gcc / ada / uintp.ads
blob55f5b971754f5269033ded46ce71b1698e4153f6
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- U I N T P --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2022, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Support for universal integer arithmetic
28 -- WARNING: There is a C version of this package. Any changes to this
29 -- source file must be properly reflected in the C header file uintp.h
31 with Alloc;
32 with Table;
33 pragma Elaborate_All (Table);
34 with Types; use Types;
36 package Uintp is
38 -------------------------------------------------
39 -- Basic Types and Constants for Uintp Package --
40 -------------------------------------------------
42 type Uint is private;
43 -- The basic universal integer type
45 No_Uint : constant Uint;
46 -- A constant value indicating a missing or unset Uint value
48 Uint_0 : constant Uint;
49 Uint_1 : constant Uint;
50 Uint_2 : constant Uint;
51 Uint_3 : constant Uint;
52 Uint_4 : constant Uint;
53 Uint_5 : constant Uint;
54 Uint_6 : constant Uint;
55 Uint_7 : constant Uint;
56 Uint_8 : constant Uint;
57 Uint_9 : constant Uint;
58 Uint_10 : constant Uint;
59 Uint_11 : constant Uint;
60 Uint_12 : constant Uint;
61 Uint_13 : constant Uint;
62 Uint_14 : constant Uint;
63 Uint_15 : constant Uint;
64 Uint_16 : constant Uint;
65 Uint_24 : constant Uint;
66 Uint_31 : constant Uint;
67 Uint_32 : constant Uint;
68 Uint_63 : constant Uint;
69 Uint_64 : constant Uint;
70 Uint_80 : constant Uint;
71 Uint_127 : constant Uint;
72 Uint_128 : constant Uint;
74 Uint_Minus_1 : constant Uint;
75 Uint_Minus_2 : constant Uint;
76 Uint_Minus_3 : constant Uint;
77 Uint_Minus_4 : constant Uint;
78 Uint_Minus_5 : constant Uint;
79 Uint_Minus_6 : constant Uint;
80 Uint_Minus_7 : constant Uint;
81 Uint_Minus_8 : constant Uint;
82 Uint_Minus_9 : constant Uint;
83 Uint_Minus_12 : constant Uint;
84 Uint_Minus_18 : constant Uint;
85 Uint_Minus_31 : constant Uint;
86 Uint_Minus_36 : constant Uint;
87 Uint_Minus_63 : constant Uint;
88 Uint_Minus_76 : constant Uint;
89 Uint_Minus_80 : constant Uint;
90 Uint_Minus_127 : constant Uint;
91 Uint_Minus_128 : constant Uint;
93 -- Functions for detecting No_Uint. Note that clients of this package
94 -- cannot use "=" and "/=" to compare with No_Uint; they must use No
95 -- and Present instead.
97 function No (X : Uint) return Boolean is (X = No_Uint);
98 -- Note that this is using the predefined "=", not the "=" declared below,
99 -- which would blow up on No_Uint.
101 function Present (X : Uint) return Boolean is (not No (X));
103 subtype Valid_Uint is Uint with Predicate => Present (Valid_Uint);
104 subtype Unat is Valid_Uint with Predicate => Unat >= Uint_0; -- natural
105 subtype Upos is Valid_Uint with Predicate => Upos >= Uint_1; -- positive
106 subtype Nonzero_Uint is Valid_Uint with Predicate => Nonzero_Uint /= Uint_0;
107 subtype Unegative is Valid_Uint with Predicate => Unegative < Uint_0;
108 subtype Ubool is Valid_Uint with
109 Predicate => Ubool = Uint_0 or else Ubool = Uint_1;
110 subtype Opt_Ubool is Uint with
111 Predicate => No (Opt_Ubool) or else Opt_Ubool in Ubool;
113 -----------------
114 -- Subprograms --
115 -----------------
117 procedure Initialize;
118 -- Initialize Uint tables. Note also that there is no lock routine in this
119 -- unit, these are among the few tables that can be expanded during
120 -- gigi processing.
122 function UI_Abs (Right : Valid_Uint) return Unat;
123 pragma Inline (UI_Abs);
124 -- Returns abs function of universal integer
126 function UI_Add (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
127 function UI_Add (Left : Int; Right : Valid_Uint) return Valid_Uint;
128 function UI_Add (Left : Valid_Uint; Right : Int) return Valid_Uint;
129 -- Returns sum of two integer values
131 function UI_Decimal_Digits_Hi (U : Valid_Uint) return Nat;
132 -- Returns an estimate of the number of decimal digits required to
133 -- represent the absolute value of U. This estimate is correct or high,
134 -- i.e. it never returns a value that is too low. The accuracy of the
135 -- estimate affects only the effectiveness of comparison optimizations
136 -- in Urealp.
138 function UI_Decimal_Digits_Lo (U : Valid_Uint) return Nat;
139 -- Returns an estimate of the number of decimal digits required to
140 -- represent the absolute value of U. This estimate is correct or low,
141 -- i.e. it never returns a value that is too high. The accuracy of the
142 -- estimate affects only the effectiveness of comparison optimizations
143 -- in Urealp.
145 function UI_Div (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
146 function UI_Div (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
147 function UI_Div (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
148 -- Returns quotient of two integer values. Fatal error if Right = 0
150 function UI_Eq (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
151 function UI_Eq (Left : Int; Right : Valid_Uint) return Boolean;
152 function UI_Eq (Left : Valid_Uint; Right : Int) return Boolean;
153 pragma Inline (UI_Eq);
154 -- Compares integer values for equality
156 function UI_Expon (Left : Valid_Uint; Right : Unat) return Valid_Uint;
157 function UI_Expon (Left : Int; Right : Unat) return Valid_Uint;
158 function UI_Expon (Left : Valid_Uint; Right : Nat) return Valid_Uint;
159 function UI_Expon (Left : Int; Right : Nat) return Valid_Uint;
160 -- Returns result of exponentiating two integer values.
161 -- Fatal error if Right is negative.
163 function UI_GCD (Uin, Vin : Valid_Uint) return Valid_Uint;
164 -- Computes GCD of input values. Assumes Uin >= Vin >= 0
166 function UI_Ge (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
167 function UI_Ge (Left : Int; Right : Valid_Uint) return Boolean;
168 function UI_Ge (Left : Valid_Uint; Right : Int) return Boolean;
169 pragma Inline (UI_Ge);
170 -- Compares integer values for greater than or equal
172 function UI_Gt (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
173 function UI_Gt (Left : Int; Right : Valid_Uint) return Boolean;
174 function UI_Gt (Left : Valid_Uint; Right : Int) return Boolean;
175 pragma Inline (UI_Gt);
176 -- Compares integer values for greater than
178 function UI_Is_In_Int_Range (Input : Valid_Uint) return Boolean;
179 pragma Inline (UI_Is_In_Int_Range);
180 -- Determines if universal integer is in Int range.
182 function UI_Le (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
183 function UI_Le (Left : Int; Right : Valid_Uint) return Boolean;
184 function UI_Le (Left : Valid_Uint; Right : Int) return Boolean;
185 pragma Inline (UI_Le);
186 -- Compares integer values for less than or equal
188 function UI_Lt (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
189 function UI_Lt (Left : Int; Right : Valid_Uint) return Boolean;
190 function UI_Lt (Left : Valid_Uint; Right : Int) return Boolean;
191 -- Compares integer values for less than
193 function UI_Max (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
194 function UI_Max (Left : Int; Right : Valid_Uint) return Valid_Uint;
195 function UI_Max (Left : Valid_Uint; Right : Int) return Valid_Uint;
196 -- Returns maximum of two integer values
198 function UI_Min (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
199 function UI_Min (Left : Int; Right : Valid_Uint) return Valid_Uint;
200 function UI_Min (Left : Valid_Uint; Right : Int) return Valid_Uint;
201 -- Returns minimum of two integer values
203 function UI_Mod (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
204 function UI_Mod (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
205 function UI_Mod (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
206 pragma Inline (UI_Mod);
207 -- Returns mod function of two integer values
209 function UI_Mul (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
210 function UI_Mul (Left : Int; Right : Valid_Uint) return Valid_Uint;
211 function UI_Mul (Left : Valid_Uint; Right : Int) return Valid_Uint;
212 -- Returns product of two integer values
214 function UI_Ne (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
215 function UI_Ne (Left : Int; Right : Valid_Uint) return Boolean;
216 function UI_Ne (Left : Valid_Uint; Right : Int) return Boolean;
217 pragma Inline (UI_Ne);
218 -- Compares integer values for inequality
220 function UI_Negate (Right : Valid_Uint) return Valid_Uint;
221 pragma Inline (UI_Negate);
222 -- Returns negative of universal integer
224 function UI_Rem (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
225 function UI_Rem (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
226 function UI_Rem (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
227 -- Returns rem of two integer values
229 function UI_Sub (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
230 function UI_Sub (Left : Int; Right : Valid_Uint) return Valid_Uint;
231 function UI_Sub (Left : Valid_Uint; Right : Int) return Valid_Uint;
232 pragma Inline (UI_Sub);
233 -- Returns difference of two integer values
235 function UI_From_Int (Input : Int) return Valid_Uint;
236 -- Converts Int value to universal integer form
238 generic
239 type In_T is range <>;
240 function UI_From_Integral (Input : In_T) return Valid_Uint;
241 -- Likewise, but converts from any integer type. Must not be applied to
242 -- biased types (instantiation will provide a warning if actual is a biased
243 -- type).
245 function UI_From_CC (Input : Char_Code) return Valid_Uint;
246 -- Converts Char_Code value to universal integer form
248 function UI_To_Int (Input : Valid_Uint) return Int;
249 -- Converts universal integer value to Int. Constraint_Error if value is
250 -- not in appropriate range.
252 type Unsigned_64 is mod 2**64;
253 function UI_To_Unsigned_64 (Input : Valid_Uint) return Unsigned_64;
254 -- Converts universal integer value to Unsigned_64. Constraint_Error if
255 -- value is not in appropriate range.
257 function UI_To_CC (Input : Valid_Uint) return Char_Code;
258 -- Converts universal integer value to Char_Code. Constraint_Error if value
259 -- is not in Char_Code range.
261 function Num_Bits (Input : Valid_Uint) return Nat;
262 -- Approximate number of binary bits in given universal integer. This
263 -- function is used for capacity checks, and it can be one bit off
264 -- without affecting its usage.
266 ---------------------
267 -- Output Routines --
268 ---------------------
270 type UI_Format is (Hex, Decimal, Auto);
271 -- Used to determine whether UI_Image/UI_Write output is in hexadecimal
272 -- or decimal format. Auto, the default setting, lets the routine make a
273 -- decision based on the value.
275 UI_Image_Max : constant := 1024;
276 UI_Image_Buffer : String (1 .. UI_Image_Max);
277 UI_Image_Length : Natural;
278 -- Buffer used for UI_Image as described below
280 procedure UI_Image (Input : Uint; Format : UI_Format := Auto);
281 -- Places a representation of Uint, consisting of a possible minus sign,
282 -- followed by the value in UI_Image_Buffer. The form of the value is an
283 -- integer literal in either decimal (no base) or hexadecimal (base 16)
284 -- format. If Hex is True on entry, then hex mode is forced, otherwise
285 -- UI_Image makes a guess at which output format is more convenient. The
286 -- value must fit in UI_Image_Buffer. The actual length of the result is
287 -- returned in UI_Image_Length. If necessary to meet this requirement, the
288 -- result is an approximation of the proper value, using an exponential
289 -- format. The image of No_Uint is output as a single question mark.
291 function UI_Image (Input : Uint; Format : UI_Format := Auto) return String;
292 -- Functional form, in which the result is returned as a string. This call
293 -- also leaves the result in UI_Image_Buffer/Length as described above.
295 procedure UI_Write (Input : Uint; Format : UI_Format := Auto);
296 -- Writes a representation of Uint, consisting of a possible minus sign,
297 -- followed by the value to the output file. The form of the value is an
298 -- integer literal in either decimal (no base) or hexadecimal (base 16)
299 -- format as appropriate. UI_Format shows which format to use. Auto, the
300 -- default, asks UI_Write to make a guess at which output format will be
301 -- more convenient to read.
303 procedure pid (Input : Uint);
304 pragma Export (Ada, pid);
305 -- Writes representation of Uint in decimal with a terminating line
306 -- return. This is intended for use from the debugger.
308 procedure pih (Input : Uint);
309 pragma Export (Ada, pih);
310 -- Writes representation of Uint in hex with a terminating line return.
311 -- This is intended for use from the debugger.
313 ------------------------
314 -- Operator Renamings --
315 ------------------------
317 function "+" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
318 renames UI_Add;
319 function "+" (Left : Int; Right : Valid_Uint) return Valid_Uint
320 renames UI_Add;
321 function "+" (Left : Valid_Uint; Right : Int) return Valid_Uint
322 renames UI_Add;
324 function "/" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
325 renames UI_Div;
326 function "/" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
327 renames UI_Div;
328 function "/" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
329 renames UI_Div;
331 function "*" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
332 renames UI_Mul;
333 function "*" (Left : Int; Right : Valid_Uint) return Valid_Uint
334 renames UI_Mul;
335 function "*" (Left : Valid_Uint; Right : Int) return Valid_Uint
336 renames UI_Mul;
338 function "-" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
339 renames UI_Sub;
340 function "-" (Left : Int; Right : Valid_Uint) return Valid_Uint
341 renames UI_Sub;
342 function "-" (Left : Valid_Uint; Right : Int) return Valid_Uint
343 renames UI_Sub;
345 function "**" (Left : Valid_Uint; Right : Unat) return Valid_Uint
346 renames UI_Expon;
347 function "**" (Left : Valid_Uint; Right : Nat) return Valid_Uint
348 renames UI_Expon;
349 function "**" (Left : Int; Right : Unat) return Valid_Uint
350 renames UI_Expon;
351 function "**" (Left : Int; Right : Nat) return Valid_Uint
352 renames UI_Expon;
354 function "abs" (Real : Valid_Uint) return Unat
355 renames UI_Abs;
357 function "mod" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
358 renames UI_Mod;
359 function "mod" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
360 renames UI_Mod;
361 function "mod" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
362 renames UI_Mod;
364 function "rem" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
365 renames UI_Rem;
366 function "rem" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
367 renames UI_Rem;
368 function "rem" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
369 renames UI_Rem;
371 function "-" (Real : Valid_Uint) return Valid_Uint
372 renames UI_Negate;
374 function "=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
375 renames UI_Eq;
376 function "=" (Left : Int; Right : Valid_Uint) return Boolean
377 renames UI_Eq;
378 function "=" (Left : Valid_Uint; Right : Int) return Boolean
379 renames UI_Eq;
381 function ">=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
382 renames UI_Ge;
383 function ">=" (Left : Int; Right : Valid_Uint) return Boolean
384 renames UI_Ge;
385 function ">=" (Left : Valid_Uint; Right : Int) return Boolean
386 renames UI_Ge;
388 function ">" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
389 renames UI_Gt;
390 function ">" (Left : Int; Right : Valid_Uint) return Boolean
391 renames UI_Gt;
392 function ">" (Left : Valid_Uint; Right : Int) return Boolean
393 renames UI_Gt;
395 function "<=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
396 renames UI_Le;
397 function "<=" (Left : Int; Right : Valid_Uint) return Boolean
398 renames UI_Le;
399 function "<=" (Left : Valid_Uint; Right : Int) return Boolean
400 renames UI_Le;
402 function "<" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
403 renames UI_Lt;
404 function "<" (Left : Int; Right : Valid_Uint) return Boolean
405 renames UI_Lt;
406 function "<" (Left : Valid_Uint; Right : Int) return Boolean
407 renames UI_Lt;
409 -----------------------------
410 -- Mark/Release Processing --
411 -----------------------------
413 -- The space used by Uint data is not automatically reclaimed. However, a
414 -- mark-release regime is implemented which allows storage to be released
415 -- back to a previously noted mark. This is used for example when doing
416 -- comparisons, where only intermediate results get stored that do not
417 -- need to be saved for future use.
419 type Save_Mark is private;
421 function Mark return Save_Mark;
422 -- Note mark point for future release
424 procedure Release (M : Save_Mark);
425 -- Release storage allocated since mark was noted
427 procedure Release_And_Save (M : Save_Mark; UI : in out Valid_Uint);
428 -- Like Release, except that the given Uint value (which is typically among
429 -- the data being released) is recopied after the release, so that it is
430 -- the most recent item, and UI is updated to point to its copied location.
432 procedure Release_And_Save (M : Save_Mark; UI1, UI2 : in out Valid_Uint);
433 -- Like Release, except that the given Uint values (which are typically
434 -- among the data being released) are recopied after the release, so that
435 -- they are the most recent items, and UI1 and UI2 are updated if necessary
436 -- to point to the copied locations. This routine is careful to do things
437 -- in the right order, so that the values do not clobber one another.
439 -----------------------------------
440 -- Representation of Uint Values --
441 -----------------------------------
443 private
445 type Uint is new Int range Uint_Low_Bound .. Uint_High_Bound;
446 for Uint'Size use 32;
448 No_Uint : constant Uint := Uint (Uint_Low_Bound);
450 -- Uint values are represented as multiple precision integers stored in
451 -- a multi-digit format using Base as the base. This value is chosen so
452 -- that the product Base*Base is within the range of allowed Int values.
454 -- Base is defined to allow efficient execution of the primitive operations
455 -- (a0, b0, c0) defined in the section "The Classical Algorithms"
456 -- (sec. 4.3.1) of Donald Knuth's "The Art of Computer Programming",
457 -- Vol. 2. These algorithms are used in this package. In particular,
458 -- the product of two single digits in this base fits in a 32-bit integer.
460 Base_Bits : constant := 15;
461 -- Number of bits in base value
463 Base : constant Int := 2**Base_Bits;
465 -- Values in the range -(Base-1) .. Max_Direct are encoded directly as
466 -- Uint values by adding a bias value. The value of Max_Direct is chosen
467 -- so that a directly represented number always fits in two digits when
468 -- represented in base format.
470 Min_Direct : constant Int := -(Base - 1);
471 Max_Direct : constant Int := (Base - 1) * (Base - 1);
473 -- The following values define the bias used to store Uint values which
474 -- are in this range, as well as the biased values for the first and last
475 -- values in this range. We use a new derived type for these constants to
476 -- avoid accidental use of Uint arithmetic on these values, which is never
477 -- correct.
479 type Ctrl is new Int;
481 Uint_Direct_Bias : constant Ctrl := Ctrl (Uint_Low_Bound) + Ctrl (Base);
482 Uint_Direct_First : constant Ctrl := Uint_Direct_Bias + Ctrl (Min_Direct);
483 Uint_Direct_Last : constant Ctrl := Uint_Direct_Bias + Ctrl (Max_Direct);
485 Uint_0 : constant Uint := Uint (Uint_Direct_Bias + 0);
486 Uint_1 : constant Uint := Uint (Uint_Direct_Bias + 1);
487 Uint_2 : constant Uint := Uint (Uint_Direct_Bias + 2);
488 Uint_3 : constant Uint := Uint (Uint_Direct_Bias + 3);
489 Uint_4 : constant Uint := Uint (Uint_Direct_Bias + 4);
490 Uint_5 : constant Uint := Uint (Uint_Direct_Bias + 5);
491 Uint_6 : constant Uint := Uint (Uint_Direct_Bias + 6);
492 Uint_7 : constant Uint := Uint (Uint_Direct_Bias + 7);
493 Uint_8 : constant Uint := Uint (Uint_Direct_Bias + 8);
494 Uint_9 : constant Uint := Uint (Uint_Direct_Bias + 9);
495 Uint_10 : constant Uint := Uint (Uint_Direct_Bias + 10);
496 Uint_11 : constant Uint := Uint (Uint_Direct_Bias + 11);
497 Uint_12 : constant Uint := Uint (Uint_Direct_Bias + 12);
498 Uint_13 : constant Uint := Uint (Uint_Direct_Bias + 13);
499 Uint_14 : constant Uint := Uint (Uint_Direct_Bias + 14);
500 Uint_15 : constant Uint := Uint (Uint_Direct_Bias + 15);
501 Uint_16 : constant Uint := Uint (Uint_Direct_Bias + 16);
502 Uint_24 : constant Uint := Uint (Uint_Direct_Bias + 24);
503 Uint_31 : constant Uint := Uint (Uint_Direct_Bias + 31);
504 Uint_32 : constant Uint := Uint (Uint_Direct_Bias + 32);
505 Uint_63 : constant Uint := Uint (Uint_Direct_Bias + 63);
506 Uint_64 : constant Uint := Uint (Uint_Direct_Bias + 64);
507 Uint_80 : constant Uint := Uint (Uint_Direct_Bias + 80);
508 Uint_127 : constant Uint := Uint (Uint_Direct_Bias + 127);
509 Uint_128 : constant Uint := Uint (Uint_Direct_Bias + 128);
511 Uint_Minus_1 : constant Uint := Uint (Uint_Direct_Bias - 1);
512 Uint_Minus_2 : constant Uint := Uint (Uint_Direct_Bias - 2);
513 Uint_Minus_3 : constant Uint := Uint (Uint_Direct_Bias - 3);
514 Uint_Minus_4 : constant Uint := Uint (Uint_Direct_Bias - 4);
515 Uint_Minus_5 : constant Uint := Uint (Uint_Direct_Bias - 5);
516 Uint_Minus_6 : constant Uint := Uint (Uint_Direct_Bias - 6);
517 Uint_Minus_7 : constant Uint := Uint (Uint_Direct_Bias - 7);
518 Uint_Minus_8 : constant Uint := Uint (Uint_Direct_Bias - 8);
519 Uint_Minus_9 : constant Uint := Uint (Uint_Direct_Bias - 9);
520 Uint_Minus_12 : constant Uint := Uint (Uint_Direct_Bias - 12);
521 Uint_Minus_18 : constant Uint := Uint (Uint_Direct_Bias - 18);
522 Uint_Minus_31 : constant Uint := Uint (Uint_Direct_Bias - 31);
523 Uint_Minus_36 : constant Uint := Uint (Uint_Direct_Bias - 36);
524 Uint_Minus_63 : constant Uint := Uint (Uint_Direct_Bias - 63);
525 Uint_Minus_76 : constant Uint := Uint (Uint_Direct_Bias - 76);
526 Uint_Minus_80 : constant Uint := Uint (Uint_Direct_Bias - 80);
527 Uint_Minus_127 : constant Uint := Uint (Uint_Direct_Bias - 127);
528 Uint_Minus_128 : constant Uint := Uint (Uint_Direct_Bias - 128);
530 Uint_Max_Simple_Mul : constant := Uint_Direct_Bias + 2**15;
531 -- If two values are directly represented and less than or equal to this
532 -- value, then we know the product fits in a 32-bit integer. This allows
533 -- UI_Mul to efficiently compute the product in this case.
535 type Save_Mark is record
536 Save_Uint : Valid_Uint;
537 Save_Udigit : Int;
538 end record;
540 -- Values outside the range that is represented directly are stored using
541 -- two tables. The secondary table Udigits contains sequences of Int values
542 -- consisting of the digits of the number in a radix Base system. The
543 -- digits are stored from most significant to least significant with the
544 -- first digit only carrying the sign.
546 -- There is one entry in the primary Uints table for each distinct Uint
547 -- value. This table entry contains the length (number of digits) and
548 -- a starting offset of the value in the Udigits table.
550 Uint_First_Entry : constant Uint := Uint (Uint_Table_Start);
552 -- Some subprograms defined in this package manipulate the Udigits table
553 -- directly, while for others it is more convenient to work with locally
554 -- defined arrays of the digits of the Universal Integers. The type
555 -- UI_Vector is declared in the package body for this purpose and some
556 -- internal subprograms used for converting from one to the other are
557 -- defined.
559 type Uint_Entry is record
560 Length : aliased Pos;
561 -- Length of entry in Udigits table in digits (i.e. in words)
563 Loc : aliased Int;
564 -- Starting location in Udigits table of this Uint value
565 end record;
567 package Uints is new Table.Table (
568 Table_Component_Type => Uint_Entry,
569 Table_Index_Type => Uint'Base,
570 Table_Low_Bound => Uint_First_Entry,
571 Table_Initial => Alloc.Uints_Initial,
572 Table_Increment => Alloc.Uints_Increment,
573 Table_Name => "Uints");
575 package Udigits is new Table.Table (
576 Table_Component_Type => Int,
577 Table_Index_Type => Int,
578 Table_Low_Bound => 0,
579 Table_Initial => Alloc.Udigits_Initial,
580 Table_Increment => Alloc.Udigits_Increment,
581 Table_Name => "Udigits");
583 -- Note: the reason these tables are defined here in the private part of
584 -- the spec, rather than in the body, is that they are referenced directly
585 -- by gigi.
587 end Uintp;