1 /* Copyright (C) 1992, 93, 1994, 1998 Free Software Foundation, Inc.
3 This file is part of GNU CC.
5 GNU CC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU CC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU CC; see the file COPYING. If not, write to
17 the Free Software Foundation, 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
23 build_component_ref (datum
, field_name
)
24 tree datum
, field_name
;
26 return build_chill_component_ref (datum
, field_name
);
29 /* Mark EXP saying that we need to be able to take the
30 address of it; it should not be allocated in a register.
31 Value is 1 if successful. */
34 mark_addressable (exp
)
37 register tree x
= exp
;
39 switch (TREE_CODE (x
))
46 /* start-sanitize-chill */
47 case TRUTH_ANDIF_EXPR
:
50 /* end-sanitize-chill */
51 x
= TREE_OPERAND (x
, 0);
53 /* start-sanitize-chill */
56 return mark_addressable (TREE_OPERAND (x
, 1))
57 & mark_addressable (TREE_OPERAND (x
, 2));
58 /* end-sanitize-chill */
61 TREE_ADDRESSABLE (x
) = 1;
68 if (DECL_REGISTER (x
) && !TREE_ADDRESSABLE (x
)
73 error ("global register variable `%s' used in nested function",
74 IDENTIFIER_POINTER (DECL_NAME (x
)));
77 pedwarn ("register variable `%s' used in nested function",
78 IDENTIFIER_POINTER (DECL_NAME (x
)));
80 else if (DECL_REGISTER (x
) && !TREE_ADDRESSABLE (x
))
84 error ("address of global register variable `%s' requested",
85 IDENTIFIER_POINTER (DECL_NAME (x
)));
89 /* If we are making this addressable due to its having
90 volatile components, give a different error message. Also
91 handle the case of an unnamed parameter by not trying
94 else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x
)))
96 error ("cannot put object with volatile field into register");
100 pedwarn ("address of register variable `%s' requested",
101 IDENTIFIER_POINTER (DECL_NAME (x
)));
103 put_var_into_stack (x
);
107 TREE_ADDRESSABLE (x
) = 1;
108 #if 0 /* poplevel deals with this now. */
109 if (DECL_CONTEXT (x
) == 0)
110 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x
)) = 1;
118 /* Return an unsigned type the same as TYPE in other respects. */
124 tree type1
= TYPE_MAIN_VARIANT (type
);
125 if (type1
== signed_char_type_node
|| type1
== char_type_node
)
126 return unsigned_char_type_node
;
127 if (type1
== integer_type_node
)
128 return unsigned_type_node
;
129 if (type1
== short_integer_type_node
)
130 return short_unsigned_type_node
;
131 if (type1
== long_integer_type_node
)
132 return long_unsigned_type_node
;
133 if (type1
== long_long_integer_type_node
)
134 return long_long_unsigned_type_node
;
138 /* Return a signed type the same as TYPE in other respects. */
144 tree type1
= TYPE_MAIN_VARIANT (type
);
145 if (type1
== unsigned_char_type_node
|| type1
== char_type_node
)
146 return signed_char_type_node
;
147 if (type1
== unsigned_type_node
)
148 return integer_type_node
;
149 if (type1
== short_unsigned_type_node
)
150 return short_integer_type_node
;
151 if (type1
== long_unsigned_type_node
)
152 return long_integer_type_node
;
153 if (type1
== long_long_unsigned_type_node
)
154 return long_long_integer_type_node
;
158 /* Return a type the same as TYPE except unsigned or
159 signed according to UNSIGNEDP. */
162 signed_or_unsigned_type (unsignedp
, type
)
166 if (! INTEGRAL_TYPE_P (type
))
168 if (TYPE_PRECISION (type
) == TYPE_PRECISION (signed_char_type_node
))
169 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
170 if (TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
171 return unsignedp
? unsigned_type_node
: integer_type_node
;
172 if (TYPE_PRECISION (type
) == TYPE_PRECISION (short_integer_type_node
))
173 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
174 if (TYPE_PRECISION (type
) == TYPE_PRECISION (long_integer_type_node
))
175 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
176 if (TYPE_PRECISION (type
) == TYPE_PRECISION (long_long_integer_type_node
))
177 return (unsignedp
? long_long_unsigned_type_node
178 : long_long_integer_type_node
);
182 extern tree intHI_type_node
;
183 extern tree intSI_type_node
;
184 extern tree intDI_type_node
;
186 extern tree unsigned_intHI_type_node
;
187 extern tree unsigned_intSI_type_node
;
188 extern tree unsigned_intDI_type_node
;
190 /* Return an integer type with BITS bits of precision,
191 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
194 type_for_size (bits
, unsignedp
)
198 if (bits
== TYPE_PRECISION (signed_char_type_node
))
199 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
201 if (bits
== TYPE_PRECISION (short_integer_type_node
))
202 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
204 if (bits
== TYPE_PRECISION (integer_type_node
))
205 return unsignedp
? unsigned_type_node
: integer_type_node
;
207 if (bits
== TYPE_PRECISION (long_integer_type_node
))
208 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
210 if (bits
== TYPE_PRECISION (long_long_integer_type_node
))
211 return (unsignedp
? long_long_unsigned_type_node
212 : long_long_integer_type_node
);
214 if (bits
<= TYPE_PRECISION (intHI_type_node
))
215 return unsignedp
? unsigned_intHI_type_node
: intHI_type_node
;
217 if (bits
<= TYPE_PRECISION (intSI_type_node
))
218 return unsignedp
? unsigned_intSI_type_node
: intSI_type_node
;
220 if (bits
<= TYPE_PRECISION (intDI_type_node
))
221 return unsignedp
? unsigned_intDI_type_node
: intDI_type_node
;
226 /* Return a data type that has machine mode MODE.
227 If the mode is an integer,
228 then UNSIGNEDP selects between signed and unsigned types. */
231 type_for_mode (mode
, unsignedp
)
232 enum machine_mode mode
;
235 if (mode
== TYPE_MODE (signed_char_type_node
))
236 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
238 if (mode
== TYPE_MODE (short_integer_type_node
))
239 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
241 if (mode
== TYPE_MODE (integer_type_node
))
242 return unsignedp
? unsigned_type_node
: integer_type_node
;
244 if (mode
== TYPE_MODE (long_integer_type_node
))
245 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
247 if (mode
== TYPE_MODE (long_long_integer_type_node
))
248 return unsignedp
? long_long_unsigned_type_node
: long_long_integer_type_node
;
250 if (mode
== TYPE_MODE (intHI_type_node
))
251 return unsignedp
? unsigned_intHI_type_node
: intHI_type_node
;
253 if (mode
== TYPE_MODE (intSI_type_node
))
254 return unsignedp
? unsigned_intSI_type_node
: intSI_type_node
;
256 if (mode
== TYPE_MODE (intDI_type_node
))
257 return unsignedp
? unsigned_intDI_type_node
: intDI_type_node
;
259 if (mode
== TYPE_MODE (float_type_node
))
260 return float_type_node
;
262 if (mode
== TYPE_MODE (double_type_node
))
263 return double_type_node
;
265 if (mode
== TYPE_MODE (long_double_type_node
))
266 return long_double_type_node
;
268 if (mode
== TYPE_MODE (build_pointer_type (char_type_node
)))
269 return build_pointer_type (char_type_node
);
271 if (mode
== TYPE_MODE (build_pointer_type (integer_type_node
)))
272 return build_pointer_type (integer_type_node
);
278 truthvalue_conversion (expr
)
281 return chill_truthvalue_conversion (expr
);