Annotation of gcc/tree.c, revision 1.1.1.6

1.1       root        1: /* Language-independent node constructors for parse phase of GNU compiler.
1.1.1.6 ! root        2:    Copyright (C) 1987, 1988, 1992, 1993 Free Software Foundation, Inc.
1.1       root        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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: 
                     21: /* This file contains the low level primitives for operating on tree nodes,
                     22:    including allocation, list operations, interning of identifiers,
                     23:    construction of data type nodes and statement nodes,
                     24:    and construction of type conversion nodes.  It also contains
                     25:    tables index by tree code that describe how to take apart
                     26:    nodes of that code.
                     27: 
                     28:    It is intended to be language-independent, but occasionally
                     29:    calls language-dependent routines defined (for C) in typecheck.c.
                     30: 
                     31:    The low-level allocation routines oballoc and permalloc
                     32:    are used also for allocating many other kinds of objects
                     33:    by all passes of the compiler.  */
                     34: 
                     35: #include "config.h"
                     36: #include "flags.h"
                     37: #include "tree.h"
1.1.1.4   root       38: #include "function.h"
1.1       root       39: #include "obstack.h"
                     40: #include "gvarargs.h"
1.1.1.4   root       41: #include <stdio.h>
1.1       root       42: 
                     43: #define obstack_chunk_alloc xmalloc
                     44: #define obstack_chunk_free free
                     45: 
                     46: /* Tree nodes of permanent duration are allocated in this obstack.
                     47:    They are the identifier nodes, and everything outside of
                     48:    the bodies and parameters of function definitions.  */
                     49: 
                     50: struct obstack permanent_obstack;
                     51: 
                     52: /* The initial RTL, and all ..._TYPE nodes, in a function
                     53:    are allocated in this obstack.  Usually they are freed at the
                     54:    end of the function, but if the function is inline they are saved.
                     55:    For top-level functions, this is maybepermanent_obstack.
                     56:    Separate obstacks are made for nested functions.  */
                     57: 
                     58: struct obstack *function_maybepermanent_obstack;
                     59: 
                     60: /* This is the function_maybepermanent_obstack for top-level functions.  */
                     61: 
                     62: struct obstack maybepermanent_obstack;
                     63: 
                     64: /* The contents of the current function definition are allocated
                     65:    in this obstack, and all are freed at the end of the function.
                     66:    For top-level functions, this is temporary_obstack.
                     67:    Separate obstacks are made for nested functions.  */
                     68: 
                     69: struct obstack *function_obstack;
                     70: 
                     71: /* This is used for reading initializers of global variables.  */
                     72: 
                     73: struct obstack temporary_obstack;
                     74: 
                     75: /* The tree nodes of an expression are allocated
                     76:    in this obstack, and all are freed at the end of the expression.  */
                     77: 
                     78: struct obstack momentary_obstack;
                     79: 
                     80: /* The tree nodes of a declarator are allocated
                     81:    in this obstack, and all are freed when the declarator
                     82:    has been parsed.  */
                     83: 
                     84: static struct obstack temp_decl_obstack;
                     85: 
                     86: /* This points at either permanent_obstack
                     87:    or the current function_maybepermanent_obstack.  */
                     88: 
                     89: struct obstack *saveable_obstack;
                     90: 
                     91: /* This is same as saveable_obstack during parse and expansion phase;
                     92:    it points to the current function's obstack during optimization.
                     93:    This is the obstack to be used for creating rtl objects.  */
                     94: 
                     95: struct obstack *rtl_obstack;
                     96: 
                     97: /* This points at either permanent_obstack or the current function_obstack.  */
                     98: 
                     99: struct obstack *current_obstack;
                    100: 
                    101: /* This points at either permanent_obstack or the current function_obstack
                    102:    or momentary_obstack.  */
                    103: 
                    104: struct obstack *expression_obstack;
                    105: 
                    106: /* Stack of obstack selections for push_obstacks and pop_obstacks.  */
                    107: 
                    108: struct obstack_stack
                    109: {
                    110:   struct obstack_stack *next;
                    111:   struct obstack *current;
                    112:   struct obstack *saveable;
                    113:   struct obstack *expression;
                    114:   struct obstack *rtl;
                    115: };
                    116: 
                    117: struct obstack_stack *obstack_stack;
                    118: 
                    119: /* Obstack for allocating struct obstack_stack entries.  */
                    120: 
                    121: static struct obstack obstack_stack_obstack;
                    122: 
                    123: /* Addresses of first objects in some obstacks.
                    124:    This is for freeing their entire contents.  */
                    125: char *maybepermanent_firstobj;
                    126: char *temporary_firstobj;
                    127: char *momentary_firstobj;
                    128: char *temp_decl_firstobj;
                    129: 
                    130: /* Nonzero means all ..._TYPE nodes should be allocated permanently.  */
                    131: 
                    132: int all_types_permanent;
                    133: 
                    134: /* Stack of places to restore the momentary obstack back to.  */
                    135:    
                    136: struct momentary_level
                    137: {
                    138:   /* Pointer back to previous such level.  */
                    139:   struct momentary_level *prev;
                    140:   /* First object allocated within this level.  */
                    141:   char *base;
                    142:   /* Value of expression_obstack saved at entry to this level.  */
                    143:   struct obstack *obstack;
                    144: };
                    145: 
                    146: struct momentary_level *momentary_stack;
                    147: 
                    148: /* Table indexed by tree code giving a string containing a character
                    149:    classifying the tree code.  Possibilities are
                    150:    t, d, s, c, r, <, 1, 2 and e.  See tree.def for details.  */
                    151: 
                    152: #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
                    153: 
                    154: char *standard_tree_code_type[] = {
                    155: #include "tree.def"
                    156: };
                    157: #undef DEFTREECODE
                    158: 
                    159: /* Table indexed by tree code giving number of expression
                    160:    operands beyond the fixed part of the node structure.
                    161:    Not used for types or decls.  */
                    162: 
                    163: #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
                    164: 
                    165: int standard_tree_code_length[] = {
                    166: #include "tree.def"
                    167: };
                    168: #undef DEFTREECODE
                    169: 
                    170: /* Names of tree components.
                    171:    Used for printing out the tree and error messages.  */
                    172: #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
                    173: 
                    174: char *standard_tree_code_name[] = {
                    175: #include "tree.def"
                    176: };
                    177: #undef DEFTREECODE
                    178: 
                    179: /* Table indexed by tree code giving a string containing a character
                    180:    classifying the tree code.  Possibilities are
                    181:    t, d, s, c, r, e, <, 1 and 2.  See tree.def for details.  */
                    182: 
                    183: char **tree_code_type;
                    184: 
                    185: /* Table indexed by tree code giving number of expression
                    186:    operands beyond the fixed part of the node structure.
                    187:    Not used for types or decls.  */
                    188: 
                    189: int *tree_code_length;
                    190: 
                    191: /* Table indexed by tree code giving name of tree code, as a string.  */
                    192: 
                    193: char **tree_code_name;
                    194: 
                    195: /* Statistics-gathering stuff.  */
                    196: typedef enum
                    197: {
1.1.1.4   root      198:   d_kind,
                    199:   t_kind,
                    200:   b_kind,
                    201:   s_kind,
                    202:   r_kind,
                    203:   e_kind,
                    204:   c_kind,
                    205:   id_kind,
                    206:   op_id_kind,
                    207:   perm_list_kind,
                    208:   temp_list_kind,
                    209:   vec_kind,
                    210:   x_kind,
                    211:   lang_decl,
                    212:   lang_type,
                    213:   all_kinds
1.1       root      214: } tree_node_kind;
1.1.1.4   root      215: 
1.1       root      216: int tree_node_counts[(int)all_kinds];
                    217: int tree_node_sizes[(int)all_kinds];
                    218: int id_string_size = 0;
1.1.1.4   root      219: 
                    220: char *tree_node_kind_names[] = {
                    221:   "decls",
                    222:   "types",
                    223:   "blocks",
                    224:   "stmts",
                    225:   "refs",
                    226:   "exprs",
                    227:   "constants",
                    228:   "identifiers",
                    229:   "op_identifiers",
                    230:   "perm_tree_lists",
                    231:   "temp_tree_lists",
                    232:   "vecs",
                    233:   "random kinds",
                    234:   "lang_decl kinds",
                    235:   "lang_type kinds"
                    236: };
1.1       root      237: 
                    238: /* Hash table for uniquizing IDENTIFIER_NODEs by name.  */
                    239: 
                    240: #define MAX_HASH_TABLE 1009
                    241: static tree hash_table[MAX_HASH_TABLE];        /* id hash buckets */
                    242: 
                    243: /* 0 while creating built-in identifiers.  */
                    244: static int do_identifier_warnings;
                    245: 
1.1.1.4   root      246: /* Unique id for next decl created.  */
                    247: static int next_decl_uid;
1.1.1.5   root      248: /* Unique id for next type created.  */
                    249: static int next_type_uid = 1;
1.1.1.4   root      250: 
1.1       root      251: extern char *mode_name[];
                    252: 
                    253: void gcc_obstack_init ();
                    254: static tree stabilize_reference_1 ();
                    255: 
                    256: /* Init the principal obstacks.  */
                    257: 
                    258: void
                    259: init_obstacks ()
                    260: {
                    261:   gcc_obstack_init (&obstack_stack_obstack);
                    262:   gcc_obstack_init (&permanent_obstack);
                    263: 
                    264:   gcc_obstack_init (&temporary_obstack);
                    265:   temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0);
                    266:   gcc_obstack_init (&momentary_obstack);
                    267:   momentary_firstobj = (char *) obstack_alloc (&momentary_obstack, 0);
                    268:   gcc_obstack_init (&maybepermanent_obstack);
                    269:   maybepermanent_firstobj
                    270:     = (char *) obstack_alloc (&maybepermanent_obstack, 0);
                    271:   gcc_obstack_init (&temp_decl_obstack);
                    272:   temp_decl_firstobj = (char *) obstack_alloc (&temp_decl_obstack, 0);
                    273: 
                    274:   function_obstack = &temporary_obstack;
                    275:   function_maybepermanent_obstack = &maybepermanent_obstack;
                    276:   current_obstack = &permanent_obstack;
                    277:   expression_obstack = &permanent_obstack;
                    278:   rtl_obstack = saveable_obstack = &permanent_obstack;
                    279: 
                    280:   /* Init the hash table of identifiers.  */
                    281:   bzero (hash_table, sizeof hash_table);
                    282: }
                    283: 
                    284: void
                    285: gcc_obstack_init (obstack)
                    286:      struct obstack *obstack;
                    287: {
                    288:   /* Let particular systems override the size of a chunk.  */
                    289: #ifndef OBSTACK_CHUNK_SIZE
                    290: #define OBSTACK_CHUNK_SIZE 0
                    291: #endif
                    292:   /* Let them override the alloc and free routines too.  */
                    293: #ifndef OBSTACK_CHUNK_ALLOC
                    294: #define OBSTACK_CHUNK_ALLOC xmalloc
                    295: #endif
                    296: #ifndef OBSTACK_CHUNK_FREE
                    297: #define OBSTACK_CHUNK_FREE free
                    298: #endif
                    299:   _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
                    300:                  (void *(*) ()) OBSTACK_CHUNK_ALLOC,
                    301:                  (void (*) ()) OBSTACK_CHUNK_FREE);
                    302: }
                    303: 
                    304: /* Save all variables describing the current status into the structure *P.
                    305:    This is used before starting a nested function.  */
                    306: 
                    307: void
                    308: save_tree_status (p)
                    309:      struct function *p;
                    310: {
                    311:   p->all_types_permanent = all_types_permanent;
                    312:   p->momentary_stack = momentary_stack;
                    313:   p->maybepermanent_firstobj = maybepermanent_firstobj;
                    314:   p->momentary_firstobj = momentary_firstobj;
                    315:   p->function_obstack = function_obstack;
                    316:   p->function_maybepermanent_obstack = function_maybepermanent_obstack;
                    317:   p->current_obstack = current_obstack;
                    318:   p->expression_obstack = expression_obstack;
                    319:   p->saveable_obstack = saveable_obstack;
                    320:   p->rtl_obstack = rtl_obstack;
                    321: 
1.1.1.6 ! root      322:   /* Objects that need to be saved in this function can be in the nonsaved
        !           323:      obstack of the enclosing function since they can't possibly be needed
        !           324:      once it has returned.  */
        !           325:   function_maybepermanent_obstack = function_obstack;
        !           326: 
1.1       root      327:   function_obstack = (struct obstack *) xmalloc (sizeof (struct obstack));
                    328:   gcc_obstack_init (function_obstack);
                    329: 
                    330:   current_obstack = &permanent_obstack;
                    331:   expression_obstack = &permanent_obstack;
                    332:   rtl_obstack = saveable_obstack = &permanent_obstack;
                    333: 
                    334:   momentary_firstobj = (char *) obstack_finish (&momentary_obstack);
                    335:   maybepermanent_firstobj
                    336:     = (char *) obstack_finish (function_maybepermanent_obstack);
                    337: }
                    338: 
                    339: /* Restore all variables describing the current status from the structure *P.
                    340:    This is used after a nested function.  */
                    341: 
                    342: void
                    343: restore_tree_status (p)
                    344:      struct function *p;
                    345: {
                    346:   all_types_permanent = p->all_types_permanent;
                    347:   momentary_stack = p->momentary_stack;
                    348: 
                    349:   obstack_free (&momentary_obstack, momentary_firstobj);
1.1.1.6 ! root      350: 
        !           351:   /* Free saveable storage used by the function just compiled and not
        !           352:      saved.
        !           353: 
        !           354:      CAUTION: This is in function_obstack of the containing function.  So
        !           355:      we must be sure that we never allocate from that obstack during
        !           356:      the compilation of a nested function if we expect it to survive past the
        !           357:      nested function's end.  */
        !           358:   obstack_free (function_maybepermanent_obstack, maybepermanent_firstobj);
        !           359: 
1.1       root      360:   obstack_free (function_obstack, 0);
                    361:   free (function_obstack);
                    362: 
                    363:   momentary_firstobj = p->momentary_firstobj;
                    364:   maybepermanent_firstobj = p->maybepermanent_firstobj;
                    365:   function_obstack = p->function_obstack;
                    366:   function_maybepermanent_obstack = p->function_maybepermanent_obstack;
                    367:   current_obstack = p->current_obstack;
                    368:   expression_obstack = p->expression_obstack;
                    369:   saveable_obstack = p->saveable_obstack;
                    370:   rtl_obstack = p->rtl_obstack;
                    371: }
                    372: 
                    373: /* Start allocating on the temporary (per function) obstack.
                    374:    This is done in start_function before parsing the function body,
                    375:    and before each initialization at top level, and to go back
1.1.1.6 ! root      376:    to temporary allocation after doing permanent_allocation.  */
1.1       root      377: 
                    378: void
                    379: temporary_allocation ()
                    380: {
                    381:   /* Note that function_obstack at top level points to temporary_obstack.
                    382:      But within a nested function context, it is a separate obstack.  */
                    383:   current_obstack = function_obstack;
                    384:   expression_obstack = function_obstack;
                    385:   rtl_obstack = saveable_obstack = function_maybepermanent_obstack;
                    386:   momentary_stack = 0;
                    387: }
                    388: 
                    389: /* Start allocating on the permanent obstack but don't
                    390:    free the temporary data.  After calling this, call
                    391:    `permanent_allocation' to fully resume permanent allocation status.  */
                    392: 
                    393: void
                    394: end_temporary_allocation ()
                    395: {
                    396:   current_obstack = &permanent_obstack;
                    397:   expression_obstack = &permanent_obstack;
                    398:   rtl_obstack = saveable_obstack = &permanent_obstack;
                    399: }
                    400: 
                    401: /* Resume allocating on the temporary obstack, undoing
                    402:    effects of `end_temporary_allocation'.  */
                    403: 
                    404: void
                    405: resume_temporary_allocation ()
                    406: {
                    407:   current_obstack = function_obstack;
                    408:   expression_obstack = function_obstack;
                    409:   rtl_obstack = saveable_obstack = function_maybepermanent_obstack;
                    410: }
                    411: 
                    412: /* While doing temporary allocation, switch to allocating in such a
                    413:    way as to save all nodes if the function is inlined.  Call
                    414:    resume_temporary_allocation to go back to ordinary temporary
                    415:    allocation.  */
                    416: 
                    417: void
                    418: saveable_allocation ()
                    419: {
                    420:   /* Note that function_obstack at top level points to temporary_obstack.
                    421:      But within a nested function context, it is a separate obstack.  */
                    422:   expression_obstack = current_obstack = saveable_obstack;
                    423: }
                    424: 
                    425: /* Switch to current obstack CURRENT and maybepermanent obstack SAVEABLE,
                    426:    recording the previously current obstacks on a stack.
                    427:    This does not free any storage in any obstack.  */
                    428: 
                    429: void
                    430: push_obstacks (current, saveable)
                    431:      struct obstack *current, *saveable;
                    432: {
                    433:   struct obstack_stack *p
                    434:     = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
                    435:                                              (sizeof (struct obstack_stack)));
                    436: 
                    437:   p->current = current_obstack;
                    438:   p->saveable = saveable_obstack;
                    439:   p->expression = expression_obstack;
                    440:   p->rtl = rtl_obstack;
                    441:   p->next = obstack_stack;
                    442:   obstack_stack = p;
                    443: 
                    444:   current_obstack = current;
                    445:   expression_obstack = current;
                    446:   rtl_obstack = saveable_obstack = saveable;
                    447: }
                    448: 
                    449: /* Save the current set of obstacks, but don't change them.  */
                    450: 
                    451: void
                    452: push_obstacks_nochange ()
                    453: {
                    454:   struct obstack_stack *p
                    455:     = (struct obstack_stack *) obstack_alloc (&obstack_stack_obstack,
                    456:                                              (sizeof (struct obstack_stack)));
                    457: 
                    458:   p->current = current_obstack;
                    459:   p->saveable = saveable_obstack;
                    460:   p->expression = expression_obstack;
                    461:   p->rtl = rtl_obstack;
                    462:   p->next = obstack_stack;
                    463:   obstack_stack = p;
                    464: }
                    465: 
                    466: /* Pop the obstack selection stack.  */
                    467: 
                    468: void
                    469: pop_obstacks ()
                    470: {
                    471:   struct obstack_stack *p = obstack_stack;
                    472:   obstack_stack = p->next;
                    473: 
                    474:   current_obstack = p->current;
                    475:   saveable_obstack = p->saveable;
                    476:   expression_obstack = p->expression;
                    477:   rtl_obstack = p->rtl;
                    478: 
                    479:   obstack_free (&obstack_stack_obstack, p);
                    480: }
                    481: 
                    482: /* Nonzero if temporary allocation is currently in effect.
                    483:    Zero if currently doing permanent allocation.  */
                    484: 
                    485: int
                    486: allocation_temporary_p ()
                    487: {
                    488:   return current_obstack != &permanent_obstack;
                    489: }
                    490: 
                    491: /* Go back to allocating on the permanent obstack
                    492:    and free everything in the temporary obstack.
                    493:    This is done in finish_function after fully compiling a function.  */
                    494: 
                    495: void
                    496: permanent_allocation ()
                    497: {
                    498:   /* Free up previous temporary obstack data */
                    499:   obstack_free (&temporary_obstack, temporary_firstobj);
                    500:   obstack_free (&momentary_obstack, momentary_firstobj);
                    501:   obstack_free (&maybepermanent_obstack, maybepermanent_firstobj);
                    502:   obstack_free (&temp_decl_obstack, temp_decl_firstobj);
                    503: 
                    504:   current_obstack = &permanent_obstack;
                    505:   expression_obstack = &permanent_obstack;
                    506:   rtl_obstack = saveable_obstack = &permanent_obstack;
                    507: }
                    508: 
                    509: /* Save permanently everything on the maybepermanent_obstack.  */
                    510: 
                    511: void
                    512: preserve_data ()
                    513: {
                    514:   maybepermanent_firstobj
                    515:     = (char *) obstack_alloc (function_maybepermanent_obstack, 0);
                    516: }
                    517: 
                    518: void
                    519: preserve_initializer ()
                    520: {
                    521:   temporary_firstobj
                    522:     = (char *) obstack_alloc (&temporary_obstack, 0);
                    523:   momentary_firstobj
                    524:     = (char *) obstack_alloc (&momentary_obstack, 0);
                    525:   maybepermanent_firstobj
                    526:     = (char *) obstack_alloc (function_maybepermanent_obstack, 0);
                    527: }
                    528: 
                    529: /* Start allocating new rtl in current_obstack.
                    530:    Use resume_temporary_allocation
                    531:    to go back to allocating rtl in saveable_obstack.  */
                    532: 
                    533: void
                    534: rtl_in_current_obstack ()
                    535: {
                    536:   rtl_obstack = current_obstack;
                    537: }
                    538: 
