OSDN Git Service

ed608e57ae9010908b0ad159c839e7bd00b5e23c
[pf3gnuchains/gcc-fork.git] / gcc / ada / gcc-interface / targtyps.c
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                            T A R G T Y P S                               *
6  *                                                                          *
7  *                                  Body                                    *
8  *                                                                          *
9  *          Copyright (C) 1992-2009, 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 see *
19  * <http://www.gnu.org/licenses/>.                                          *
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 /* Functions for retrieving target types. See Ada package Get_Targ */
27
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "tm.h"
32 #include "tree.h"
33
34 #include "ada.h"
35 #include "types.h"
36 #include "atree.h"
37 #include "elists.h"
38 #include "namet.h"
39 #include "nlists.h"
40 #include "snames.h"
41 #include "stringt.h"
42 #include "uintp.h"
43 #include "urealp.h"
44 #include "fe.h"
45 #include "sinfo.h"
46 #include "einfo.h"
47 #include "ada-tree.h"
48 #include "gigi.h"
49
50 /* If we don't have a specific size for Ada's equivalent of `long', use that
51    of C.  */
52 #ifndef ADA_LONG_TYPE_SIZE
53 #define ADA_LONG_TYPE_SIZE LONG_TYPE_SIZE
54 #endif
55
56 #ifndef WIDEST_HARDWARE_FP_SIZE
57 #define WIDEST_HARDWARE_FP_SIZE LONG_DOUBLE_TYPE_SIZE
58 #endif
59
60 /* The following provide a functional interface for the front end Ada code
61    to determine the sizes that are used for various C types. */
62
63 Pos
64 get_target_bits_per_unit (void)
65 {
66   return BITS_PER_UNIT;
67 }
68
69 Pos
70 get_target_bits_per_word (void)
71 {
72   return BITS_PER_WORD;
73 }
74
75 Pos
76 get_target_char_size (void)
77 {
78   return CHAR_TYPE_SIZE;
79 }
80
81 Pos
82 get_target_wchar_t_size (void)
83 {
84   /* We never want wide characters less than "short" in Ada.  */
85   return MAX (SHORT_TYPE_SIZE, WCHAR_TYPE_SIZE);
86 }
87
88 Pos
89 get_target_short_size (void)
90 {
91   return SHORT_TYPE_SIZE;
92 }
93
94 Pos
95 get_target_int_size (void)
96 {
97   return INT_TYPE_SIZE;
98 }
99
100 Pos
101 get_target_long_size (void)
102 {
103   return ADA_LONG_TYPE_SIZE;
104 }
105
106 Pos
107 get_target_long_long_size (void)
108 {
109   return LONG_LONG_TYPE_SIZE;
110 }
111
112 Pos
113 get_target_float_size (void)
114 {
115   return fp_prec_to_size (FLOAT_TYPE_SIZE);
116 }
117
118 Pos
119 get_target_double_size (void)
120 {
121   return fp_prec_to_size (DOUBLE_TYPE_SIZE);
122 }
123
124 Pos
125 get_target_long_double_size (void)
126 {
127   return fp_prec_to_size (WIDEST_HARDWARE_FP_SIZE);
128 }
129
130
131 Pos
132 get_target_pointer_size (void)
133 {
134   return POINTER_SIZE;
135 }
136
137 /* Alignment related values, mapped to attributes for functional and
138    documentation purposes.  */
139
140 /* Standard'Maximum_Default_Alignment.  Maximum alignment that the compiler
141    might choose by default for a type or object.
142
143    Stricter alignment requests trigger gigi's aligning_type circuitry for
144    stack objects or objects allocated by the default allocator.  */
145
146 Pos
147 get_target_maximum_default_alignment (void)
148 {
149   return BIGGEST_ALIGNMENT / BITS_PER_UNIT;
150 }
151
152 /* Standard'Default_Allocator_Alignment.  Alignment guaranteed to be honored
153    by the default allocator (System.Memory.Alloc or malloc if we have no
154    run-time library at hand).
155
156    Stricter alignment requests trigger gigi's aligning_type circuitry for
157    objects allocated by the default allocator.  */
158
159 /* ??? Need a way to get info about __gnat_malloc from here (whether it is
160    handy and what alignment it honors).  In the meantime, resort to malloc
161    considerations only.  */
162
163 Pos
164 get_target_default_allocator_alignment (void)
165 {
166   return MALLOC_ABI_ALIGNMENT / BITS_PER_UNIT;
167 }
168
169 /* Standard'Maximum_Allowed_Alignment.  Maximum alignment that we may
170    accept for any type or object.  */
171
172 #ifndef MAX_OFILE_ALIGNMENT
173 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
174 #endif
175
176 Pos
177 get_target_maximum_allowed_alignment (void)
178 {
179   return MAX_OFILE_ALIGNMENT / BITS_PER_UNIT;
180 }
181
182 /* Standard'Maximum_Alignment.  The single attribute initially made
183    available, now a synonym of Standard'Maximum_Default_Alignment.  */
184
185 Pos
186 get_target_maximum_alignment (void)
187 {
188   return get_target_maximum_default_alignment ();
189 }
190
191 #ifndef FLOAT_WORDS_BIG_ENDIAN
192 #define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
193 #endif
194
195 Nat
196 get_float_words_be (void)
197 {
198   return FLOAT_WORDS_BIG_ENDIAN;
199 }
200
201 Nat
202 get_words_be (void)
203 {
204   return WORDS_BIG_ENDIAN;
205 }
206
207 Nat
208 get_bytes_be (void)
209 {
210   return BYTES_BIG_ENDIAN;
211 }
212
213 Nat
214 get_bits_be (void)
215 {
216   return BITS_BIG_ENDIAN;
217 }
218
219 Nat
220 get_strict_alignment (void)
221 {
222   return STRICT_ALIGNMENT;
223 }