1 /* Copyright (C) 1992, 1993, 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 x
= TREE_OPERAND (x
, 0);
50 TREE_ADDRESSABLE (x
) = 1;
57 if (DECL_REGISTER (x
) && !TREE_ADDRESSABLE (x
)
62 error ("global register variable `%s' used in nested function",
63 IDENTIFIER_POINTER (DECL_NAME (x
)));
66 pedwarn ("register variable `%s' used in nested function",
67 IDENTIFIER_POINTER (DECL_NAME (x
)));
69 else if (DECL_REGISTER (x
) && !TREE_ADDRESSABLE (x
))
73 error ("address of global register variable `%s' requested",
74 IDENTIFIER_POINTER (DECL_NAME (x
)));
78 /* If we are making this addressable due to its having
79 volatile components, give a different error message. Also
80 handle the case of an unnamed parameter by not trying
83 else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x
)))
85 error ("cannot put object with volatile field into register");
89 pedwarn ("address of register variable `%s' requested",
90 IDENTIFIER_POINTER (DECL_NAME (x
)));
92 put_var_into_stack (x
);
96 TREE_ADDRESSABLE (x
) = 1;
97 #if 0 /* poplevel deals with this now. */
98 if (DECL_CONTEXT (x
) == 0)
99 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x
)) = 1;
107 /* Return an unsigned type the same as TYPE in other respects. */
113 tree type1
= TYPE_MAIN_VARIANT (type
);
114 if (type1
== signed_char_type_node
|| type1
== char_type_node
)
115 return unsigned_char_type_node
;
116 if (type1
== integer_type_node
)
117 return unsigned_type_node
;
118 if (type1
== short_integer_type_node
)
119 return short_unsigned_type_node
;
120 if (type1
== long_integer_type_node
)
121 return long_unsigned_type_node
;
122 if (type1
== long_long_integer_type_node
)
123 return long_long_unsigned_type_node
;
127 /* Return a signed type the same as TYPE in other respects. */
133 tree type1
= TYPE_MAIN_VARIANT (type
);
134 if (type1
== unsigned_char_type_node
|| type1
== char_type_node
)
135 return signed_char_type_node
;
136 if (type1
== unsigned_type_node
)
137 return integer_type_node
;
138 if (type1
== short_unsigned_type_node
)
139 return short_integer_type_node
;
140 if (type1
== long_unsigned_type_node
)
141 return long_integer_type_node
;
142 if (type1
== long_long_unsigned_type_node
)
143 return long_long_integer_type_node
;
147 /* Return a type the same as TYPE except unsigned or
148 signed according to UNSIGNEDP. */
151 signed_or_unsigned_type (unsignedp
, type
)
155 if (! INTEGRAL_TYPE_P (type
))
157 if (TYPE_PRECISION (type
) == TYPE_PRECISION (signed_char_type_node
))
158 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
159 if (TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
160 return unsignedp
? unsigned_type_node
: integer_type_node
;
161 if (TYPE_PRECISION (type
) == TYPE_PRECISION (short_integer_type_node
))
162 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
163 if (TYPE_PRECISION (type
) == TYPE_PRECISION (long_integer_type_node
))
164 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
165 if (TYPE_PRECISION (type
) == TYPE_PRECISION (long_long_integer_type_node
))
166 return (unsignedp
? long_long_unsigned_type_node
167 : long_long_integer_type_node
);
171 extern tree intHI_type_node
;
172 extern tree intSI_type_node
;
173 extern tree intDI_type_node
;
175 extern tree unsigned_intHI_type_node
;
176 extern tree unsigned_intSI_type_node
;
177 extern tree unsigned_intDI_type_node
;
179 /* Return an integer type with BITS bits of precision,
180 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
183 type_for_size (bits
, unsignedp
)
187 if (bits
== TYPE_PRECISION (signed_char_type_node
))
188 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
190 if (bits
== TYPE_PRECISION (short_integer_type_node
))
191 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
193 if (bits
== TYPE_PRECISION (integer_type_node
))
194 return unsignedp
? unsigned_type_node
: integer_type_node
;
196 if (bits
== TYPE_PRECISION (long_integer_type_node
))
197 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
199 if (bits
== TYPE_PRECISION (long_long_integer_type_node
))
200 return (unsignedp
? long_long_unsigned_type_node
201 : long_long_integer_type_node
);
203 if (bits
<= TYPE_PRECISION (intHI_type_node
))
204 return unsignedp
? unsigned_intHI_type_node
: intHI_type_node
;
206 if (bits
<= TYPE_PRECISION (intSI_type_node
))
207 return unsignedp
? unsigned_intSI_type_node
: intSI_type_node
;
209 if (bits
<= TYPE_PRECISION (intDI_type_node
))
210 return unsignedp
? unsigned_intDI_type_node
: intDI_type_node
;
215 /* Return a data type that has machine mode MODE.
216 If the mode is an integer,
217 then UNSIGNEDP selects between signed and unsigned types. */
220 type_for_mode (mode
, unsignedp
)
221 enum machine_mode mode
;
224 if (mode
== TYPE_MODE (signed_char_type_node
))
225 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
227 if (mode
== TYPE_MODE (short_integer_type_node
))
228 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
230 if (mode
== TYPE_MODE (integer_type_node
))
231 return unsignedp
? unsigned_type_node
: integer_type_node
;
233 if (mode
== TYPE_MODE (long_integer_type_node
))
234 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
236 if (mode
== TYPE_MODE (long_long_integer_type_node
))
237 return unsignedp
? long_long_unsigned_type_node
: long_long_integer_type_node
;
239 if (mode
== TYPE_MODE (intHI_type_node
))
240 return unsignedp
? unsigned_intHI_type_node
: intHI_type_node
;
242 if (mode
== TYPE_MODE (intSI_type_node
))
243 return unsignedp
? unsigned_intSI_type_node
: intSI_type_node
;
245 if (mode
== TYPE_MODE (intDI_type_node
))
246 return unsignedp
? unsigned_intDI_type_node
: intDI_type_node
;
248 if (mode
== TYPE_MODE (float_type_node
))
249 return float_type_node
;
251 if (mode
== TYPE_MODE (double_type_node
))
252 return double_type_node
;
254 if (mode
== TYPE_MODE (long_double_type_node
))
255 return long_double_type_node
;
257 if (mode
== TYPE_MODE (build_pointer_type (char_type_node
)))
258 return build_pointer_type (char_type_node
);
260 if (mode
== TYPE_MODE (build_pointer_type (integer_type_node
)))
261 return build_pointer_type (integer_type_node
);
267 truthvalue_conversion (expr
)
270 return chill_truthvalue_conversion (expr
);