1.1.1.5   root      539: /* Start allocating rtl from saveable_obstack.  Intended to be used after
                    540:    a call to push_obstacks_nochange.  */
1.1       root      541: 
1.1.1.5   root      542: void
1.1       root      543: rtl_in_saveable_obstack ()
                    544: {
1.1.1.5   root      545:   rtl_obstack = saveable_obstack;
1.1       root      546: }
                    547: 
                    548: /* Allocate SIZE bytes in the current obstack
                    549:    and return a pointer to them.
                    550:    In practice the current obstack is always the temporary one.  */
                    551: 
                    552: char *
                    553: oballoc (size)
                    554:      int size;
                    555: {
                    556:   return (char *) obstack_alloc (current_obstack, size);
                    557: }
                    558: 
                    559: /* Free the object PTR in the current obstack
                    560:    as well as everything allocated since PTR.
                    561:    In practice the current obstack is always the temporary one.  */
                    562: 
                    563: void
                    564: obfree (ptr)
                    565:      char *ptr;
                    566: {
                    567:   obstack_free (current_obstack, ptr);
                    568: }
                    569: 
                    570: /* Allocate SIZE bytes in the permanent obstack
                    571:    and return a pointer to them.  */
                    572: 
                    573: char *
                    574: permalloc (size)
1.1.1.4   root      575:      int size;
1.1       root      576: {
                    577:   return (char *) obstack_alloc (&permanent_obstack, size);
                    578: }
                    579: 
                    580: /* Allocate NELEM items of SIZE bytes in the permanent obstack
                    581:    and return a pointer to them.  The storage is cleared before
                    582:    returning the value.  */
                    583: 
                    584: char *
                    585: perm_calloc (nelem, size)
                    586:      int nelem;
                    587:      long size;
                    588: {
                    589:   char *rval = (char *) obstack_alloc (&permanent_obstack, nelem * size);
                    590:   bzero (rval, nelem * size);
                    591:   return rval;
                    592: }
                    593: 
                    594: /* Allocate SIZE bytes in the saveable obstack
                    595:    and return a pointer to them.  */
                    596: 
                    597: char *
                    598: savealloc (size)
                    599:      int size;
                    600: {
                    601:   return (char *) obstack_alloc (saveable_obstack, size);
                    602: }
                    603: 
                    604: /* Print out which obstack an object is in.  */
                    605: 
                    606: void
1.1.1.6 ! root      607: print_obstack_name (object, file, prefix)
1.1       root      608:      char *object;
1.1.1.6 ! root      609:      FILE *file;
        !           610:      char *prefix;
1.1       root      611: {
                    612:   struct obstack *obstack = NULL;
                    613:   char *obstack_name = NULL;
                    614:   struct function *p;
                    615: 
                    616:   for (p = outer_function_chain; p; p = p->next)
                    617:     {
                    618:       if (_obstack_allocated_p (p->function_obstack, object))
                    619:        {
                    620:          obstack = p->function_obstack;
                    621:          obstack_name = "containing function obstack";
                    622:        }
                    623:       if (_obstack_allocated_p (p->function_maybepermanent_obstack, object))
                    624:        {
                    625:          obstack = p->function_maybepermanent_obstack;
                    626:          obstack_name = "containing function maybepermanent obstack";
                    627:        }
                    628:     }
                    629: 
                    630:   if (_obstack_allocated_p (&obstack_stack_obstack, object))
                    631:     {
                    632:       obstack = &obstack_stack_obstack;
                    633:       obstack_name = "obstack_stack_obstack";
                    634:     }
                    635:   else if (_obstack_allocated_p (function_obstack, object))
                    636:     {
                    637:       obstack = function_obstack;
                    638:       obstack_name = "function obstack";
                    639:     }
                    640:   else if (_obstack_allocated_p (&permanent_obstack, object))
                    641:     {
                    642:       obstack = &permanent_obstack;
                    643:       obstack_name = "permanent_obstack";
                    644:     }
                    645:   else if (_obstack_allocated_p (&momentary_obstack, object))
                    646:     {
                    647:       obstack = &momentary_obstack;
                    648:       obstack_name = "momentary_obstack";
                    649:     }
                    650:   else if (_obstack_allocated_p (function_maybepermanent_obstack, object))
                    651:     {
                    652:       obstack = function_maybepermanent_obstack;
                    653:       obstack_name = "function maybepermanent obstack";
                    654:     }
                    655:   else if (_obstack_allocated_p (&temp_decl_obstack, object))
                    656:     {
                    657:       obstack = &temp_decl_obstack;
                    658:       obstack_name = "temp_decl_obstack";
                    659:     }
                    660: 
                    661:   /* Check to see if the object is in the free area of the obstack. */
                    662:   if (obstack != NULL)
                    663:     {
                    664:       if (object >= obstack->next_free
                    665:          && object < obstack->chunk_limit)
1.1.1.6 ! root      666:        fprintf (file, "%s in free portion of obstack %s",
        !           667:                 prefix, obstack_name);
1.1       root      668:       else
1.1.1.6 ! root      669:        fprintf (file, "%s allocated from %s", prefix, obstack_name);
1.1       root      670:     }
                    671:   else
1.1.1.6 ! root      672:     fprintf (file, "%s not allocated from any obstack", prefix);
        !           673: }
        !           674: 
        !           675: void
        !           676: debug_obstack (object)
        !           677:      char *object;
        !           678: {
        !           679:   print_obstack_name (object, stderr, "object");
        !           680:   fprintf (stderr, ".\n");
1.1       root      681: }
                    682: 
                    683: /* Return 1 if OBJ is in the permanent obstack.
                    684:    This is slow, and should be used only for debugging.
                    685:    Use TREE_PERMANENT for other purposes.  */
                    686: 
                    687: int
                    688: object_permanent_p (obj)
                    689:      tree obj;
                    690: {
                    691:   return _obstack_allocated_p (&permanent_obstack, obj);
                    692: }
                    693: 
                    694: /* Start a level of momentary allocation.
                    695:    In C, each compound statement has its own level
                    696:    and that level is freed at the end of each statement.
                    697:    All expression nodes are allocated in the momentary allocation level.  */
                    698: 
                    699: void
                    700: push_momentary ()
                    701: {
                    702:   struct momentary_level *tem
                    703:     = (struct momentary_level *) obstack_alloc (&momentary_obstack,
                    704:                                                sizeof (struct momentary_level));
                    705:   tem->prev = momentary_stack;
                    706:   tem->base = (char *) obstack_base (&momentary_obstack);
                    707:   tem->obstack = expression_obstack;
                    708:   momentary_stack = tem;
                    709:   expression_obstack = &momentary_obstack;
                    710: }
                    711: 
                    712: /* Free all the storage in the current momentary-allocation level.
                    713:    In C, this happens at the end of each statement.  */
                    714: 
                    715: void
                    716: clear_momentary ()
                    717: {
                    718:   obstack_free (&momentary_obstack, momentary_stack->base);
                    719: }
                    720: 
                    721: /* Discard a level of momentary allocation.
                    722:    In C, this happens at the end of each compound statement.
                    723:    Restore the status of expression node allocation
                    724:    that was in effect before this level was created.  */
                    725: 
                    726: void
                    727: pop_momentary ()
                    728: {
                    729:   struct momentary_level *tem = momentary_stack;
                    730:   momentary_stack = tem->prev;
                    731:   expression_obstack = tem->obstack;
                    732:   obstack_free (&momentary_obstack, tem);
                    733: }
                    734: 
1.1.1.6 ! root      735: /* Pop back to the previous level of momentary allocation,
        !           736:    but don't free any momentary data just yet.  */
        !           737: 
        !           738: void
        !           739: pop_momentary_nofree ()
        !           740: {
        !           741:   struct momentary_level *tem = momentary_stack;
        !           742:   momentary_stack = tem->prev;
        !           743:   expression_obstack = tem->obstack;
        !           744: }
        !           745: 
1.1       root      746: /* Call when starting to parse a declaration:
                    747:    make expressions in the declaration last the length of the function.
                    748:    Returns an argument that should be passed to resume_momentary later.  */
                    749: 
                    750: int
                    751: suspend_momentary ()
                    752: {
                    753:   register int tem = expression_obstack == &momentary_obstack;
                    754:   expression_obstack = saveable_obstack;
                    755:   return tem;
                    756: }
                    757: 
                    758: /* Call when finished parsing a declaration:
                    759:    restore the treatment of node-allocation that was
                    760:    in effect before the suspension.
                    761:    YES should be the value previously returned by suspend_momentary.  */
                    762: 
                    763: void
                    764: resume_momentary (yes)
                    765:      int yes;
                    766: {
                    767:   if (yes)
                    768:     expression_obstack = &momentary_obstack;
                    769: }
                    770: 
                    771: /* Init the tables indexed by tree code.
                    772:    Note that languages can add to these tables to define their own codes.  */
                    773: 
                    774: void
                    775: init_tree_codes ()
                    776: {
                    777:   tree_code_type = (char **) xmalloc (sizeof (standard_tree_code_type));
                    778:   tree_code_length = (int *) xmalloc (sizeof (standard_tree_code_length));
                    779:   tree_code_name = (char **) xmalloc (sizeof (standard_tree_code_name));
                    780:   bcopy (standard_tree_code_type, tree_code_type,
                    781:         sizeof (standard_tree_code_type));
                    782:   bcopy (standard_tree_code_length, tree_code_length,
                    783:         sizeof (standard_tree_code_length));
                    784:   bcopy (standard_tree_code_name, tree_code_name,
                    785:         sizeof (standard_tree_code_name));
                    786: }
                    787: 
                    788: /* Return a newly allocated node of code CODE.
                    789:    Initialize the node's unique id and its TREE_PERMANENT flag.
                    790:    For decl and type nodes, some other fields are initialized.
                    791:    The rest of the node is initialized to zero.
                    792: 
                    793:    Achoo!  I got a code in the node.  */
                    794: 
                    795: tree
                    796: make_node (code)
                    797:      enum tree_code code;
                    798: {
                    799:   register tree t;
                    800:   register int type = TREE_CODE_CLASS (code);
                    801:   register int length;
                    802:   register struct obstack *obstack = current_obstack;
                    803:   register int i;
                    804:   register tree_node_kind kind;
                    805: 
                    806:   switch (type)
                    807:     {
                    808:     case 'd':  /* A decl node */
                    809: #ifdef GATHER_STATISTICS
                    810:       kind = d_kind;
                    811: #endif
                    812:       length = sizeof (struct tree_decl);
                    813:       /* All decls in an inline function need to be saved.  */
                    814:       if (obstack != &permanent_obstack)
                    815:        obstack = saveable_obstack;
1.1.1.6 ! root      816: 
        !           817:       /* PARM_DECLs go on the context of the parent. If this is a nested
        !           818:         function, then we must allocate the PARM_DECL on the parent's
        !           819:         obstack, so that they will live to the end of the parent's
        !           820:         closing brace.  This is neccesary in case we try to inline the
        !           821:         function into its parent.
        !           822: 
        !           823:         PARM_DECLs of top-level functions do not have this problem.  However,
        !           824:         we allocate them where we put the FUNCTION_DECL for languauges such as
        !           825:         Ada that need to consult some flags in the PARM_DECLs of the function
        !           826:         when calling it. 
        !           827: 
        !           828:         See comment in restore_tree_status for why we can't put this
        !           829:         in function_obstack.  */
        !           830:       if (code == PARM_DECL && obstack != &permanent_obstack)
        !           831:        {
        !           832:          tree context = 0;
        !           833:          if (current_function_decl)
        !           834:            context = decl_function_context (current_function_decl);
        !           835: 
        !           836:          if (context)
        !           837:            obstack
        !           838:              = find_function_data (context)->function_maybepermanent_obstack;
        !           839:        }
1.1       root      840:       break;
                    841: 
                    842:     case 't':  /* a type node */
                    843: #ifdef GATHER_STATISTICS
                    844:       kind = t_kind;
                    845: #endif
                    846:       length = sizeof (struct tree_type);
                    847:       /* All data types are put where we can preserve them if nec.  */
                    848:       if (obstack != &permanent_obstack)
                    849:        obstack = all_types_permanent ? &permanent_obstack : saveable_obstack;
                    850:       break;
                    851: 
1.1.1.4   root      852:     case 'b':  /* a lexical block */
                    853: #ifdef GATHER_STATISTICS
                    854:       kind = b_kind;
                    855: #endif
                    856:       length = sizeof (struct tree_block);
                    857:       /* All BLOCK nodes are put where we can preserve them if nec.  */
                    858:       if (obstack != &permanent_obstack)
                    859:        obstack = saveable_obstack;
                    860:       break;
                    861: 
1.1       root      862:     case 's':  /* an expression with side effects */
                    863: #ifdef GATHER_STATISTICS
                    864:       kind = s_kind;
                    865:       goto usual_kind;
                    866: #endif
                    867:     case 'r':  /* a reference */
                    868: #ifdef GATHER_STATISTICS
                    869:       kind = r_kind;
                    870:       goto usual_kind;
                    871: #endif
                    872:     case 'e':  /* an expression */
                    873:     case '<':  /* a comparison expression */
                    874:     case '1':  /* a unary arithmetic expression */
                    875:     case '2':  /* a binary arithmetic expression */
                    876: #ifdef GATHER_STATISTICS
                    877:       kind = e_kind;
                    878:     usual_kind:
                    879: #endif
                    880:       obstack = expression_obstack;
1.1.1.4   root      881:       /* All BIND_EXPR nodes are put where we can preserve them if nec.  */
                    882:       if (code == BIND_EXPR && obstack != &permanent_obstack)
1.1       root      883:        obstack = saveable_obstack;
                    884:       length = sizeof (struct tree_exp)
                    885:        + (tree_code_length[(int) code] - 1) * sizeof (char *);
                    886:       break;
                    887: 
                    888:     case 'c':  /* a constant */
                    889: #ifdef GATHER_STATISTICS
                    890:       kind = c_kind;
                    891: #endif
                    892:       obstack = expression_obstack;
1.1.1.5   root      893: 
                    894:       /* We can't use tree_code_length for INTEGER_CST, since the number of
                    895:         words is machine-dependent due to varying length of HOST_WIDE_INT,
                    896:         which might be wider than a pointer (e.g., long long).  Similarly
                    897:         for REAL_CST, since the number of words is machine-dependent due
                    898:         to varying size and alignment of `double'.  */
                    899: 
                    900:       if (code == INTEGER_CST)
                    901:        length = sizeof (struct tree_int_cst);
                    902:       else if (code == REAL_CST)
                    903:        length = sizeof (struct tree_real_cst);
                    904:       else
                    905:        length = sizeof (struct tree_common)
                    906:          + tree_code_length[(int) code] * sizeof (char *);
                    907:       break;
1.1       root      908: 
                    909:     case 'x':  /* something random, like an identifier.  */
                    910: #ifdef GATHER_STATISTICS
                    911:       if (code == IDENTIFIER_NODE)
                    912:        kind = id_kind;
                    913:       else if (code == OP_IDENTIFIER)
                    914:        kind = op_id_kind;
                    915:       else if (code == TREE_VEC)
                    916:        kind = vec_kind;
                    917:       else
                    918:        kind = x_kind;
                    919: #endif
                    920:       length = sizeof (struct tree_common)
                    921:        + tree_code_length[(int) code] * sizeof (char *);
                    922:       /* Identifier nodes are always permanent since they are
                    923:         unique in a compiler run.  */
                    924:       if (code == IDENTIFIER_NODE) obstack = &permanent_obstack;
                    925:     }
                    926: 
                    927:   t = (tree) obstack_alloc (obstack, length);
                    928: 
                    929: #ifdef GATHER_STATISTICS
                    930:   tree_node_counts[(int)kind]++;
                    931:   tree_node_sizes[(int)kind] += length;
                    932: #endif
                    933: 
1.1.1.4   root      934:   /* Clear a word at a time.  */
                    935:   for (i = (length / sizeof (int)) - 1; i >= 0; i--)
1.1       root      936:     ((int *) t)[i] = 0;
1.1.1.4   root      937:   /* Clear any extra bytes.  */
                    938:   for (i = length / sizeof (int) * sizeof (int); i < length; i++)
                    939:     ((char *) t)[i] = 0;
1.1       root      940: 
                    941:   TREE_SET_CODE (t, code);
                    942:   if (obstack == &permanent_obstack)
                    943:     TREE_PERMANENT (t) = 1;
                    944: 
                    945:   switch (type)
                    946:     {
                    947:     case 's':
                    948:       TREE_SIDE_EFFECTS (t) = 1;
                    949:       TREE_TYPE (t) = void_type_node;
                    950:       break;
                    951: 
                    952:     case 'd':
1.1.1.3   root      953:       if (code != FUNCTION_DECL)
                    954:        DECL_ALIGN (t) = 1;
1.1.1.4   root      955:       DECL_IN_SYSTEM_HEADER (t)
                    956:        = in_system_header && (obstack == &permanent_obstack);
1.1       root      957:       DECL_SOURCE_LINE (t) = lineno;
                    958:       DECL_SOURCE_FILE (t) = (input_filename) ? input_filename : "<built-in>";
1.1.1.4   root      959:       DECL_UID (t) = next_decl_uid++;
1.1       root      960:       break;
                    961: 
                    962:     case 't':
1.1.1.5   root      963:       TYPE_UID (t) = next_type_uid++;
1.1       root      964:       TYPE_ALIGN (t) = 1;
                    965:       TYPE_MAIN_VARIANT (t) = t;
1.1.1.6 ! root      966:       TYPE_OBSTACK (t) = obstack;
1.1       root      967:       break;
                    968: 
                    969:     case 'c':
                    970:       TREE_CONSTANT (t) = 1;
                    971:       break;
                    972:     }
                    973: 
                    974:   return t;
                    975: }
                    976: 
                    977: /* Return a new node with the same contents as NODE
                    978:    except that its TREE_CHAIN is zero and it has a fresh uid.  */
                    979: 
                    980: tree
                    981: copy_node (node)
                    982:      tree node;
                    983: {
                    984:   register tree t;
                    985:   register enum tree_code code = TREE_CODE (node);
                    986:   register int length;
                    987:   register int i;
                    988: 
                    989:   switch (TREE_CODE_CLASS (code))
                    990:     {
                    991:     case 'd':  /* A decl node */
                    992:       length = sizeof (struct tree_decl);
                    993:       break;
                    994: 
                    995:     case 't':  /* a type node */
                    996:       length = sizeof (struct tree_type);
                    997:       break;
                    998: 
1.1.1.4   root      999:     case 'b':  /* a lexical block node */
                   1000:       length = sizeof (struct tree_block);
                   1001:       break;
                   1002: 
1.1       root     1003:     case 'r':  /* a reference */
1.1.1.4   root     1004:     case 'e':  /* an expression */
1.1       root     1005:     case 's':  /* an expression with side effects */
                   1006:     case '<':  /* a comparison expression */
                   1007:     case '1':  /* a unary arithmetic expression */
                   1008:     case '2':  /* a binary arithmetic expression */
                   1009:       length = sizeof (struct tree_exp)
                   1010:        + (tree_code_length[(int) code] - 1) * sizeof (char *);
                   1011:       break;
                   1012: 
                   1013:     case 'c':  /* a constant */
                   1014:       /* We can't use tree_code_length for this, since the number of words
                   1015:         is machine-dependent due to varying alignment of `double'.  */
                   1016:       if (code == REAL_CST)
                   1017:        {
                   1018:          length = sizeof (struct tree_real_cst);
                   1019:          break;
                   1020:        }
                   1021: 
                   1022:     case 'x':  /* something random, like an identifier.  */
                   1023:       length = sizeof (struct tree_common)
                   1024:        + tree_code_length[(int) code] * sizeof (char *);
                   1025:       if (code == TREE_VEC)
                   1026:        length += (TREE_VEC_LENGTH (node) - 1) * sizeof (char *);
                   1027:     }
                   1028: 
                   1029:   t = (tree) obstack_alloc (current_obstack, length);
                   1030: 
1.1.1.4   root     1031:   for (i = (length / sizeof (int)) - 1; i >= 0; i--)
1.1       root     1032:     ((int *) t)[i] = ((int *) node)[i];
1.1.1.4   root     1033:   /* Clear any extra bytes.  */
                   1034:   for (i = length / sizeof (int) * sizeof (int); i < length; i++)
                   1035:     ((char *) t)[i] = ((char *) node)[i];
1.1       root     1036: 
                   1037:   TREE_CHAIN (t) = 0;
                   1038: 
1.1.1.5   root     1039:   if (TREE_CODE_CLASS (code) == 'd')
                   1040:     DECL_UID (t) = next_decl_uid++;
                   1041:   else if (TREE_CODE_CLASS (code) == 't')
1.1.1.6 ! root     1042:     {
        !          1043:       TYPE_UID (t) = next_type_uid++;
        !          1044:       TYPE_OBSTACK (t) = current_obstack;
        !          1045:     }
1.1.1.5   root     1046: 
1.1       root     1047:   TREE_PERMANENT (t) = (current_obstack == &permanent_obstack);
                   1048: 
                   1049:   return t;
                   1050: }
                   1051: 
                   1052: /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
                   1053:    For example, this can copy a list made of TREE_LIST nodes.  */
                   1054: 
                   1055: tree
                   1056: copy_list (list)
                   1057:      tree list;
                   1058: {
                   1059:   tree head;
                   1060:   register tree prev, next;
                   1061: 
                   1062:   if (list == 0)
                   1063:     return 0;
                   1064: 
                   1065:   head = prev = copy_node (list);
                   1066:   next = TREE_CHAIN (list);
                   1067:   while (next)
                   1068:     {
                   1069:       TREE_CHAIN (prev) = copy_node (next);
                   1070:       prev = TREE_CHAIN (prev);
                   1071:       next = TREE_CHAIN (next);
                   1072:     }
                   1073:   return head;
                   1074: }
                   1075: 
                   1076: #define HASHBITS 30
                   1077: 
                   1078: /* Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string).
                   1079:    If an identifier with that name has previously been referred to,
                   1080:    the same node is returned this time.  */
                   1081: 
                   1082: tree
                   1083: get_identifier (text)
                   1084:      register char *text;
                   1085: {
                   1086:   register int hi;
                   1087:   register int i;
                   1088:   register tree idp;
                   1089:   register int len, hash_len;
                   1090: 
                   1091:   /* Compute length of text in len.  */
                   1092:   for (len = 0; text[len]; len++);
                   1093: 
                   1094:   /* Decide how much of that length to hash on */
                   1095:   hash_len = len;
                   1096:   if (warn_id_clash && len > id_clash_len)
                   1097:     hash_len = id_clash_len;
                   1098: 
                   1099:   /* Compute hash code */
                   1100:   hi = hash_len * 613 + (unsigned)text[0];
                   1101:   for (i = 1; i < hash_len; i += 2)
                   1102:     hi = ((hi * 613) + (unsigned)(text[i]));
                   1103: 
                   1104:   hi &= (1 << HASHBITS) - 1;
                   1105:   hi %= MAX_HASH_TABLE;
                   1106:   
                   1107:   /* Search table for identifier */
                   1108:   for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp))
                   1109:     if (IDENTIFIER_LENGTH (idp) == len
                   1110:        && IDENTIFIER_POINTER (idp)[0] == text[0]
                   1111:        && !bcmp (IDENTIFIER_POINTER (idp), text, len))
                   1112:       return idp;              /* <-- return if found */
                   1113: 
                   1114:   /* Not found; optionally warn about a similar identifier */
                   1115:   if (warn_id_clash && do_identifier_warnings && len >= id_clash_len)
                   1116:     for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp))
                   1117:       if (!strncmp (IDENTIFIER_POINTER (idp), text, id_clash_len))
                   1118:        {
                   1119:          warning ("`%s' and `%s' identical in first %d characters",
                   1120:                   IDENTIFIER_POINTER (idp), text, id_clash_len);
                   1121:          break;
                   1122:        }
                   1123: 
                   1124:   if (tree_code_length[(int) IDENTIFIER_NODE] < 0)
                   1125:     abort ();                  /* set_identifier_size hasn't been called.  */
                   1126: 
                   1127:   /* Not found, create one, add to chain */
                   1128:   idp = make_node (IDENTIFIER_NODE);
                   1129:   IDENTIFIER_LENGTH (idp) = len;
                   1130: #ifdef GATHER_STATISTICS
                   1131:   id_string_size += len;
                   1132: #endif
                   1133: 
                   1134:   IDENTIFIER_POINTER (idp) = obstack_copy0 (&permanent_obstack, text, len);
                   1135: 
                   1136:   TREE_CHAIN (idp) = hash_table[hi];
                   1137:   hash_table[hi] = idp;
                   1138:   return idp;                  /* <-- return if created */
                   1139: }
                   1140: 
                   1141: /* Enable warnings on similar identifiers (if requested).
                   1142:    Done after the built-in identifiers are created.  */
                   1143: 
                   1144: void
                   1145: start_identifier_warnings ()
                   1146: {
                   1147:   do_identifier_warnings = 1;
                   1148: }
                   1149: 
                   1150: /* Record the size of an identifier node for the language in use.
                   1151:    SIZE is the total size in bytes.
                   1152:    This is called by the language-specific files.  This must be
                   1153:    called before allocating any identifiers.  */
                   1154: 
                   1155: void
                   1156: set_identifier_size (size)
                   1157:      int size;
                   1158: {
                   1159:   tree_code_length[(int) IDENTIFIER_NODE]
                   1160:     = (size - sizeof (struct tree_common)) / sizeof (tree);
                   1161: }
                   1162: 
                   1163: /* Return a newly constructed INTEGER_CST node whose constant value
                   1164:    is specified by the two ints LOW and HI.
1.1.1.4   root     1165:    The TREE_TYPE is set to `int'. 
                   1166: 
                   1167:    This function should be used via the `build_int_2' macro.  */
