OSDN Git Service

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