OSDN Git Service

[pf3gnuchains/gcc-fork.git] / gcc / ch / xtypeck.c
1
2 #if 0
3 tree
4 build_component_ref (datum, field_name)
5   tree datum, field_name;
6 {
7   return build_chill_component_ref (datum, field_name);
8 }
9
10 /* Mark EXP saying that we need to be able to take the
11    address of it; it should not be allocated in a register.
12    Value is 1 if successful.  */
13
14 int
15 mark_addressable (exp)
16      tree exp;
17 {
18   register tree x = exp;
19   while (1)
20     switch (TREE_CODE (x))
21       {
22       case ADDR_EXPR:
23       case COMPONENT_REF:
24       case ARRAY_REF:
25       case REALPART_EXPR:
26       case IMAGPART_EXPR:
27 /* start-sanitize-chill */
28       case TRUTH_ANDIF_EXPR:
29       case TRUTH_ORIF_EXPR:
30       case COMPOUND_EXPR:
31 /* end-sanitize-chill */
32         x = TREE_OPERAND (x, 0);
33         break;
34 /* start-sanitize-chill */
35
36       case COND_EXPR:
37         return mark_addressable (TREE_OPERAND (x, 1))
38           & mark_addressable (TREE_OPERAND (x, 2));
39 /* end-sanitize-chill */
40
41       case CONSTRUCTOR:
42         TREE_ADDRESSABLE (x) = 1;
43         return 1;
44
45       case VAR_DECL:
46       case CONST_DECL:
47       case PARM_DECL:
48       case RESULT_DECL:
49         if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
50             && DECL_NONLOCAL (x))
51           {
52             if (TREE_PUBLIC (x))
53               {
54                 error ("global register variable `%s' used in nested function",
55                        IDENTIFIER_POINTER (DECL_NAME (x)));
56                 return 0;
57               }
58             pedwarn ("register variable `%s' used in nested function",
59                      IDENTIFIER_POINTER (DECL_NAME (x)));
60           }
61         else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
62           {
63             if (TREE_PUBLIC (x))
64               {
65                 error ("address of global register variable `%s' requested",
66                        IDENTIFIER_POINTER (DECL_NAME (x)));
67                 return 0;
68               }
69
70             /* If we are making this addressable due to its having
71                volatile components, give a different error message.  Also
72                handle the case of an unnamed parameter by not trying
73                to give the name.  */
74
75             else if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (x)))
76               {
77                 error ("cannot put object with volatile field into register");
78                 return 0;
79               }
80
81             pedwarn ("address of register variable `%s' requested",
82                      IDENTIFIER_POINTER (DECL_NAME (x)));
83           }
84         put_var_into_stack (x);
85
86         /* drops in */
87       case FUNCTION_DECL:
88         TREE_ADDRESSABLE (x) = 1;
89 #if 0  /* poplevel deals with this now.  */
90         if (DECL_CONTEXT (x) == 0)
91           TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
92 #endif
93
94       default:
95         return 1;
96     }
97 }
98
99 /* Return an unsigned type the same as TYPE in other respects.  */
100
101 tree
102 unsigned_type (type)
103      tree type;
104 {
105   tree type1 = TYPE_MAIN_VARIANT (type);
106   if (type1 == signed_char_type_node || type1 == char_type_node)
107     return unsigned_char_type_node;
108   if (type1 == integer_type_node)
109     return unsigned_type_node;
110   if (type1 == short_integer_type_node)
111     return short_unsigned_type_node;
112   if (type1 == long_integer_type_node)
113     return long_unsigned_type_node;
114   if (type1 == long_long_integer_type_node)
115     return long_long_unsigned_type_node;
116   return type;
117 }
118
119 /* Return a signed type the same as TYPE in other respects.  */
120
121 tree
122 signed_type (type)
123      tree type;
124 {
125   tree type1 = TYPE_MAIN_VARIANT (type);
126   if (type1 == unsigned_char_type_node || type1 == char_type_node)
127     return signed_char_type_node;
128   if (type1 == unsigned_type_node)
129     return integer_type_node;
130   if (type1 == short_unsigned_type_node)
131     return short_integer_type_node;
132   if (type1 == long_unsigned_type_node)
133     return long_integer_type_node;
134   if (type1 == long_long_unsigned_type_node)
135     return long_long_integer_type_node;
136   return type;
137 }
138
139 /* Return a type the same as TYPE except unsigned or
140    signed according to UNSIGNEDP.  */
141
142 tree
143 signed_or_unsigned_type (unsignedp, type)
144      int unsignedp;
145      tree type;
146 {
147   if (! INTEGRAL_TYPE_P (type))
148     return type;
149   if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
150     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
151   if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) 
152     return unsignedp ? unsigned_type_node : integer_type_node;
153   if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node)) 
154     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
155   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node)) 
156     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
157   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) 
158     return (unsignedp ? long_long_unsigned_type_node
159             : long_long_integer_type_node);
160   return type;
161 }
162
163 extern tree intHI_type_node;
164 extern tree intSI_type_node;
165 extern tree intDI_type_node;
166
167 extern tree unsigned_intHI_type_node;
168 extern tree unsigned_intSI_type_node;
169 extern tree unsigned_intDI_type_node;
170
171 /* Return an integer type with BITS bits of precision,
172    that is unsigned if UNSIGNEDP is nonzero, otherwise signed.  */
173
174 tree
175 type_for_size (bits, unsignedp)
176      unsigned bits;
177      int unsignedp;
178 {
179   if (bits == TYPE_PRECISION (signed_char_type_node))
180     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
181
182   if (bits == TYPE_PRECISION (short_integer_type_node))
183     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
184
185   if (bits == TYPE_PRECISION (integer_type_node))
186     return unsignedp ? unsigned_type_node : integer_type_node;
187
188   if (bits == TYPE_PRECISION (long_integer_type_node))
189     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
190
191   if (bits == TYPE_PRECISION (long_long_integer_type_node))
192     return (unsignedp ? long_long_unsigned_type_node
193             : long_long_integer_type_node);
194
195   if (bits <= TYPE_PRECISION (intHI_type_node))
196     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
197
198   if (bits <= TYPE_PRECISION (intSI_type_node))
199     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
200
201   if (bits <= TYPE_PRECISION (intDI_type_node))
202     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
203
204   return 0;
205 }
206
207 /* Return a data type that has machine mode MODE.
208    If the mode is an integer,
209    then UNSIGNEDP selects between signed and unsigned types.  */
210
211 tree
212 type_for_mode (mode, unsignedp)
213      enum machine_mode mode;
214      int unsignedp;
215 {
216   if (mode == TYPE_MODE (signed_char_type_node))
217     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
218
219   if (mode == TYPE_MODE (short_integer_type_node))
220     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
221
222   if (mode == TYPE_MODE (integer_type_node))
223     return unsignedp ? unsigned_type_node : integer_type_node;
224
225   if (mode == TYPE_MODE (long_integer_type_node))
226     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
227
228   if (mode == TYPE_MODE (long_long_integer_type_node))
229     return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
230
231   if (mode == TYPE_MODE (intHI_type_node))
232     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
233
234   if (mode == TYPE_MODE (intSI_type_node))
235     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
236
237   if (mode == TYPE_MODE (intDI_type_node))
238     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
239
240   if (mode == TYPE_MODE (float_type_node))
241     return float_type_node;
242
243   if (mode == TYPE_MODE (double_type_node))
244     return double_type_node;
245
246   if (mode == TYPE_MODE (long_double_type_node))
247     return long_double_type_node;
248
249   if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
250     return build_pointer_type (char_type_node);
251
252   if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
253     return build_pointer_type (integer_type_node);
254
255   return 0;
256 }
257
258 tree
259 truthvalue_conversion (expr)
260      tree expr;
261 {
262   return chill_truthvalue_conversion (expr);
263 }
264 #endif