1.1       root     1168: 
                   1169: tree
1.1.1.4   root     1170: build_int_2_wide (low, hi)
                   1171:      HOST_WIDE_INT low, hi;
1.1       root     1172: {
                   1173:   register tree t = make_node (INTEGER_CST);
                   1174:   TREE_INT_CST_LOW (t) = low;
                   1175:   TREE_INT_CST_HIGH (t) = hi;
                   1176:   TREE_TYPE (t) = integer_type_node;
                   1177:   return t;
                   1178: }
                   1179: 
                   1180: /* Return a new REAL_CST node whose type is TYPE and value is D.  */
                   1181: 
                   1182: tree
                   1183: build_real (type, d)
                   1184:      tree type;
                   1185:      REAL_VALUE_TYPE d;
                   1186: {
                   1187:   tree v;
                   1188: 
                   1189:   /* Check for valid float value for this type on this target machine;
                   1190:      if not, can print error message and store a valid value in D.  */
                   1191: #ifdef CHECK_FLOAT_VALUE
                   1192:   CHECK_FLOAT_VALUE (TYPE_MODE (type), d);
                   1193: #endif
                   1194: 
                   1195:   v = make_node (REAL_CST);
                   1196:   TREE_TYPE (v) = type;
                   1197:   TREE_REAL_CST (v) = d;
                   1198:   return v;
                   1199: }
                   1200: 
                   1201: /* Return a new REAL_CST node whose type is TYPE
                   1202:    and whose value is the integer value of the INTEGER_CST node I.  */
                   1203: 
                   1204: #if !defined (REAL_IS_NOT_DOUBLE) || defined (REAL_ARITHMETIC)
                   1205: 
                   1206: REAL_VALUE_TYPE
                   1207: real_value_from_int_cst (i)
                   1208:      tree i;
                   1209: {
                   1210:   REAL_VALUE_TYPE d;
1.1.1.5   root     1211:   REAL_VALUE_TYPE e;
                   1212:   /* Some 386 compilers mishandle unsigned int to float conversions,
                   1213:      so introduce a temporary variable E to avoid those bugs.  */
                   1214: 
1.1       root     1215: #ifdef REAL_ARITHMETIC
1.1.1.5   root     1216:   if (! TREE_UNSIGNED (TREE_TYPE (i)))
                   1217:     REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i));
                   1218:   else
                   1219:     REAL_VALUE_FROM_UNSIGNED_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i));
1.1       root     1220: #else /* not REAL_ARITHMETIC */
1.1.1.4   root     1221:   if (TREE_INT_CST_HIGH (i) < 0 && ! TREE_UNSIGNED (TREE_TYPE (i)))
1.1       root     1222:     {
                   1223:       d = (double) (~ TREE_INT_CST_HIGH (i));
1.1.1.5   root     1224:       e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
1.1.1.4   root     1225:            * (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)));
1.1.1.5   root     1226:       d *= e;
                   1227:       e = (double) (unsigned HOST_WIDE_INT) (~ TREE_INT_CST_LOW (i));
                   1228:       d += e;
1.1       root     1229:       d = (- d - 1.0);
                   1230:     }
                   1231:   else
                   1232:     {
1.1.1.4   root     1233:       d = (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (i);
1.1.1.5   root     1234:       e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))
1.1.1.4   root     1235:            * (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)));
1.1.1.5   root     1236:       d *= e;
                   1237:       e = (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (i);
                   1238:       d += e;
1.1       root     1239:     }
                   1240: #endif /* not REAL_ARITHMETIC */
                   1241:   return d;
                   1242: }
                   1243: 
                   1244: /* This function can't be implemented if we can't do arithmetic
                   1245:    on the float representation.  */
                   1246: 
                   1247: tree
                   1248: build_real_from_int_cst (type, i)
                   1249:      tree type;
                   1250:      tree i;
                   1251: {
                   1252:   tree v;
                   1253:   REAL_VALUE_TYPE d;
                   1254: 
                   1255:   v = make_node (REAL_CST);
                   1256:   TREE_TYPE (v) = type;
                   1257: 
1.1.1.4   root     1258:   d = REAL_VALUE_TRUNCATE (TYPE_MODE (type), real_value_from_int_cst (i));
1.1       root     1259:   /* Check for valid float value for this type on this target machine;
                   1260:      if not, can print error message and store a valid value in D.  */
                   1261: #ifdef CHECK_FLOAT_VALUE
                   1262:   CHECK_FLOAT_VALUE (TYPE_MODE (type), d);
                   1263: #endif
                   1264: 
                   1265:   TREE_REAL_CST (v) = d;
                   1266:   return v;
                   1267: }
                   1268: 
                   1269: #endif /* not REAL_IS_NOT_DOUBLE, or REAL_ARITHMETIC */
                   1270: 
                   1271: /* Return a newly constructed STRING_CST node whose value is
                   1272:    the LEN characters at STR.
                   1273:    The TREE_TYPE is not initialized.  */
                   1274: 
                   1275: tree
                   1276: build_string (len, str)
                   1277:      int len;
                   1278:      char *str;
                   1279: {
1.1.1.6 ! root     1280:   /* Put the string in saveable_obstack since it will be placed in the RTL
        !          1281:      for an "asm" statement and will also be kept around a while if
        !          1282:      deferring constant output in varasm.c.  */
        !          1283: 
1.1       root     1284:   register tree s = make_node (STRING_CST);
                   1285:   TREE_STRING_LENGTH (s) = len;
                   1286:   TREE_STRING_POINTER (s) = obstack_copy0 (saveable_obstack, str, len);
                   1287:   return s;
                   1288: }
                   1289: 
                   1290: /* Return a newly constructed COMPLEX_CST node whose value is
                   1291:    specified by the real and imaginary parts REAL and IMAG.
                   1292:    Both REAL and IMAG should be constant nodes.
                   1293:    The TREE_TYPE is not initialized.  */
                   1294: 
                   1295: tree
                   1296: build_complex (real, imag)
                   1297:      tree real, imag;
                   1298: {
                   1299:   register tree t = make_node (COMPLEX_CST);
                   1300:   TREE_REALPART (t) = real;
                   1301:   TREE_IMAGPART (t) = imag;
1.1.1.5   root     1302:   TREE_TYPE (t) = build_complex_type (TREE_TYPE (real));
1.1       root     1303:   return t;
                   1304: }
                   1305: 
                   1306: /* Build a newly constructed TREE_VEC node of length LEN.  */
                   1307: tree
                   1308: make_tree_vec (len)
                   1309:      int len;
                   1310: {
                   1311:   register tree t;
                   1312:   register int length = (len-1) * sizeof (tree) + sizeof (struct tree_vec);
                   1313:   register struct obstack *obstack = current_obstack;
                   1314:   register int i;
                   1315: 
                   1316: #ifdef GATHER_STATISTICS
                   1317:   tree_node_counts[(int)vec_kind]++;
                   1318:   tree_node_sizes[(int)vec_kind] += length;
                   1319: #endif
                   1320: 
                   1321:   t = (tree) obstack_alloc (obstack, length);
                   1322: 
1.1.1.4   root     1323:   for (i = (length / sizeof (int)) - 1; i >= 0; i--)
1.1       root     1324:     ((int *) t)[i] = 0;
1.1.1.4   root     1325: 
1.1       root     1326:   TREE_SET_CODE (t, TREE_VEC);
                   1327:   TREE_VEC_LENGTH (t) = len;
                   1328:   if (obstack == &permanent_obstack)
                   1329:     TREE_PERMANENT (t) = 1;
                   1330: 
                   1331:   return t;
                   1332: }
                   1333: 
                   1334: /* Return 1 if EXPR is the integer constant zero.  */
                   1335: 
                   1336: int
                   1337: integer_zerop (expr)
                   1338:      tree expr;
                   1339: {
1.1.1.4   root     1340:   STRIP_NOPS (expr);
1.1       root     1341: 
                   1342:   return (TREE_CODE (expr) == INTEGER_CST
                   1343:          && TREE_INT_CST_LOW (expr) == 0
                   1344:          && TREE_INT_CST_HIGH (expr) == 0);
                   1345: }
                   1346: 
                   1347: /* Return 1 if EXPR is the integer constant one.  */
                   1348: 
                   1349: int
                   1350: integer_onep (expr)
                   1351:      tree expr;
                   1352: {
1.1.1.4   root     1353:   STRIP_NOPS (expr);
1.1       root     1354: 
                   1355:   return (TREE_CODE (expr) == INTEGER_CST
                   1356:          && TREE_INT_CST_LOW (expr) == 1
                   1357:          && TREE_INT_CST_HIGH (expr) == 0);
                   1358: }
                   1359: 
                   1360: /* Return 1 if EXPR is an integer containing all 1's
                   1361:    in as much precision as it contains.  */
                   1362: 
                   1363: int
                   1364: integer_all_onesp (expr)
                   1365:      tree expr;
                   1366: {
                   1367:   register int prec;
                   1368:   register int uns;
                   1369: 
1.1.1.4   root     1370:   STRIP_NOPS (expr);
1.1       root     1371: 
                   1372:   if (TREE_CODE (expr) != INTEGER_CST)
                   1373:     return 0;
                   1374: 
                   1375:   uns = TREE_UNSIGNED (TREE_TYPE (expr));
                   1376:   if (!uns)
                   1377:     return TREE_INT_CST_LOW (expr) == -1 && TREE_INT_CST_HIGH (expr) == -1;
                   1378: 
                   1379:   prec = TYPE_PRECISION (TREE_TYPE (expr));
1.1.1.4   root     1380:   if (prec >= HOST_BITS_PER_WIDE_INT)
1.1       root     1381:     {
                   1382:       int high_value, shift_amount;
                   1383: 
1.1.1.4   root     1384:       shift_amount = prec - HOST_BITS_PER_WIDE_INT;
1.1       root     1385: 
1.1.1.4   root     1386:       if (shift_amount > HOST_BITS_PER_WIDE_INT)
1.1       root     1387:        /* Can not handle precisions greater than twice the host int size.  */
                   1388:        abort ();
1.1.1.4   root     1389:       else if (shift_amount == HOST_BITS_PER_WIDE_INT)
1.1       root     1390:        /* Shifting by the host word size is undefined according to the ANSI
                   1391:           standard, so we must handle this as a special case.  */
                   1392:        high_value = -1;
                   1393:       else
1.1.1.4   root     1394:        high_value = ((HOST_WIDE_INT) 1 << shift_amount) - 1;
1.1       root     1395: 
                   1396:       return TREE_INT_CST_LOW (expr) == -1
                   1397:        && TREE_INT_CST_HIGH (expr) == high_value;
                   1398:     }
                   1399:   else
1.1.1.4   root     1400:     return TREE_INT_CST_LOW (expr) == ((HOST_WIDE_INT) 1 << prec) - 1;
1.1       root     1401: }
                   1402: 
                   1403: /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only
                   1404:    one bit on).  */
                   1405: 
                   1406: int
                   1407: integer_pow2p (expr)
                   1408:      tree expr;
                   1409: {
1.1.1.4   root     1410:   HOST_WIDE_INT high, low;
1.1       root     1411: 
1.1.1.4   root     1412:   STRIP_NOPS (expr);
1.1       root     1413: 
                   1414:   if (TREE_CODE (expr) != INTEGER_CST)
                   1415:     return 0;
                   1416: 
                   1417:   high = TREE_INT_CST_HIGH (expr);
                   1418:   low = TREE_INT_CST_LOW (expr);
                   1419: 
                   1420:   if (high == 0 && low == 0)
                   1421:     return 0;
                   1422: 
                   1423:   return ((high == 0 && (low & (low - 1)) == 0)
                   1424:          || (low == 0 && (high & (high - 1)) == 0));
                   1425: }
                   1426: 
                   1427: /* Return 1 if EXPR is the real constant zero.  */
                   1428: 
                   1429: int
                   1430: real_zerop (expr)
                   1431:      tree expr;
                   1432: {
1.1.1.4   root     1433:   STRIP_NOPS (expr);
1.1       root     1434: 
                   1435:   return (TREE_CODE (expr) == REAL_CST
                   1436:          && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0));
                   1437: }
                   1438: 
                   1439: /* Return 1 if EXPR is the real constant one.  */
                   1440: 
                   1441: int
                   1442: real_onep (expr)
                   1443:      tree expr;
                   1444: {
1.1.1.4   root     1445:   STRIP_NOPS (expr);
1.1       root     1446: 
                   1447:   return (TREE_CODE (expr) == REAL_CST
                   1448:          && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1));
                   1449: }
                   1450: 
                   1451: /* Return 1 if EXPR is the real constant two.  */
                   1452: 
                   1453: int
                   1454: real_twop (expr)
                   1455:      tree expr;
                   1456: {
1.1.1.4   root     1457:   STRIP_NOPS (expr);
1.1       root     1458: 
                   1459:   return (TREE_CODE (expr) == REAL_CST
                   1460:          && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst2));
                   1461: }
                   1462: 
                   1463: /* Nonzero if EXP is a constant or a cast of a constant.  */
                   1464:  
                   1465: int
                   1466: really_constant_p (exp)
                   1467:      tree exp;
                   1468: {
1.1.1.4   root     1469:   /* This is not quite the same as STRIP_NOPS.  It does more.  */
1.1       root     1470:   while (TREE_CODE (exp) == NOP_EXPR
                   1471:         || TREE_CODE (exp) == CONVERT_EXPR
                   1472:         || TREE_CODE (exp) == NON_LVALUE_EXPR)
                   1473:     exp = TREE_OPERAND (exp, 0);
                   1474:   return TREE_CONSTANT (exp);
                   1475: }
                   1476: 
                   1477: /* Return first list element whose TREE_VALUE is ELEM.
                   1478:    Return 0 if ELEM is not it LIST.  */
                   1479: 
                   1480: tree
                   1481: value_member (elem, list)
                   1482:      tree elem, list;
                   1483: {
                   1484:   while (list)
                   1485:     {
                   1486:       if (elem == TREE_VALUE (list))
                   1487:        return list;
                   1488:       list = TREE_CHAIN (list);
                   1489:     }
                   1490:   return NULL_TREE;
                   1491: }
                   1492: 
                   1493: /* Return first list element whose TREE_PURPOSE is ELEM.
                   1494:    Return 0 if ELEM is not it LIST.  */
                   1495: 
                   1496: tree
                   1497: purpose_member (elem, list)
                   1498:      tree elem, list;
                   1499: {
                   1500:   while (list)
                   1501:     {
                   1502:       if (elem == TREE_PURPOSE (list))
                   1503:        return list;
                   1504:       list = TREE_CHAIN (list);
                   1505:     }
                   1506:   return NULL_TREE;
                   1507: }
                   1508: 
                   1509: /* Return first list element whose BINFO_TYPE is ELEM.
                   1510:    Return 0 if ELEM is not it LIST.  */
                   1511: 
                   1512: tree
                   1513: binfo_member (elem, list)
                   1514:      tree elem, list;
                   1515: {
                   1516:   while (list)
                   1517:     {
                   1518:       if (elem == BINFO_TYPE (list))
                   1519:        return list;
                   1520:       list = TREE_CHAIN (list);
                   1521:     }
                   1522:   return NULL_TREE;
                   1523: }
                   1524: 
                   1525: /* Return nonzero if ELEM is part of the chain CHAIN.  */
                   1526: 
                   1527: int
                   1528: chain_member (elem, chain)
                   1529:      tree elem, chain;
                   1530: {
                   1531:   while (chain)
                   1532:     {
                   1533:       if (elem == chain)
                   1534:        return 1;
                   1535:       chain = TREE_CHAIN (chain);
                   1536:     }
                   1537: 
                   1538:   return 0;
                   1539: }
                   1540: 
                   1541: /* Return the length of a chain of nodes chained through TREE_CHAIN.
                   1542:    We expect a null pointer to mark the end of the chain.
                   1543:    This is the Lisp primitive `length'.  */
                   1544: 
                   1545: int
                   1546: list_length (t)
                   1547:      tree t;
                   1548: {
                   1549:   register tree tail;
                   1550:   register int len = 0;
                   1551: 
                   1552:   for (tail = t; tail; tail = TREE_CHAIN (tail))
                   1553:     len++;
                   1554: 
                   1555:   return len;
                   1556: }
                   1557: 
                   1558: /* Concatenate two chains of nodes (chained through TREE_CHAIN)
                   1559:    by modifying the last node in chain 1 to point to chain 2.
                   1560:    This is the Lisp primitive `nconc'.  */
                   1561: 
                   1562: tree
                   1563: chainon (op1, op2)
                   1564:      tree op1, op2;
                   1565: {
                   1566:   tree t;
                   1567: 
                   1568:   if (op1)
                   1569:     {
                   1570:       for (t = op1; TREE_CHAIN (t); t = TREE_CHAIN (t))
                   1571:        if (t == op2) abort (); /* Circularity being created */
1.1.1.4   root     1572:       if (t == op2) abort ();  /* Circularity being created */
1.1       root     1573:       TREE_CHAIN (t) = op2;
                   1574:       return op1;
                   1575:     }
                   1576:   else return op2;
                   1577: }
                   1578: 
                   1579: /* Return the last node in a chain of nodes (chained through TREE_CHAIN).  */
                   1580: 
                   1581: tree
                   1582: tree_last (chain)
                   1583:      register tree chain;
                   1584: {
                   1585:   register tree next;
                   1586:   if (chain)
                   1587:     while (next = TREE_CHAIN (chain))
                   1588:       chain = next;
                   1589:   return chain;
                   1590: }
                   1591: 
                   1592: /* Reverse the order of elements in the chain T,
                   1593:    and return the new head of the chain (old last element).  */
                   1594: 
                   1595: tree
                   1596: nreverse (t)
                   1597:      tree t;
                   1598: {
                   1599:   register tree prev = 0, decl, next;
                   1600:   for (decl = t; decl; decl = next)
                   1601:     {
                   1602:       next = TREE_CHAIN (decl);
                   1603:       TREE_CHAIN (decl) = prev;
                   1604:       prev = decl;
                   1605:     }
                   1606:   return prev;
                   1607: }
                   1608: 
                   1609: /* Given a chain CHAIN of tree nodes,
                   1610:    construct and return a list of those nodes.  */
                   1611: 
                   1612: tree
                   1613: listify (chain)
                   1614:      tree chain;
                   1615: {
                   1616:   tree result = NULL_TREE;
                   1617:   tree in_tail = chain;
                   1618:   tree out_tail = NULL_TREE;
                   1619: 
                   1620:   while (in_tail)
                   1621:     {
                   1622:       tree next = tree_cons (NULL_TREE, in_tail, NULL_TREE);
                   1623:       if (out_tail)
                   1624:        TREE_CHAIN (out_tail) = next;
                   1625:       else
                   1626:        result = next;
                   1627:       out_tail = next;
                   1628:       in_tail = TREE_CHAIN (in_tail);
                   1629:     }
                   1630: 
                   1631:   return result;
                   1632: }
                   1633: 
                   1634: /* Return a newly created TREE_LIST node whose
                   1635:    purpose and value fields are PARM and VALUE.  */
                   1636: 
                   1637: tree
                   1638: build_tree_list (parm, value)
                   1639:      tree parm, value;
                   1640: {
                   1641:   register tree t = make_node (TREE_LIST);
                   1642:   TREE_PURPOSE (t) = parm;
                   1643:   TREE_VALUE (t) = value;
                   1644:   return t;
                   1645: }
                   1646: 
                   1647: /* Similar, but build on the temp_decl_obstack.  */
                   1648: 
                   1649: tree
                   1650: build_decl_list (parm, value)
                   1651:      tree parm, value;
                   1652: {
                   1653:   register tree node;
                   1654:   register struct obstack *ambient_obstack = current_obstack;
                   1655:   current_obstack = &temp_decl_obstack;
                   1656:   node = build_tree_list (parm, value);
                   1657:   current_obstack = ambient_obstack;
                   1658:   return node;
                   1659: }
                   1660: 
                   1661: /* Return a newly created TREE_LIST node whose
                   1662:    purpose and value fields are PARM and VALUE
                   1663:    and whose TREE_CHAIN is CHAIN.  */
                   1664: 
                   1665: tree
                   1666: tree_cons (purpose, value, chain)
                   1667:      tree purpose, value, chain;
                   1668: {
                   1669: #if 0
                   1670:   register tree node = make_node (TREE_LIST);
                   1671: #else
                   1672:   register int i;
                   1673:   register tree node = (tree) obstack_alloc (current_obstack, sizeof (struct tree_list));
                   1674: #ifdef GATHER_STATISTICS
                   1675:   tree_node_counts[(int)x_kind]++;
                   1676:   tree_node_sizes[(int)x_kind] += sizeof (struct tree_list);
                   1677: #endif
                   1678: 
1.1.1.4   root     1679:   for (i = (sizeof (struct tree_common) / sizeof (int)) - 1; i >= 0; i--)
                   1680:     ((int *) node)[i] = 0;
                   1681: 
1.1       root     1682:   TREE_SET_CODE (node, TREE_LIST);
                   1683:   if (current_obstack == &permanent_obstack)
                   1684:     TREE_PERMANENT (node) = 1;
                   1685: #endif
                   1686: 
                   1687:   TREE_CHAIN (node) = chain;
                   1688:   TREE_PURPOSE (node) = purpose;
                   1689:   TREE_VALUE (node) = value;
                   1690:   return node;
                   1691: }
                   1692: 
                   1693: /* Similar, but build on the temp_decl_obstack.  */
                   1694: 
                   1695: tree
                   1696: decl_tree_cons (purpose, value, chain)
                   1697:      tree purpose, value, chain;
                   1698: {
                   1699:   register tree node;
                   1700:   register struct obstack *ambient_obstack = current_obstack;
                   1701:   current_obstack = &temp_decl_obstack;
                   1702:   node = tree_cons (purpose, value, chain);
                   1703:   current_obstack = ambient_obstack;
                   1704:   return node;
                   1705: }
                   1706: 
                   1707: /* Same as `tree_cons' but make a permanent object.  */
                   1708: 
                   1709: tree
                   1710: perm_tree_cons (purpose, value, chain)
                   1711:      tree purpose, value, chain;
                   1712: {
                   1713:   register tree node;
                   1714:   register struct obstack *ambient_obstack = current_obstack;
                   1715:   current_obstack = &permanent_obstack;
                   1716: 
                   1717:   node = tree_cons (purpose, value, chain);
                   1718:   current_obstack = ambient_obstack;
                   1719:   return node;
                   1720: }
                   1721: 
                   1722: /* Same as `tree_cons', but make this node temporary, regardless.  */
                   1723: 
                   1724: tree
                   1725: temp_tree_cons (purpose, value, chain)
                   1726:      tree purpose, value, chain;
                   1727: {
                   1728:   register tree node;
                   1729:   register struct obstack *ambient_obstack = current_obstack;
                   1730:   current_obstack = &temporary_obstack;
                   1731: 
                   1732:   node = tree_cons (purpose, value, chain);
                   1733:   current_obstack = ambient_obstack;
                   1734:   return node;
                   1735: }
                   1736: 
                   1737: /* Same as `tree_cons', but save this node if the function's RTL is saved.  */
                   1738: 
                   1739: tree
                   1740: saveable_tree_cons (purpose, value, chain)
                   1741:      tree purpose, value, chain;
                   1742: {
                   1743:   register tree node;
                   1744:   register struct obstack *ambient_obstack = current_obstack;
                   1745:   current_obstack = saveable_obstack;
                   1746: 
                   1747:   node = tree_cons (purpose, value, chain);
                   1748:   current_obstack = ambient_obstack;
                   1749:   return node;
                   1750: }
                   1751: 
                   1752: /* Return the size nominally occupied by an object of type TYPE
                   1753:    when it resides in memory.  The value is measured in units of bytes,
                   1754:    and its data type is that normally used for type sizes
                   1755:    (which is the first type created by make_signed_type or
                   1756:    make_unsigned_type).  */
                   1757: 
                   1758: tree
                   1759: size_in_bytes (type)
                   1760:      tree type;
                   1761: {
1.1.1.5   root     1762:   tree t;
                   1763: 
1.1       root     1764:   if (type == error_mark_node)
                   1765:     return integer_zero_node;
                   1766:   type = TYPE_MAIN_VARIANT (type);
                   1767:   if (TYPE_SIZE (type) == 0)
                   1768:     {
1.1.1.4   root     1769:       incomplete_type_error (NULL_TREE, type);
1.1       root     1770:       return integer_zero_node;
                   1771:     }
1.1.1.5   root     1772:   t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
                   1773:                  size_int (BITS_PER_UNIT));
                   1774:   if (TREE_CODE (t) == INTEGER_CST)
                   1775:     force_fit_type (t, 0);
                   1776:   return t;
