]> gcc.gnu.org Git - gcc.git/blame - gcc/stor-layout.c
(FUNCTION_PROFILER): Use $28 instead of $27.
[gcc.git] / gcc / stor-layout.c
CommitLineData
7306ed3f 1/* C-compiler utilities for types and variables storage layout
68de3831 2 Copyright (C) 1987, 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
7306ed3f
JW
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21#include "config.h"
22#include <stdio.h>
23
24#include "tree.h"
25#include "function.h"
26
27#define CEIL(x,y) (((x) + (y) - 1) / (y))
28
29/* Data type for the expressions representing sizes of data types.
30 It is the first integer type laid out.
31 In C, this is int. */
32
33tree sizetype;
34
35/* An integer constant with value 0 whose type is sizetype. */
36
37tree size_zero_node;
38
39/* An integer constant with value 1 whose type is sizetype. */
40
41tree size_one_node;
42
d4c40650
RS
43/* If nonzero, this is an upper limit on alignment of structure fields.
44 The value is measured in bits. */
45int maximum_field_alignment;
46
b5d11e41
PB
47/* If non-zero, the alignment of a bitsting or (power-)set value, in bits.
48 May be overridden by front-ends. */
49int set_alignment = 0;
50
7306ed3f
JW
51#define GET_MODE_ALIGNMENT(MODE) \
52 MIN (BIGGEST_ALIGNMENT, \
53 MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)))
5e9bec99
RK
54
55static enum machine_mode smallest_mode_for_size PROTO((unsigned int,
56 enum mode_class));
57static tree layout_record PROTO((tree));
58static void layout_union PROTO((tree));
7306ed3f
JW
59\f
60/* SAVE_EXPRs for sizes of types and decls, waiting to be expanded. */
61
62static tree pending_sizes;
63
64/* Nonzero means cannot safely call expand_expr now,
65 so put variable sizes onto `pending_sizes' instead. */
66
67int immediate_size_expand;
68
69tree
70get_pending_sizes ()
71{
72 tree chain = pending_sizes;
4e4b555d
RS
73 tree t;
74
75 /* Put each SAVE_EXPR into the current function. */
76 for (t = chain; t; t = TREE_CHAIN (t))
77 SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = current_function_decl;
7306ed3f
JW
78 pending_sizes = 0;
79 return chain;
80}
81
82/* Given a size SIZE that isn't constant, return a SAVE_EXPR
83 to serve as the actual size-expression for a type or decl. */
84
4e4b555d 85tree
7306ed3f
JW
86variable_size (size)
87 tree size;
88{
5e9bec99
RK
89 /* If the language-processor is to take responsibility for variable-sized
90 items (e.g., languages which have elaboration procedures like Ada),
e5852cff
RK
91 just return SIZE unchanged. Likewise for self-referential sizes. */
92 if (global_bindings_p () < 0 || contains_placeholder_p (size))
5e9bec99
RK
93 return size;
94
68de3831
RK
95 size = save_expr (size);
96
97 if (global_bindings_p ())
7306ed3f 98 {
80f9c711
RS
99 if (TREE_CONSTANT (size))
100 error ("type size can't be explicitly evaluated");
101 else
102 error ("variable-size type declared outside of any function");
103
7306ed3f
JW
104 return size_int (1);
105 }
106
107 if (immediate_size_expand)
93609dfb
RK
108 /* NULL_RTX is not defined; neither is the rtx type.
109 Also, we would like to pass const0_rtx here, but don't have it. */
110 expand_expr (size, expand_expr (integer_zero_node, NULL_PTR, VOIDmode, 0),
111 VOIDmode, 0);
7306ed3f 112 else
c166a311 113 pending_sizes = tree_cons (NULL_TREE, size, pending_sizes);
7306ed3f
JW
114
115 return size;
116}
117\f
118#ifndef MAX_FIXED_MODE_SIZE
119#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
120#endif
121
122/* Return the machine mode to use for a nonscalar of SIZE bits.
123 The mode must be in class CLASS, and have exactly that many bits.
124 If LIMIT is nonzero, modes of wider than MAX_FIXED_MODE_SIZE will not
125 be used. */
126
127enum machine_mode
128mode_for_size (size, class, limit)
129 unsigned int size;
130 enum mode_class class;
131 int limit;
132{
133 register enum machine_mode mode;
134
135 if (limit && size > MAX_FIXED_MODE_SIZE)
136 return BLKmode;
137
5e9bec99 138 /* Get the first mode which has this size, in the specified class. */
7306ed3f
JW
139 for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
140 mode = GET_MODE_WIDER_MODE (mode))
141 if (GET_MODE_BITSIZE (mode) == size)
142 return mode;
143
144 return BLKmode;
145}
146
5e9bec99
RK
147/* Similar, but never return BLKmode; return the narrowest mode that
148 contains at least the requested number of bits. */
149
150static enum machine_mode
151smallest_mode_for_size (size, class)
152 unsigned int size;
153 enum mode_class class;
154{
155 register enum machine_mode mode;
156
157 /* Get the first mode which has at least this size, in the
158 specified class. */
159 for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
160 mode = GET_MODE_WIDER_MODE (mode))
161 if (GET_MODE_BITSIZE (mode) >= size)
162 return mode;
163
164 abort ();
165}
166
7306ed3f
JW
167/* Return the value of VALUE, rounded up to a multiple of DIVISOR. */
168
169tree
170round_up (value, divisor)
171 tree value;
172 int divisor;
173{
174 return size_binop (MULT_EXPR,
175 size_binop (CEIL_DIV_EXPR, value, size_int (divisor)),
176 size_int (divisor));
177}
178\f
179/* Set the size, mode and alignment of a ..._DECL node.
180 TYPE_DECL does need this for C++.
181 Note that LABEL_DECL and CONST_DECL nodes do not need this,
182 and FUNCTION_DECL nodes have them set up in a special (and simple) way.
183 Don't call layout_decl for them.
184
185 KNOWN_ALIGN is the amount of alignment we can assume this
186 decl has with no special effort. It is relevant only for FIELD_DECLs
187 and depends on the previous fields.
188 All that matters about KNOWN_ALIGN is which powers of 2 divide it.
189 If KNOWN_ALIGN is 0, it means, "as much alignment as you like":
190 the record will be aligned to suit. */
191
192void
193layout_decl (decl, known_align)
194 tree decl;
195 unsigned known_align;
196{
197 register tree type = TREE_TYPE (decl);
198 register enum tree_code code = TREE_CODE (decl);
77f934bb 199 int spec_size = DECL_FIELD_SIZE (decl);
7306ed3f
JW
200
201 if (code == CONST_DECL)
202 return;
203
204 if (code != VAR_DECL && code != PARM_DECL && code != RESULT_DECL
205 && code != FIELD_DECL && code != TYPE_DECL)
206 abort ();
207
208 if (type == error_mark_node)
209 {
210 type = void_type_node;
211 spec_size = 0;
212 }
213
214 /* Usually the size and mode come from the data type without change. */
215
216 DECL_MODE (decl) = TYPE_MODE (type);
7306ed3f 217 TREE_UNSIGNED (decl) = TREE_UNSIGNED (type);
5e9bec99
RK
218 if (DECL_SIZE (decl) == 0)
219 DECL_SIZE (decl) = TYPE_SIZE (type);
7306ed3f
JW
220
221 if (code == FIELD_DECL && DECL_BIT_FIELD (decl))
222 {
223 /* This is a bit-field. We don't know how to handle
b02cb287 224 them except for integral types, and front ends should
7306ed3f
JW
225 never generate them otherwise. */
226
b02cb287 227 if (! INTEGRAL_TYPE_P (type))
7306ed3f
JW
228 abort ();
229
230 if (spec_size == 0 && DECL_NAME (decl) != 0)
231 abort ();
232
233 /* Size is specified number of bits. */
234 DECL_SIZE (decl) = size_int (spec_size);
235 }
236 /* Force alignment required for the data type.
23ad4d41
RS
237 But if the decl itself wants greater alignment, don't override that.
238 Likewise, if the decl is packed, don't override it. */
239 else if (DECL_ALIGN (decl) == 0
240 || (! DECL_PACKED (decl) && TYPE_ALIGN (type) > DECL_ALIGN (decl)))
7306ed3f
JW
241 DECL_ALIGN (decl) = TYPE_ALIGN (type);
242
243 /* See if we can use an ordinary integer mode for a bit-field. */
244 /* Conditions are: a fixed size that is correct for another mode
245 and occupying a complete byte or bytes on proper boundary. */
246 if (code == FIELD_DECL)
d4c40650
RS
247 {
248 DECL_BIT_FIELD_TYPE (decl) = DECL_BIT_FIELD (decl) ? type : 0;
249 if (maximum_field_alignment != 0)
250 DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), maximum_field_alignment);
251 }
252
7306ed3f
JW
253 if (DECL_BIT_FIELD (decl)
254 && TYPE_SIZE (type) != 0
255 && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
256 {
257 register enum machine_mode xmode
258 = mode_for_size (TREE_INT_CST_LOW (DECL_SIZE (decl)), MODE_INT, 1);
259
260 if (xmode != BLKmode
261 && known_align % GET_MODE_ALIGNMENT (xmode) == 0)
262 {
263 DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode),
264 DECL_ALIGN (decl));
265 DECL_MODE (decl) = xmode;
266 DECL_SIZE (decl) = size_int (GET_MODE_BITSIZE (xmode));
267 /* This no longer needs to be accessed as a bit field. */
268 DECL_BIT_FIELD (decl) = 0;
269 }
270 }
271
272 /* Evaluate nonconstant size only once, either now or as soon as safe. */
273 if (DECL_SIZE (decl) != 0 && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
274 DECL_SIZE (decl) = variable_size (DECL_SIZE (decl));
275}
276\f
277/* Lay out a RECORD_TYPE type (a C struct).
278 This means laying out the fields, determining their positions,
279 and computing the overall size and required alignment of the record.
280 Note that if you set the TYPE_ALIGN before calling this
281 then the struct is aligned to at least that boundary.
282
283 If the type has basetypes, you must call layout_basetypes
284 before calling this function.
285
286 The return value is a list of static members of the record.
287 They still need to be laid out. */
288
289static tree
290layout_record (rec)
291 tree rec;
292{
293 register tree field;
294#ifdef STRUCTURE_SIZE_BOUNDARY
295 unsigned record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec));
296#else
297 unsigned record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
298#endif
299 /* These must be laid out *after* the record is. */
300 tree pending_statics = NULL_TREE;
301 /* Record size so far is CONST_SIZE + VAR_SIZE bits,
302 where CONST_SIZE is an integer
303 and VAR_SIZE is a tree expression.
304 If VAR_SIZE is null, the size is just CONST_SIZE.
305 Naturally we try to avoid using VAR_SIZE. */
306 register int const_size = 0;
307 register tree var_size = 0;
308 /* Once we start using VAR_SIZE, this is the maximum alignment
309 that we know VAR_SIZE has. */
310 register int var_align = BITS_PER_UNIT;
311
312
313 for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field))
314 {
8df06118 315 register int known_align = var_size ? var_align : const_size;
7306ed3f
JW
316 register int desired_align;
317
318 /* If FIELD is static, then treat it like a separate variable,
319 not really like a structure field.
320 If it is a FUNCTION_DECL, it's a method.
321 In both cases, all we do is lay out the decl,
322 and we do it *after* the record is laid out. */
323
324 if (TREE_STATIC (field))
325 {
c166a311 326 pending_statics = tree_cons (NULL_TREE, field, pending_statics);
7306ed3f
JW
327 continue;
328 }
329 /* Enumerators and enum types which are local to this class need not
330 be laid out. Likewise for initialized constant fields. */
331 if (TREE_CODE (field) != FIELD_DECL)
332 continue;
333
334 /* Lay out the field so we know what alignment it needs.
8df06118 335 For a packed field, use the alignment as specified,
7306ed3f
JW
336 disregarding what the type would want. */
337 if (DECL_PACKED (field))
338 desired_align = DECL_ALIGN (field);
8df06118 339 layout_decl (field, known_align);
7306ed3f
JW
340 if (! DECL_PACKED (field))
341 desired_align = DECL_ALIGN (field);
342 /* Some targets (i.e. VMS) limit struct field alignment
343 to a lower boundary than alignment of variables. */
344#ifdef BIGGEST_FIELD_ALIGNMENT
345 desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT);
346#endif
347
348 /* Record must have at least as much alignment as any field.
349 Otherwise, the alignment of the field within the record
350 is meaningless. */
351
352#ifndef PCC_BITFIELD_TYPE_MATTERS
353 record_align = MAX (record_align, desired_align);
354#else
355 if (PCC_BITFIELD_TYPE_MATTERS && TREE_TYPE (field) != error_mark_node
cdc54cc9 356 && DECL_BIT_FIELD_TYPE (field)
7306ed3f
JW
357 && ! integer_zerop (TYPE_SIZE (TREE_TYPE (field))))
358 {
359 /* For these machines, a zero-length field does not
360 affect the alignment of the structure as a whole.
361 It does, however, affect the alignment of the next field
362 within the structure. */
363 if (! integer_zerop (DECL_SIZE (field)))
364 record_align = MAX (record_align, desired_align);
365 else if (! DECL_PACKED (field))
366 desired_align = TYPE_ALIGN (TREE_TYPE (field));
367 /* A named bit field of declared type `int'
368 forces the entire structure to have `int' alignment. */
369 if (DECL_NAME (field) != 0)
e2301a83
RS
370 {
371 int type_align = TYPE_ALIGN (TREE_TYPE (field));
372 if (maximum_field_alignment != 0)
373 type_align = MIN (type_align, maximum_field_alignment);
374
375 record_align = MAX (record_align, type_align);
376 }
7306ed3f
JW
377 }
378 else
379 record_align = MAX (record_align, desired_align);
380#endif
381
382 /* Does this field automatically have alignment it needs
383 by virtue of the fields that precede it and the record's
384 own alignment? */
385
386 if (const_size % desired_align != 0
387 || (var_align % desired_align != 0
388 && var_size != 0))
389 {
390 /* No, we need to skip space before this field.
391 Bump the cumulative size to multiple of field alignment. */
392
393 if (var_size == 0
394 || var_align % desired_align == 0)
395 const_size
396 = CEIL (const_size, desired_align) * desired_align;
397 else
398 {
399 if (const_size > 0)
e7c33f54
RK
400 var_size = size_binop (PLUS_EXPR, var_size,
401 size_int (const_size));
7306ed3f
JW
402 const_size = 0;
403 var_size = round_up (var_size, desired_align);
404 var_align = MIN (var_align, desired_align);
405 }
406 }
407
408#ifdef PCC_BITFIELD_TYPE_MATTERS
409 if (PCC_BITFIELD_TYPE_MATTERS
410 && TREE_CODE (field) == FIELD_DECL
411 && TREE_TYPE (field) != error_mark_node
cdc54cc9 412 && DECL_BIT_FIELD_TYPE (field)
7306ed3f 413 && !DECL_PACKED (field)
da57b63a
RS
414 /* If #pragma pack is in effect, turn off this feature. */
415 && maximum_field_alignment == 0
7306ed3f
JW
416 && !integer_zerop (DECL_SIZE (field)))
417 {
418 int type_align = TYPE_ALIGN (TREE_TYPE (field));
419 register tree dsize = DECL_SIZE (field);
420 int field_size = TREE_INT_CST_LOW (dsize);
421
422 /* A bit field may not span the unit of alignment of its type.
423 Advance to next boundary if necessary. */
e2301a83
RS
424 /* ??? There is some uncertainty here as to what
425 should be done if type_align is less than the width of the type.
426 That can happen because the width exceeds BIGGEST_ALIGNMENT
427 or because it exceeds maximum_field_alignment. */
7306ed3f
JW
428 if (const_size / type_align
429 != (const_size + field_size - 1) / type_align)
430 const_size = CEIL (const_size, type_align) * type_align;
431 }
432#endif
433
434/* No existing machine description uses this parameter.
435 So I have made it in this aspect identical to PCC_BITFIELD_TYPE_MATTERS. */
436#ifdef BITFIELD_NBYTES_LIMITED
437 if (BITFIELD_NBYTES_LIMITED
438 && TREE_CODE (field) == FIELD_DECL
439 && TREE_TYPE (field) != error_mark_node
cdc54cc9 440 && DECL_BIT_FIELD_TYPE (field)
7306ed3f
JW
441 && !DECL_PACKED (field)
442 && !integer_zerop (DECL_SIZE (field)))
443 {
444 int type_align = TYPE_ALIGN (TREE_TYPE (field));
445 register tree dsize = DECL_SIZE (field);
446 int field_size = TREE_INT_CST_LOW (dsize);
447
e2301a83
RS
448 if (maximum_field_alignment != 0)
449 type_align = MIN (type_align, maximum_field_alignment);
450
7306ed3f
JW
451 /* A bit field may not span the unit of alignment of its type.
452 Advance to next boundary if necessary. */
453 if (const_size / type_align
454 != (const_size + field_size - 1) / type_align)
455 const_size = CEIL (const_size, type_align) * type_align;
456 }
457#endif
458
459 /* Size so far becomes the position of this field. */
460
461 if (var_size && const_size)
462 DECL_FIELD_BITPOS (field)
463 = size_binop (PLUS_EXPR, var_size, size_int (const_size));
464 else if (var_size)
465 DECL_FIELD_BITPOS (field) = var_size;
466 else
8df06118
RK
467 {
468 DECL_FIELD_BITPOS (field) = size_int (const_size);
469
470 /* If this field ended up more aligned than we thought it
471 would be (we approximate this by seeing if its position
472 changed), lay out the field again; perhaps we can use an
473 integral mode for it now. */
474 if (known_align != const_size)
475 layout_decl (field, const_size);
476 }
7306ed3f 477
7306ed3f
JW
478 /* Now add size of this field to the size of the record. */
479
480 {
481 register tree dsize = DECL_SIZE (field);
482
e0b382b1
RS
483 /* This can happen when we have an invalid nested struct definition,
484 such as struct j { struct j { int i; } }. The error message is
485 printed in finish_struct. */
486 if (dsize == 0)
487 /* Do nothing. */;
370f6918
RS
488 else if (TREE_CODE (dsize) == INTEGER_CST
489 && TREE_INT_CST_HIGH (dsize) == 0
490 && TREE_INT_CST_LOW (dsize) + const_size > const_size)
491 /* Use const_size if there's no overflow. */
7306ed3f
JW
492 const_size += TREE_INT_CST_LOW (dsize);
493 else
494 {
495 if (var_size == 0)
496 var_size = dsize;
497 else
498 var_size = size_binop (PLUS_EXPR, var_size, dsize);
499 }
500 }
501 }
502
503 /* Work out the total size and alignment of the record
504 as one expression and store in the record type.
505 Round it up to a multiple of the record's alignment. */
506
507 if (var_size == 0)
508 {
509 TYPE_SIZE (rec) = size_int (const_size);
510 }
511 else
512 {
513 if (const_size)
514 var_size
515 = size_binop (PLUS_EXPR, var_size, size_int (const_size));
516 TYPE_SIZE (rec) = var_size;
517 }
518
519 /* Determine the desired alignment. */
520#ifdef ROUND_TYPE_ALIGN
521 TYPE_ALIGN (rec) = ROUND_TYPE_ALIGN (rec, TYPE_ALIGN (rec), record_align);
522#else
523 TYPE_ALIGN (rec) = MAX (TYPE_ALIGN (rec), record_align);
524#endif
525
526#ifdef ROUND_TYPE_SIZE
527 TYPE_SIZE (rec) = ROUND_TYPE_SIZE (rec, TYPE_SIZE (rec), TYPE_ALIGN (rec));
528#else
529 /* Round the size up to be a multiple of the required alignment */
530 TYPE_SIZE (rec) = round_up (TYPE_SIZE (rec), TYPE_ALIGN (rec));
531#endif
532
533 return pending_statics;
534}
535\f
1aa4cb3a 536/* Lay out a UNION_TYPE or QUAL_UNION_TYPE type.
7306ed3f
JW
537 Lay out all the fields, set their positions to zero,
538 and compute the size and alignment of the union (maximum of any field).
539 Note that if you set the TYPE_ALIGN before calling this
540 then the union align is aligned to at least that boundary. */
541
542static void
543layout_union (rec)
544 tree rec;
545{
546 register tree field;
547#ifdef STRUCTURE_SIZE_BOUNDARY
548 unsigned union_align = STRUCTURE_SIZE_BOUNDARY;
549#else
550 unsigned union_align = BITS_PER_UNIT;
551#endif
552
553 /* The size of the union, based on the fields scanned so far,
554 is max (CONST_SIZE, VAR_SIZE).
555 VAR_SIZE may be null; then CONST_SIZE by itself is the size. */
556 register int const_size = 0;
557 register tree var_size = 0;
558
1aa4cb3a
RK
559 /* If this is a QUAL_UNION_TYPE, we want to process the fields in
560 the reverse order in building the COND_EXPR that denotes its
561 size. We reverse them again later. */
562 if (TREE_CODE (rec) == QUAL_UNION_TYPE)
563 TYPE_FIELDS (rec) = nreverse (TYPE_FIELDS (rec));
564
7306ed3f
JW
565 for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field))
566 {
567 /* Enums which are local to this class need not be laid out. */
568 if (TREE_CODE (field) == CONST_DECL || TREE_CODE (field) == TYPE_DECL)
569 continue;
570
571 layout_decl (field, 0);
572 DECL_FIELD_BITPOS (field) = size_int (0);
573
574 /* Union must be at least as aligned as any field requires. */
575
576 union_align = MAX (union_align, DECL_ALIGN (field));
577
578#ifdef PCC_BITFIELD_TYPE_MATTERS
579 /* On the m88000, a bit field of declare type `int'
580 forces the entire union to have `int' alignment. */
cdc54cc9 581 if (PCC_BITFIELD_TYPE_MATTERS && DECL_BIT_FIELD_TYPE (field))
7306ed3f
JW
582 union_align = MAX (union_align, TYPE_ALIGN (TREE_TYPE (field)));
583#endif
584
1aa4cb3a
RK
585 if (TREE_CODE (rec) == UNION_TYPE)
586 {
587 /* Set union_size to max (decl_size, union_size).
588 There are more and less general ways to do this.
589 Use only CONST_SIZE unless forced to use VAR_SIZE. */
7306ed3f 590
1aa4cb3a
RK
591 if (TREE_CODE (DECL_SIZE (field)) == INTEGER_CST)
592 const_size
593 = MAX (const_size, TREE_INT_CST_LOW (DECL_SIZE (field)));
594 else if (var_size == 0)
595 var_size = DECL_SIZE (field);
596 else
597 var_size = size_binop (MAX_EXPR, var_size, DECL_SIZE (field));
598 }
599 else if (TREE_CODE (rec) == QUAL_UNION_TYPE)
600 var_size = fold (build (COND_EXPR, sizetype, DECL_QUALIFIER (field),
601 DECL_SIZE (field),
602 var_size ? var_size : integer_zero_node));
603 }
604
605 if (TREE_CODE (rec) == QUAL_UNION_TYPE)
606 TYPE_FIELDS (rec) = nreverse (TYPE_FIELDS (rec));
7306ed3f
JW
607
608 /* Determine the ultimate size of the union (in bytes). */
609 if (NULL == var_size)
610 TYPE_SIZE (rec) = size_int (CEIL (const_size, BITS_PER_UNIT)
611 * BITS_PER_UNIT);
612 else if (const_size == 0)
613 TYPE_SIZE (rec) = var_size;
614 else
615 TYPE_SIZE (rec) = size_binop (MAX_EXPR, var_size,
616 round_up (size_int (const_size),
617 BITS_PER_UNIT));
618
619 /* Determine the desired alignment. */
620#ifdef ROUND_TYPE_ALIGN
621 TYPE_ALIGN (rec) = ROUND_TYPE_ALIGN (rec, TYPE_ALIGN (rec), union_align);
622#else
623 TYPE_ALIGN (rec) = MAX (TYPE_ALIGN (rec), union_align);
624#endif
625
626#ifdef ROUND_TYPE_SIZE
627 TYPE_SIZE (rec) = ROUND_TYPE_SIZE (rec, TYPE_SIZE (rec), TYPE_ALIGN (rec));
628#else
629 /* Round the size up to be a multiple of the required alignment */
630 TYPE_SIZE (rec) = round_up (TYPE_SIZE (rec), TYPE_ALIGN (rec));
631#endif
632}
633\f
634/* Calculate the mode, size, and alignment for TYPE.
635 For an array type, calculate the element separation as well.
636 Record TYPE on the chain of permanent or temporary types
637 so that dbxout will find out about it.
638
639 TYPE_SIZE of a type is nonzero if the type has been laid out already.
640 layout_type does nothing on such a type.
641
642 If the type is incomplete, its TYPE_SIZE remains zero. */
643
644void
645layout_type (type)
646 tree type;
647{
648 int old;
649 tree pending_statics;
650
651 if (type == 0)
652 abort ();
653
654 /* Do nothing if type has been laid out before. */
655 if (TYPE_SIZE (type))
656 return;
657
658 /* Make sure all nodes we allocate are not momentary;
659 they must last past the current statement. */
660 old = suspend_momentary ();
661
a6388960
RK
662 /* Put all our nodes into the same obstack as the type. Also,
663 make expressions saveable (this is a no-op for permanent types). */
664
665 push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
666 saveable_allocation ();
7306ed3f
JW
667
668 switch (TREE_CODE (type))
669 {
670 case LANG_TYPE:
671 /* This kind of type is the responsibility
672 of the languge-specific code. */
673 abort ();
674
675 case INTEGER_TYPE:
676 case ENUMERAL_TYPE:
e2a77f99
RK
677 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
678 && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0)
7306ed3f
JW
679 TREE_UNSIGNED (type) = 1;
680
5e9bec99
RK
681 TYPE_MODE (type) = smallest_mode_for_size (TYPE_PRECISION (type),
682 MODE_INT);
7306ed3f
JW
683 TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
684 break;
685
686 case REAL_TYPE:
687 TYPE_MODE (type) = mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0);
688 TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
689 break;
690
691 case COMPLEX_TYPE:
692 TREE_UNSIGNED (type) = TREE_UNSIGNED (TREE_TYPE (type));
693 TYPE_MODE (type)
694 = mode_for_size (2 * TYPE_PRECISION (TREE_TYPE (type)),
695 (TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE
696 ? MODE_COMPLEX_INT : MODE_COMPLEX_FLOAT),
697 0);
698 TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
699 break;
700
701 case VOID_TYPE:
702 TYPE_SIZE (type) = size_zero_node;
703 TYPE_ALIGN (type) = 1;
704 TYPE_MODE (type) = VOIDmode;
705 break;
706
321cb743 707 case OFFSET_TYPE:
13275056
RK
708 TYPE_SIZE (type) = size_int (POINTER_SIZE);
709 TYPE_MODE (type) = mode_for_size (POINTER_SIZE,
710 GET_MODE_CLASS (Pmode), 0);
321cb743
MT
711 break;
712
7306ed3f
JW
713 case FUNCTION_TYPE:
714 case METHOD_TYPE:
13275056
RK
715 TYPE_MODE (type) = mode_for_size (2 * POINTER_SIZE, MODE_INT, 0);
716 TYPE_SIZE (type) = size_int (2 * POINTER_SIZE);
7306ed3f
JW
717 break;
718
719 case POINTER_TYPE:
720 case REFERENCE_TYPE:
13275056
RK
721 TYPE_MODE (type) = mode_for_size (POINTER_SIZE,
722 GET_MODE_CLASS (Pmode), 0);
723 TYPE_SIZE (type) = size_int (POINTER_SIZE);
7306ed3f 724 TREE_UNSIGNED (type) = 1;
13275056 725 TYPE_PRECISION (type) = POINTER_SIZE;
7306ed3f
JW
726 break;
727
728 case ARRAY_TYPE:
729 {
730 register tree index = TYPE_DOMAIN (type);
731 register tree element = TREE_TYPE (type);
732
733 build_pointer_type (element);
734
735 /* We need to know both bounds in order to compute the size. */
736 if (index && TYPE_MAX_VALUE (index) && TYPE_MIN_VALUE (index)
737 && TYPE_SIZE (element))
738 {
739 tree length
740 = size_binop (PLUS_EXPR, size_one_node,
741 size_binop (MINUS_EXPR, TYPE_MAX_VALUE (index),
742 TYPE_MIN_VALUE (index)));
743
744 TYPE_SIZE (type) = size_binop (MULT_EXPR, length,
745 TYPE_SIZE (element));
746 }
747
748 /* Now round the alignment and size,
749 using machine-dependent criteria if any. */
750
751#ifdef ROUND_TYPE_ALIGN
752 TYPE_ALIGN (type)
753 = ROUND_TYPE_ALIGN (type, TYPE_ALIGN (element), BITS_PER_UNIT);
754#else
755 TYPE_ALIGN (type) = MAX (TYPE_ALIGN (element), BITS_PER_UNIT);
756#endif
757
758#ifdef ROUND_TYPE_SIZE
759 if (TYPE_SIZE (type) != 0)
760 TYPE_SIZE (type)
761 = ROUND_TYPE_SIZE (type, TYPE_SIZE (type), TYPE_ALIGN (type));
762#endif
763
764 TYPE_MODE (type) = BLKmode;
765 if (TYPE_SIZE (type) != 0
766 && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
767 /* BLKmode elements force BLKmode aggregate;
768 else extract/store fields may lose. */
769 && (TYPE_MODE (TREE_TYPE (type)) != BLKmode
770 || TYPE_NO_FORCE_BLK (TREE_TYPE (type))))
771 {
772 TYPE_MODE (type)
773 = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
774 MODE_INT, 1);
775
4e4b555d 776 if (STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
7306ed3f
JW
777 && TYPE_ALIGN (type) < TREE_INT_CST_LOW (TYPE_SIZE (type))
778 && TYPE_MODE (type) != BLKmode)
779 {
780 TYPE_NO_FORCE_BLK (type) = 1;
781 TYPE_MODE (type) = BLKmode;
782 }
7306ed3f
JW
783 }
784 break;
785 }
786
787 case RECORD_TYPE:
788 pending_statics = layout_record (type);
789 TYPE_MODE (type) = BLKmode;
790 if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
791 {
792 tree field;
793 /* A record which has any BLKmode members must itself be BLKmode;
794 it can't go in a register.
795 Unless the member is BLKmode only because it isn't aligned. */
796 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
797 {
798 int bitpos;
799
800 if (TREE_CODE (field) != FIELD_DECL)
801 continue;
802
803 if (TYPE_MODE (TREE_TYPE (field)) == BLKmode
804 && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)))
805 goto record_lose;
806
807 if (TREE_CODE (DECL_FIELD_BITPOS (field)) != INTEGER_CST)
808 goto record_lose;
809
810 bitpos = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
811
812 /* Must be BLKmode if any field crosses a word boundary,
813 since extract_bit_field can't handle that in registers. */
814 if (bitpos / BITS_PER_WORD
815 != ((TREE_INT_CST_LOW (DECL_SIZE (field)) + bitpos - 1)
816 / BITS_PER_WORD)
817 /* But there is no problem if the field is entire words. */
818 && TREE_INT_CST_LOW (DECL_SIZE (field)) % BITS_PER_WORD == 0)
819 goto record_lose;
820 }
821
822 TYPE_MODE (type)
823 = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
824 MODE_INT, 1);
825
826 /* If structure's known alignment is less than
827 what the scalar mode would need, and it matters,
828 then stick with BLKmode. */
4e4b555d
RS
829 if (STRICT_ALIGNMENT
830 && ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
831 || (TYPE_ALIGN (type)
832 >= TREE_INT_CST_LOW (TYPE_SIZE (type)))))
7306ed3f
JW
833 {
834 if (TYPE_MODE (type) != BLKmode)
835 /* If this is the only reason this type is BLKmode,
836 then don't force containing types to be BLKmode. */
837 TYPE_NO_FORCE_BLK (type) = 1;
838 TYPE_MODE (type) = BLKmode;
839 }
4e4b555d 840
7306ed3f
JW
841 record_lose: ;
842 }
843
844 /* Lay out any static members. This is done now
845 because their type may use the record's type. */
846 while (pending_statics)
847 {
848 layout_decl (TREE_VALUE (pending_statics), 0);
849 pending_statics = TREE_CHAIN (pending_statics);
850 }
851 break;
852
853 case UNION_TYPE:
1aa4cb3a 854 case QUAL_UNION_TYPE:
7306ed3f
JW
855 layout_union (type);
856 TYPE_MODE (type) = BLKmode;
857 if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
858 /* If structure's known alignment is less than
859 what the scalar mode would need, and it matters,
860 then stick with BLKmode. */
4e4b555d
RS
861 && (! STRICT_ALIGNMENT
862 || TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
863 || TYPE_ALIGN (type) >= TREE_INT_CST_LOW (TYPE_SIZE (type))))
7306ed3f
JW
864 {
865 tree field;
866 /* A union which has any BLKmode members must itself be BLKmode;
867 it can't go in a register.
868 Unless the member is BLKmode only because it isn't aligned. */
869 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
870 {
871 if (TREE_CODE (field) != FIELD_DECL)
872 continue;
873
874 if (TYPE_MODE (TREE_TYPE (field)) == BLKmode
875 && ! TYPE_NO_FORCE_BLK (TREE_TYPE (field)))
876 goto union_lose;
877 }
878
879 TYPE_MODE (type)
880 = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
881 MODE_INT, 1);
882
883 union_lose: ;
884 }
885 break;
886
a6458cef 887 /* Pascal and Chill types */
4cc89e53
RS
888 case BOOLEAN_TYPE: /* store one byte/boolean for now. */
889 TYPE_MODE (type) = QImode;
890 TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
891 TYPE_PRECISION (type) = 1;
892 TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type));
a6458cef
PB
893 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
894 && tree_int_cst_sgn (TYPE_MIN_VALUE (type)) >= 0)
895 TREE_UNSIGNED (type) = 1;
4cc89e53
RS
896 break;
897
898 case CHAR_TYPE:
899 TYPE_MODE (type) = QImode;
900 TYPE_SIZE (type) = size_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
901 TYPE_PRECISION (type) = GET_MODE_BITSIZE (TYPE_MODE (type));
902 TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type));
903 break;
904
b5d11e41
PB
905 case SET_TYPE:
906 if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) != INTEGER_CST
907 || TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) != INTEGER_CST)
908 abort();
909 else
910 {
911#ifndef SET_WORD_SIZE
912#define SET_WORD_SIZE BITS_PER_WORD
913#endif
914 int alignment = set_alignment ? set_alignment : SET_WORD_SIZE;
915 int size_in_bits =
916 TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
917 - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1;
918 int rounded_size
919 = ((size_in_bits + alignment - 1) / alignment) * alignment;
920 if (rounded_size > alignment)
921 TYPE_MODE (type) = BLKmode;
922 else
923 TYPE_MODE (type) = mode_for_size (alignment, MODE_INT, 1);
924 TYPE_SIZE (type) = size_int (rounded_size);
925 TYPE_ALIGN (type) = alignment;
926 TYPE_PRECISION (type) = size_in_bits;
927 }
928 break;
929
4cc89e53
RS
930 case FILE_TYPE:
931 /* The size may vary in different languages, so the language front end
932 should fill in the size. */
933 TYPE_ALIGN (type) = BIGGEST_ALIGNMENT;
934 TYPE_MODE (type) = BLKmode;
935 break;
936
7306ed3f
JW
937 default:
938 abort ();
939 } /* end switch */
940
941 /* Normally, use the alignment corresponding to the mode chosen.
942 However, where strict alignment is not required, avoid
943 over-aligning structures, since most compilers do not do this
944 alignment. */
945
946 if (TYPE_MODE (type) != BLKmode && TYPE_MODE (type) != VOIDmode
4e4b555d
RS
947 && (STRICT_ALIGNMENT
948 || (TREE_CODE (type) != RECORD_TYPE && TREE_CODE (type) != UNION_TYPE
1aa4cb3a 949 && TREE_CODE (type) != QUAL_UNION_TYPE
4e4b555d 950 && TREE_CODE (type) != ARRAY_TYPE)))
7306ed3f
JW
951 TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type));
952
953 /* Evaluate nonconstant size only once, either now or as soon as safe. */
954 if (TYPE_SIZE (type) != 0 && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
955 TYPE_SIZE (type) = variable_size (TYPE_SIZE (type));
956
957 /* Also layout any other variants of the type. */
958 if (TYPE_NEXT_VARIANT (type)
959 || type != TYPE_MAIN_VARIANT (type))
960 {
961 tree variant;
962 /* Record layout info of this variant. */
963 tree size = TYPE_SIZE (type);
964 int align = TYPE_ALIGN (type);
965 enum machine_mode mode = TYPE_MODE (type);
966
967 /* Copy it into all variants. */
968 for (variant = TYPE_MAIN_VARIANT (type);
969 variant;
970 variant = TYPE_NEXT_VARIANT (variant))
971 {
972 TYPE_SIZE (variant) = size;
973 TYPE_ALIGN (variant) = align;
974 TYPE_MODE (variant) = mode;
975 }
976 }
977
978 pop_obstacks ();
979 resume_momentary (old);
980}
981\f
982/* Create and return a type for signed integers of PRECISION bits. */
983
984tree
985make_signed_type (precision)
986 int precision;
987{
988 register tree type = make_node (INTEGER_TYPE);
989
990 TYPE_PRECISION (type) = precision;
991
992 /* Create the extreme values based on the number of bits. */
993
994 TYPE_MIN_VALUE (type)
c166a311
CH
995 = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
996 ? 0 : (HOST_WIDE_INT) (-1) << (precision - 1)),
997 (((HOST_WIDE_INT) (-1)
998 << (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
13756074 999 ? precision - HOST_BITS_PER_WIDE_INT - 1
c166a311 1000 : 0))));
7306ed3f 1001 TYPE_MAX_VALUE (type)
13756074 1002 = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
c166a311
CH
1003 ? -1 : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1),
1004 (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
1005 ? (((HOST_WIDE_INT) 1
13756074 1006 << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1
7306ed3f
JW
1007 : 0));
1008
1009 /* Give this type's extreme values this type as their type. */
1010
1011 TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
1012 TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
1013
1014 /* The first type made with this or `make_unsigned_type'
1015 is the type for size values. */
1016
1017 if (sizetype == 0)
1018 {
1019 sizetype = type;
1020 }
1021
1022 /* Lay out the type: set its alignment, size, etc. */
1023
1024 layout_type (type);
1025
1026 return type;
1027}
1028
1029/* Create and return a type for unsigned integers of PRECISION bits. */
1030
1031tree
1032make_unsigned_type (precision)
1033 int precision;
1034{
1035 register tree type = make_node (INTEGER_TYPE);
1036
1037 TYPE_PRECISION (type) = precision;
1038
1039 /* The first type made with this or `make_signed_type'
1040 is the type for size values. */
1041
1042 if (sizetype == 0)
1043 {
1044 sizetype = type;
1045 }
1046
1047 fixup_unsigned_type (type);
1048 return type;
1049}
1050
4cc89e53 1051/* Set the extreme values of TYPE based on its precision in bits,
13756074 1052 then lay it out. Used when make_signed_type won't do
4cc89e53
RS
1053 because the tree code is not INTEGER_TYPE.
1054 E.g. for Pascal, when the -fsigned-char option is given. */
1055
1056void
1057fixup_signed_type (type)
1058 tree type;
1059{
1060 register int precision = TYPE_PRECISION (type);
1061
1062 TYPE_MIN_VALUE (type)
13756074
JW
1063 = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
1064 ? 0 : (HOST_WIDE_INT) (-1) << (precision - 1)),
1065 (((HOST_WIDE_INT) (-1)
1066 << (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
1067 ? precision - HOST_BITS_PER_WIDE_INT - 1
1068 : 0))));
4cc89e53 1069 TYPE_MAX_VALUE (type)
13756074
JW
1070 = build_int_2 ((precision - HOST_BITS_PER_WIDE_INT > 0
1071 ? -1 : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1),
1072 (precision - HOST_BITS_PER_WIDE_INT - 1 > 0
1073 ? (((HOST_WIDE_INT) 1
1074 << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1
4cc89e53
RS
1075 : 0));
1076
1077 TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
1078 TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
1079
1080 /* Lay out the type: set its alignment, size, etc. */
1081
1082 layout_type (type);
1083}
1084
7306ed3f 1085/* Set the extreme values of TYPE based on its precision in bits,
13756074 1086 then lay it out. This is used both in `make_unsigned_type'
7306ed3f
JW
1087 and for enumeral types. */
1088
1089void
1090fixup_unsigned_type (type)
1091 tree type;
1092{
1093 register int precision = TYPE_PRECISION (type);
1094
1095 TYPE_MIN_VALUE (type) = build_int_2 (0, 0);
1096 TYPE_MAX_VALUE (type)
c166a311 1097 = build_int_2 (precision - HOST_BITS_PER_WIDE_INT >= 0
13756074 1098 ? -1 : ((HOST_WIDE_INT) 1 << precision) - 1,
c166a311
CH
1099 precision - HOST_BITS_PER_WIDE_INT > 0
1100 ? ((unsigned HOST_WIDE_INT) ~0
1101 >> (HOST_BITS_PER_WIDE_INT
1102 - (precision - HOST_BITS_PER_WIDE_INT)))
7306ed3f
JW
1103 : 0);
1104 TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
1105 TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
1106
1107 /* Lay out the type: set its alignment, size, etc. */
1108
1109 layout_type (type);
1110}
1111\f
1112/* Find the best machine mode to use when referencing a bit field of length
1113 BITSIZE bits starting at BITPOS.
1114
1115 The underlying object is known to be aligned to a boundary of ALIGN bits.
1116 If LARGEST_MODE is not VOIDmode, it means that we should not use a mode
1117 larger than LARGEST_MODE (usually SImode).
1118
1119 If no mode meets all these conditions, we return VOIDmode. Otherwise, if
1120 VOLATILEP is true or SLOW_BYTE_ACCESS is false, we return the smallest
1121 mode meeting these conditions.
1122
77fa0940
RK
1123 Otherwise (VOLATILEP is false and SLOW_BYTE_ACCESS is true), we return
1124 the largest mode (but a mode no wider than UNITS_PER_WORD) that meets
1125 all the conditions. */
7306ed3f
JW
1126
1127enum machine_mode
1128get_best_mode (bitsize, bitpos, align, largest_mode, volatilep)
1129 int bitsize, bitpos;
1130 int align;
1131 enum machine_mode largest_mode;
1132 int volatilep;
1133{
1134 enum machine_mode mode;
1135 int unit;
1136
1137 /* Find the narrowest integer mode that contains the bit field. */
1138 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
1139 mode = GET_MODE_WIDER_MODE (mode))
1140 {
1141 unit = GET_MODE_BITSIZE (mode);
1142 if (bitpos / unit == (bitpos + bitsize - 1) / unit)
1143 break;
1144 }
1145
1146 if (mode == MAX_MACHINE_MODE
1147 /* It is tempting to omit the following line
4e4b555d 1148 if STRICT_ALIGNMENT is true.
7306ed3f
JW
1149 But that is incorrect, since if the bitfield uses part of 3 bytes
1150 and we use a 4-byte mode, we could get a spurious segv
1151 if the extra 4th byte is past the end of memory.
1152 (Though at least one Unix compiler ignores this problem:
1153 that on the Sequent 386 machine. */
1154 || MIN (unit, BIGGEST_ALIGNMENT) > align
1155 || (largest_mode != VOIDmode && unit > GET_MODE_BITSIZE (largest_mode)))
1156 return VOIDmode;
1157
77fa0940
RK
1158 if (SLOW_BYTE_ACCESS && ! volatilep)
1159 {
1160 enum machine_mode wide_mode = VOIDmode, tmode;
1161
1162 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); tmode != VOIDmode;
1163 tmode = GET_MODE_WIDER_MODE (tmode))
1164 {
1165 unit = GET_MODE_BITSIZE (tmode);
1166 if (bitpos / unit == (bitpos + bitsize - 1) / unit
1167 && unit <= BITS_PER_WORD
1168 && unit <= MIN (align, BIGGEST_ALIGNMENT)
1169 && (largest_mode == VOIDmode
1170 || unit <= GET_MODE_BITSIZE (largest_mode)))
1171 wide_mode = tmode;
1172 }
1173
1174 if (wide_mode != VOIDmode)
1175 return wide_mode;
1176 }
7306ed3f
JW
1177
1178 return mode;
1179}
1180\f
1181/* Save all variables describing the current status into the structure *P.
1182 This is used before starting a nested function. */
1183
1184void
1185save_storage_status (p)
1186 struct function *p;
1187{
1188#if 0 /* Need not save, since always 0 and non0 (resp.) within a function. */
1189 p->pending_sizes = pending_sizes;
1190 p->immediate_size_expand = immediate_size_expand;
1191#endif /* 0 */
1192}
1193
1194/* Restore all variables describing the current status from the structure *P.
1195 This is used after a nested function. */
1196
1197void
1198restore_storage_status (p)
1199 struct function *p;
1200{
1201#if 0
1202 pending_sizes = p->pending_sizes;
1203 immediate_size_expand = p->immediate_size_expand;
1204#endif /* 0 */
1205}
This page took 0.344683 seconds and 5 git commands to generate.