* gcc-interface/misc.c (default_pass_by_ref): Minor tweak.
[official-gcc.git] / gcc / ada / gcc-interface / targtyps.c
blob78a9db94282a3ff0404a3367c8e385eabb7a6021
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * T A R G T Y P S *
6 * *
7 * Body *
8 * *
9 * Copyright (C) 1992-2015, 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 ****************************************************************************/
26 /* Functions for retrieving target types. See Ada package Get_Targ. */
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "tm.h"
32 #include "tree.h"
34 #include "ada.h"
35 #include "types.h"
36 #include "ada-tree.h"
37 #include "gigi.h"
39 /* If we don't have a specific size for Ada's equivalent of `long', use that
40 of C. */
41 #ifndef ADA_LONG_TYPE_SIZE
42 #define ADA_LONG_TYPE_SIZE LONG_TYPE_SIZE
43 #endif
45 /* The following provide a functional interface for the front end Ada code
46 to determine the sizes that are used for various C types. */
48 Pos
49 get_target_bits_per_unit (void)
51 return BITS_PER_UNIT;
54 Pos
55 get_target_bits_per_word (void)
57 return BITS_PER_WORD;
60 Pos
61 get_target_char_size (void)
63 return CHAR_TYPE_SIZE;
66 Pos
67 get_target_wchar_t_size (void)
69 /* We never want wide characters less than "short" in Ada. */
70 return MAX (SHORT_TYPE_SIZE, WCHAR_TYPE_SIZE);
73 Pos
74 get_target_short_size (void)
76 return SHORT_TYPE_SIZE;
79 Pos
80 get_target_int_size (void)
82 return INT_TYPE_SIZE;
85 Pos
86 get_target_long_size (void)
88 return ADA_LONG_TYPE_SIZE;
91 Pos
92 get_target_long_long_size (void)
94 return LONG_LONG_TYPE_SIZE;
97 Pos
98 get_target_pointer_size (void)
100 return POINTER_SIZE;
103 /* Alignment related values, mapped to attributes for functional and
104 documentation purposes. */
106 /* Standard'Maximum_Default_Alignment. Maximum alignment that the compiler
107 might choose by default for a type or object.
109 Stricter alignment requests trigger gigi's aligning_type circuitry for
110 stack objects or objects allocated by the default allocator. */
113 get_target_maximum_default_alignment (void)
115 return BIGGEST_ALIGNMENT / BITS_PER_UNIT;
118 /* Standard'System_Allocator_Alignment. Alignment guaranteed to be honored
119 by the default allocator (System.Memory.Alloc or malloc if we have no
120 run-time library at hand).
122 Stricter alignment requests trigger gigi's aligning_type circuitry for
123 objects allocated by the default allocator. */
125 /* ??? Need a way to get info about __gnat_malloc from here (whether it is
126 handy and what alignment it honors). In the meantime, resort to malloc
127 considerations only. */
129 /* Account for MALLOC_OBSERVABLE_ALIGNMENTs here. Use this or the ABI
130 guaranteed alignment if greater. */
132 #ifdef MALLOC_OBSERVABLE_ALIGNMENT
133 #define MALLOC_ALIGNMENT MALLOC_OBSERVABLE_ALIGNMENT
134 #else
135 #define MALLOC_OBSERVABLE_ALIGNMENT (2 * LONG_TYPE_SIZE)
136 #define MALLOC_ALIGNMENT \
137 MAX (MALLOC_ABI_ALIGNMENT, MALLOC_OBSERVABLE_ALIGNMENT)
138 #endif
141 get_target_system_allocator_alignment (void)
143 return MALLOC_ALIGNMENT / BITS_PER_UNIT;
146 /* Standard'Maximum_Allowed_Alignment. Maximum alignment that we may
147 accept for any type or object. */
149 #ifndef MAX_OFILE_ALIGNMENT
150 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
151 #endif
154 get_target_maximum_allowed_alignment (void)
156 return MAX_OFILE_ALIGNMENT / BITS_PER_UNIT;
159 /* Standard'Maximum_Alignment. The single attribute initially made
160 available, now a synonym of Standard'Maximum_Default_Alignment. */
163 get_target_maximum_alignment (void)
165 return get_target_maximum_default_alignment ();
168 #ifndef FLOAT_WORDS_BIG_ENDIAN
169 #define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
170 #endif
173 get_target_float_words_be (void)
175 return FLOAT_WORDS_BIG_ENDIAN;
179 get_target_words_be (void)
181 return WORDS_BIG_ENDIAN;
185 get_target_bytes_be (void)
187 return BYTES_BIG_ENDIAN;
191 get_target_bits_be (void)
193 return BITS_BIG_ENDIAN;
197 get_target_strict_alignment (void)
199 return STRICT_ALIGNMENT;
203 get_target_double_float_alignment (void)
205 #ifdef TARGET_ALIGN_NATURAL
206 /* This macro is only defined by the rs6000 port. */
207 if (!TARGET_ALIGN_NATURAL
208 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN))
209 return 32 / BITS_PER_UNIT;
210 #endif
211 return 0;
215 get_target_double_scalar_alignment (void)
217 #ifdef TARGET_ALIGN_DOUBLE
218 /* This macro is only defined by the i386 and sh ports. */
219 if (!TARGET_ALIGN_DOUBLE
220 #ifdef TARGET_64BIT
221 && !TARGET_64BIT
222 #endif
224 return 32 / BITS_PER_UNIT;
225 #endif
226 return 0;