1.1       root     1777: }
                   1778: 
                   1779: /* Return the size of TYPE (in bytes) as an integer,
                   1780:    or return -1 if the size can vary.  */
                   1781: 
                   1782: int
                   1783: int_size_in_bytes (type)
                   1784:      tree type;
                   1785: {
1.1.1.5   root     1786:   unsigned int size;
1.1       root     1787:   if (type == error_mark_node)
                   1788:     return 0;
                   1789:   type = TYPE_MAIN_VARIANT (type);
                   1790:   if (TYPE_SIZE (type) == 0)
                   1791:     return -1;
                   1792:   if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
                   1793:     return -1;
1.1.1.5   root     1794:   if (TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0)
                   1795:     {
                   1796:       tree t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
                   1797:                           size_int (BITS_PER_UNIT));
                   1798:       return TREE_INT_CST_LOW (t);
                   1799:     }
1.1       root     1800:   size = TREE_INT_CST_LOW (TYPE_SIZE (type));
                   1801:   return (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
                   1802: }
1.1.1.6 ! root     1803: 
        !          1804: /* Return, as a tree node, the number of elements for TYPE (which is an
        !          1805:    ARRAY_TYPE) minus one. This counts only elements of the top array.  */
1.1       root     1806: 
                   1807: tree
                   1808: array_type_nelts (type)
                   1809:      tree type;
                   1810: {
                   1811:   tree index_type = TYPE_DOMAIN (type);
1.1.1.6 ! root     1812: 
        !          1813:   return (integer_zerop (TYPE_MIN_VALUE (index_type))
1.1       root     1814:          ? TYPE_MAX_VALUE (index_type)
1.1.1.6 ! root     1815:          : fold (build (MINUS_EXPR, TREE_TYPE (TYPE_MAX_VALUE (index_type)),
1.1       root     1816:                         TYPE_MAX_VALUE (index_type),
                   1817:                         TYPE_MIN_VALUE (index_type))));
                   1818: }
                   1819: 
                   1820: /* Return nonzero if arg is static -- a reference to an object in
                   1821:    static storage.  This is not the same as the C meaning of `static'.  */
                   1822: 
                   1823: int
                   1824: staticp (arg)
                   1825:      tree arg;
                   1826: {
                   1827:   switch (TREE_CODE (arg))
                   1828:     {
                   1829:     case VAR_DECL:
                   1830:     case FUNCTION_DECL:
1.1.1.4   root     1831:       return TREE_STATIC (arg) || DECL_EXTERNAL (arg);
1.1       root     1832: 
1.1.1.6 ! root     1833:     case CONSTRUCTOR:
        !          1834:       return TREE_STATIC (arg);
        !          1835: 
1.1       root     1836:     case STRING_CST:
                   1837:       return 1;
                   1838: 
                   1839:     case COMPONENT_REF:
                   1840:     case BIT_FIELD_REF:
                   1841:       return staticp (TREE_OPERAND (arg, 0));
                   1842: 
                   1843:     case INDIRECT_REF:
                   1844:       return TREE_CONSTANT (TREE_OPERAND (arg, 0));
                   1845: 
                   1846:     case ARRAY_REF:
                   1847:       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
                   1848:          && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
                   1849:        return staticp (TREE_OPERAND (arg, 0));
                   1850:     }
                   1851: 
                   1852:   return 0;
                   1853: }
                   1854: 
1.1.1.6 ! root     1855: /* Wrap a SAVE_EXPR around EXPR, if appropriate.
        !          1856:    Do this to any expression which may be used in more than one place,
        !          1857:    but must be evaluated only once.
        !          1858: 
        !          1859:    Normally, expand_expr would reevaluate the expression each time.
        !          1860:    Calling save_expr produces something that is evaluated and recorded
        !          1861:    the first time expand_expr is called on it.  Subsequent calls to
        !          1862:    expand_expr just reuse the recorded value.
        !          1863: 
        !          1864:    The call to expand_expr that generates code that actually computes
        !          1865:    the value is the first call *at compile time*.  Subsequent calls
        !          1866:    *at compile time* generate code to use the saved value.
        !          1867:    This produces correct result provided that *at run time* control
        !          1868:    always flows through the insns made by the first expand_expr
        !          1869:    before reaching the other places where the save_expr was evaluated.
        !          1870:    You, the caller of save_expr, must make sure this is so.
        !          1871: 
        !          1872:    Constants, and certain read-only nodes, are returned with no
        !          1873:    SAVE_EXPR because that is safe.  Expressions containing placeholders
        !          1874:    are not touched; see tree.def for an explanation of what these
        !          1875:    are used for.  */
1.1       root     1876: 
                   1877: tree
                   1878: save_expr (expr)
                   1879:      tree expr;
                   1880: {
                   1881:   register tree t = fold (expr);
                   1882: 
                   1883:   /* We don't care about whether this can be used as an lvalue in this
                   1884:      context.  */
                   1885:   while (TREE_CODE (t) == NON_LVALUE_EXPR)
                   1886:     t = TREE_OPERAND (t, 0);
                   1887: 
                   1888:   /* If the tree evaluates to a constant, then we don't want to hide that
                   1889:      fact (i.e. this allows further folding, and direct checks for constants).
1.1.1.3   root     1890:      However, a read-only object that has side effects cannot be bypassed.
1.1       root     1891:      Since it is no problem to reevaluate literals, we just return the 
                   1892:      literal node. */
                   1893: 
1.1.1.3   root     1894:   if (TREE_CONSTANT (t) || (TREE_READONLY (t) && ! TREE_SIDE_EFFECTS (t))
                   1895:       || TREE_CODE (t) == SAVE_EXPR)
1.1       root     1896:     return t;
                   1897: 
1.1.1.6 ! root     1898:   /* If T contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
        !          1899:      it means that the size or offset of some field of an object depends on
        !          1900:      the value within another field.
        !          1901: 
        !          1902:      Note that it must not be the case that T contains both a PLACEHOLDER_EXPR
        !          1903:      and some variable since it would then need to be both evaluated once and
        !          1904:      evaluated more than once.  Front-ends must assure this case cannot
        !          1905:      happen by surrounding any such subexpressions in their own SAVE_EXPR
        !          1906:      and forcing evaluation at the proper time.  */
        !          1907:   if (contains_placeholder_p (t))
        !          1908:     return t;
        !          1909: 
1.1.1.4   root     1910:   t = build (SAVE_EXPR, TREE_TYPE (expr), t, current_function_decl, NULL_TREE);
1.1       root     1911: 
                   1912:   /* This expression might be placed ahead of a jump to ensure that the
                   1913:      value was computed on both sides of the jump.  So make sure it isn't
                   1914:      eliminated as dead.  */
                   1915:   TREE_SIDE_EFFECTS (t) = 1;
                   1916:   return t;
                   1917: }
