OSDN Git Service

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