OSDN Git Service

2007-09-10 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / uintp.h
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                                U I N T P                                 *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *            Copyright (C) 1992-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 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  ****************************************************************************/
25
26 /* This file corresponds to the Ada package specification Uintp. It was
27    created manually from the files uintp.ads and uintp.adb  */
28
29 /* Support for universal integer arithmetic */
30
31 struct Uint_Entry
32 {
33   Pos Length;
34   Int Loc;
35 };
36
37 /* See if a Uint is within the range of an integer.  */
38 #define UI_Is_In_Int_Range  uintp__ui_is_in_int_range
39 extern Boolean UI_Is_In_Int_Range       (Uint);
40
41 /* Obtain Char_Code value from Uint input. Value must be in range.  */
42 #define UI_To_CC uintp__ui_to_cc
43 extern Char_Code UI_To_CC               (Uint);
44
45 /* Obtain Int value from Uint input. This will abort if the result is
46    out of range.  */
47 #define UI_To_Int uintp__ui_to_int
48 extern Int UI_To_Int                    (Uint);
49
50 /* Convert an Int into a Uint.  */
51 #define UI_From_Int uintp__ui_from_int
52 extern Uint UI_From_Int                 (int);
53
54 /* Convert a Char_Code into a Uint.  */
55 #define UI_From_CC uintp__ui_from_cc
56 extern Uint UI_From_CC                  (Char_Code);
57
58 /* Similarly, but return a GCC INTEGER_CST.  Overflow is tested by the
59    constant-folding used to build the node.  TYPE is the GCC type of the
60    resulting node.  */
61 extern tree UI_To_gnu                   (Uint, tree);
62
63 /* Universal integers are represented by the Uint type which is an index into
64    the Uints_Ptr table containing Uint_Entry values.  A Uint_Entry contains an
65    index and length for getting the "digits" of the universal integer from the
66    Udigits_Ptr table.
67
68    For efficiency, this method is used only for integer values larger than the
69    constant Uint_Bias.  If a Uint is less than this constant, then it contains
70    the integer value itself.  The origin of the Uints_Ptr table is adjusted so
71    that a Uint value of Uint_Bias indexes the first element.  */
72
73 #define Uints_Ptr (uintp__uints__table - Uint_Table_Start)
74 extern struct Uint_Entry *uintp__uints__table;
75
76 #define Udigits_Ptr uintp__udigits__table
77 extern int *uintp__udigits__table;
78
79 #define Uint_0 (Uint_Direct_Bias + 0)
80 #define Uint_1 (Uint_Direct_Bias + 1)