1.1.1.6 ! root     1918: 
        !          1919: /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size
        !          1920:    or offset that depends on a field within a record.
        !          1921: 
        !          1922:    Note that we only allow such expressions within simple arithmetic
        !          1923:    or a COND_EXPR.  */
        !          1924: 
        !          1925: int
        !          1926: contains_placeholder_p (exp)
        !          1927:      tree exp;
        !          1928: {
        !          1929:   register enum tree_code code = TREE_CODE (exp);
        !          1930:   tree inner;
        !          1931: 
        !          1932:   /* If we have a WITH_RECORD_EXPR, it "cancels" any PLACEHOLDER_EXPR
        !          1933:      in it since it is supplying a value for it.  */
        !          1934:   if (code == WITH_RECORD_EXPR)
        !          1935:     return 0;
        !          1936: 
        !          1937:   switch (TREE_CODE_CLASS (code))
        !          1938:     {
        !          1939:     case 'r':
        !          1940:       for (inner = TREE_OPERAND (exp, 0);
        !          1941:           TREE_CODE_CLASS (TREE_CODE (inner)) == 'r';
        !          1942:           inner = TREE_OPERAND (inner, 0))
        !          1943:        ;
        !          1944:       return TREE_CODE (inner) == PLACEHOLDER_EXPR;
        !          1945: 
        !          1946:     case '1':
        !          1947:     case '2':  case '<':
        !          1948:     case 'e':
        !          1949:       switch (tree_code_length[(int) code])
        !          1950:        {
        !          1951:        case 1:
        !          1952:          return contains_placeholder_p (TREE_OPERAND (exp, 0));
        !          1953:        case 2:
        !          1954:          return (code != RTL_EXPR
        !          1955:                  && code != CONSTRUCTOR
        !          1956:                  && ! (code == SAVE_EXPR && SAVE_EXPR_RTL (exp) != 0)
        !          1957:                  && code != WITH_RECORD_EXPR
        !          1958:                  && (contains_placeholder_p (TREE_OPERAND (exp, 0))
        !          1959:                      || contains_placeholder_p (TREE_OPERAND (exp, 1))));
        !          1960:        case 3:
        !          1961:          return (code == COND_EXPR
        !          1962:                  && (contains_placeholder_p (TREE_OPERAND (exp, 0))
        !          1963:                      || contains_placeholder_p (TREE_OPERAND (exp, 1))
        !          1964:                      || contains_placeholder_p (TREE_OPERAND (exp, 2))));
        !          1965:        }
        !          1966:     }
        !          1967: 
        !          1968:   return 0;
        !          1969: }
        !          1970: 
        !          1971: /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
        !          1972:    return a tree with all occurrences of references to F in a
        !          1973:    PLACEHOLDER_EXPR replaced by R.   Note that we assume here that EXP
        !          1974:    contains only arithmetic expressions.  */
        !          1975: 
        !          1976: tree
        !          1977: substitute_in_expr (exp, f, r)
        !          1978:      tree exp;
        !          1979:      tree f;
        !          1980:      tree r;
        !          1981: {
        !          1982:   enum tree_code code = TREE_CODE (exp);
        !          1983:   tree inner;
        !          1984: 
        !          1985:   switch (TREE_CODE_CLASS (code))
        !          1986:     {
        !          1987:     case 'c':
        !          1988:     case 'd':
        !          1989:       return exp;
        !          1990: 
        !          1991:     case 'x':
        !          1992:       if (code == PLACEHOLDER_EXPR)
        !          1993:        return exp;
        !          1994:       break;
        !          1995: 
        !          1996:     case '1':
        !          1997:     case '2':
        !          1998:     case '<':
        !          1999:     case 'e':
        !          2000:       switch (tree_code_length[(int) code])
        !          2001:        {
        !          2002:        case 1:
        !          2003:          return fold (build1 (code, TREE_TYPE (exp),
        !          2004:                               substitute_in_expr (TREE_OPERAND (exp, 0),
        !          2005:                                                   f, r)));
        !          2006: 
        !          2007:        case 2:
        !          2008:          /* An RTL_EXPR cannot contain a PLACEHOLDER_EXPR; a CONSTRUCTOR
        !          2009:             could, but we don't support it.  */
        !          2010:          if (code == RTL_EXPR)
        !          2011:            return exp;
        !          2012:          else if (code == CONSTRUCTOR)
        !          2013:            abort ();
        !          2014: 
        !          2015:          return fold (build (code, TREE_TYPE (exp),
        !          2016:                              substitute_in_expr (TREE_OPERAND (exp, 0), f, r),
        !          2017:                              substitute_in_expr (TREE_OPERAND (exp, 1),
        !          2018:                                                  f, r)));
        !          2019: 
        !          2020:        case 3:
        !          2021:          /* It cannot be that anything inside a SAVE_EXPR contains a
        !          2022:             PLACEHOLDER_EXPR.  */
        !          2023:          if (code == SAVE_EXPR)
        !          2024:            return exp;
        !          2025: 
        !          2026:          if (code != COND_EXPR)
        !          2027:            abort ();
        !          2028: 
        !          2029:          return fold (build (code, TREE_TYPE (exp),
        !          2030:                              substitute_in_expr (TREE_OPERAND (exp, 0), f, r),
        !          2031:                              substitute_in_expr (TREE_OPERAND (exp, 1), f, r),
        !          2032:                              substitute_in_expr (TREE_OPERAND (exp, 2),
        !          2033:                                                  f, r)));
        !          2034:        }
        !          2035: 
        !          2036:       break;
        !          2037: 
        !          2038:     case 'r':
        !          2039:       switch (code)
        !          2040:        {
        !          2041:        case COMPONENT_REF:
        !          2042:          /* If this expression is getting a value from a PLACEHOLDER_EXPR
        !          2043:             and it is the right field, replace it with R.  */
        !          2044:          for (inner = TREE_OPERAND (exp, 0);
        !          2045:               TREE_CODE_CLASS (TREE_CODE (inner)) == 'r';
        !          2046:               inner = TREE_OPERAND (inner, 0))
        !          2047:            ;
        !          2048:          if (TREE_CODE (inner) == PLACEHOLDER_EXPR
        !          2049:              && TREE_OPERAND (exp, 1) == f)
        !          2050:            return r;
        !          2051: 
        !          2052:          return fold (build (code, TREE_TYPE (exp),
        !          2053:                              substitute_in_expr (TREE_OPERAND (exp, 0), f, r),
        !          2054:                              TREE_OPERAND (exp, 1)));
        !          2055:        case BIT_FIELD_REF:
        !          2056:          return fold (build (code, TREE_TYPE (exp),
        !          2057:                              substitute_in_expr (TREE_OPERAND (exp, 0), f, r),
        !          2058:                              substitute_in_expr (TREE_OPERAND (exp, 1), f, r),
        !          2059:                              substitute_in_expr (TREE_OPERAND (exp, 2), f, r)));
        !          2060:        case INDIRECT_REF:
        !          2061:        case BUFFER_REF:
        !          2062:          return fold (build1 (code, TREE_TYPE (exp),
        !          2063:                               substitute_in_expr (TREE_OPERAND (exp, 0),
        !          2064:                                                 f, r)));
        !          2065:        case OFFSET_REF:
        !          2066:          return fold (build (code, TREE_TYPE (exp),
        !          2067:                              substitute_in_expr (TREE_OPERAND (exp, 0), f, r),
        !          2068:                              substitute_in_expr (TREE_OPERAND (exp, 1), f, r)));
        !          2069:        }
        !          2070:     }
        !          2071: 
        !          2072:   /* If it wasn't one of the cases we handle, give up.  */
        !          2073: 
        !          2074:   abort ();
        !          2075: }
        !          2076: 
        !          2077: /* Given a type T, a FIELD_DECL F, and a replacement value R,
        !          2078:    return a new type with all size expressions that contain F
        !          2079:    updated by replacing F with R.  */
        !          2080: 
        !          2081: tree
        !          2082: substitute_in_type (t, f, r)
        !          2083:      tree t, f, r;
        !          2084: {
        !          2085:   switch (TREE_CODE (t))
        !          2086:     {
        !          2087:     case POINTER_TYPE:
        !          2088:     case VOID_TYPE:
        !          2089:       return t;
        !          2090:     case INTEGER_TYPE:
        !          2091:     case ENUMERAL_TYPE:
        !          2092:     case BOOLEAN_TYPE:
        !          2093:     case CHAR_TYPE:
        !          2094:       if ((TREE_CODE (TYPE_MIN_VALUE (t)) != INTEGER_CST
        !          2095:           && contains_placeholder_p (TYPE_MIN_VALUE (t)))
        !          2096:          || (TREE_CODE (TYPE_MAX_VALUE (t)) != INTEGER_CST
        !          2097:              && contains_placeholder_p (TYPE_MAX_VALUE (t))))
        !          2098:        return build_range_type (t,
        !          2099:                                 substitute_in_expr (TYPE_MIN_VALUE (t), f, r),
        !          2100:                                 substitute_in_expr (TYPE_MAX_VALUE (t), f, r));
        !          2101:       return t;
        !          2102: 
        !          2103:     case REAL_TYPE:
        !          2104:       if ((TREE_CODE (TYPE_MIN_VALUE (t)) != INTEGER_CST
        !          2105:           && contains_placeholder_p (TYPE_MIN_VALUE (t)))
        !          2106:          || (TREE_CODE (TYPE_MAX_VALUE (t)) != INTEGER_CST
        !          2107:              && contains_placeholder_p (TYPE_MAX_VALUE (t))))
        !          2108:        {
        !          2109:          t = build_type_copy (t);
        !          2110:          TYPE_MIN_VALUE (t) = substitute_in_expr (TYPE_MIN_VALUE (t), f, r);
        !          2111:          TYPE_MAX_VALUE (t) = substitute_in_expr (TYPE_MAX_VALUE (t), f, r);
        !          2112:        }
        !          2113:       return t;
1.1       root     2114: 
1.1.1.6 ! root     2115:     case COMPLEX_TYPE:
        !          2116:       return build_complex_type (substitute_in_type (TREE_TYPE (t), f, r));
        !          2117: 
        !          2118:     case OFFSET_TYPE:
        !          2119:     case METHOD_TYPE:
        !          2120:     case REFERENCE_TYPE:
        !          2121:     case FILE_TYPE:
        !          2122:     case SET_TYPE:
        !          2123:     case STRING_TYPE:
        !          2124:     case FUNCTION_TYPE:
        !          2125:     case LANG_TYPE:
        !          2126:       /* Don't know how to do these yet.  */
        !          2127:       abort ();
        !          2128: 
        !          2129:     case ARRAY_TYPE:
        !          2130:       t = build_array_type (substitute_in_type (TREE_TYPE (t), f, r),
        !          2131:                            substitute_in_type (TYPE_DOMAIN (t), f, r));
        !          2132:       TYPE_SIZE (t) = 0;
        !          2133:       layout_type (t);
        !          2134:       return t;
        !          2135: 
        !          2136:     case RECORD_TYPE:
        !          2137:     case UNION_TYPE:
        !          2138:     case QUAL_UNION_TYPE:
        !          2139:       {
        !          2140:        tree new = copy_node (t);
        !          2141:        tree field;
        !          2142:        tree last_field = 0;
        !          2143: 
        !          2144:        /* Start out with no fields, make new fields, and chain them
        !          2145:           in.  */
        !          2146: 
        !          2147:        TYPE_FIELDS (new) = 0;
        !          2148:        TYPE_SIZE (new) = 0;
        !          2149: 
        !          2150:        for (field = TYPE_FIELDS (t); field;
        !          2151:             field = TREE_CHAIN (field))
        !          2152:          {
        !          2153:            tree new_field = copy_node (field);
        !          2154: 
        !          2155:            TREE_TYPE (new_field)
        !          2156:              = substitute_in_type (TREE_TYPE (new_field), f, r);
        !          2157: 
        !          2158:            /* If this is an anonymous field and the type of this field is
        !          2159:               a UNION_TYPE or RECORD_TYPE with no elements, ignore it.  If
        !          2160:               the type just has one element, treat that as the field. 
        !          2161:               But don't do this if we are processing a QUAL_UNION_TYPE.  */
        !          2162:            if (TREE_CODE (t) != QUAL_UNION_TYPE && DECL_NAME (new_field) == 0
        !          2163:                && (TREE_CODE (TREE_TYPE (new_field)) == UNION_TYPE
        !          2164:                    || TREE_CODE (TREE_TYPE (new_field)) == RECORD_TYPE))
        !          2165:              {
        !          2166:                if (TYPE_FIELDS (TREE_TYPE (new_field)) == 0)
        !          2167:                  continue;
        !          2168: 
        !          2169:                if (TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (new_field))) == 0)
        !          2170:                  new_field = TYPE_FIELDS (TREE_TYPE (new_field));
        !          2171:              }
        !          2172: 
        !          2173:            DECL_CONTEXT (new_field) = new;
        !          2174:            DECL_SIZE (new_field) = 0;
        !          2175: 
        !          2176:            if (TREE_CODE (t) == QUAL_UNION_TYPE)
        !          2177:              {
        !          2178:                /* Do the substitution inside the qualifier and if we find
        !          2179:                   that this field will not be present, omit it.  */
        !          2180:                DECL_QUALIFIER (new_field)
        !          2181:                  = substitute_in_expr (DECL_QUALIFIER (field), f, r);
        !          2182:                if (integer_zerop (DECL_QUALIFIER (new_field)))
        !          2183:                  continue;
        !          2184:              }
        !          2185: 
        !          2186:            if (last_field == 0)
        !          2187:              TYPE_FIELDS (new) = new_field;
        !          2188:            else
        !          2189:              TREE_CHAIN (last_field) = new_field;
        !          2190: 
        !          2191:            last_field = new_field;
        !          2192: 
        !          2193:            /* If this is a qualified type and this field will always be
        !          2194:               present, we are done.  */
        !          2195:            if (TREE_CODE (t) == QUAL_UNION_TYPE
        !          2196:                && integer_onep (DECL_QUALIFIER (new_field)))
        !          2197:              break;
        !          2198:          }
        !          2199: 
        !          2200:        /* If this used to be a qualified union type, but we now know what
        !          2201:           field will be present, make this a normal union.  */
        !          2202:        if (TREE_CODE (new) == QUAL_UNION_TYPE
        !          2203:            && (TYPE_FIELDS (new) == 0
        !          2204:                || integer_onep (DECL_QUALIFIER (TYPE_FIELDS (new)))))
        !          2205:          TREE_SET_CODE (new, UNION_TYPE);
        !          2206: 
        !          2207:        layout_type (new);
        !          2208:        return new;
        !          2209:       }
        !          2210:     }
        !          2211: }
        !          2212: 
