OSDN Git Service

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