1.1       root     2213: /* Stabilize a reference so that we can use it any number of times
                   2214:    without causing its operands to be evaluated more than once.
1.1.1.6 ! root     2215:    Returns the stabilized reference.  This works by means of save_expr,
        !          2216:    so see the caveats in the comments about save_expr.
1.1       root     2217: 
                   2218:    Also allows conversion expressions whose operands are references.
                   2219:    Any other kind of expression is returned unchanged.  */
                   2220: 
                   2221: tree
                   2222: stabilize_reference (ref)
                   2223:      tree ref;
                   2224: {
                   2225:   register tree result;
                   2226:   register enum tree_code code = TREE_CODE (ref);
                   2227: 
                   2228:   switch (code)
                   2229:     {
                   2230:     case VAR_DECL:
                   2231:     case PARM_DECL:
                   2232:     case RESULT_DECL:
                   2233:       /* No action is needed in this case.  */
                   2234:       return ref;
                   2235: 
                   2236:     case NOP_EXPR:
                   2237:     case CONVERT_EXPR:
                   2238:     case FLOAT_EXPR:
                   2239:     case FIX_TRUNC_EXPR:
                   2240:     case FIX_FLOOR_EXPR:
                   2241:     case FIX_ROUND_EXPR:
                   2242:     case FIX_CEIL_EXPR:
                   2243:       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
                   2244:       break;
                   2245: 
                   2246:     case INDIRECT_REF:
                   2247:       result = build_nt (INDIRECT_REF,
                   2248:                         stabilize_reference_1 (TREE_OPERAND (ref, 0)));
                   2249:       break;
                   2250: 
                   2251:     case COMPONENT_REF:
                   2252:       result = build_nt (COMPONENT_REF,
                   2253:                         stabilize_reference (TREE_OPERAND (ref, 0)),
                   2254:                         TREE_OPERAND (ref, 1));
                   2255:       break;
                   2256: 
                   2257:     case BIT_FIELD_REF:
                   2258:       result = build_nt (BIT_FIELD_REF,
                   2259:                         stabilize_reference (TREE_OPERAND (ref, 0)),
                   2260:                         stabilize_reference_1 (TREE_OPERAND (ref, 1)),
                   2261:                         stabilize_reference_1 (TREE_OPERAND (ref, 2)));
                   2262:       break;
                   2263: 
                   2264:     case ARRAY_REF:
                   2265:       result = build_nt (ARRAY_REF,
                   2266:                         stabilize_reference (TREE_OPERAND (ref, 0)),
                   2267:                         stabilize_reference_1 (TREE_OPERAND (ref, 1)));
                   2268:       break;
                   2269: 
                   2270:       /* If arg isn't a kind of lvalue we recognize, make no change.
                   2271:         Caller should recognize the error for an invalid lvalue.  */
                   2272:     default:
                   2273:       return ref;
                   2274: 
                   2275:     case ERROR_MARK:
                   2276:       return error_mark_node;
                   2277:     }
                   2278: 
                   2279:   TREE_TYPE (result) = TREE_TYPE (ref);
                   2280:   TREE_READONLY (result) = TREE_READONLY (ref);
                   2281:   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
                   2282:   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
                   2283:   TREE_RAISES (result) = TREE_RAISES (ref);
                   2284: 
                   2285:   return result;
                   2286: }
                   2287: 
                   2288: /* Subroutine of stabilize_reference; this is called for subtrees of
                   2289:    references.  Any expression with side-effects must be put in a SAVE_EXPR
                   2290:    to ensure that it is only evaluated once.
                   2291: 
                   2292:    We don't put SAVE_EXPR nodes around everything, because assigning very
                   2293:    simple expressions to temporaries causes us to miss good opportunities
                   2294:    for optimizations.  Among other things, the opportunity to fold in the
                   2295:    addition of a constant into an addressing mode often gets lost, e.g.
                   2296:    "y[i+1] += x;".  In general, we take the approach that we should not make
                   2297:    an assignment unless we are forced into it - i.e., that any non-side effect
                   2298:    operator should be allowed, and that cse should take care of coalescing
                   2299:    multiple utterances of the same expression should that prove fruitful.  */
                   2300: 
                   2301: static tree
                   2302: stabilize_reference_1 (e)
                   2303:      tree e;
                   2304: {
                   2305:   register tree result;
                   2306:   register int length;
                   2307:   register enum tree_code code = TREE_CODE (e);
                   2308: 
1.1.1.3   root     2309:   /* We cannot ignore const expressions because it might be a reference
                   2310:      to a const array but whose index contains side-effects.  But we can
                   2311:      ignore things that are actual constant or that already have been
                   2312:      handled by this function.  */
                   2313: 
                   2314:   if (TREE_CONSTANT (e) || code == SAVE_EXPR)
1.1       root     2315:     return e;
                   2316: 
                   2317:   switch (TREE_CODE_CLASS (code))
                   2318:     {
                   2319:     case 'x':
                   2320:     case 't':
                   2321:     case 'd':
1.1.1.4   root     2322:     case 'b':
1.1       root     2323:     case '<':
                   2324:     case 's':
                   2325:     case 'e':
                   2326:     case 'r':
                   2327:       /* If the expression has side-effects, then encase it in a SAVE_EXPR
                   2328:         so that it will only be evaluated once.  */
                   2329:       /* The reference (r) and comparison (<) classes could be handled as
                   2330:         below, but it is generally faster to only evaluate them once.  */
                   2331:       if (TREE_SIDE_EFFECTS (e))
                   2332:        return save_expr (e);
                   2333:       return e;
                   2334: 
                   2335:     case 'c':
                   2336:       /* Constants need no processing.  In fact, we should never reach
                   2337:         here.  */
                   2338:       return e;
                   2339:       
                   2340:     case '2':
1.1.1.5   root     2341:       /* Division is slow and tends to be compiled with jumps,
                   2342:         especially the division by powers of 2 that is often
                   2343:         found inside of an array reference.  So do it just once.  */
                   2344:       if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR
                   2345:          || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR
                   2346:          || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR
                   2347:          || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR)
                   2348:        return save_expr (e);
1.1       root     2349:       /* Recursively stabilize each operand.  */
                   2350:       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)),
                   2351:                         stabilize_reference_1 (TREE_OPERAND (e, 1)));
                   2352:       break;
                   2353: 
                   2354:     case '1':
                   2355:       /* Recursively stabilize each operand.  */
                   2356:       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)));
                   2357:       break;
                   2358:     }
                   2359:   
                   2360:   TREE_TYPE (result) = TREE_TYPE (e);
                   2361:   TREE_READONLY (result) = TREE_READONLY (e);
                   2362:   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
                   2363:   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
                   2364:   TREE_RAISES (result) = TREE_RAISES (e);
                   2365: 
                   2366:   return result;
                   2367: }
                   2368: 
                   2369: /* Low-level constructors for expressions.  */
                   2370: 
                   2371: /* Build an expression of code CODE, data type TYPE,
                   2372:    and operands as specified by the arguments ARG1 and following arguments.
                   2373:    Expressions and reference nodes can be created this way.
                   2374:    Constants, decls, types and misc nodes cannot be.  */
                   2375: 
                   2376: tree
                   2377: build (va_alist)
                   2378:      va_dcl
                   2379: {
                   2380:   va_list p;
                   2381:   enum tree_code code;
                   2382:   register tree t;
                   2383:   register int length;
                   2384:   register int i;
                   2385: 
                   2386:   va_start (p);
                   2387: 
                   2388:   code = va_arg (p, enum tree_code);
                   2389:   t = make_node (code);
                   2390:   length = tree_code_length[(int) code];
                   2391:   TREE_TYPE (t) = va_arg (p, tree);
                   2392: 
                   2393:   if (length == 2)
                   2394:     {
                   2395:       /* This is equivalent to the loop below, but faster.  */
                   2396:       register tree arg0 = va_arg (p, tree);
                   2397:       register tree arg1 = va_arg (p, tree);
                   2398:       TREE_OPERAND (t, 0) = arg0;
                   2399:       TREE_OPERAND (t, 1) = arg1;
                   2400:       if ((arg0 && TREE_SIDE_EFFECTS (arg0))
                   2401:          || (arg1 && TREE_SIDE_EFFECTS (arg1)))
                   2402:        TREE_SIDE_EFFECTS (t) = 1;
                   2403:       TREE_RAISES (t)
                   2404:        = (arg0 && TREE_RAISES (arg0)) || (arg1 && TREE_RAISES (arg1));
                   2405:     }
                   2406:   else if (length == 1)
                   2407:     {
                   2408:       register tree arg0 = va_arg (p, tree);
                   2409: 
                   2410:       /* Call build1 for this!  */
                   2411:       if (TREE_CODE_CLASS (code) != 's')
                   2412:        abort ();
                   2413:       TREE_OPERAND (t, 0) = arg0;
                   2414:       if (arg0 && TREE_SIDE_EFFECTS (arg0))
                   2415:        TREE_SIDE_EFFECTS (t) = 1;
                   2416:       TREE_RAISES (t) = (arg0 && TREE_RAISES (arg0));
                   2417:     }
                   2418:   else
                   2419:     {
                   2420:       for (i = 0; i < length; i++)
                   2421:        {
                   2422:          register tree operand = va_arg (p, tree);
                   2423:          TREE_OPERAND (t, i) = operand;
                   2424:          if (operand)
                   2425:            {
                   2426:              if (TREE_SIDE_EFFECTS (operand))
                   2427:                TREE_SIDE_EFFECTS (t) = 1;
                   2428:              if (TREE_RAISES (operand))
                   2429:                TREE_RAISES (t) = 1;
                   2430:            }
                   2431:        }
                   2432:     }
                   2433:   va_end (p);
                   2434:   return t;
                   2435: }
                   2436: 
                   2437: /* Same as above, but only builds for unary operators.
                   2438:    Saves lions share of calls to `build'; cuts down use
                   2439:    of varargs, which is expensive for RISC machines.  */
                   2440: tree
                   2441: build1 (code, type, node)
                   2442:      enum tree_code code;
                   2443:      tree type;
                   2444:      tree node;
                   2445: {
                   2446:   register struct obstack *obstack = current_obstack;
                   2447:   register int i, length;
                   2448:   register tree_node_kind kind;
                   2449:   register tree t;
                   2450: 
                   2451: #ifdef GATHER_STATISTICS
                   2452:   if (TREE_CODE_CLASS (code) == 'r')
                   2453:     kind = r_kind;
                   2454:   else
                   2455:     kind = e_kind;
                   2456: #endif
                   2457: 
                   2458:   obstack = expression_obstack;
                   2459:   length = sizeof (struct tree_exp);
                   2460: 
                   2461:   t = (tree) obstack_alloc (obstack, length);
                   2462: 
                   2463: #ifdef GATHER_STATISTICS
                   2464:   tree_node_counts[(int)kind]++;
                   2465:   tree_node_sizes[(int)kind] += length;
                   2466: #endif
                   2467: 
1.1.1.4   root     2468:   for (i = (length / sizeof (int)) - 1; i >= 0; i--)
1.1       root     2469:     ((int *) t)[i] = 0;
1.1.1.4   root     2470: 
                   2471:   TREE_TYPE (t) = type;
1.1       root     2472:   TREE_SET_CODE (t, code);
                   2473: 
                   2474:   if (obstack == &permanent_obstack)
                   2475:     TREE_PERMANENT (t) = 1;
                   2476: 
                   2477:   TREE_OPERAND (t, 0) = node;
                   2478:   if (node)
                   2479:     {
                   2480:       if (TREE_SIDE_EFFECTS (node))
                   2481:        TREE_SIDE_EFFECTS (t) = 1;
                   2482:       if (TREE_RAISES (node))
                   2483:        TREE_RAISES (t) = 1;
                   2484:     }
                   2485: 
                   2486:   return t;
                   2487: }
                   2488: 
                   2489: /* Similar except don't specify the TREE_TYPE
                   2490:    and leave the TREE_SIDE_EFFECTS as 0.
                   2491:    It is permissible for arguments to be null,
                   2492:    or even garbage if their values do not matter.  */
                   2493: 
                   2494: tree
                   2495: build_nt (va_alist)
                   2496:      va_dcl
                   2497: {
                   2498:   va_list p;
                   2499:   register enum tree_code code;
                   2500:   register tree t;
                   2501:   register int length;
                   2502:   register int i;
                   2503: 
                   2504:   va_start (p);
                   2505: 
                   2506:   code = va_arg (p, enum tree_code);
                   2507:   t = make_node (code);
                   2508:   length = tree_code_length[(int) code];
                   2509: 
                   2510:   for (i = 0; i < length; i++)
                   2511:     TREE_OPERAND (t, i) = va_arg (p, tree);
                   2512: 
                   2513:   va_end (p);
                   2514:   return t;
                   2515: }
                   2516: 
                   2517: /* Similar to `build_nt', except we build
                   2518:    on the temp_decl_obstack, regardless.  */
                   2519: 
                   2520: tree
                   2521: build_parse_node (va_alist)
                   2522:      va_dcl
                   2523: {
                   2524:   register struct obstack *ambient_obstack = expression_obstack;
                   2525:   va_list p;
                   2526:   register enum tree_code code;
                   2527:   register tree t;
                   2528:   register int length;
                   2529:   register int i;
                   2530: 
                   2531:   expression_obstack = &temp_decl_obstack;
                   2532: 
                   2533:   va_start (p);
                   2534: 
                   2535:   code = va_arg (p, enum tree_code);
                   2536:   t = make_node (code);
                   2537:   length = tree_code_length[(int) code];
                   2538: 
                   2539:   for (i = 0; i < length; i++)
                   2540:     TREE_OPERAND (t, i) = va_arg (p, tree);
                   2541: 
                   2542:   va_end (p);
                   2543:   expression_obstack = ambient_obstack;
                   2544:   return t;
                   2545: }
                   2546: 
                   2547: #if 0
                   2548: /* Commented out because this wants to be done very
                   2549:    differently.  See cp-lex.c.  */
                   2550: tree
                   2551: build_op_identifier (op1, op2)
                   2552:      tree op1, op2;
                   2553: {
                   2554:   register tree t = make_node (OP_IDENTIFIER);
                   2555:   TREE_PURPOSE (t) = op1;
                   2556:   TREE_VALUE (t) = op2;
                   2557:   return t;
                   2558: }
                   2559: #endif
                   2560: 
                   2561: /* Create a DECL_... node of code CODE, name NAME and data type TYPE.
                   2562:    We do NOT enter this node in any sort of symbol table.
                   2563: 
                   2564:    layout_decl is used to set up the decl's storage layout.
                   2565:    Other slots are initialized to 0 or null pointers.  */
                   2566: 
                   2567: tree
                   2568: build_decl (code, name, type)
                   2569:      enum tree_code code;
                   2570:      tree name, type;
                   2571: {
                   2572:   register tree t;
                   2573: 
                   2574:   t = make_node (code);
                   2575: 
                   2576: /*  if (type == error_mark_node)
                   2577:     type = integer_type_node; */
                   2578: /* That is not done, deliberately, so that having error_mark_node
                   2579:    as the type can suppress useless errors in the use of this variable.  */
                   2580: 
                   2581:   DECL_NAME (t) = name;
                   2582:   DECL_ASSEMBLER_NAME (t) = name;
                   2583:   TREE_TYPE (t) = type;
                   2584: 
                   2585:   if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
                   2586:     layout_decl (t, 0);
                   2587:   else if (code == FUNCTION_DECL)
                   2588:     DECL_MODE (t) = FUNCTION_MODE;
                   2589: 
                   2590:   return t;
                   2591: }
                   2592: 
                   2593: /* BLOCK nodes are used to represent the structure of binding contours
                   2594:    and declarations, once those contours have been exited and their contents
1.1.1.4   root     2595:    compiled.  This information is used for outputting debugging info.  */
1.1       root     2596: 
                   2597: tree
                   2598: build_block (vars, tags, subblocks, supercontext, chain)
                   2599:      tree vars, tags, subblocks, supercontext, chain;
                   2600: {
                   2601:   register tree block = make_node (BLOCK);
                   2602:   BLOCK_VARS (block) = vars;
                   2603:   BLOCK_TYPE_TAGS (block) = tags;
                   2604:   BLOCK_SUBBLOCKS (block) = subblocks;
                   2605:   BLOCK_SUPERCONTEXT (block) = supercontext;
                   2606:   BLOCK_CHAIN (block) = chain;
                   2607:   return block;
                   2608: }
                   2609: 
                   2610: /* Return a type like TYPE except that its TYPE_READONLY is CONSTP
                   2611:    and its TYPE_VOLATILE is VOLATILEP.
                   2612: 
                   2613:    Such variant types already made are recorded so that duplicates
                   2614:    are not made.
                   2615: 
                   2616:    A variant types should never be used as the type of an expression.
                   2617:    Always copy the variant information into the TREE_READONLY
                   2618:    and TREE_THIS_VOLATILE of the expression, and then give the expression
                   2619:    as its type the "main variant", the variant whose TYPE_READONLY
                   2620:    and TYPE_VOLATILE are zero.  Use TYPE_MAIN_VARIANT to find the
                   2621:    main variant.  */
                   2622: 
                   2623: tree
                   2624: build_type_variant (type, constp, volatilep)
                   2625:      tree type;
                   2626:      int constp, volatilep;
                   2627: {
                   2628:   register tree t, m = TYPE_MAIN_VARIANT (type);
                   2629:   register struct obstack *ambient_obstack = current_obstack;
                   2630: 
                   2631:   /* Treat any nonzero argument as 1.  */
                   2632:   constp = !!constp;
                   2633:   volatilep = !!volatilep;
                   2634: 
1.1.1.2   root     2635:   /* If not generating auxiliary info, search the chain of variants to see
1.1       root     2636:      if there is already one there just like the one we need to have.  If so,
                   2637:      use that existing one.
                   2638: 
                   2639:      We don't do this in the case where we are generating aux info because
                   2640:      in that case we want each typedef names to get it's own distinct type
                   2641:      node, even if the type of this new typedef is the same as some other
                   2642:      (existing) type.  */
                   2643: 
                   2644:   if (!flag_gen_aux_info)
                   2645:     for (t = m; t; t = TYPE_NEXT_VARIANT (t))
                   2646:       if (constp == TYPE_READONLY (t) && volatilep == TYPE_VOLATILE (t))
                   2647:         return t;
                   2648: 
                   2649:   /* We need a new one.  */
                   2650: 
1.1.1.6 ! root     2651:   current_obstack = TYPE_OBSTACK (type);
1.1       root     2652:   t = copy_node (type);
1.1.1.6 ! root     2653:   current_obstack = ambient_obstack;
        !          2654: 
1.1       root     2655:   TYPE_READONLY (t) = constp;
                   2656:   TYPE_VOLATILE (t) = volatilep;
                   2657:   TYPE_POINTER_TO (t) = 0;
                   2658:   TYPE_REFERENCE_TO (t) = 0;
                   2659: 
                   2660:   /* Add this type to the chain of variants of TYPE.  */
                   2661:   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
                   2662:   TYPE_NEXT_VARIANT (m) = t;
                   2663: 
                   2664:   return t;
                   2665: }
1.1.1.2   root     2666: 
1.1.1.5   root     2667: /* Give TYPE a new main variant: NEW_MAIN.
                   2668:    This is the right thing to do only when something else
                   2669:    about TYPE is modified in place.  */
                   2670: 
                   2671: tree
                   2672: change_main_variant (type, new_main)
                   2673:      tree type, new_main;
                   2674: {
                   2675:   tree t;
                   2676:   tree omain = TYPE_MAIN_VARIANT (type);
                   2677: 
                   2678:   /* Remove TYPE from the TYPE_NEXT_VARIANT chain of its main variant.  */
                   2679:   if (TYPE_NEXT_VARIANT (omain) == type)
                   2680:     TYPE_NEXT_VARIANT (omain) = TYPE_NEXT_VARIANT (type);
                   2681:   else
                   2682:     for (t = TYPE_NEXT_VARIANT (omain); t && TYPE_NEXT_VARIANT (t);
                   2683:         t = TYPE_NEXT_VARIANT (t))
                   2684:       if (TYPE_NEXT_VARIANT (t) == type)
                   2685:        {
                   2686:          TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (type);
                   2687:          break;
                   2688:        }
                   2689: 
                   2690:   TYPE_MAIN_VARIANT (type) = new_main;
                   2691:   TYPE_NEXT_VARIANT (type) = TYPE_NEXT_VARIANT (new_main);
                   2692:   TYPE_NEXT_VARIANT (new_main) = type;
                   2693: }
                   2694: 
1.1.1.2   root     2695: /* Create a new variant of TYPE, equivalent but distinct.
                   2696:    This is so the caller can modify it.  */
                   2697: 
                   2698: tree
                   2699: build_type_copy (type)
                   2700:      tree type;
                   2701: {
                   2702:   register tree t, m = TYPE_MAIN_VARIANT (type);
                   2703:   register struct obstack *ambient_obstack = current_obstack;
                   2704: 
1.1.1.6 ! root     2705:   current_obstack = TYPE_OBSTACK (type);
1.1.1.2   root     2706:   t = copy_node (type);
1.1.1.6 ! root     2707:   current_obstack = ambient_obstack;
        !          2708: 
1.1.1.2   root     2709:   TYPE_POINTER_TO (t) = 0;
                   2710:   TYPE_REFERENCE_TO (t) = 0;
                   2711: 
                   2712:   /* Add this type to the chain of variants of TYPE.  */
                   2713:   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
                   2714:   TYPE_NEXT_VARIANT (m) = t;
                   2715: 
                   2716:   return t;
                   2717: }
1.1       root     2718: 
                   2719: /* Hashing of types so that we don't make duplicates.
                   2720:    The entry point is `type_hash_canon'.  */
                   2721: 
                   2722: /* Each hash table slot is a bucket containing a chain
                   2723:    of these structures.  */
                   2724: 
                   2725: struct type_hash
                   2726: {
                   2727:   struct type_hash *next;      /* Next structure in the bucket.  */
                   2728:   int hashcode;                        /* Hash code of this type.  */
                   2729:   tree type;                   /* The type recorded here.  */
                   2730: };
                   2731: 
                   2732: /* Now here is the hash table.  When recording a type, it is added
                   2733:    to the slot whose index is the hash code mod the table size.
                   2734:    Note that the hash table is used for several kinds of types
                   2735:    (function types, array types and array index range types, for now).
                   2736:    While all these live in the same table, they are completely independent,
                   2737:    and the hash code is computed differently for each of these.  */
                   2738: 
                   2739: #define TYPE_HASH_SIZE 59
                   2740: struct type_hash *type_hash_table[TYPE_HASH_SIZE];
                   2741: 
                   2742: /* Here is how primitive or already-canonicalized types' hash
                   2743:    codes are made.  */
1.1.1.4   root     2744: #define TYPE_HASH(TYPE) ((HOST_WIDE_INT) (TYPE) & 0777777)
1.1       root     2745: 
                   2746: /* Compute a hash code for a list of types (chain of TREE_LIST nodes
                   2747:    with types in the TREE_VALUE slots), by adding the hash codes
                   2748:    of the individual types.  */
                   2749: 
                   2750: int
                   2751: type_hash_list (list)
                   2752:      tree list;
                   2753: {
                   2754:   register int hashcode;
                   2755:   register tree tail;
                   2756:   for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail))
                   2757:     hashcode += TYPE_HASH (TREE_VALUE (tail));
                   2758:   return hashcode;
                   2759: }
                   2760: 
                   2761: /* Look in the type hash table for a type isomorphic to TYPE.
                   2762:    If one is found, return it.  Otherwise return 0.  */
                   2763: 
                   2764: tree
                   2765: type_hash_lookup (hashcode, type)
                   2766:      int hashcode;
                   2767:      tree type;
                   2768: {
                   2769:   register struct type_hash *h;
                   2770:   for (h = type_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next)
                   2771:     if (h->hashcode == hashcode
                   2772:        && TREE_CODE (h->type) == TREE_CODE (type)
                   2773:        && TREE_TYPE (h->type) == TREE_TYPE (type)
                   2774:        && (TYPE_MAX_VALUE (h->type) == TYPE_MAX_VALUE (type)
                   2775:            || tree_int_cst_equal (TYPE_MAX_VALUE (h->type),
                   2776:                                   TYPE_MAX_VALUE (type)))
                   2777:        && (TYPE_MIN_VALUE (h->type) == TYPE_MIN_VALUE (type)
                   2778:            || tree_int_cst_equal (TYPE_MIN_VALUE (h->type),
                   2779:                                   TYPE_MIN_VALUE (type)))
                   2780:        && (TYPE_DOMAIN (h->type) == TYPE_DOMAIN (type)
                   2781:            || (TYPE_DOMAIN (h->type)
                   2782:                && TREE_CODE (TYPE_DOMAIN (h->type)) == TREE_LIST
                   2783:                && TYPE_DOMAIN (type)
                   2784:                && TREE_CODE (TYPE_DOMAIN (type)) == TREE_LIST
                   2785:                && type_list_equal (TYPE_DOMAIN (h->type), TYPE_DOMAIN (type)))))
                   2786:       return h->type;
                   2787:   return 0;
                   2788: }
                   2789: 
                   2790: /* Add an entry to the type-hash-table
                   2791:    for a type TYPE whose hash code is HASHCODE.  */
                   2792: 
                   2793: void
                   2794: type_hash_add (hashcode, type)
                   2795:      int hashcode;
                   2796:      tree type;
                   2797: {
                   2798:   register struct type_hash *h;
                   2799: 
                   2800:   h = (struct type_hash *) oballoc (sizeof (struct type_hash));
                   2801:   h->hashcode = hashcode;
                   2802:   h->type = type;
                   2803:   h->next = type_hash_table[hashcode % TYPE_HASH_SIZE];
                   2804:   type_hash_table[hashcode % TYPE_HASH_SIZE] = h;
                   2805: }
                   2806: 
                   2807: /* Given TYPE, and HASHCODE its hash code, return the canonical
                   2808:    object for an identical type if one already exists.
                   2809:    Otherwise, return TYPE, and record it as the canonical object
                   2810:    if it is a permanent object.
                   2811: 
                   2812:    To use this function, first create a type of the sort you want.
                   2813:    Then compute its hash code from the fields of the type that
                   2814:    make it different from other similar types.
                   2815:    Then call this function and use the value.
                   2816:    This function frees the type you pass in if it is a duplicate.  */
                   2817: 
                   2818: /* Set to 1 to debug without canonicalization.  Never set by program.  */
                   2819: int debug_no_type_hash = 0;
                   2820: 
                   2821: tree
                   2822: type_hash_canon (hashcode, type)
                   2823:      int hashcode;
                   2824:      tree type;
                   2825: {
                   2826:   tree t1;
                   2827: 
                   2828:   if (debug_no_type_hash)
                   2829:     return type;
                   2830: 
                   2831:   t1 = type_hash_lookup (hashcode, type);
                   2832:   if (t1 != 0)
                   2833:     {
                   2834:       struct obstack *o
                   2835:        = TREE_PERMANENT (type) ? &permanent_obstack : saveable_obstack;
                   2836:       obstack_free (o, type);
                   2837: #ifdef GATHER_STATISTICS
                   2838:       tree_node_counts[(int)t_kind]--;
                   2839:       tree_node_sizes[(int)t_kind] -= sizeof (struct tree_type);
                   2840: #endif
                   2841:       return t1;
                   2842:     }
                   2843: 
                   2844:   /* If this is a new type, record it for later reuse.  */
                   2845:   if (current_obstack == &permanent_obstack)
                   2846:     type_hash_add (hashcode, type);
                   2847: 
                   2848:   return type;
                   2849: }
                   2850: 
                   2851: /* Given two lists of types
                   2852:    (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
                   2853:    return 1 if the lists contain the same types in the same order.
                   2854:    Also, the TREE_PURPOSEs must match.  */
                   2855: 
                   2856: int
                   2857: type_list_equal (l1, l2)
                   2858:      tree l1, l2;
                   2859: {
                   2860:   register tree t1, t2;
                   2861:   for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
                   2862:     {
                   2863:       if (TREE_VALUE (t1) != TREE_VALUE (t2))
                   2864:        return 0;
                   2865:       if (TREE_PURPOSE (t1) != TREE_PURPOSE (t2))
                   2866:        {
                   2867:          int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2));
                   2868:          if (cmp < 0)
                   2869:            abort ();
                   2870:          if (cmp == 0)
                   2871:            return 0;
                   2872:        }
                   2873:     }
                   2874: 
                   2875:   return t1 == t2;
                   2876: }
                   2877: 
                   2878: /* Nonzero if integer constants T1 and T2
                   2879:    represent the same constant value.  */
                   2880: 
                   2881: int
                   2882: tree_int_cst_equal (t1, t2)
                   2883:      tree t1, t2;
                   2884: {
                   2885:   if (t1 == t2)
                   2886:     return 1;
                   2887:   if (t1 == 0 || t2 == 0)
                   2888:     return 0;
                   2889:   if (TREE_CODE (t1) == INTEGER_CST
                   2890:       && TREE_CODE (t2) == INTEGER_CST
                   2891:       && TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
                   2892:       && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2))
                   2893:     return 1;
                   2894:   return 0;
                   2895: }
                   2896: 
                   2897: /* Nonzero if integer constants T1 and T2 represent values that satisfy <.
                   2898:    The precise way of comparison depends on their data type.  */
                   2899: 
                   2900: int
                   2901: tree_int_cst_lt (t1, t2)
                   2902:      tree t1, t2;
                   2903: {
                   2904:   if (t1 == t2)
                   2905:     return 0;
                   2906: 
                   2907:   if (!TREE_UNSIGNED (TREE_TYPE (t1)))
                   2908:     return INT_CST_LT (t1, t2);
                   2909:   return INT_CST_LT_UNSIGNED (t1, t2);
                   2910: }
                   2911: 
                   2912: /* Compare two constructor-element-type constants.  */
                   2913: int
                   2914: simple_cst_list_equal (l1, l2)
                   2915:      tree l1, l2;
                   2916: {
                   2917:   while (l1 != NULL_TREE && l2 != NULL_TREE)
                   2918:     {
                   2919:       int cmp = simple_cst_equal (TREE_VALUE (l1), TREE_VALUE (l2));
                   2920:       if (cmp < 0)
                   2921:        abort ();
                   2922:       if (cmp == 0)
                   2923:        return 0;
                   2924:       l1 = TREE_CHAIN (l1);
                   2925:       l2 = TREE_CHAIN (l2);
                   2926:     }
                   2927:   return (l1 == l2);
                   2928: }
                   2929: 
                   2930: /* Return truthvalue of whether T1 is the same tree structure as T2.
                   2931:    Return 1 if they are the same.
                   2932:    Return 0 if they are understandably different.
                   2933:    Return -1 if either contains tree structure not understood by
                   2934:    this function.  */
                   2935: 
                   2936: int
                   2937: simple_cst_equal (t1, t2)
                   2938:      tree t1, t2;
                   2939: {
                   2940:   register enum tree_code code1, code2;
                   2941:   int cmp;
                   2942: 
                   2943:   if (t1 == t2)
                   2944:     return 1;
                   2945:   if (t1 == 0 || t2 == 0)
                   2946:     return 0;
                   2947: 
                   2948:   code1 = TREE_CODE (t1);
                   2949:   code2 = TREE_CODE (t2);
                   2950: 
                   2951:   if (code1 == NOP_EXPR || code1 == CONVERT_EXPR || code1 == NON_LVALUE_EXPR)
                   2952:     if (code2 == NOP_EXPR || code2 == CONVERT_EXPR || code2 == NON_LVALUE_EXPR)
                   2953:       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   2954:     else
                   2955:       return simple_cst_equal (TREE_OPERAND (t1, 0), t2);
                   2956:   else if (code2 == NOP_EXPR || code2 == CONVERT_EXPR
                   2957:           || code2 == NON_LVALUE_EXPR)
                   2958:     return simple_cst_equal (t1, TREE_OPERAND (t2, 0));
                   2959: 
                   2960:   if (code1 != code2)
                   2961:     return 0;
                   2962: 
                   2963:   switch (code1)
                   2964:     {
                   2965:     case INTEGER_CST:
                   2966:       return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
                   2967:        && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2);
                   2968: 
                   2969:     case REAL_CST:
                   2970:       return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
                   2971: 
                   2972:     case STRING_CST:
                   2973:       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
                   2974:        && !bcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
                   2975:                  TREE_STRING_LENGTH (t1));
                   2976: 
                   2977:     case CONSTRUCTOR:
                   2978:       abort ();
                   2979: 
                   2980:     case SAVE_EXPR:
                   2981:       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   2982: 
                   2983:     case CALL_EXPR:
                   2984:       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   2985:       if (cmp <= 0)
                   2986:        return cmp;
                   2987:       return simple_cst_list_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
                   2988: 
                   2989:     case TARGET_EXPR:
                   2990:       /* Special case: if either target is an unallocated VAR_DECL,
                   2991:         it means that it's going to be unified with whatever the
                   2992:         TARGET_EXPR is really supposed to initialize, so treat it
                   2993:         as being equivalent to anything.  */
                   2994:       if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
                   2995:           && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
                   2996:           && DECL_RTL (TREE_OPERAND (t1, 0)) == 0)
                   2997:          || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
                   2998:              && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
                   2999:              && DECL_RTL (TREE_OPERAND (t2, 0)) == 0))
                   3000:        cmp = 1;
                   3001:       else
                   3002:        cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   3003:       if (cmp <= 0)
                   3004:        return cmp;
                   3005:       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
                   3006: 
                   3007:     case WITH_CLEANUP_EXPR:
                   3008:       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   3009:       if (cmp <= 0)
                   3010:        return cmp;
                   3011:       return simple_cst_equal (TREE_OPERAND (t1, 2), TREE_OPERAND (t1, 2));
                   3012: 
                   3013:     case COMPONENT_REF:
                   3014:       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
                   3015:        return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
                   3016:       return 0;
                   3017: 
                   3018:     case VAR_DECL:
                   3019:     case PARM_DECL:
                   3020:     case CONST_DECL:
                   3021:     case FUNCTION_DECL:
                   3022:       return 0;
1.1.1.5   root     3023:     }
1.1       root     3024: 
1.1.1.5   root     3025:   /* This general rule works for most tree codes.
                   3026:      All exceptions should be handled above.  */
1.1       root     3027: 
1.1.1.5   root     3028:   switch (TREE_CODE_CLASS (code1))
                   3029:     {
                   3030:       int i;
                   3031:     case '1':
                   3032:     case '2':
                   3033:     case '<':
                   3034:     case 'e':
                   3035:     case 'r':
                   3036:     case 's':
                   3037:       cmp = 1;
                   3038:       for (i=0; i<tree_code_length[(int) code1]; ++i)
                   3039:        {
                   3040:          cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
                   3041:          if (cmp <= 0)
                   3042:            return cmp;
                   3043:        }
                   3044:       return cmp;
1.1       root     3045:     }
1.1.1.5   root     3046: 
                   3047:   return -1;
1.1       root     3048: }
                   3049: 
                   3050: /* Constructors for pointer, array and function types.
                   3051:    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
                   3052:    constructed by language-dependent code, not here.)  */
                   3053: 
                   3054: /* Construct, lay out and return the type of pointers to TO_TYPE.
                   3055:    If such a type has already been constructed, reuse it.  */
                   3056: 
                   3057: tree
                   3058: build_pointer_type (to_type)
                   3059:      tree to_type;
                   3060: {
                   3061:   register tree t = TYPE_POINTER_TO (to_type);
                   3062: 
                   3063:   /* First, if we already have a type for pointers to TO_TYPE, use it.  */
                   3064: 
                   3065:   if (t)
                   3066:     return t;
                   3067: 
1.1.1.6 ! root     3068:   /* We need a new one.  Put this in the same obstack as TO_TYPE.   */
        !          3069:   push_obstacks (TYPE_OBSTACK (to_type), TYPE_OBSTACK (to_type));
1.1       root     3070:   t = make_node (POINTER_TYPE);
1.1.1.6 ! root     3071:   pop_obstacks ();
        !          3072: 
1.1       root     3073:   TREE_TYPE (t) = to_type;
                   3074: 
                   3075:   /* Record this type as the pointer to TO_TYPE.  */
                   3076:   TYPE_POINTER_TO (to_type) = t;
                   3077: 
                   3078:   /* Lay out the type.  This function has many callers that are concerned
                   3079:      with expression-construction, and this simplifies them all.
1.1.1.6 ! root     3080:      Also, it guarantees the TYPE_SIZE is in the same obstack as the type.  */
1.1       root     3081:   layout_type (t);
                   3082: 
                   3083:   return t;
                   3084: }
                   3085: 
                   3086: /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
                   3087:    MAXVAL should be the maximum value in the domain
                   3088:    (one less than the length of the array).  */
                   3089: 
                   3090: tree
                   3091: build_index_type (maxval)
                   3092:      tree maxval;
                   3093: {
                   3094:   register tree itype = make_node (INTEGER_TYPE);
                   3095:   TYPE_PRECISION (itype) = TYPE_PRECISION (sizetype);
                   3096:   TYPE_MIN_VALUE (itype) = build_int_2 (0, 0);
                   3097:   TREE_TYPE (TYPE_MIN_VALUE (itype)) = sizetype;
                   3098:   TYPE_MAX_VALUE (itype) = convert (sizetype, maxval);
                   3099:   TYPE_MODE (itype) = TYPE_MODE (sizetype);
                   3100:   TYPE_SIZE (itype) = TYPE_SIZE (sizetype);
                   3101:   TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype);
                   3102:   if (TREE_CODE (maxval) == INTEGER_CST)
                   3103:     {
1.1.1.4   root     3104:       int maxint = (int) TREE_INT_CST_LOW (maxval);
1.1.1.5   root     3105:       /* If the domain should be empty, make sure the maxval
                   3106:         remains -1 and is not spoiled by truncation.  */
                   3107:       if (INT_CST_LT (maxval, integer_zero_node))
                   3108:        {
                   3109:          TYPE_MAX_VALUE (itype) = build_int_2 (-1, -1);
                   3110:          TREE_TYPE (TYPE_MAX_VALUE (itype)) = sizetype;
                   3111:        }
1.1.1.4   root     3112:       return type_hash_canon (maxint < 0 ? ~maxint : maxint, itype);
1.1       root     3113:     }
                   3114:   else
                   3115:     return itype;
                   3116: }
                   3117: 
1.1.1.5   root     3118: /* Create a range of some discrete type TYPE (an INTEGER_TYPE,
                   3119:    ENUMERAL_TYPE, BOOLEAN_TYPE, or CHAR_TYPE), with
                   3120:    low bound LOWVAL and high bound HIGHVAL.
                   3121:    if TYPE==NULL_TREE, sizetype is used. */
1.1       root     3122: 
                   3123: tree
1.1.1.5   root     3124: build_range_type (type, lowval, highval)
                   3125:      tree type, lowval, highval;
1.1       root     3126: {
                   3127:   register tree itype = make_node (INTEGER_TYPE);
1.1.1.5   root     3128:   TREE_TYPE (itype) = type;
                   3129:   if (type == NULL_TREE)
                   3130:     type = sizetype;
                   3131:   TYPE_PRECISION (itype) = TYPE_PRECISION (type);
                   3132:   TYPE_MIN_VALUE (itype) = convert (type, lowval);
                   3133:   TYPE_MAX_VALUE (itype) = convert (type, highval);
                   3134:   TYPE_MODE (itype) = TYPE_MODE (type);
                   3135:   TYPE_SIZE (itype) = TYPE_SIZE (type);
                   3136:   TYPE_ALIGN (itype) = TYPE_ALIGN (type);
1.1       root     3137:   if ((TREE_CODE (lowval) == INTEGER_CST)
                   3138:       && (TREE_CODE (highval) == INTEGER_CST))
                   3139:     {
1.1.1.4   root     3140:       HOST_WIDE_INT highint = TREE_INT_CST_LOW (highval);
                   3141:       HOST_WIDE_INT lowint = TREE_INT_CST_LOW (lowval);
                   3142:       int maxint = (int) (highint - lowint);
                   3143:       return type_hash_canon (maxint < 0 ? ~maxint : maxint, itype);
1.1       root     3144:     }
                   3145:   else
                   3146:     return itype;
                   3147: }
                   3148: 
1.1.1.5   root     3149: /* Just like build_index_type, but takes lowval and highval instead
                   3150:    of just highval (maxval). */
                   3151: 
                   3152: tree
                   3153: build_index_2_type (lowval,highval)
                   3154:      tree lowval, highval;
                   3155: {
                   3156:   return build_range_type (NULL_TREE, lowval, highval);
                   3157: }
                   3158: 
1.1       root     3159: /* Return nonzero iff ITYPE1 and ITYPE2 are equal (in the LISP sense).
                   3160:    Needed because when index types are not hashed, equal index types
                   3161:    built at different times appear distinct, even though structurally,
                   3162:    they are not.  */
                   3163: 
                   3164: int
                   3165: index_type_equal (itype1, itype2)
                   3166:      tree itype1, itype2;
                   3167: {
                   3168:   if (TREE_CODE (itype1) != TREE_CODE (itype2))
                   3169:     return 0;
                   3170:   if (TREE_CODE (itype1) == INTEGER_TYPE)
                   3171:     {
                   3172:       if (TYPE_PRECISION (itype1) != TYPE_PRECISION (itype2)
                   3173:          || TYPE_MODE (itype1) != TYPE_MODE (itype2)
                   3174:          || ! simple_cst_equal (TYPE_SIZE (itype1), TYPE_SIZE (itype2))
                   3175:          || TYPE_ALIGN (itype1) != TYPE_ALIGN (itype2))
                   3176:        return 0;
                   3177:       if (simple_cst_equal (TYPE_MIN_VALUE (itype1), TYPE_MIN_VALUE (itype2))
                   3178:          && simple_cst_equal (TYPE_MAX_VALUE (itype1), TYPE_MAX_VALUE (itype2)))
                   3179:        return 1;
                   3180:     }
                   3181:   return 0;
                   3182: }
                   3183: 
                   3184: /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
                   3185:    and number of elements specified by the range of values of INDEX_TYPE.
                   3186:    If such a type has already been constructed, reuse it.  */
                   3187: 
                   3188: tree
                   3189: build_array_type (elt_type, index_type)
                   3190:      tree elt_type, index_type;
                   3191: {
                   3192:   register tree t;
                   3193:   int hashcode;
                   3194: 
                   3195:   if (TREE_CODE (elt_type) == FUNCTION_TYPE)
                   3196:     {
                   3197:       error ("arrays of functions are not meaningful");
                   3198:       elt_type = integer_type_node;
                   3199:     }
                   3200: 
                   3201:   /* Make sure TYPE_POINTER_TO (elt_type) is filled in.  */
                   3202:   build_pointer_type (elt_type);
                   3203: 
                   3204:   /* Allocate the array after the pointer type,
                   3205:      in case we free it in type_hash_canon.  */
                   3206:   t = make_node (ARRAY_TYPE);
                   3207:   TREE_TYPE (t) = elt_type;
                   3208:   TYPE_DOMAIN (t) = index_type;
                   3209: 
                   3210:   if (index_type == 0)
1.1.1.5   root     3211:     {
                   3212:       return t;
                   3213:     }
1.1       root     3214: 
                   3215:   hashcode = TYPE_HASH (elt_type) + TYPE_HASH (index_type);
                   3216:   t = type_hash_canon (hashcode, t);
                   3217: 
1.1.1.5   root     3218: #if 0 /* This led to crashes, because it could put a temporary node
                   3219:         on the TYPE_NEXT_VARIANT chain of a permanent one.  */
                   3220:   /* The main variant of an array type should always
                   3221:      be an array whose element type is the main variant.  */
                   3222:   if (elt_type != TYPE_MAIN_VARIANT (elt_type))
                   3223:     change_main_variant (t, build_array_type (TYPE_MAIN_VARIANT (elt_type),
                   3224:                                              index_type));
                   3225: #endif
                   3226: 
1.1       root     3227:   if (TYPE_SIZE (t) == 0)
                   3228:     layout_type (t);
                   3229:   return t;
                   3230: }
                   3231: 
                   3232: /* Construct, lay out and return
                   3233:    the type of functions returning type VALUE_TYPE
                   3234:    given arguments of types ARG_TYPES.
                   3235:    ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
                   3236:    are data type nodes for the arguments of the function.
                   3237:    If such a type has already been constructed, reuse it.  */
                   3238: 
                   3239: tree
                   3240: build_function_type (value_type, arg_types)
                   3241:      tree value_type, arg_types;
                   3242: {
                   3243:   register tree t;
                   3244:   int hashcode;
                   3245: 
1.1.1.6 ! root     3246:   if (TREE_CODE (value_type) == FUNCTION_TYPE)
1.1       root     3247:     {
1.1.1.6 ! root     3248:       error ("function return type cannot be function");
1.1       root     3249:       value_type = integer_type_node;
                   3250:     }
                   3251: 
                   3252:   /* Make a node of the sort we want.  */
                   3253:   t = make_node (FUNCTION_TYPE);
                   3254:   TREE_TYPE (t) = value_type;
                   3255:   TYPE_ARG_TYPES (t) = arg_types;
                   3256: 
                   3257:   /* If we already have such a type, use the old one and free this one.  */
                   3258:   hashcode = TYPE_HASH (value_type) + type_hash_list (arg_types);
                   3259:   t = type_hash_canon (hashcode, t);
                   3260: 
                   3261:   if (TYPE_SIZE (t) == 0)
                   3262:     layout_type (t);
                   3263:   return t;
                   3264: }
                   3265: 
                   3266: /* Build the node for the type of references-to-TO_TYPE.  */
                   3267: 
                   3268: tree
                   3269: build_reference_type (to_type)
                   3270:      tree to_type;
                   3271: {
                   3272:   register tree t = TYPE_REFERENCE_TO (to_type);
                   3273:   register struct obstack *ambient_obstack = current_obstack;
                   3274:   register struct obstack *ambient_saveable_obstack = saveable_obstack;
                   3275: 
                   3276:   /* First, if we already have a type for pointers to TO_TYPE, use it.  */
                   3277: 
                   3278:   if (t)
                   3279:     return t;
                   3280: 
                   3281:   /* We need a new one.  If TO_TYPE is permanent, make this permanent too.  */
                   3282:   if (TREE_PERMANENT (to_type))
                   3283:     {
                   3284:       current_obstack = &permanent_obstack;
                   3285:       saveable_obstack = &permanent_obstack;
                   3286:     }
                   3287: 
                   3288:   t = make_node (REFERENCE_TYPE);
                   3289:   TREE_TYPE (t) = to_type;
                   3290: 
                   3291:   /* Record this type as the pointer to TO_TYPE.  */
                   3292:   TYPE_REFERENCE_TO (to_type) = t;
                   3293: 
                   3294:   layout_type (t);
                   3295: 
                   3296:   current_obstack = ambient_obstack;
                   3297:   saveable_obstack = ambient_saveable_obstack;
                   3298:   return t;
                   3299: }
                   3300: 
                   3301: /* Construct, lay out and return the type of methods belonging to class
                   3302:    BASETYPE and whose arguments and values are described by TYPE.
                   3303:    If that type exists already, reuse it.
                   3304:    TYPE must be a FUNCTION_TYPE node.  */
                   3305: 
                   3306: tree
                   3307: build_method_type (basetype, type)
                   3308:      tree basetype, type;
                   3309: {
                   3310:   register tree t;
                   3311:   int hashcode;
                   3312: 
                   3313:   /* Make a node of the sort we want.  */
                   3314:   t = make_node (METHOD_TYPE);
                   3315: 
                   3316:   if (TREE_CODE (type) != FUNCTION_TYPE)
                   3317:     abort ();
                   3318: 
                   3319:   TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
                   3320:   TREE_TYPE (t) = TREE_TYPE (type);
                   3321: 
                   3322:   /* The actual arglist for this function includes a "hidden" argument
                   3323:      which is "this".  Put it into the list of argument types.  */
                   3324: 
                   3325:   TYPE_ARG_TYPES (t)
1.1.1.4   root     3326:     = tree_cons (NULL_TREE,
                   3327:                 build_pointer_type (basetype), TYPE_ARG_TYPES (type));
1.1       root     3328: 
                   3329:   /* If we already have such a type, use the old one and free this one.  */
                   3330:   hashcode = TYPE_HASH (basetype) + TYPE_HASH (type);
                   3331:   t = type_hash_canon (hashcode, t);
                   3332: 
                   3333:   if (TYPE_SIZE (t) == 0)
                   3334:     layout_type (t);
                   3335: 
                   3336:   return t;
                   3337: }
                   3338: 
1.1.1.5   root     3339: /* Construct, lay out and return the type of offsets to a value
                   3340:    of type TYPE, within an object of type BASETYPE.
                   3341:    If a suitable offset type exists already, reuse it.  */
1.1       root     3342: 
                   3343: tree
                   3344: build_offset_type (basetype, type)
                   3345:      tree basetype, type;
                   3346: {
                   3347:   register tree t;
                   3348:   int hashcode;
                   3349: 
                   3350:   /* Make a node of the sort we want.  */
                   3351:   t = make_node (OFFSET_TYPE);
                   3352: 
                   3353:   TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
                   3354:   TREE_TYPE (t) = type;
                   3355: 
                   3356:   /* If we already have such a type, use the old one and free this one.  */
                   3357:   hashcode = TYPE_HASH (basetype) + TYPE_HASH (type);
                   3358:   t = type_hash_canon (hashcode, t);
                   3359: 
                   3360:   if (TYPE_SIZE (t) == 0)
                   3361:     layout_type (t);
                   3362: 
                   3363:   return t;
                   3364: }
                   3365: 
                   3366: /* Create a complex type whose components are COMPONENT_TYPE.  */
                   3367: 
                   3368: tree
                   3369: build_complex_type (component_type)
                   3370:      tree component_type;
                   3371: {
                   3372:   register tree t;
                   3373:   int hashcode;
                   3374: 
                   3375:   /* Make a node of the sort we want.  */
                   3376:   t = make_node (COMPLEX_TYPE);
                   3377: 
                   3378:   TREE_TYPE (t) = TYPE_MAIN_VARIANT (component_type);
                   3379:   TYPE_VOLATILE (t) = TYPE_VOLATILE (component_type);
                   3380:   TYPE_READONLY (t) = TYPE_READONLY (component_type);
                   3381: 
                   3382:   /* If we already have such a type, use the old one and free this one.  */
                   3383:   hashcode = TYPE_HASH (component_type);
                   3384:   t = type_hash_canon (hashcode, t);
                   3385: 
                   3386:   if (TYPE_SIZE (t) == 0)
                   3387:     layout_type (t);
                   3388: 
                   3389:   return t;
                   3390: }
                   3391: 
                   3392: /* Return OP, stripped of any conversions to wider types as much as is safe.
                   3393:    Converting the value back to OP's type makes a value equivalent to OP.
                   3394: 
                   3395:    If FOR_TYPE is nonzero, we return a value which, if converted to
                   3396:    type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
                   3397: 
                   3398:    If FOR_TYPE is nonzero, unaligned bit-field references may be changed to the
                   3399:    narrowest type that can hold the value, even if they don't exactly fit.
                   3400:    Otherwise, bit-field references are changed to a narrower type
                   3401:    only if they can be fetched directly from memory in that type.
                   3402: 
                   3403:    OP must have integer, real or enumeral type.  Pointers are not allowed!
                   3404: 
                   3405:    There are some cases where the obvious value we could return
                   3406:    would regenerate to OP if converted to OP's type, 
                   3407:    but would not extend like OP to wider types.
                   3408:    If FOR_TYPE indicates such extension is contemplated, we eschew such values.
                   3409:    For example, if OP is (unsigned short)(signed char)-1,
                   3410:    we avoid returning (signed char)-1 if FOR_TYPE is int,
                   3411:    even though extending that to an unsigned short would regenerate OP,
                   3412:    since the result of extending (signed char)-1 to (int)
                   3413:    is different from (int) OP.  */
                   3414: 
                   3415: tree
                   3416: get_unwidened (op, for_type)
                   3417:      register tree op;
                   3418:      tree for_type;
                   3419: {
                   3420:   /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension.  */
                   3421:   /* TYPE_PRECISION is safe in place of type_precision since
                   3422:      pointer types are not allowed.  */
                   3423:   register tree type = TREE_TYPE (op);
                   3424:   register unsigned final_prec
                   3425:     = TYPE_PRECISION (for_type != 0 ? for_type : type);
                   3426:   register int uns
                   3427:     = (for_type != 0 && for_type != type
                   3428:        && final_prec > TYPE_PRECISION (type)
                   3429:        && TREE_UNSIGNED (type));
                   3430:   register tree win = op;
                   3431: 
                   3432:   while (TREE_CODE (op) == NOP_EXPR)
                   3433:     {
                   3434:       register int bitschange
                   3435:        = TYPE_PRECISION (TREE_TYPE (op))
                   3436:          - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
                   3437: 
                   3438:       /* Truncations are many-one so cannot be removed.
                   3439:         Unless we are later going to truncate down even farther.  */
                   3440:       if (bitschange < 0
                   3441:          && final_prec > TYPE_PRECISION (TREE_TYPE (op)))
                   3442:        break;
                   3443: 
                   3444:       /* See what's inside this conversion.  If we decide to strip it,
                   3445:         we will set WIN.  */
                   3446:       op = TREE_OPERAND (op, 0);
                   3447: 
                   3448:       /* If we have not stripped any zero-extensions (uns is 0),
                   3449:         we can strip any kind of extension.
                   3450:         If we have previously stripped a zero-extension,
                   3451:         only zero-extensions can safely be stripped.
                   3452:         Any extension can be stripped if the bits it would produce
                   3453:         are all going to be discarded later by truncating to FOR_TYPE.  */
                   3454: 
                   3455:       if (bitschange > 0)
                   3456:        {
                   3457:          if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op)))
                   3458:            win = op;
                   3459:          /* TREE_UNSIGNED says whether this is a zero-extension.
                   3460:             Let's avoid computing it if it does not affect WIN
                   3461:             and if UNS will not be needed again.  */
                   3462:          if ((uns || TREE_CODE (op) == NOP_EXPR)
                   3463:              && TREE_UNSIGNED (TREE_TYPE (op)))
                   3464:            {
                   3465:              uns = 1;
                   3466:              win = op;
                   3467:            }
                   3468:        }
                   3469:     }
                   3470: 
                   3471:   if (TREE_CODE (op) == COMPONENT_REF
                   3472:       /* Since type_for_size always gives an integer type.  */
                   3473:       && TREE_CODE (type) != REAL_TYPE)
                   3474:     {
                   3475:       unsigned innerprec = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1)));
                   3476:       type = type_for_size (innerprec, TREE_UNSIGNED (TREE_OPERAND (op, 1)));
                   3477: 
                   3478:       /* We can get this structure field in the narrowest type it fits in.
                   3479:         If FOR_TYPE is 0, do this only for a field that matches the
                   3480:         narrower type exactly and is aligned for it
                   3481:         The resulting extension to its nominal type (a fullword type)
                   3482:         must fit the same conditions as for other extensions.  */
                   3483: 
                   3484:       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
                   3485:          && (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
                   3486:          && (! uns || final_prec <= innerprec
                   3487:              || TREE_UNSIGNED (TREE_OPERAND (op, 1)))
                   3488:          && type != 0)
                   3489:        {
                   3490:          win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0),
                   3491:                       TREE_OPERAND (op, 1));
                   3492:          TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
                   3493:          TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
                   3494:          TREE_RAISES (win) = TREE_RAISES (op);
                   3495:        }
                   3496:     }
                   3497:   return win;
                   3498: }
                   3499: 
                   3500: /* Return OP or a simpler expression for a narrower value
                   3501:    which can be sign-extended or zero-extended to give back OP.
                   3502:    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
                   3503:    or 0 if the value should be sign-extended.  */
                   3504: 
                   3505: tree
                   3506: get_narrower (op, unsignedp_ptr)
                   3507:      register tree op;
                   3508:      int *unsignedp_ptr;
                   3509: {
                   3510:   register int uns = 0;
                   3511:   int first = 1;
                   3512:   register tree win = op;
                   3513: 
                   3514:   while (TREE_CODE (op) == NOP_EXPR)
                   3515:     {
                   3516:       register int bitschange
                   3517:        = TYPE_PRECISION (TREE_TYPE (op))
                   3518:          - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
                   3519: 
                   3520:       /* Truncations are many-one so cannot be removed.  */
                   3521:       if (bitschange < 0)
                   3522:        break;
                   3523: 
                   3524:       /* See what's inside this conversion.  If we decide to strip it,
                   3525:         we will set WIN.  */
                   3526:       op = TREE_OPERAND (op, 0);
                   3527: 
                   3528:       if (bitschange > 0)
                   3529:        {
                   3530:          /* An extension: the outermost one can be stripped,
                   3531:             but remember whether it is zero or sign extension.  */
                   3532:          if (first)
                   3533:            uns = TREE_UNSIGNED (TREE_TYPE (op));
                   3534:          /* Otherwise, if a sign extension has been stripped,
                   3535:             only sign extensions can now be stripped;
                   3536:             if a zero extension has been stripped, only zero-extensions.  */
                   3537:          else if (uns != TREE_UNSIGNED (TREE_TYPE (op)))
                   3538:            break;
                   3539:          first = 0;
                   3540:        }
1.1.1.6 ! root     3541:       else /* bitschange == 0 */
        !          3542:        {
        !          3543:          /* A change in nominal type can always be stripped, but we must
        !          3544:             preserve the unsignedness.  */
        !          3545:          if (first)
        !          3546:            uns = TREE_UNSIGNED (TREE_TYPE (op));
        !          3547:          first = 0;
        !          3548:        }
1.1       root     3549: 
                   3550:       win = op;
                   3551:     }
                   3552: 
                   3553:   if (TREE_CODE (op) == COMPONENT_REF
                   3554:       /* Since type_for_size always gives an integer type.  */
                   3555:       && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE)
                   3556:     {
                   3557:       unsigned innerprec = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1)));
                   3558:       tree type = type_for_size (innerprec, TREE_UNSIGNED (op));
                   3559: 
                   3560:       /* We can get this structure field in a narrower type that fits it,
                   3561:         but the resulting extension to its nominal type (a fullword type)
                   3562:         must satisfy the same conditions as for other extensions.
                   3563: 
                   3564:         Do this only for fields that are aligned (not bit-fields),
                   3565:         because when bit-field insns will be used there is no
                   3566:         advantage in doing this.  */
                   3567: 
                   3568:       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
                   3569:          && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
                   3570:          && (first || uns == TREE_UNSIGNED (TREE_OPERAND (op, 1)))
                   3571:          && type != 0)
                   3572:        {
                   3573:          if (first)
                   3574:            uns = TREE_UNSIGNED (TREE_OPERAND (op, 1));
                   3575:          win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0),
                   3576:                       TREE_OPERAND (op, 1));
                   3577:          TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
                   3578:          TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
                   3579:          TREE_RAISES (win) = TREE_RAISES (op);
                   3580:        }
                   3581:     }
                   3582:   *unsignedp_ptr = uns;
                   3583:   return win;
                   3584: }
                   3585: 
                   3586: /* Return the precision of a type, for arithmetic purposes.
                   3587:    Supports all types on which arithmetic is possible
                   3588:    (including pointer types).
                   3589:    It's not clear yet what will be right for complex types.  */
                   3590: 
                   3591: int
                   3592: type_precision (type)
                   3593:      register tree type;
                   3594: {
                   3595:   return ((TREE_CODE (type) == INTEGER_TYPE
                   3596:           || TREE_CODE (type) == ENUMERAL_TYPE
                   3597:           || TREE_CODE (type) == REAL_TYPE)
                   3598:          ? TYPE_PRECISION (type) : POINTER_SIZE);
                   3599: }
                   3600: 
                   3601: /* Nonzero if integer constant C has a value that is permissible
                   3602:    for type TYPE (an INTEGER_TYPE).  */
                   3603: 
                   3604: int
                   3605: int_fits_type_p (c, type)
                   3606:      tree c, type;
                   3607: {
                   3608:   if (TREE_UNSIGNED (type))
                   3609:     return (!INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c)
1.1.1.4   root     3610:            && !INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type))
                   3611:            && (TREE_INT_CST_HIGH (c) >= 0 || TREE_UNSIGNED (TREE_TYPE (c))));
1.1       root     3612:   else
                   3613:     return (!INT_CST_LT (TYPE_MAX_VALUE (type), c)
1.1.1.4   root     3614:            && !INT_CST_LT (c, TYPE_MIN_VALUE (type))
                   3615:            && (TREE_INT_CST_HIGH (c) >= 0 || !TREE_UNSIGNED (TREE_TYPE (c))));
1.1       root     3616: }
                   3617: 
1.1.1.3   root     3618: /* Return the innermost context enclosing DECL that is
1.1       root     3619:    a FUNCTION_DECL, or zero if none.  */
                   3620: 
                   3621: tree
1.1.1.3   root     3622: decl_function_context (decl)
                   3623:      tree decl;
1.1       root     3624: {
                   3625:   tree context;
                   3626: 
1.1.1.3   root     3627:   if (TREE_CODE (decl) == ERROR_MARK)
1.1       root     3628:     return 0;
                   3629: 
1.1.1.3   root     3630:   if (TREE_CODE (decl) == SAVE_EXPR)
                   3631:     context = SAVE_EXPR_CONTEXT (decl);
1.1       root     3632:   else
1.1.1.3   root     3633:     context = DECL_CONTEXT (decl);
1.1       root     3634: 
                   3635:   while (context && TREE_CODE (context) != FUNCTION_DECL)
                   3636:     {
                   3637:       if (TREE_CODE (context) == RECORD_TYPE
                   3638:          || TREE_CODE (context) == UNION_TYPE)
                   3639:        context = TYPE_CONTEXT (context);
                   3640:       else if (TREE_CODE (context) == TYPE_DECL)
                   3641:        context = DECL_CONTEXT (context);
                   3642:       else if (TREE_CODE (context) == BLOCK)
                   3643:        context = BLOCK_SUPERCONTEXT (context);
                   3644:       else
                   3645:        /* Unhandled CONTEXT !?  */
                   3646:        abort ();
                   3647:     }
                   3648: 
                   3649:   return context;
                   3650: }
                   3651: 
1.1.1.3   root     3652: /* Return the innermost context enclosing DECL that is
1.1.1.6 ! root     3653:    a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
1.1       root     3654:    TYPE_DECLs and FUNCTION_DECLs are transparent to this function.  */
                   3655: 
                   3656: tree
1.1.1.3   root     3657: decl_type_context (decl)
                   3658:      tree decl;
1.1       root     3659: {
1.1.1.3   root     3660:   tree context = DECL_CONTEXT (decl);
1.1       root     3661: 
                   3662:   while (context)
                   3663:     {
                   3664:       if (TREE_CODE (context) == RECORD_TYPE
1.1.1.6 ! root     3665:          || TREE_CODE (context) == UNION_TYPE
        !          3666:          || TREE_CODE (context) == QUAL_UNION_TYPE)
1.1       root     3667:        return context;
                   3668:       if (TREE_CODE (context) == TYPE_DECL
                   3669:          || TREE_CODE (context) == FUNCTION_DECL)
                   3670:        context = DECL_CONTEXT (context);
                   3671:       else if (TREE_CODE (context) == BLOCK)
                   3672:        context = BLOCK_SUPERCONTEXT (context);
                   3673:       else
                   3674:        /* Unhandled CONTEXT!?  */
                   3675:        abort ();
                   3676:     }
                   3677:   return NULL_TREE;
                   3678: }
                   3679: 
                   3680: void
                   3681: print_obstack_statistics (str, o)
                   3682:      char *str;
                   3683:      struct obstack *o;
                   3684: {
                   3685:   struct _obstack_chunk *chunk = o->chunk;
                   3686:   int n_chunks = 0;
                   3687:   int n_alloc = 0;
                   3688: 
                   3689:   while (chunk)
                   3690:     {
                   3691:       n_chunks += 1;
                   3692:       n_alloc += chunk->limit - &chunk->contents[0];
                   3693:       chunk = chunk->prev;
                   3694:     }
                   3695:   fprintf (stderr, "obstack %s: %d bytes, %d chunks\n",
                   3696:           str, n_alloc, n_chunks);
                   3697: }
                   3698: void
                   3699: dump_tree_statistics ()
                   3700: {
                   3701:   int i;
                   3702:   int total_nodes, total_bytes;
                   3703: 
                   3704:   fprintf (stderr, "\n??? tree nodes created\n\n");
                   3705: #ifdef GATHER_STATISTICS
                   3706:   fprintf (stderr, "Kind                  Nodes     Bytes\n");
                   3707:   fprintf (stderr, "-------------------------------------\n");
                   3708:   total_nodes = total_bytes = 0;
                   3709:   for (i = 0; i < (int) all_kinds; i++)
                   3710:     {
                   3711:       fprintf (stderr, "%-20s %6d %9d\n", tree_node_kind_names[i],
                   3712:               tree_node_counts[i], tree_node_sizes[i]);
                   3713:       total_nodes += tree_node_counts[i];
                   3714:       total_bytes += tree_node_sizes[i];
                   3715:     }
                   3716:   fprintf (stderr, "%-20s        %9d\n", "identifier names", id_string_size);
                   3717:   fprintf (stderr, "-------------------------------------\n");
                   3718:   fprintf (stderr, "%-20s %6d %9d\n", "Total", total_nodes, total_bytes);
                   3719:   fprintf (stderr, "-------------------------------------\n");
                   3720: #else
                   3721:   fprintf (stderr, "(No per-node statistics)\n");
                   3722: #endif
                   3723:   print_lang_statistics ();
                   3724: }
1.1.1.6 ! root     3725: 
        !          3726: #define FILE_FUNCTION_PREFIX_LEN 9
        !          3727: 
        !          3728: #ifndef NO_DOLLAR_IN_LABEL
        !          3729: #define FILE_FUNCTION_FORMAT "_GLOBAL_$D$%s"
        !          3730: #else /* NO_DOLLAR_IN_LABEL */
        !          3731: #ifndef NO_DOT_IN_LABEL
        !          3732: #define FILE_FUNCTION_FORMAT "_GLOBAL_.D.%s"
        !          3733: #else /* NO_DOT_IN_LABEL */
        !          3734: #define FILE_FUNCTION_FORMAT "__GLOBAL_D_%s"
        !          3735: #endif /* NO_DOT_IN_LABEL */
        !          3736: #endif /* NO_DOLLAR_IN_LABEL */
        !          3737: 
        !          3738: extern char * first_global_object_name;
        !          3739: 
        !          3740: /* If KIND=='I', return a suitable global initializer (constructor) name.
        !          3741:    If KIND=='D', return a suitable global clean-up (destructor) name. */
        !          3742: 
        !          3743: tree
        !          3744: get_file_function_name (kind)
        !          3745:      int kind;
        !          3746: {
        !          3747:   char *buf;
        !          3748:   register char *p;
        !          3749: 
        !          3750:   if (first_global_object_name)
        !          3751:     p = first_global_object_name;
        !          3752:   else if (main_input_filename)
        !          3753:     p = main_input_filename;
        !          3754:   else
        !          3755:     p = input_filename;
        !          3756: 
        !          3757:   buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p));
        !          3758: 
        !          3759:   /* Set up the name of the file-level functions we may need.  */
        !          3760:   /* Use a global object (which is already required to be unique over
        !          3761:      the program) rather than the file name (which imposes extra
        !          3762:      constraints).  -- [email protected], 10 Jan 1990.  */
        !          3763:   sprintf (buf, FILE_FUNCTION_FORMAT, p);
        !          3764: 
        !          3765:   /* Don't need to pull wierd characters out of global names.  */
        !          3766:   if (p != first_global_object_name)
        !          3767:     {
        !          3768:       for (p = buf+11; *p; p++)
        !          3769:        if (! ((*p >= '0' && *p <= '9')
        !          3770: #if 0 /* we always want labels, which are valid C++ identifiers (+ `$') */
        !          3771: #ifndef ASM_IDENTIFY_GCC       /* this is required if `.' is invalid -- k. raeburn */
        !          3772:               || *p == '.'
        !          3773: #endif
        !          3774: #endif
        !          3775: #ifndef NO_DOLLAR_IN_LABEL     /* this for `$'; unlikely, but... -- kr */
        !          3776:               || *p == '$'
        !          3777: #endif
        !          3778: #ifndef NO_DOT_IN_LABEL                /* this for `.'; unlikely, but... */
        !          3779:               || *p == '.'
        !          3780: #endif
        !          3781:               || (*p >= 'A' && *p <= 'Z')
        !          3782:               || (*p >= 'a' && *p <= 'z')))
        !          3783:          *p = '_';
        !          3784:     }
        !          3785: 
        !          3786:   buf[FILE_FUNCTION_PREFIX_LEN] = kind;
        !          3787: 
        !          3788:   return get_identifier (buf);
        !          3789: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.