• Main Page
  • Modules
  • Data Types
  • Files

osprey-gcc/gcc/tree.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006, 2007. QLogic Corporation. All Rights Reserved.
00003  */
00004 
00005 /* Language-independent node constructors for parse phase of GNU compiler.
00006    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
00007    1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
00008 
00009 This file is part of GCC.
00010 
00011 GCC is free software; you can redistribute it and/or modify it under
00012 the terms of the GNU General Public License as published by the Free
00013 Software Foundation; either version 2, or (at your option) any later
00014 version.
00015 
00016 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
00017 WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019 for more details.
00020 
00021 You should have received a copy of the GNU General Public License
00022 along with GCC; see the file COPYING.  If not, write to the Free
00023 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
00024 02111-1307, USA.  */
00025 
00026 /* This file contains the low level primitives for operating on tree nodes,
00027    including allocation, list operations, interning of identifiers,
00028    construction of data type nodes and statement nodes,
00029    and construction of type conversion nodes.  It also contains
00030    tables index by tree code that describe how to take apart
00031    nodes of that code.
00032 
00033    It is intended to be language-independent, but occasionally
00034    calls language-dependent routines defined (for C) in typecheck.c.  */
00035 
00036 #include "config.h"
00037 #include "system.h"
00038 #include "coretypes.h"
00039 #include "tm.h"
00040 #include "flags.h"
00041 #include "tree.h"
00042 #include "real.h"
00043 #include "tm_p.h"
00044 #include "function.h"
00045 #include "obstack.h"
00046 #include "toplev.h"
00047 #include "ggc.h"
00048 #include "hashtab.h"
00049 #include "output.h"
00050 #include "target.h"
00051 #include "langhooks.h"
00052 #include "tree-iterator.h"
00053 #include "basic-block.h"
00054 #include "tree-flow.h"
00055 #include "params.h"
00056 #include "diagnostic.h"
00057 
00058 #ifdef KEY
00059 #include "dwarf2.h"
00060 
00061 extern tree cplus_expand_constant (tree);
00062 extern void mangle_decl (const tree decl);
00063 #endif
00064 
00065 /* Each tree code class has an associated string representation.
00066    These must correspond to the tree_code_class entries.  */
00067 
00068 const char *const tree_code_class_strings[] =
00069 {
00070   "exceptional",
00071   "constant",
00072   "type",
00073   "declaration",
00074   "reference",
00075   "comparison",
00076   "unary",
00077   "binary",
00078   "statement",
00079   "expression",
00080 };
00081 
00082 /* obstack.[ch] explicitly declined to prototype this.  */
00083 extern int _obstack_allocated_p (struct obstack *h, void *obj);
00084 
00085 #ifdef GATHER_STATISTICS
00086 /* Statistics-gathering stuff.  */
00087 
00088 int tree_node_counts[(int) all_kinds];
00089 int tree_node_sizes[(int) all_kinds];
00090 
00091 /* Keep in sync with tree.h:enum tree_node_kind.  */
00092 static const char * const tree_node_kind_names[] = {
00093   "decls",
00094   "types",
00095   "blocks",
00096   "stmts",
00097   "refs",
00098   "exprs",
00099   "constants",
00100   "identifiers",
00101   "perm_tree_lists",
00102   "temp_tree_lists",
00103   "vecs",
00104   "binfos",
00105   "phi_nodes",
00106   "ssa names",
00107   "random kinds",
00108   "lang_decl kinds",
00109   "lang_type kinds"
00110 };
00111 #endif /* GATHER_STATISTICS */
00112 
00113 /* Unique id for next decl created.  */
00114 static GTY(()) int next_decl_uid;
00115 /* Unique id for next type created.  */
00116 static GTY(()) int next_type_uid = 1;
00117 
00118 /* Since we cannot rehash a type after it is in the table, we have to
00119    keep the hash code.  */
00120 
00121 struct type_hash GTY(())
00122 {
00123   unsigned long hash;
00124   tree type;
00125 };
00126 
00127 /* Initial size of the hash table (rounded to next prime).  */
00128 #define TYPE_HASH_INITIAL_SIZE 1000
00129 
00130 /* Now here is the hash table.  When recording a type, it is added to
00131    the slot whose index is the hash code.  Note that the hash table is
00132    used for several kinds of types (function types, array types and
00133    array index range types, for now).  While all these live in the
00134    same table, they are completely independent, and the hash code is
00135    computed differently for each of these.  */
00136 
00137 static GTY ((if_marked ("type_hash_marked_p"), param_is (struct type_hash)))
00138      htab_t type_hash_table;
00139 
00140 /* Hash table and temporary node for larger integer const values.  */
00141 static GTY (()) tree int_cst_node;
00142 static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node)))
00143      htab_t int_cst_hash_table;
00144 
00145 static void set_type_quals (tree, int);
00146 static int type_hash_eq (const void *, const void *);
00147 static hashval_t type_hash_hash (const void *);
00148 static hashval_t int_cst_hash_hash (const void *);
00149 static int int_cst_hash_eq (const void *, const void *);
00150 static void print_type_hash_statistics (void);
00151 static tree make_vector_type (tree, int, enum machine_mode);
00152 static int type_hash_marked_p (const void *);
00153 static unsigned int type_hash_list (tree, hashval_t);
00154 static unsigned int attribute_hash_list (tree, hashval_t);
00155 
00156 tree global_trees[TI_MAX];
00157 tree integer_types[itk_none];
00158 
00159 /* Init tree.c.  */
00160 
00161 void
00162 init_ttree (void)
00163 {
00164   /* Initialize the hash table of types.  */
00165   type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash,
00166              type_hash_eq, 0);
00167   int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash,
00168           int_cst_hash_eq, NULL);
00169   int_cst_node = make_node (INTEGER_CST);
00170 }
00171 
00172 
00173 /* The name of the object as the assembler will see it (but before any
00174    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
00175    as DECL_NAME.  It is an IDENTIFIER_NODE.  */
00176 tree
00177 decl_assembler_name (tree decl)
00178 {
00179   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
00180     lang_hooks.set_decl_assembler_name (decl);
00181   return DECL_CHECK (decl)->decl.assembler_name;
00182 }
00183 
00184 /* Compute the number of bytes occupied by a tree with code CODE.
00185    This function cannot be used for TREE_VEC, PHI_NODE, or STRING_CST
00186    codes, which are of variable length.  */
00187 size_t
00188 tree_code_size (enum tree_code code)
00189 {
00190   switch (TREE_CODE_CLASS (code))
00191     {
00192     case tcc_declaration:  /* A decl node */
00193       return sizeof (struct tree_decl);
00194 
00195     case tcc_type:  /* a type node */
00196       return sizeof (struct tree_type);
00197 
00198     case tcc_reference:   /* a reference */
00199     case tcc_expression:  /* an expression */
00200     case tcc_statement:   /* an expression with side effects */
00201     case tcc_comparison:  /* a comparison expression */
00202     case tcc_unary:       /* a unary arithmetic expression */
00203     case tcc_binary:      /* a binary arithmetic expression */
00204       return (sizeof (struct tree_exp)
00205         + (TREE_CODE_LENGTH (code) - 1) * sizeof (char *));
00206 
00207     case tcc_constant:  /* a constant */
00208       switch (code)
00209   {
00210   case INTEGER_CST: return sizeof (struct tree_int_cst);
00211   case REAL_CST:    return sizeof (struct tree_real_cst);
00212   case COMPLEX_CST: return sizeof (struct tree_complex);
00213   case VECTOR_CST:  return sizeof (struct tree_vector);
00214   case STRING_CST:  gcc_unreachable ();
00215   default:
00216     return lang_hooks.tree_size (code);
00217   }
00218 
00219     case tcc_exceptional:  /* something random, like an identifier.  */
00220       switch (code)
00221   {
00222   case IDENTIFIER_NODE: return lang_hooks.identifier_size;
00223   case TREE_LIST:   return sizeof (struct tree_list);
00224 
00225   case ERROR_MARK:
00226   case PLACEHOLDER_EXPR:  return sizeof (struct tree_common);
00227 
00228   case TREE_VEC:
00229   case PHI_NODE:    gcc_unreachable ();
00230 
00231   case SSA_NAME:    return sizeof (struct tree_ssa_name);
00232 
00233   case STATEMENT_LIST:  return sizeof (struct tree_statement_list);
00234   case BLOCK:   return sizeof (struct tree_block);
00235   case VALUE_HANDLE:  return sizeof (struct tree_value_handle);
00236 
00237   default:
00238     return lang_hooks.tree_size (code);
00239   }
00240 
00241     default:
00242       gcc_unreachable ();
00243     }
00244 }
00245 
00246 /* Compute the number of bytes occupied by NODE.  This routine only
00247    looks at TREE_CODE, except for PHI_NODE and TREE_VEC nodes.  */
00248 size_t
00249 tree_size (tree node)
00250 {
00251   enum tree_code code = TREE_CODE (node);
00252   switch (code)
00253     {
00254     case PHI_NODE:
00255       return (sizeof (struct tree_phi_node)
00256         + (PHI_ARG_CAPACITY (node) - 1) * sizeof (struct phi_arg_d));
00257 
00258     case TREE_BINFO:
00259       return (offsetof (struct tree_binfo, base_binfos)
00260         + VEC_embedded_size (tree, BINFO_N_BASE_BINFOS (node)));
00261 
00262     case TREE_VEC:
00263       return (sizeof (struct tree_vec)
00264         + (TREE_VEC_LENGTH (node) - 1) * sizeof(char *));
00265 
00266     case STRING_CST:
00267       return sizeof (struct tree_string) + TREE_STRING_LENGTH (node) - 1;
00268 
00269     default:
00270       return tree_code_size (code);
00271     }
00272 }
00273 
00274 /* Return a newly allocated node of code CODE.  For decl and type
00275    nodes, some other fields are initialized.  The rest of the node is
00276    initialized to zero.  This function cannot be used for PHI_NODE or
00277    TREE_VEC nodes, which is enforced by asserts in tree_code_size.
00278 
00279    Achoo!  I got a code in the node.  */
00280 
00281 tree
00282 make_node_stat (enum tree_code code MEM_STAT_DECL)
00283 {
00284   tree t;
00285   enum tree_code_class type = TREE_CODE_CLASS (code);
00286   size_t length = tree_code_size (code);
00287 #ifdef GATHER_STATISTICS
00288   tree_node_kind kind;
00289 
00290   switch (type)
00291     {
00292     case tcc_declaration:  /* A decl node */
00293       kind = d_kind;
00294       break;
00295 
00296     case tcc_type:  /* a type node */
00297       kind = t_kind;
00298       break;
00299 
00300     case tcc_statement:  /* an expression with side effects */
00301       kind = s_kind;
00302       break;
00303 
00304     case tcc_reference:  /* a reference */
00305       kind = r_kind;
00306       break;
00307 
00308     case tcc_expression:  /* an expression */
00309     case tcc_comparison:  /* a comparison expression */
00310     case tcc_unary:  /* a unary arithmetic expression */
00311     case tcc_binary:  /* a binary arithmetic expression */
00312       kind = e_kind;
00313       break;
00314 
00315     case tcc_constant:  /* a constant */
00316       kind = c_kind;
00317       break;
00318 
00319     case tcc_exceptional:  /* something random, like an identifier.  */
00320       switch (code)
00321   {
00322   case IDENTIFIER_NODE:
00323     kind = id_kind;
00324     break;
00325 
00326   case TREE_VEC:;
00327     kind = vec_kind;
00328     break;
00329 
00330   case TREE_BINFO:
00331     kind = binfo_kind;
00332     break;
00333 
00334   case PHI_NODE:
00335     kind = phi_kind;
00336     break;
00337 
00338   case SSA_NAME:
00339     kind = ssa_name_kind;
00340     break;
00341 
00342   case BLOCK:
00343     kind = b_kind;
00344     break;
00345 
00346   default:
00347     kind = x_kind;
00348     break;
00349   }
00350       break;
00351       
00352     default:
00353       gcc_unreachable ();
00354     }
00355 
00356   tree_node_counts[(int) kind]++;
00357   tree_node_sizes[(int) kind] += length;
00358 #endif
00359 
00360   t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
00361 
00362   memset (t, 0, length);
00363 
00364   TREE_SET_CODE (t, code);
00365 
00366   switch (type)
00367     {
00368     case tcc_statement:
00369       TREE_SIDE_EFFECTS (t) = 1;
00370       break;
00371 
00372     case tcc_declaration:
00373       if (code != FUNCTION_DECL)
00374   DECL_ALIGN (t) = 1;
00375       DECL_USER_ALIGN (t) = 0;
00376       DECL_IN_SYSTEM_HEADER (t) = in_system_header;
00377       DECL_SOURCE_LOCATION (t) = input_location;
00378       DECL_UID (t) = next_decl_uid++;
00379 
00380       /* We have not yet computed the alias set for this declaration.  */
00381       DECL_POINTER_ALIAS_SET (t) = -1;
00382       break;
00383 
00384     case tcc_type:
00385       TYPE_UID (t) = next_type_uid++;
00386       TYPE_ALIGN (t) = char_type_node ? TYPE_ALIGN (char_type_node) : 0;
00387       TYPE_USER_ALIGN (t) = 0;
00388       TYPE_MAIN_VARIANT (t) = t;
00389 
00390       /* Default to no attributes for type, but let target change that.  */
00391       TYPE_ATTRIBUTES (t) = NULL_TREE;
00392       targetm.set_default_type_attributes (t);
00393 
00394       /* We have not yet computed the alias set for this type.  */
00395       TYPE_ALIAS_SET (t) = -1;
00396       break;
00397 
00398     case tcc_constant:
00399       TREE_CONSTANT (t) = 1;
00400       TREE_INVARIANT (t) = 1;
00401       break;
00402 
00403     case tcc_expression:
00404       switch (code)
00405   {
00406   case INIT_EXPR:
00407   case MODIFY_EXPR:
00408   case VA_ARG_EXPR:
00409   case PREDECREMENT_EXPR:
00410   case PREINCREMENT_EXPR:
00411   case POSTDECREMENT_EXPR:
00412   case POSTINCREMENT_EXPR:
00413     /* All of these have side-effects, no matter what their
00414        operands are.  */
00415     TREE_SIDE_EFFECTS (t) = 1;
00416     break;
00417 
00418   default:
00419     break;
00420   }
00421       break;
00422 
00423     default:
00424       /* Other classes need no special treatment.  */
00425       break;
00426     }
00427 
00428   return t;
00429 }
00430 
00431 /* Return a new node with the same contents as NODE except that its
00432    TREE_CHAIN is zero and it has a fresh uid.  */
00433 
00434 /* KEY: Also gs_node translation related fields are 0, so that this new
00435    node is again translated to gs_t. */
00436 
00437 tree
00438 copy_node_stat (tree node MEM_STAT_DECL)
00439 {
00440   tree t;
00441   enum tree_code code = TREE_CODE (node);
00442   size_t length;
00443 
00444   gcc_assert (code != STATEMENT_LIST);
00445 
00446   length = tree_size (node);
00447   t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
00448   memcpy (t, node, length);
00449 
00450   TREE_CHAIN (t) = 0;
00451   TREE_ASM_WRITTEN (t) = 0;
00452   TREE_VISITED (t) = 0;
00453   t->common.ann = 0;
00454 #ifdef KEY
00455   if (flag_spin_file)
00456     TREE_TO_TRANSLATED_GS (t) = 0;
00457 #endif
00458 
00459   if (TREE_CODE_CLASS (code) == tcc_declaration)
00460     DECL_UID (t) = next_decl_uid++;
00461   else if (TREE_CODE_CLASS (code) == tcc_type)
00462     {
00463       TYPE_UID (t) = next_type_uid++;
00464       /* The following is so that the debug code for
00465    the copy is different from the original type.
00466    The two statements usually duplicate each other
00467    (because they clear fields of the same union),
00468    but the optimizer should catch that.  */
00469       TYPE_SYMTAB_POINTER (t) = 0;
00470       TYPE_SYMTAB_ADDRESS (t) = 0;
00471       
00472       /* Do not copy the values cache.  */
00473       if (TYPE_CACHED_VALUES_P(t))
00474   {
00475     TYPE_CACHED_VALUES_P (t) = 0;
00476     TYPE_CACHED_VALUES (t) = NULL_TREE;
00477   }
00478     }
00479 
00480   return t;
00481 }
00482 
00483 /* Return a copy of a chain of nodes, chained through the TREE_CHAIN field.
00484    For example, this can copy a list made of TREE_LIST nodes.  */
00485 
00486 tree
00487 copy_list (tree list)
00488 {
00489   tree head;
00490   tree prev, next;
00491 
00492   if (list == 0)
00493     return 0;
00494 
00495   head = prev = copy_node (list);
00496   next = TREE_CHAIN (list);
00497   while (next)
00498     {
00499       TREE_CHAIN (prev) = copy_node (next);
00500       prev = TREE_CHAIN (prev);
00501       next = TREE_CHAIN (next);
00502     }
00503   return head;
00504 }
00505 
00506 
00507 /* Create an INT_CST node with a LOW value sign extended.  */
00508 
00509 tree
00510 build_int_cst (tree type, HOST_WIDE_INT low)
00511 {
00512   return build_int_cst_wide (type, low, low < 0 ? -1 : 0);
00513 }
00514 
00515 /* Create an INT_CST node with a LOW value zero extended.  */
00516 
00517 tree
00518 build_int_cstu (tree type, unsigned HOST_WIDE_INT low)
00519 {
00520   return build_int_cst_wide (type, low, 0);
00521 }
00522 
00523 /* Create an INT_CST node with a LOW value in TYPE.  The value is sign extended
00524    if it is negative.  This function is similar to build_int_cst, but
00525    the extra bits outside of the type precision are cleared.  Constants
00526    with these extra bits may confuse the fold so that it detects overflows
00527    even in cases when they do not occur, and in general should be avoided.
00528    We cannot however make this a default behavior of build_int_cst without
00529    more intrusive changes, since there are parts of gcc that rely on the extra
00530    precision of the integer constants.  */
00531 
00532 tree
00533 build_int_cst_type (tree type, HOST_WIDE_INT low)
00534 {
00535   unsigned HOST_WIDE_INT val = (unsigned HOST_WIDE_INT) low;
00536   unsigned HOST_WIDE_INT hi;
00537   unsigned bits;
00538   bool signed_p;
00539   bool negative;
00540 
00541   if (!type)
00542     type = integer_type_node;
00543 
00544   bits = TYPE_PRECISION (type);
00545   signed_p = !TYPE_UNSIGNED (type);
00546 
00547   if (bits >= HOST_BITS_PER_WIDE_INT)
00548     negative = (low < 0);
00549   else
00550     {
00551       /* If the sign bit is inside precision of LOW, use it to determine
00552    the sign of the constant.  */
00553       negative = ((val >> (bits - 1)) & 1) != 0;
00554 
00555       /* Mask out the bits outside of the precision of the constant.  */
00556       if (signed_p && negative)
00557   val = val | ((~(unsigned HOST_WIDE_INT) 0) << bits);
00558       else
00559   val = val & ~((~(unsigned HOST_WIDE_INT) 0) << bits);
00560     }
00561 
00562   /* Determine the high bits.  */
00563   hi = (negative ? ~(unsigned HOST_WIDE_INT) 0 : 0);
00564 
00565   /* For unsigned type we need to mask out the bits outside of the type
00566      precision.  */
00567   if (!signed_p)
00568     {
00569       if (bits <= HOST_BITS_PER_WIDE_INT)
00570   hi = 0;
00571       else
00572   {
00573     bits -= HOST_BITS_PER_WIDE_INT;
00574     hi = hi & ~((~(unsigned HOST_WIDE_INT) 0) << bits);
00575   }
00576     }
00577 
00578   return build_int_cst_wide (type, val, hi);
00579 }
00580 
00581 /* These are the hash table functions for the hash table of INTEGER_CST
00582    nodes of a sizetype.  */
00583 
00584 /* Return the hash code code X, an INTEGER_CST.  */
00585 
00586 static hashval_t
00587 int_cst_hash_hash (const void *x)
00588 {
00589   tree t = (tree) x;
00590 
00591   return (TREE_INT_CST_HIGH (t) ^ TREE_INT_CST_LOW (t)
00592     ^ htab_hash_pointer (TREE_TYPE (t)));
00593 }
00594 
00595 /* Return nonzero if the value represented by *X (an INTEGER_CST tree node)
00596    is the same as that given by *Y, which is the same.  */
00597 
00598 static int
00599 int_cst_hash_eq (const void *x, const void *y)
00600 {
00601   tree xt = (tree) x;
00602   tree yt = (tree) y;
00603 
00604   return (TREE_TYPE (xt) == TREE_TYPE (yt)
00605     && TREE_INT_CST_HIGH (xt) == TREE_INT_CST_HIGH (yt)
00606     && TREE_INT_CST_LOW (xt) == TREE_INT_CST_LOW (yt));
00607 }
00608 
00609 /* Create an INT_CST node of TYPE and value HI:LOW.  If TYPE is NULL,
00610    integer_type_node is used.  The returned node is always shared.
00611    For small integers we use a per-type vector cache, for larger ones
00612    we use a single hash table.  */
00613 
00614 tree
00615 build_int_cst_wide (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)
00616 {
00617   tree t;
00618   int ix = -1;
00619   int limit = 0;
00620 
00621   if (!type)
00622     type = integer_type_node;
00623 
00624   switch (TREE_CODE (type))
00625     {
00626     case POINTER_TYPE:
00627     case REFERENCE_TYPE:
00628       /* Cache NULL pointer.  */
00629       if (!hi && !low)
00630   {
00631     limit = 1;
00632     ix = 0;
00633   }
00634       break;
00635 
00636     case BOOLEAN_TYPE:
00637       /* Cache false or true.  */
00638       limit = 2;
00639       if (!hi && low < 2)
00640   ix = low;
00641       break;
00642 
00643     case INTEGER_TYPE:
00644     case CHAR_TYPE:
00645     case OFFSET_TYPE:
00646       if (TYPE_UNSIGNED (type))
00647   {
00648     /* Cache 0..N */
00649     limit = INTEGER_SHARE_LIMIT;
00650     if (!hi && low < (unsigned HOST_WIDE_INT)INTEGER_SHARE_LIMIT)
00651       ix = low;
00652   }
00653       else
00654   {
00655     /* Cache -1..N */
00656     limit = INTEGER_SHARE_LIMIT + 1;
00657     if (!hi && low < (unsigned HOST_WIDE_INT)INTEGER_SHARE_LIMIT)
00658       ix = low + 1;
00659     else if (hi == -1 && low == -(unsigned HOST_WIDE_INT)1)
00660       ix = 0;
00661   }
00662       break;
00663     default:
00664       break;
00665     }
00666 
00667   if (ix >= 0)
00668     {
00669       /* Look for it in the type's vector of small shared ints.  */
00670       if (!TYPE_CACHED_VALUES_P (type))
00671   {
00672     TYPE_CACHED_VALUES_P (type) = 1;
00673     TYPE_CACHED_VALUES (type) = make_tree_vec (limit);
00674   }
00675 
00676       t = TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix);
00677       if (t)
00678   {
00679     /* Make sure no one is clobbering the shared constant.  */
00680     gcc_assert (TREE_TYPE (t) == type);
00681     gcc_assert (TREE_INT_CST_LOW (t) == low);
00682     gcc_assert (TREE_INT_CST_HIGH (t) == hi);
00683   }
00684       else
00685   {
00686     /* Create a new shared int.  */
00687     t = make_node (INTEGER_CST);
00688 
00689     TREE_INT_CST_LOW (t) = low;
00690     TREE_INT_CST_HIGH (t) = hi;
00691     TREE_TYPE (t) = type;
00692     
00693     TREE_VEC_ELT (TYPE_CACHED_VALUES (type), ix) = t;
00694   }
00695     }
00696   else
00697     {
00698       /* Use the cache of larger shared ints.  */
00699       void **slot;
00700 
00701       TREE_INT_CST_LOW (int_cst_node) = low;
00702       TREE_INT_CST_HIGH (int_cst_node) = hi;
00703       TREE_TYPE (int_cst_node) = type;
00704 
00705       slot = htab_find_slot (int_cst_hash_table, int_cst_node, INSERT);
00706       t = *slot;
00707       if (!t)
00708   {
00709     /* Insert this one into the hash table.  */
00710     t = int_cst_node;
00711     *slot = t;
00712     /* Make a new node for next time round.  */
00713     int_cst_node = make_node (INTEGER_CST);
00714   }
00715     }
00716 
00717   return t;
00718 }
00719 
00720 /* Builds an integer constant in TYPE such that lowest BITS bits are ones
00721    and the rest are zeros.  */
00722 
00723 tree
00724 build_low_bits_mask (tree type, unsigned bits)
00725 {
00726   unsigned HOST_WIDE_INT low;
00727   HOST_WIDE_INT high;
00728   unsigned HOST_WIDE_INT all_ones = ~(unsigned HOST_WIDE_INT) 0;
00729 
00730   gcc_assert (bits <= TYPE_PRECISION (type));
00731 
00732   if (bits == TYPE_PRECISION (type)
00733       && !TYPE_UNSIGNED (type))
00734     {
00735       /* Sign extended all-ones mask.  */
00736       low = all_ones;
00737       high = -1;
00738     }
00739   else if (bits <= HOST_BITS_PER_WIDE_INT)
00740     {
00741       low = all_ones >> (HOST_BITS_PER_WIDE_INT - bits);
00742       high = 0;
00743     }
00744   else
00745     {
00746       bits -= HOST_BITS_PER_WIDE_INT;
00747       low = all_ones;
00748       high = all_ones >> (HOST_BITS_PER_WIDE_INT - bits);
00749     }
00750 
00751   return build_int_cst_wide (type, low, high);
00752 }
00753 
00754 /* Checks that X is integer constant that can be expressed in (unsigned)
00755    HOST_WIDE_INT without loss of precision.  */
00756 
00757 bool
00758 cst_and_fits_in_hwi (tree x)
00759 {
00760   if (TREE_CODE (x) != INTEGER_CST)
00761     return false;
00762 
00763   if (TYPE_PRECISION (TREE_TYPE (x)) > HOST_BITS_PER_WIDE_INT)
00764     return false;
00765 
00766   return (TREE_INT_CST_HIGH (x) == 0
00767     || TREE_INT_CST_HIGH (x) == -1);
00768 }
00769 
00770 /* Return a new VECTOR_CST node whose type is TYPE and whose values
00771    are in a list pointed by VALS.  */
00772 
00773 tree
00774 build_vector (tree type, tree vals)
00775 {
00776   tree v = make_node (VECTOR_CST);
00777   int over1 = 0, over2 = 0;
00778   tree link;
00779 
00780   TREE_VECTOR_CST_ELTS (v) = vals;
00781   TREE_TYPE (v) = type;
00782 
00783   /* Iterate through elements and check for overflow.  */
00784   for (link = vals; link; link = TREE_CHAIN (link))
00785     {
00786       tree value = TREE_VALUE (link);
00787 
00788       over1 |= TREE_OVERFLOW (value);
00789       over2 |= TREE_CONSTANT_OVERFLOW (value);
00790     }
00791 
00792   TREE_OVERFLOW (v) = over1;
00793   TREE_CONSTANT_OVERFLOW (v) = over2;
00794 
00795   return v;
00796 }
00797 
00798 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values
00799    are in a list pointed to by VALS.  */
00800 tree
00801 build_constructor (tree type, tree vals)
00802 {
00803   tree c = make_node (CONSTRUCTOR);
00804   TREE_TYPE (c) = type;
00805   CONSTRUCTOR_ELTS (c) = vals;
00806 
00807   /* ??? May not be necessary.  Mirrors what build does.  */
00808   if (vals)
00809     {
00810       TREE_SIDE_EFFECTS (c) = TREE_SIDE_EFFECTS (vals);
00811       TREE_READONLY (c) = TREE_READONLY (vals);
00812       TREE_CONSTANT (c) = TREE_CONSTANT (vals);
00813       TREE_INVARIANT (c) = TREE_INVARIANT (vals);
00814     }
00815 
00816   return c;
00817 }
00818 
00819 /* Return a new REAL_CST node whose type is TYPE and value is D.  */
00820 
00821 tree
00822 build_real (tree type, REAL_VALUE_TYPE d)
00823 {
00824   tree v;
00825   REAL_VALUE_TYPE *dp;
00826   int overflow = 0;
00827 
00828   /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE.
00829      Consider doing it via real_convert now.  */
00830 
00831   v = make_node (REAL_CST);
00832   dp = ggc_alloc (sizeof (REAL_VALUE_TYPE));
00833   memcpy (dp, &d, sizeof (REAL_VALUE_TYPE));
00834 
00835   TREE_TYPE (v) = type;
00836   TREE_REAL_CST_PTR (v) = dp;
00837   TREE_OVERFLOW (v) = TREE_CONSTANT_OVERFLOW (v) = overflow;
00838   return v;
00839 }
00840 
00841 /* Return a new REAL_CST node whose type is TYPE
00842    and whose value is the integer value of the INTEGER_CST node I.  */
00843 
00844 REAL_VALUE_TYPE
00845 real_value_from_int_cst (tree type, tree i)
00846 {
00847   REAL_VALUE_TYPE d;
00848 
00849   /* Clear all bits of the real value type so that we can later do
00850      bitwise comparisons to see if two values are the same.  */
00851   memset (&d, 0, sizeof d);
00852 
00853   real_from_integer (&d, type ? TYPE_MODE (type) : VOIDmode,
00854          TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i),
00855          TYPE_UNSIGNED (TREE_TYPE (i)));
00856   return d;
00857 }
00858 
00859 /* Given a tree representing an integer constant I, return a tree
00860    representing the same value as a floating-point constant of type TYPE.  */
00861 
00862 tree
00863 build_real_from_int_cst (tree type, tree i)
00864 {
00865   tree v;
00866   int overflow = TREE_OVERFLOW (i);
00867 
00868   v = build_real (type, real_value_from_int_cst (type, i));
00869 
00870   TREE_OVERFLOW (v) |= overflow;
00871   TREE_CONSTANT_OVERFLOW (v) |= overflow;
00872   return v;
00873 }
00874 
00875 /* Return a newly constructed STRING_CST node whose value is
00876    the LEN characters at STR.
00877    The TREE_TYPE is not initialized.  */
00878 
00879 tree
00880 build_string (int len, const char *str)
00881 {
00882   tree s;
00883   size_t length;
00884   
00885   length = len + sizeof (struct tree_string);
00886 
00887 #ifdef GATHER_STATISTICS
00888   tree_node_counts[(int) c_kind]++;
00889   tree_node_sizes[(int) c_kind] += length;
00890 #endif  
00891 
00892   s = ggc_alloc_tree (length);
00893 
00894   memset (s, 0, sizeof (struct tree_common));
00895   TREE_SET_CODE (s, STRING_CST);
00896   TREE_CONSTANT (s) = 1;
00897   TREE_INVARIANT (s) = 1;
00898   TREE_STRING_LENGTH (s) = len;
00899   memcpy ((char *) TREE_STRING_POINTER (s), str, len);
00900   ((char *) TREE_STRING_POINTER (s))[len] = '\0';
00901 
00902   return s;
00903 }
00904 
00905 /* Return a newly constructed COMPLEX_CST node whose value is
00906    specified by the real and imaginary parts REAL and IMAG.
00907    Both REAL and IMAG should be constant nodes.  TYPE, if specified,
00908    will be the type of the COMPLEX_CST; otherwise a new type will be made.  */
00909 
00910 tree
00911 build_complex (tree type, tree real, tree imag)
00912 {
00913   tree t = make_node (COMPLEX_CST);
00914 
00915   TREE_REALPART (t) = real;
00916   TREE_IMAGPART (t) = imag;
00917   TREE_TYPE (t) = type ? type : build_complex_type (TREE_TYPE (real));
00918   TREE_OVERFLOW (t) = TREE_OVERFLOW (real) | TREE_OVERFLOW (imag);
00919   TREE_CONSTANT_OVERFLOW (t)
00920     = TREE_CONSTANT_OVERFLOW (real) | TREE_CONSTANT_OVERFLOW (imag);
00921   return t;
00922 }
00923 
00924 /* Build a BINFO with LEN language slots.  */
00925 
00926 tree
00927 make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
00928 {
00929   tree t;
00930   size_t length = (offsetof (struct tree_binfo, base_binfos)
00931        + VEC_embedded_size (tree, base_binfos));
00932 
00933 #ifdef GATHER_STATISTICS
00934   tree_node_counts[(int) binfo_kind]++;
00935   tree_node_sizes[(int) binfo_kind] += length;
00936 #endif
00937 
00938   t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
00939 
00940   memset (t, 0, offsetof (struct tree_binfo, base_binfos));
00941 
00942   TREE_SET_CODE (t, TREE_BINFO);
00943 
00944   VEC_embedded_init (tree, BINFO_BASE_BINFOS (t), base_binfos);
00945 
00946   return t;
00947 }
00948 
00949 
00950 /* Build a newly constructed TREE_VEC node of length LEN.  */
00951 
00952 tree
00953 make_tree_vec_stat (int len MEM_STAT_DECL)
00954 {
00955   tree t;
00956   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
00957 
00958 #ifdef GATHER_STATISTICS
00959   tree_node_counts[(int) vec_kind]++;
00960   tree_node_sizes[(int) vec_kind] += length;
00961 #endif
00962 
00963   t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
00964 
00965   memset (t, 0, length);
00966 
00967   TREE_SET_CODE (t, TREE_VEC);
00968   TREE_VEC_LENGTH (t) = len;
00969 
00970   return t;
00971 }
00972 
00973 /* Return 1 if EXPR is the integer constant zero or a complex constant
00974    of zero.  */
00975 
00976 int
00977 integer_zerop (tree expr)
00978 {
00979   STRIP_NOPS (expr);
00980 
00981   return ((TREE_CODE (expr) == INTEGER_CST
00982      && ! TREE_CONSTANT_OVERFLOW (expr)
00983      && TREE_INT_CST_LOW (expr) == 0
00984      && TREE_INT_CST_HIGH (expr) == 0)
00985     || (TREE_CODE (expr) == COMPLEX_CST
00986         && integer_zerop (TREE_REALPART (expr))
00987         && integer_zerop (TREE_IMAGPART (expr))));
00988 }
00989 
00990 /* Return 1 if EXPR is the integer constant one or the corresponding
00991    complex constant.  */
00992 
00993 int
00994 integer_onep (tree expr)
00995 {
00996   STRIP_NOPS (expr);
00997 
00998   return ((TREE_CODE (expr) == INTEGER_CST
00999      && ! TREE_CONSTANT_OVERFLOW (expr)
01000      && TREE_INT_CST_LOW (expr) == 1
01001      && TREE_INT_CST_HIGH (expr) == 0)
01002     || (TREE_CODE (expr) == COMPLEX_CST
01003         && integer_onep (TREE_REALPART (expr))
01004         && integer_zerop (TREE_IMAGPART (expr))));
01005 }
01006 
01007 /* Return 1 if EXPR is an integer containing all 1's in as much precision as
01008    it contains.  Likewise for the corresponding complex constant.  */
01009 
01010 int
01011 integer_all_onesp (tree expr)
01012 {
01013   int prec;
01014   int uns;
01015 
01016   STRIP_NOPS (expr);
01017 
01018   if (TREE_CODE (expr) == COMPLEX_CST
01019       && integer_all_onesp (TREE_REALPART (expr))
01020       && integer_zerop (TREE_IMAGPART (expr)))
01021     return 1;
01022 
01023   else if (TREE_CODE (expr) != INTEGER_CST
01024      || TREE_CONSTANT_OVERFLOW (expr))
01025     return 0;
01026 
01027   uns = TYPE_UNSIGNED (TREE_TYPE (expr));
01028   if (!uns)
01029     return (TREE_INT_CST_LOW (expr) == ~(unsigned HOST_WIDE_INT) 0
01030       && TREE_INT_CST_HIGH (expr) == -1);
01031 
01032   /* Note that using TYPE_PRECISION here is wrong.  We care about the
01033      actual bits, not the (arbitrary) range of the type.  */
01034   prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr)));
01035   if (prec >= HOST_BITS_PER_WIDE_INT)
01036     {
01037       HOST_WIDE_INT high_value;
01038       int shift_amount;
01039 
01040       shift_amount = prec - HOST_BITS_PER_WIDE_INT;
01041 
01042       /* Can not handle precisions greater than twice the host int size.  */
01043       gcc_assert (shift_amount <= HOST_BITS_PER_WIDE_INT);
01044       if (shift_amount == HOST_BITS_PER_WIDE_INT)
01045   /* Shifting by the host word size is undefined according to the ANSI
01046      standard, so we must handle this as a special case.  */
01047   high_value = -1;
01048       else
01049   high_value = ((HOST_WIDE_INT) 1 << shift_amount) - 1;
01050 
01051       return (TREE_INT_CST_LOW (expr) == ~(unsigned HOST_WIDE_INT) 0
01052         && TREE_INT_CST_HIGH (expr) == high_value);
01053     }
01054   else
01055     return TREE_INT_CST_LOW (expr) == ((unsigned HOST_WIDE_INT) 1 << prec) - 1;
01056 }
01057 
01058 /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only
01059    one bit on).  */
01060 
01061 int
01062 integer_pow2p (tree expr)
01063 {
01064   int prec;
01065   HOST_WIDE_INT high, low;
01066 
01067   STRIP_NOPS (expr);
01068 
01069   if (TREE_CODE (expr) == COMPLEX_CST
01070       && integer_pow2p (TREE_REALPART (expr))
01071       && integer_zerop (TREE_IMAGPART (expr)))
01072     return 1;
01073 
01074   if (TREE_CODE (expr) != INTEGER_CST || TREE_CONSTANT_OVERFLOW (expr))
01075     return 0;
01076 
01077   prec = (POINTER_TYPE_P (TREE_TYPE (expr))
01078     ? POINTER_SIZE : TYPE_PRECISION (TREE_TYPE (expr)));
01079   high = TREE_INT_CST_HIGH (expr);
01080   low = TREE_INT_CST_LOW (expr);
01081 
01082   /* First clear all bits that are beyond the type's precision in case
01083      we've been sign extended.  */
01084 
01085   if (prec == 2 * HOST_BITS_PER_WIDE_INT)
01086     ;
01087   else if (prec > HOST_BITS_PER_WIDE_INT)
01088     high &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT));
01089   else
01090     {
01091       high = 0;
01092       if (prec < HOST_BITS_PER_WIDE_INT)
01093   low &= ~((HOST_WIDE_INT) (-1) << prec);
01094     }
01095 
01096   if (high == 0 && low == 0)
01097     return 0;
01098 
01099   return ((high == 0 && (low & (low - 1)) == 0)
01100     || (low == 0 && (high & (high - 1)) == 0));
01101 }
01102 
01103 /* Return 1 if EXPR is an integer constant other than zero or a
01104    complex constant other than zero.  */
01105 
01106 int
01107 integer_nonzerop (tree expr)
01108 {
01109   STRIP_NOPS (expr);
01110 
01111   return ((TREE_CODE (expr) == INTEGER_CST
01112      && ! TREE_CONSTANT_OVERFLOW (expr)
01113      && (TREE_INT_CST_LOW (expr) != 0
01114          || TREE_INT_CST_HIGH (expr) != 0))
01115     || (TREE_CODE (expr) == COMPLEX_CST
01116         && (integer_nonzerop (TREE_REALPART (expr))
01117       || integer_nonzerop (TREE_IMAGPART (expr)))));
01118 }
01119 
01120 /* Return the power of two represented by a tree node known to be a
01121    power of two.  */
01122 
01123 int
01124 tree_log2 (tree expr)
01125 {
01126   int prec;
01127   HOST_WIDE_INT high, low;
01128 
01129   STRIP_NOPS (expr);
01130 
01131   if (TREE_CODE (expr) == COMPLEX_CST)
01132     return tree_log2 (TREE_REALPART (expr));
01133 
01134   prec = (POINTER_TYPE_P (TREE_TYPE (expr))
01135     ? POINTER_SIZE : TYPE_PRECISION (TREE_TYPE (expr)));
01136 
01137   high = TREE_INT_CST_HIGH (expr);
01138   low = TREE_INT_CST_LOW (expr);
01139 
01140   /* First clear all bits that are beyond the type's precision in case
01141      we've been sign extended.  */
01142 
01143   if (prec == 2 * HOST_BITS_PER_WIDE_INT)
01144     ;
01145   else if (prec > HOST_BITS_PER_WIDE_INT)
01146     high &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT));
01147   else
01148     {
01149       high = 0;
01150       if (prec < HOST_BITS_PER_WIDE_INT)
01151   low &= ~((HOST_WIDE_INT) (-1) << prec);
01152     }
01153 
01154   return (high != 0 ? HOST_BITS_PER_WIDE_INT + exact_log2 (high)
01155     : exact_log2 (low));
01156 }
01157 
01158 /* Similar, but return the largest integer Y such that 2 ** Y is less
01159    than or equal to EXPR.  */
01160 
01161 int
01162 tree_floor_log2 (tree expr)
01163 {
01164   int prec;
01165   HOST_WIDE_INT high, low;
01166 
01167   STRIP_NOPS (expr);
01168 
01169   if (TREE_CODE (expr) == COMPLEX_CST)
01170     return tree_log2 (TREE_REALPART (expr));
01171 
01172   prec = (POINTER_TYPE_P (TREE_TYPE (expr))
01173     ? POINTER_SIZE : TYPE_PRECISION (TREE_TYPE (expr)));
01174 
01175   high = TREE_INT_CST_HIGH (expr);
01176   low = TREE_INT_CST_LOW (expr);
01177 
01178   /* First clear all bits that are beyond the type's precision in case
01179      we've been sign extended.  Ignore if type's precision hasn't been set
01180      since what we are doing is setting it.  */
01181 
01182   if (prec == 2 * HOST_BITS_PER_WIDE_INT || prec == 0)
01183     ;
01184   else if (prec > HOST_BITS_PER_WIDE_INT)
01185     high &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT));
01186   else
01187     {
01188       high = 0;
01189       if (prec < HOST_BITS_PER_WIDE_INT)
01190   low &= ~((HOST_WIDE_INT) (-1) << prec);
01191     }
01192 
01193   return (high != 0 ? HOST_BITS_PER_WIDE_INT + floor_log2 (high)
01194     : floor_log2 (low));
01195 }
01196 
01197 /* Return 1 if EXPR is the real constant zero.  */
01198 
01199 int
01200 real_zerop (tree expr)
01201 {
01202   STRIP_NOPS (expr);
01203 
01204   return ((TREE_CODE (expr) == REAL_CST
01205      && ! TREE_CONSTANT_OVERFLOW (expr)
01206      && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst0))
01207     || (TREE_CODE (expr) == COMPLEX_CST
01208         && real_zerop (TREE_REALPART (expr))
01209         && real_zerop (TREE_IMAGPART (expr))));
01210 }
01211 
01212 /* Return 1 if EXPR is the real constant one in real or complex form.  */
01213 
01214 int
01215 real_onep (tree expr)
01216 {
01217   STRIP_NOPS (expr);
01218 
01219   return ((TREE_CODE (expr) == REAL_CST
01220      && ! TREE_CONSTANT_OVERFLOW (expr)
01221      && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst1))
01222     || (TREE_CODE (expr) == COMPLEX_CST
01223         && real_onep (TREE_REALPART (expr))
01224         && real_zerop (TREE_IMAGPART (expr))));
01225 }
01226 
01227 /* Return 1 if EXPR is the real constant two.  */
01228 
01229 int
01230 real_twop (tree expr)
01231 {
01232   STRIP_NOPS (expr);
01233 
01234   return ((TREE_CODE (expr) == REAL_CST
01235      && ! TREE_CONSTANT_OVERFLOW (expr)
01236      && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconst2))
01237     || (TREE_CODE (expr) == COMPLEX_CST
01238         && real_twop (TREE_REALPART (expr))
01239         && real_zerop (TREE_IMAGPART (expr))));
01240 }
01241 
01242 /* Return 1 if EXPR is the real constant minus one.  */
01243 
01244 int
01245 real_minus_onep (tree expr)
01246 {
01247   STRIP_NOPS (expr);
01248 
01249   return ((TREE_CODE (expr) == REAL_CST
01250      && ! TREE_CONSTANT_OVERFLOW (expr)
01251      && REAL_VALUES_EQUAL (TREE_REAL_CST (expr), dconstm1))
01252     || (TREE_CODE (expr) == COMPLEX_CST
01253         && real_minus_onep (TREE_REALPART (expr))
01254         && real_zerop (TREE_IMAGPART (expr))));
01255 }
01256 
01257 /* Nonzero if EXP is a constant or a cast of a constant.  */
01258 
01259 int
01260 really_constant_p (tree exp)
01261 {
01262   /* This is not quite the same as STRIP_NOPS.  It does more.  */
01263   while (TREE_CODE (exp) == NOP_EXPR
01264    || TREE_CODE (exp) == CONVERT_EXPR
01265    || TREE_CODE (exp) == NON_LVALUE_EXPR)
01266     exp = TREE_OPERAND (exp, 0);
01267   return TREE_CONSTANT (exp);
01268 }
01269 
01270 /* Return first list element whose TREE_VALUE is ELEM.
01271    Return 0 if ELEM is not in LIST.  */
01272 
01273 tree
01274 value_member (tree elem, tree list)
01275 {
01276   while (list)
01277     {
01278       if (elem == TREE_VALUE (list))
01279   return list;
01280       list = TREE_CHAIN (list);
01281     }
01282   return NULL_TREE;
01283 }
01284 
01285 /* Return first list element whose TREE_PURPOSE is ELEM.
01286    Return 0 if ELEM is not in LIST.  */
01287 
01288 tree
01289 purpose_member (tree elem, tree list)
01290 {
01291   while (list)
01292     {
01293       if (elem == TREE_PURPOSE (list))
01294   return list;
01295       list = TREE_CHAIN (list);
01296     }
01297   return NULL_TREE;
01298 }
01299 
01300 /* Return nonzero if ELEM is part of the chain CHAIN.  */
01301 
01302 int
01303 chain_member (tree elem, tree chain)
01304 {
01305   while (chain)
01306     {
01307       if (elem == chain)
01308   return 1;
01309       chain = TREE_CHAIN (chain);
01310     }
01311 
01312   return 0;
01313 }
01314 
01315 /* Return the length of a chain of nodes chained through TREE_CHAIN.
01316    We expect a null pointer to mark the end of the chain.
01317    This is the Lisp primitive `length'.  */
01318 
01319 int
01320 list_length (tree t)
01321 {
01322   tree p = t;
01323 #ifdef ENABLE_TREE_CHECKING
01324   tree q = t;
01325 #endif
01326   int len = 0;
01327 
01328   while (p)
01329     {
01330       p = TREE_CHAIN (p);
01331 #ifdef ENABLE_TREE_CHECKING
01332       if (len % 2)
01333   q = TREE_CHAIN (q);
01334       gcc_assert (p != q);
01335 #endif
01336       len++;
01337     }
01338 
01339   return len;
01340 }
01341 
01342 /* Returns the number of FIELD_DECLs in TYPE.  */
01343 
01344 int
01345 fields_length (tree type)
01346 {
01347   tree t = TYPE_FIELDS (type);
01348   int count = 0;
01349 
01350   for (; t; t = TREE_CHAIN (t))
01351     if (TREE_CODE (t) == FIELD_DECL)
01352       ++count;
01353 
01354   return count;
01355 }
01356 
01357 /* Concatenate two chains of nodes (chained through TREE_CHAIN)
01358    by modifying the last node in chain 1 to point to chain 2.
01359    This is the Lisp primitive `nconc'.  */
01360 
01361 tree
01362 chainon (tree op1, tree op2)
01363 {
01364   tree t1;
01365 
01366   if (!op1)
01367     return op2;
01368   if (!op2)
01369     return op1;
01370 
01371   for (t1 = op1; TREE_CHAIN (t1); t1 = TREE_CHAIN (t1))
01372     continue;
01373   TREE_CHAIN (t1) = op2;
01374 
01375 #ifdef ENABLE_TREE_CHECKING
01376   {
01377     tree t2;
01378     for (t2 = op2; t2; t2 = TREE_CHAIN (t2))
01379       gcc_assert (t2 != t1);
01380   }
01381 #endif
01382 
01383   return op1;
01384 }
01385 
01386 /* Return the last node in a chain of nodes (chained through TREE_CHAIN).  */
01387 
01388 tree
01389 tree_last (tree chain)
01390 {
01391   tree next;
01392   if (chain)
01393     while ((next = TREE_CHAIN (chain)))
01394       chain = next;
01395   return chain;
01396 }
01397 
01398 /* Reverse the order of elements in the chain T,
01399    and return the new head of the chain (old last element).  */
01400 
01401 tree
01402 nreverse (tree t)
01403 {
01404   tree prev = 0, decl, next;
01405   for (decl = t; decl; decl = next)
01406     {
01407       next = TREE_CHAIN (decl);
01408       TREE_CHAIN (decl) = prev;
01409       prev = decl;
01410     }
01411   return prev;
01412 }
01413 
01414 /* Return a newly created TREE_LIST node whose
01415    purpose and value fields are PARM and VALUE.  */
01416 
01417 tree
01418 build_tree_list_stat (tree parm, tree value MEM_STAT_DECL)
01419 {
01420   tree t = make_node_stat (TREE_LIST PASS_MEM_STAT);
01421   TREE_PURPOSE (t) = parm;
01422   TREE_VALUE (t) = value;
01423   return t;
01424 }
01425 
01426 /* Return a newly created TREE_LIST node whose
01427    purpose and value fields are PURPOSE and VALUE
01428    and whose TREE_CHAIN is CHAIN.  */
01429 
01430 tree
01431 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
01432 {
01433   tree node;
01434 
01435   node = ggc_alloc_zone_stat (sizeof (struct tree_list),
01436             tree_zone PASS_MEM_STAT);
01437 
01438   memset (node, 0, sizeof (struct tree_common));
01439 
01440 #ifdef GATHER_STATISTICS
01441   tree_node_counts[(int) x_kind]++;
01442   tree_node_sizes[(int) x_kind] += sizeof (struct tree_list);
01443 #endif
01444 
01445   TREE_SET_CODE (node, TREE_LIST);
01446   TREE_CHAIN (node) = chain;
01447   TREE_PURPOSE (node) = purpose;
01448   TREE_VALUE (node) = value;
01449   return node;
01450 }
01451 
01452 
01453 /* Return the size nominally occupied by an object of type TYPE
01454    when it resides in memory.  The value is measured in units of bytes,
01455    and its data type is that normally used for type sizes
01456    (which is the first type created by make_signed_type or
01457    make_unsigned_type).  */
01458 
01459 tree
01460 size_in_bytes (tree type)
01461 {
01462   tree t;
01463 
01464   if (type == error_mark_node)
01465     return integer_zero_node;
01466 
01467   type = TYPE_MAIN_VARIANT (type);
01468   t = TYPE_SIZE_UNIT (type);
01469 
01470   if (t == 0)
01471     {
01472       lang_hooks.types.incomplete_type_error (NULL_TREE, type);
01473       return size_zero_node;
01474     }
01475 
01476   if (TREE_CODE (t) == INTEGER_CST)
01477     t = force_fit_type (t, 0, false, false);
01478 
01479   return t;
01480 }
01481 
01482 /* Return the size of TYPE (in bytes) as a wide integer
01483    or return -1 if the size can vary or is larger than an integer.  */
01484 
01485 HOST_WIDE_INT
01486 int_size_in_bytes (tree type)
01487 {
01488   tree t;
01489 
01490   if (type == error_mark_node)
01491     return 0;
01492 
01493   type = TYPE_MAIN_VARIANT (type);
01494   t = TYPE_SIZE_UNIT (type);
01495   if (t == 0
01496       || TREE_CODE (t) != INTEGER_CST
01497       || TREE_OVERFLOW (t)
01498       || TREE_INT_CST_HIGH (t) != 0
01499       /* If the result would appear negative, it's too big to represent.  */
01500       || (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)
01501     return -1;
01502 
01503   return TREE_INT_CST_LOW (t);
01504 }
01505 
01506 /* Return the bit position of FIELD, in bits from the start of the record.
01507    This is a tree of type bitsizetype.  */
01508 
01509 tree
01510 bit_position (tree field)
01511 {
01512   return bit_from_pos (DECL_FIELD_OFFSET (field),
01513            DECL_FIELD_BIT_OFFSET (field));
01514 }
01515 
01516 /* Likewise, but return as an integer.  Abort if it cannot be represented
01517    in that way (since it could be a signed value, we don't have the option
01518    of returning -1 like int_size_in_byte can.  */
01519 
01520 HOST_WIDE_INT
01521 int_bit_position (tree field)
01522 {
01523   return tree_low_cst (bit_position (field), 0);
01524 }
01525 
01526 /* Return the byte position of FIELD, in bytes from the start of the record.
01527    This is a tree of type sizetype.  */
01528 
01529 tree
01530 byte_position (tree field)
01531 {
01532   return byte_from_pos (DECL_FIELD_OFFSET (field),
01533       DECL_FIELD_BIT_OFFSET (field));
01534 }
01535 
01536 /* Likewise, but return as an integer.  Abort if it cannot be represented
01537    in that way (since it could be a signed value, we don't have the option
01538    of returning -1 like int_size_in_byte can.  */
01539 
01540 HOST_WIDE_INT
01541 int_byte_position (tree field)
01542 {
01543   return tree_low_cst (byte_position (field), 0);
01544 }
01545 
01546 /* Return the strictest alignment, in bits, that T is known to have.  */
01547 
01548 unsigned int
01549 expr_align (tree t)
01550 {
01551   unsigned int align0, align1;
01552 
01553   switch (TREE_CODE (t))
01554     {
01555     case NOP_EXPR:  case CONVERT_EXPR:  case NON_LVALUE_EXPR:
01556       /* If we have conversions, we know that the alignment of the
01557    object must meet each of the alignments of the types.  */
01558       align0 = expr_align (TREE_OPERAND (t, 0));
01559       align1 = TYPE_ALIGN (TREE_TYPE (t));
01560       return MAX (align0, align1);
01561 
01562     case SAVE_EXPR:         case COMPOUND_EXPR:       case MODIFY_EXPR:
01563     case INIT_EXPR:         case TARGET_EXPR:         case WITH_CLEANUP_EXPR:
01564     case CLEANUP_POINT_EXPR:
01565       /* These don't change the alignment of an object.  */
01566       return expr_align (TREE_OPERAND (t, 0));
01567 
01568     case COND_EXPR:
01569       /* The best we can do is say that the alignment is the least aligned
01570    of the two arms.  */
01571       align0 = expr_align (TREE_OPERAND (t, 1));
01572       align1 = expr_align (TREE_OPERAND (t, 2));
01573       return MIN (align0, align1);
01574 
01575     case LABEL_DECL:     case CONST_DECL:
01576     case VAR_DECL:       case PARM_DECL:   case RESULT_DECL:
01577       if (DECL_ALIGN (t) != 0)
01578   return DECL_ALIGN (t);
01579       break;
01580 
01581     case FUNCTION_DECL:
01582       return FUNCTION_BOUNDARY;
01583 
01584     default:
01585       break;
01586     }
01587 
01588   /* Otherwise take the alignment from that of the type.  */
01589   return TYPE_ALIGN (TREE_TYPE (t));
01590 }
01591 
01592 /* Return, as a tree node, the number of elements for TYPE (which is an
01593    ARRAY_TYPE) minus one. This counts only elements of the top array.  */
01594 
01595 tree
01596 array_type_nelts (tree type)
01597 {
01598   tree index_type, min, max;
01599 
01600   /* If they did it with unspecified bounds, then we should have already
01601      given an error about it before we got here.  */
01602   if (! TYPE_DOMAIN (type))
01603     return error_mark_node;
01604 
01605   index_type = TYPE_DOMAIN (type);
01606   min = TYPE_MIN_VALUE (index_type);
01607   max = TYPE_MAX_VALUE (index_type);
01608 
01609   return (integer_zerop (min)
01610     ? max
01611     : fold (build2 (MINUS_EXPR, TREE_TYPE (max), max, min)));
01612 }
01613 
01614 /* If arg is static -- a reference to an object in static storage -- then
01615    return the object.  This is not the same as the C meaning of `static'.
01616    If arg isn't static, return NULL.  */
01617 
01618 tree
01619 staticp (tree arg)
01620 {
01621   switch (TREE_CODE (arg))
01622     {
01623     case FUNCTION_DECL:
01624       /* Nested functions are static, even though taking their address will
01625    involve a trampoline as we unnest the nested function and create
01626    the trampoline on the tree level.  */
01627       return arg;
01628 
01629     case VAR_DECL:
01630       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
01631         && ! DECL_THREAD_LOCAL (arg)
01632         && ! DECL_NON_ADDR_CONST_P (arg)
01633         ? arg : NULL);
01634 
01635     case CONST_DECL:
01636       return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
01637         ? arg : NULL);
01638 
01639     case CONSTRUCTOR:
01640       return TREE_STATIC (arg) ? arg : NULL;
01641 
01642     case LABEL_DECL:
01643     case STRING_CST:
01644       return arg;
01645 
01646     case COMPONENT_REF:
01647       /* If the thing being referenced is not a field, then it is
01648    something language specific.  */
01649       if (TREE_CODE (TREE_OPERAND (arg, 1)) != FIELD_DECL)
01650   return (*lang_hooks.staticp) (arg);
01651 
01652       /* If we are referencing a bitfield, we can't evaluate an
01653    ADDR_EXPR at compile time and so it isn't a constant.  */
01654       if (DECL_BIT_FIELD (TREE_OPERAND (arg, 1)))
01655   return NULL;
01656 
01657       return staticp (TREE_OPERAND (arg, 0));
01658 
01659     case BIT_FIELD_REF:
01660       return NULL;
01661 
01662     case MISALIGNED_INDIRECT_REF:
01663     case ALIGN_INDIRECT_REF:
01664     case INDIRECT_REF:
01665       return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL;
01666 
01667     case ARRAY_REF:
01668     case ARRAY_RANGE_REF:
01669       if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST
01670     && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
01671   return staticp (TREE_OPERAND (arg, 0));
01672       else
01673   return false;
01674 
01675     default:
01676       if ((unsigned int) TREE_CODE (arg)
01677     >= (unsigned int) LAST_AND_UNUSED_TREE_CODE)
01678   return lang_hooks.staticp (arg);
01679       else
01680   return NULL;
01681     }
01682 }
01683 
01684 /* Wrap a SAVE_EXPR around EXPR, if appropriate.
01685    Do this to any expression which may be used in more than one place,
01686    but must be evaluated only once.
01687 
01688    Normally, expand_expr would reevaluate the expression each time.
01689    Calling save_expr produces something that is evaluated and recorded
01690    the first time expand_expr is called on it.  Subsequent calls to
01691    expand_expr just reuse the recorded value.
01692 
01693    The call to expand_expr that generates code that actually computes
01694    the value is the first call *at compile time*.  Subsequent calls
01695    *at compile time* generate code to use the saved value.
01696    This produces correct result provided that *at run time* control
01697    always flows through the insns made by the first expand_expr
01698    before reaching the other places where the save_expr was evaluated.
01699    You, the caller of save_expr, must make sure this is so.
01700 
01701    Constants, and certain read-only nodes, are returned with no
01702    SAVE_EXPR because that is safe.  Expressions containing placeholders
01703    are not touched; see tree.def for an explanation of what these
01704    are used for.  */
01705 
01706 tree
01707 save_expr (tree expr)
01708 {
01709   tree t = fold (expr);
01710   tree inner;
01711 
01712   /* If the tree evaluates to a constant, then we don't want to hide that
01713      fact (i.e. this allows further folding, and direct checks for constants).
01714      However, a read-only object that has side effects cannot be bypassed.
01715      Since it is no problem to reevaluate literals, we just return the
01716      literal node.  */
01717   inner = skip_simple_arithmetic (t);
01718 
01719   if (TREE_INVARIANT (inner)
01720       || (TREE_READONLY (inner) && ! TREE_SIDE_EFFECTS (inner))
01721       || TREE_CODE (inner) == SAVE_EXPR
01722       || TREE_CODE (inner) == ERROR_MARK)
01723     return t;
01724 
01725   /* If INNER contains a PLACEHOLDER_EXPR, we must evaluate it each time, since
01726      it means that the size or offset of some field of an object depends on
01727      the value within another field.
01728 
01729      Note that it must not be the case that T contains both a PLACEHOLDER_EXPR
01730      and some variable since it would then need to be both evaluated once and
01731      evaluated more than once.  Front-ends must assure this case cannot
01732      happen by surrounding any such subexpressions in their own SAVE_EXPR
01733      and forcing evaluation at the proper time.  */
01734   if (contains_placeholder_p (inner))
01735     return t;
01736 
01737   t = build1 (SAVE_EXPR, TREE_TYPE (expr), t);
01738 
01739   /* This expression might be placed ahead of a jump to ensure that the
01740      value was computed on both sides of the jump.  So make sure it isn't
01741      eliminated as dead.  */
01742   TREE_SIDE_EFFECTS (t) = 1;
01743   TREE_INVARIANT (t) = 1;
01744   return t;
01745 }
01746 
01747 /* Look inside EXPR and into any simple arithmetic operations.  Return
01748    the innermost non-arithmetic node.  */
01749 
01750 tree
01751 skip_simple_arithmetic (tree expr)
01752 {
01753   tree inner;
01754 
01755   /* We don't care about whether this can be used as an lvalue in this
01756      context.  */
01757   while (TREE_CODE (expr) == NON_LVALUE_EXPR)
01758     expr = TREE_OPERAND (expr, 0);
01759 
01760   /* If we have simple operations applied to a SAVE_EXPR or to a SAVE_EXPR and
01761      a constant, it will be more efficient to not make another SAVE_EXPR since
01762      it will allow better simplification and GCSE will be able to merge the
01763      computations if they actually occur.  */
01764   inner = expr;
01765   while (1)
01766     {
01767       if (UNARY_CLASS_P (inner))
01768   inner = TREE_OPERAND (inner, 0);
01769       else if (BINARY_CLASS_P (inner))
01770   {
01771     if (TREE_INVARIANT (TREE_OPERAND (inner, 1)))
01772       inner = TREE_OPERAND (inner, 0);
01773     else if (TREE_INVARIANT (TREE_OPERAND (inner, 0)))
01774       inner = TREE_OPERAND (inner, 1);
01775     else
01776       break;
01777   }
01778       else
01779   break;
01780     }
01781 
01782   return inner;
01783 }
01784 
01785 /* Return which tree structure is used by T.  */
01786 
01787 enum tree_node_structure_enum
01788 tree_node_structure (tree t)
01789 {
01790   enum tree_code code = TREE_CODE (t);
01791 
01792   switch (TREE_CODE_CLASS (code))
01793     {
01794     case tcc_declaration:
01795       return TS_DECL;
01796     case tcc_type:
01797       return TS_TYPE;
01798     case tcc_reference:
01799     case tcc_comparison:
01800     case tcc_unary:
01801     case tcc_binary:
01802     case tcc_expression:
01803     case tcc_statement:
01804       return TS_EXP;
01805     default:  /* tcc_constant and tcc_exceptional */
01806       break;
01807     }
01808   switch (code)
01809     {
01810       /* tcc_constant cases.  */
01811     case INTEGER_CST:   return TS_INT_CST;
01812     case REAL_CST:    return TS_REAL_CST;
01813     case COMPLEX_CST:   return TS_COMPLEX;
01814     case VECTOR_CST:    return TS_VECTOR;
01815     case STRING_CST:    return TS_STRING;
01816       /* tcc_exceptional cases.  */
01817     case ERROR_MARK:    return TS_COMMON;
01818     case IDENTIFIER_NODE: return TS_IDENTIFIER;
01819     case TREE_LIST:   return TS_LIST;
01820     case TREE_VEC:    return TS_VEC;
01821     case PHI_NODE:    return TS_PHI_NODE;
01822     case SSA_NAME:    return TS_SSA_NAME;
01823     case PLACEHOLDER_EXPR:  return TS_COMMON;
01824     case STATEMENT_LIST:  return TS_STATEMENT_LIST;
01825     case BLOCK:     return TS_BLOCK;
01826     case TREE_BINFO:    return TS_BINFO;
01827     case VALUE_HANDLE:    return TS_VALUE_HANDLE;
01828 
01829     default:
01830       gcc_unreachable ();
01831     }
01832 }
01833 
01834 /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size
01835    or offset that depends on a field within a record.  */
01836 
01837 bool
01838 contains_placeholder_p (tree exp)
01839 {
01840   enum tree_code code;
01841 
01842   if (!exp)
01843     return 0;
01844 
01845   code = TREE_CODE (exp);
01846   if (code == PLACEHOLDER_EXPR)
01847     return 1;
01848 
01849   switch (TREE_CODE_CLASS (code))
01850     {
01851     case tcc_reference:
01852       /* Don't look at any PLACEHOLDER_EXPRs that might be in index or bit
01853    position computations since they will be converted into a
01854    WITH_RECORD_EXPR involving the reference, which will assume
01855    here will be valid.  */
01856       return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
01857 
01858     case tcc_exceptional:
01859       if (code == TREE_LIST)
01860   return (CONTAINS_PLACEHOLDER_P (TREE_VALUE (exp))
01861     || CONTAINS_PLACEHOLDER_P (TREE_CHAIN (exp)));
01862       break;
01863 
01864     case tcc_unary:
01865     case tcc_binary:
01866     case tcc_comparison:
01867     case tcc_expression:
01868       switch (code)
01869   {
01870   case COMPOUND_EXPR:
01871     /* Ignoring the first operand isn't quite right, but works best.  */
01872     return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1));
01873 
01874   case COND_EXPR:
01875     return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
01876       || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1))
01877       || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 2)));
01878 
01879   case CALL_EXPR:
01880     return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1));
01881 
01882   default:
01883     break;
01884   }
01885 
01886       switch (TREE_CODE_LENGTH (code))
01887   {
01888   case 1:
01889     return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
01890   case 2:
01891     return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0))
01892       || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1)));
01893   default:
01894     return 0;
01895   }
01896 
01897     default:
01898       return 0;
01899     }
01900   return 0;
01901 }
01902 
01903 /* Return true if any part of the computation of TYPE involves a
01904    PLACEHOLDER_EXPR.  This includes size, bounds, qualifiers
01905    (for QUAL_UNION_TYPE) and field positions.  */
01906 
01907 static bool
01908 type_contains_placeholder_1 (tree type)
01909 {
01910   /* If the size contains a placeholder or the parent type (component type in
01911      the case of arrays) type involves a placeholder, this type does.  */
01912   if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type))
01913       || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type))
01914       || (TREE_TYPE (type) != 0
01915     && type_contains_placeholder_p (TREE_TYPE (type))))
01916     return true;
01917 
01918   /* Now do type-specific checks.  Note that the last part of the check above
01919      greatly limits what we have to do below.  */
01920   switch (TREE_CODE (type))
01921     {
01922     case VOID_TYPE:
01923     case COMPLEX_TYPE:
01924     case ENUMERAL_TYPE:
01925     case BOOLEAN_TYPE:
01926     case CHAR_TYPE:
01927     case POINTER_TYPE:
01928     case OFFSET_TYPE:
01929     case REFERENCE_TYPE:
01930     case METHOD_TYPE:
01931     case FILE_TYPE:
01932     case FUNCTION_TYPE:
01933     case VECTOR_TYPE:
01934       return false;
01935 
01936     case INTEGER_TYPE:
01937     case REAL_TYPE:
01938       /* Here we just check the bounds.  */
01939       return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type))
01940         || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type)));
01941 
01942     case ARRAY_TYPE:
01943       /* We're already checked the component type (TREE_TYPE), so just check
01944    the index type.  */
01945       return type_contains_placeholder_p (TYPE_DOMAIN (type));
01946 
01947     case RECORD_TYPE:
01948     case UNION_TYPE:
01949     case QUAL_UNION_TYPE:
01950       {
01951   tree field;
01952 
01953   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
01954     if (TREE_CODE (field) == FIELD_DECL
01955         && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field))
01956       || (TREE_CODE (type) == QUAL_UNION_TYPE
01957           && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field)))
01958       || type_contains_placeholder_p (TREE_TYPE (field))))
01959       return true;
01960 
01961   return false;
01962       }
01963 
01964     default:
01965       gcc_unreachable ();
01966     }
01967 }
01968 
01969 bool
01970 type_contains_placeholder_p (tree type)
01971 {
01972   bool result;
01973 
01974   /* If the contains_placeholder_bits field has been initialized,
01975      then we know the answer.  */
01976   if (TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) > 0)
01977     return TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) - 1;
01978 
01979   /* Indicate that we've seen this type node, and the answer is false.
01980      This is what we want to return if we run into recursion via fields.  */
01981   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = 1;
01982 
01983   /* Compute the real value.  */
01984   result = type_contains_placeholder_1 (type);
01985 
01986   /* Store the real value.  */
01987   TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type) = result + 1;
01988 
01989   return result;
01990 }
01991 
01992 /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
01993    return a tree with all occurrences of references to F in a
01994    PLACEHOLDER_EXPR replaced by R.   Note that we assume here that EXP
01995    contains only arithmetic expressions or a CALL_EXPR with a
01996    PLACEHOLDER_EXPR occurring only in its arglist.  */
01997 
01998 tree
01999 substitute_in_expr (tree exp, tree f, tree r)
02000 {
02001   enum tree_code code = TREE_CODE (exp);
02002   tree op0, op1, op2;
02003   tree new;
02004   tree inner;
02005 
02006   /* We handle TREE_LIST and COMPONENT_REF separately.  */
02007   if (code == TREE_LIST)
02008     {
02009       op0 = SUBSTITUTE_IN_EXPR (TREE_CHAIN (exp), f, r);
02010       op1 = SUBSTITUTE_IN_EXPR (TREE_VALUE (exp), f, r);
02011       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
02012   return exp;
02013 
02014       return tree_cons (TREE_PURPOSE (exp), op1, op0);
02015     }
02016   else if (code == COMPONENT_REF)
02017    {
02018      /* If this expression is getting a value from a PLACEHOLDER_EXPR
02019   and it is the right field, replace it with R.  */
02020      for (inner = TREE_OPERAND (exp, 0);
02021     REFERENCE_CLASS_P (inner);
02022     inner = TREE_OPERAND (inner, 0))
02023        ;
02024      if (TREE_CODE (inner) == PLACEHOLDER_EXPR
02025    && TREE_OPERAND (exp, 1) == f)
02026        return r;
02027 
02028      /* If this expression hasn't been completed let, leave it alone.  */
02029      if (TREE_CODE (inner) == PLACEHOLDER_EXPR && TREE_TYPE (inner) == 0)
02030        return exp;
02031 
02032      op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
02033      if (op0 == TREE_OPERAND (exp, 0))
02034        return exp;
02035 
02036      new = fold (build3 (COMPONENT_REF, TREE_TYPE (exp),
02037        op0, TREE_OPERAND (exp, 1), NULL_TREE));
02038    }
02039   else
02040     switch (TREE_CODE_CLASS (code))
02041       {
02042       case tcc_constant:
02043       case tcc_declaration:
02044   return exp;
02045 
02046       case tcc_exceptional:
02047       case tcc_unary:
02048       case tcc_binary:
02049       case tcc_comparison:
02050       case tcc_expression:
02051       case tcc_reference:
02052   switch (TREE_CODE_LENGTH (code))
02053     {
02054     case 0:
02055       return exp;
02056 
02057     case 1:
02058       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
02059       if (op0 == TREE_OPERAND (exp, 0))
02060         return exp;
02061 
02062       new = fold (build1 (code, TREE_TYPE (exp), op0));
02063       break;
02064 
02065     case 2:
02066       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
02067       op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
02068 
02069       if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
02070         return exp;
02071 
02072       new = fold (build2 (code, TREE_TYPE (exp), op0, op1));
02073       break;
02074 
02075     case 3:
02076       op0 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 0), f, r);
02077       op1 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 1), f, r);
02078       op2 = SUBSTITUTE_IN_EXPR (TREE_OPERAND (exp, 2), f, r);
02079 
02080       if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
02081     && op2 == TREE_OPERAND (exp, 2))
02082         return exp;
02083 
02084       new = fold (build3 (code, TREE_TYPE (exp), op0, op1, op2));
02085       break;
02086 
02087     default:
02088       gcc_unreachable ();
02089     }
02090   break;
02091 
02092       default:
02093   gcc_unreachable ();
02094       }
02095 
02096   TREE_READONLY (new) = TREE_READONLY (exp);
02097   return new;
02098 }
02099 
02100 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
02101    for it within OBJ, a tree that is an object or a chain of references.  */
02102 
02103 tree
02104 substitute_placeholder_in_expr (tree exp, tree obj)
02105 {
02106   enum tree_code code = TREE_CODE (exp);
02107   tree op0, op1, op2, op3;
02108 
02109   /* If this is a PLACEHOLDER_EXPR, see if we find a corresponding type
02110      in the chain of OBJ.  */
02111   if (code == PLACEHOLDER_EXPR)
02112     {
02113       tree need_type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
02114       tree elt;
02115 
02116       for (elt = obj; elt != 0;
02117      elt = ((TREE_CODE (elt) == COMPOUND_EXPR
02118        || TREE_CODE (elt) == COND_EXPR)
02119       ? TREE_OPERAND (elt, 1)
02120       : (REFERENCE_CLASS_P (elt)
02121          || UNARY_CLASS_P (elt)
02122          || BINARY_CLASS_P (elt)
02123          || EXPRESSION_CLASS_P (elt))
02124       ? TREE_OPERAND (elt, 0) : 0))
02125   if (TYPE_MAIN_VARIANT (TREE_TYPE (elt)) == need_type)
02126     return elt;
02127 
02128       for (elt = obj; elt != 0;
02129      elt = ((TREE_CODE (elt) == COMPOUND_EXPR
02130        || TREE_CODE (elt) == COND_EXPR)
02131       ? TREE_OPERAND (elt, 1)
02132       : (REFERENCE_CLASS_P (elt)
02133          || UNARY_CLASS_P (elt)
02134          || BINARY_CLASS_P (elt)
02135          || EXPRESSION_CLASS_P (elt))
02136       ? TREE_OPERAND (elt, 0) : 0))
02137   if (POINTER_TYPE_P (TREE_TYPE (elt))
02138       && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt)))
02139     == need_type))
02140     return fold (build1 (INDIRECT_REF, need_type, elt));
02141 
02142       /* If we didn't find it, return the original PLACEHOLDER_EXPR.  If it
02143    survives until RTL generation, there will be an error.  */
02144       return exp;
02145     }
02146 
02147   /* TREE_LIST is special because we need to look at TREE_VALUE
02148      and TREE_CHAIN, not TREE_OPERANDS.  */
02149   else if (code == TREE_LIST)
02150     {
02151       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_CHAIN (exp), obj);
02152       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_VALUE (exp), obj);
02153       if (op0 == TREE_CHAIN (exp) && op1 == TREE_VALUE (exp))
02154   return exp;
02155 
02156       return tree_cons (TREE_PURPOSE (exp), op1, op0);
02157     }
02158   else
02159     switch (TREE_CODE_CLASS (code))
02160       {
02161       case tcc_constant:
02162       case tcc_declaration:
02163   return exp;
02164 
02165       case tcc_exceptional:
02166       case tcc_unary:
02167       case tcc_binary:
02168       case tcc_comparison:
02169       case tcc_expression:
02170       case tcc_reference:
02171       case tcc_statement:
02172   switch (TREE_CODE_LENGTH (code))
02173     {
02174     case 0:
02175       return exp;
02176 
02177     case 1:
02178       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
02179       if (op0 == TREE_OPERAND (exp, 0))
02180         return exp;
02181       else
02182         return fold (build1 (code, TREE_TYPE (exp), op0));
02183 
02184     case 2:
02185       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
02186       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
02187 
02188       if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1))
02189         return exp;
02190       else
02191         return fold (build2 (code, TREE_TYPE (exp), op0, op1));
02192 
02193     case 3:
02194       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
02195       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
02196       op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
02197 
02198       if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
02199     && op2 == TREE_OPERAND (exp, 2))
02200         return exp;
02201       else
02202         return fold (build3 (code, TREE_TYPE (exp), op0, op1, op2));
02203 
02204     case 4:
02205       op0 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 0), obj);
02206       op1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 1), obj);
02207       op2 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 2), obj);
02208       op3 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TREE_OPERAND (exp, 3), obj);
02209 
02210       if (op0 == TREE_OPERAND (exp, 0) && op1 == TREE_OPERAND (exp, 1)
02211     && op2 == TREE_OPERAND (exp, 2)
02212     && op3 == TREE_OPERAND (exp, 3))
02213         return exp;
02214       else
02215         return fold (build4 (code, TREE_TYPE (exp), op0, op1, op2, op3));
02216 
02217     default:
02218       gcc_unreachable ();
02219     }
02220   break;
02221 
02222       default:
02223   gcc_unreachable ();
02224       }
02225 }
02226 
02227 /* Stabilize a reference so that we can use it any number of times
02228    without causing its operands to be evaluated more than once.
02229    Returns the stabilized reference.  This works by means of save_expr,
02230    so see the caveats in the comments about save_expr.
02231 
02232    Also allows conversion expressions whose operands are references.
02233    Any other kind of expression is returned unchanged.  */
02234 
02235 tree
02236 stabilize_reference (tree ref)
02237 {
02238   tree result;
02239   enum tree_code code = TREE_CODE (ref);
02240 
02241   switch (code)
02242     {
02243     case VAR_DECL:
02244     case PARM_DECL:
02245     case RESULT_DECL:
02246       /* No action is needed in this case.  */
02247       return ref;
02248 
02249     case NOP_EXPR:
02250     case CONVERT_EXPR:
02251     case FLOAT_EXPR:
02252     case FIX_TRUNC_EXPR:
02253     case FIX_FLOOR_EXPR:
02254     case FIX_ROUND_EXPR:
02255     case FIX_CEIL_EXPR:
02256       result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
02257       break;
02258 
02259     case INDIRECT_REF:
02260       result = build_nt (INDIRECT_REF,
02261        stabilize_reference_1 (TREE_OPERAND (ref, 0)));
02262       break;
02263 
02264     case COMPONENT_REF:
02265       result = build_nt (COMPONENT_REF,
02266        stabilize_reference (TREE_OPERAND (ref, 0)),
02267        TREE_OPERAND (ref, 1), NULL_TREE);
02268       break;
02269 
02270     case BIT_FIELD_REF:
02271       result = build_nt (BIT_FIELD_REF,
02272        stabilize_reference (TREE_OPERAND (ref, 0)),
02273        stabilize_reference_1 (TREE_OPERAND (ref, 1)),
02274        stabilize_reference_1 (TREE_OPERAND (ref, 2)));
02275       break;
02276 
02277     case ARRAY_REF:
02278       result = build_nt (ARRAY_REF,
02279        stabilize_reference (TREE_OPERAND (ref, 0)),
02280        stabilize_reference_1 (TREE_OPERAND (ref, 1)),
02281        TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
02282       break;
02283 
02284     case ARRAY_RANGE_REF:
02285       result = build_nt (ARRAY_RANGE_REF,
02286        stabilize_reference (TREE_OPERAND (ref, 0)),
02287        stabilize_reference_1 (TREE_OPERAND (ref, 1)),
02288        TREE_OPERAND (ref, 2), TREE_OPERAND (ref, 3));
02289       break;
02290 
02291     case COMPOUND_EXPR:
02292       /* We cannot wrap the first expression in a SAVE_EXPR, as then
02293    it wouldn't be ignored.  This matters when dealing with
02294    volatiles.  */
02295       return stabilize_reference_1 (ref);
02296 
02297       /* If arg isn't a kind of lvalue we recognize, make no change.
02298    Caller should recognize the error for an invalid lvalue.  */
02299     default:
02300       return ref;
02301 
02302     case ERROR_MARK:
02303       return error_mark_node;
02304     }
02305 
02306   TREE_TYPE (result) = TREE_TYPE (ref);
02307   TREE_READONLY (result) = TREE_READONLY (ref);
02308   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
02309   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
02310 
02311   return result;
02312 }
02313 
02314 /* Subroutine of stabilize_reference; this is called for subtrees of
02315    references.  Any expression with side-effects must be put in a SAVE_EXPR
02316    to ensure that it is only evaluated once.
02317 
02318    We don't put SAVE_EXPR nodes around everything, because assigning very
02319    simple expressions to temporaries causes us to miss good opportunities
02320    for optimizations.  Among other things, the opportunity to fold in the
02321    addition of a constant into an addressing mode often gets lost, e.g.
02322    "y[i+1] += x;".  In general, we take the approach that we should not make
02323    an assignment unless we are forced into it - i.e., that any non-side effect
02324    operator should be allowed, and that cse should take care of coalescing
02325    multiple utterances of the same expression should that prove fruitful.  */
02326 
02327 tree
02328 stabilize_reference_1 (tree e)
02329 {
02330   tree result;
02331   enum tree_code code = TREE_CODE (e);
02332 
02333   /* We cannot ignore const expressions because it might be a reference
02334      to a const array but whose index contains side-effects.  But we can
02335      ignore things that are actual constant or that already have been
02336      handled by this function.  */
02337 
02338   if (TREE_INVARIANT (e))
02339     return e;
02340 
02341   switch (TREE_CODE_CLASS (code))
02342     {
02343     case tcc_exceptional:
02344     case tcc_type:
02345     case tcc_declaration:
02346     case tcc_comparison:
02347     case tcc_statement:
02348     case tcc_expression:
02349     case tcc_reference:
02350       /* If the expression has side-effects, then encase it in a SAVE_EXPR
02351    so that it will only be evaluated once.  */
02352       /* The reference (r) and comparison (<) classes could be handled as
02353    below, but it is generally faster to only evaluate them once.  */
02354       if (TREE_SIDE_EFFECTS (e))
02355   return save_expr (e);
02356       return e;
02357 
02358     case tcc_constant:
02359       /* Constants need no processing.  In fact, we should never reach
02360    here.  */
02361       return e;
02362 
02363     case tcc_binary:
02364       /* Division is slow and tends to be compiled with jumps,
02365    especially the division by powers of 2 that is often
02366    found inside of an array reference.  So do it just once.  */
02367       if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR
02368     || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR
02369     || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR
02370     || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR)
02371   return save_expr (e);
02372       /* Recursively stabilize each operand.  */
02373       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)),
02374        stabilize_reference_1 (TREE_OPERAND (e, 1)));
02375       break;
02376 
02377     case tcc_unary:
02378       /* Recursively stabilize each operand.  */
02379       result = build_nt (code, stabilize_reference_1 (TREE_OPERAND (e, 0)));
02380       break;
02381 
02382     default:
02383       gcc_unreachable ();
02384     }
02385 
02386   TREE_TYPE (result) = TREE_TYPE (e);
02387   TREE_READONLY (result) = TREE_READONLY (e);
02388   TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (e);
02389   TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e);
02390   TREE_INVARIANT (result) = 1;
02391 
02392   return result;
02393 }
02394 
02395 /* Low-level constructors for expressions.  */
02396 
02397 /* A helper function for build1 and constant folders.  Set TREE_CONSTANT,
02398    TREE_INVARIANT, and TREE_SIDE_EFFECTS for an ADDR_EXPR.  */
02399 
02400 void
02401 recompute_tree_invarant_for_addr_expr (tree t)
02402 {
02403   tree node;
02404   bool tc = true, ti = true, se = false;
02405 
02406   /* We started out assuming this address is both invariant and constant, but
02407      does not have side effects.  Now go down any handled components and see if
02408      any of them involve offsets that are either non-constant or non-invariant.
02409      Also check for side-effects.
02410 
02411      ??? Note that this code makes no attempt to deal with the case where
02412      taking the address of something causes a copy due to misalignment.  */
02413 
02414 #define UPDATE_TITCSE(NODE)  \
02415 do { tree _node = (NODE); \
02416      if (_node && !TREE_INVARIANT (_node)) ti = false; \
02417      if (_node && !TREE_CONSTANT (_node)) tc = false; \
02418      if (_node && TREE_SIDE_EFFECTS (_node)) se = true; } while (0)
02419 
02420   for (node = TREE_OPERAND (t, 0); handled_component_p (node);
02421        node = TREE_OPERAND (node, 0))
02422     {
02423       /* If the first operand doesn't have an ARRAY_TYPE, this is a bogus
02424    array reference (probably made temporarily by the G++ front end),
02425    so ignore all the operands.  */
02426       if ((TREE_CODE (node) == ARRAY_REF
02427      || TREE_CODE (node) == ARRAY_RANGE_REF)
02428     && TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == ARRAY_TYPE)
02429   {
02430     UPDATE_TITCSE (TREE_OPERAND (node, 1));
02431     if (TREE_OPERAND (node, 2))
02432       UPDATE_TITCSE (TREE_OPERAND (node, 2));
02433     if (TREE_OPERAND (node, 3))
02434       UPDATE_TITCSE (TREE_OPERAND (node, 3));
02435   }
02436       /* Likewise, just because this is a COMPONENT_REF doesn't mean we have a
02437    FIELD_DECL, apparently.  The G++ front end can put something else
02438    there, at least temporarily.  */
02439       else if (TREE_CODE (node) == COMPONENT_REF
02440          && TREE_CODE (TREE_OPERAND (node, 1)) == FIELD_DECL)
02441   {
02442     if (TREE_OPERAND (node, 2))
02443       UPDATE_TITCSE (TREE_OPERAND (node, 2));
02444   }
02445       else if (TREE_CODE (node) == BIT_FIELD_REF)
02446   UPDATE_TITCSE (TREE_OPERAND (node, 2));
02447     }
02448 
02449   node = lang_hooks.expr_to_decl (node, &tc, &ti, &se);
02450 
02451   /* Now see what's inside.  If it's an INDIRECT_REF, copy our properties from
02452      the address, since &(*a)->b is a form of addition.  If it's a decl, it's
02453      invariant and constant if the decl is static.  It's also invariant if it's
02454      a decl in the current function.  Taking the address of a volatile variable
02455      is not volatile.  If it's a constant, the address is both invariant and
02456      constant.  Otherwise it's neither.  */
02457   if (TREE_CODE (node) == INDIRECT_REF)
02458     UPDATE_TITCSE (TREE_OPERAND (node, 0));
02459   else if (DECL_P (node))
02460     {
02461       if (staticp (node))
02462   ;
02463       else if (decl_function_context (node) == current_function_decl
02464          /* Addresses of thread-local variables are invariant.  */
02465          || (TREE_CODE (node) == VAR_DECL && DECL_THREAD_LOCAL (node)))
02466   tc = false;
02467       else
02468   ti = tc = false;
02469     }
02470   else if (CONSTANT_CLASS_P (node))
02471     ;
02472   else
02473     {
02474       ti = tc = false;
02475       se |= TREE_SIDE_EFFECTS (node);
02476     }
02477 
02478   TREE_CONSTANT (t) = tc;
02479   TREE_INVARIANT (t) = ti;
02480   TREE_SIDE_EFFECTS (t) = se;
02481 #undef UPDATE_TITCSE
02482 }
02483 
02484 /* Build an expression of code CODE, data type TYPE, and operands as
02485    specified.  Expressions and reference nodes can be created this way.
02486    Constants, decls, types and misc nodes cannot be.
02487 
02488    We define 5 non-variadic functions, from 0 to 4 arguments.  This is
02489    enough for all extant tree codes.  These functions can be called
02490    directly (preferably!), but can also be obtained via GCC preprocessor
02491    magic within the build macro.  */
02492 
02493 tree
02494 build0_stat (enum tree_code code, tree tt MEM_STAT_DECL)
02495 {
02496   tree t;
02497 
02498   gcc_assert (TREE_CODE_LENGTH (code) == 0);
02499 
02500   t = make_node_stat (code PASS_MEM_STAT);
02501   TREE_TYPE (t) = tt;
02502 
02503   return t;
02504 }
02505 
02506 tree
02507 build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
02508 {
02509   int length = sizeof (struct tree_exp);
02510 #ifdef GATHER_STATISTICS
02511   tree_node_kind kind;
02512 #endif
02513   tree t;
02514 
02515 #ifdef GATHER_STATISTICS
02516   switch (TREE_CODE_CLASS (code))
02517     {
02518     case tcc_statement:  /* an expression with side effects */
02519       kind = s_kind;
02520       break;
02521     case tcc_reference:  /* a reference */
02522       kind = r_kind;
02523       break;
02524     default:
02525       kind = e_kind;
02526       break;
02527     }
02528 
02529   tree_node_counts[(int) kind]++;
02530   tree_node_sizes[(int) kind] += length;
02531 #endif
02532 
02533   gcc_assert (TREE_CODE_LENGTH (code) == 1);
02534 
02535   t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
02536 
02537   memset (t, 0, sizeof (struct tree_common));
02538 
02539   TREE_SET_CODE (t, code);
02540 
02541   TREE_TYPE (t) = type;
02542 #ifdef USE_MAPPED_LOCATION
02543   SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
02544 #else
02545   SET_EXPR_LOCUS (t, NULL);
02546 #endif
02547   TREE_COMPLEXITY (t) = 0;
02548   TREE_OPERAND (t, 0) = node;
02549   TREE_BLOCK (t) = NULL_TREE;
02550   if (node && !TYPE_P (node))
02551     {
02552       TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
02553       TREE_READONLY (t) = TREE_READONLY (node);
02554     }
02555 
02556   if (TREE_CODE_CLASS (code) == tcc_statement)
02557     TREE_SIDE_EFFECTS (t) = 1;
02558   else switch (code)
02559     {
02560     case INIT_EXPR:
02561     case MODIFY_EXPR:
02562     case VA_ARG_EXPR:
02563     case PREDECREMENT_EXPR:
02564     case PREINCREMENT_EXPR:
02565     case POSTDECREMENT_EXPR:
02566     case POSTINCREMENT_EXPR:
02567       /* All of these have side-effects, no matter what their
02568    operands are.  */
02569       TREE_SIDE_EFFECTS (t) = 1;
02570       TREE_READONLY (t) = 0;
02571       break;
02572 
02573     case MISALIGNED_INDIRECT_REF:
02574     case ALIGN_INDIRECT_REF:
02575     case INDIRECT_REF:
02576       /* Whether a dereference is readonly has nothing to do with whether
02577    its operand is readonly.  */
02578       TREE_READONLY (t) = 0;
02579       break;
02580 
02581     case ADDR_EXPR:
02582       if (node)
02583   recompute_tree_invarant_for_addr_expr (t);
02584       break;
02585 
02586     default:
02587       if (TREE_CODE_CLASS (code) == tcc_unary
02588     && node && !TYPE_P (node)
02589     && TREE_CONSTANT (node))
02590   TREE_CONSTANT (t) = 1;
02591       if (TREE_CODE_CLASS (code) == tcc_unary
02592     && node && TREE_INVARIANT (node))
02593   TREE_INVARIANT (t) = 1;
02594       if (TREE_CODE_CLASS (code) == tcc_reference
02595     && node && TREE_THIS_VOLATILE (node))
02596   TREE_THIS_VOLATILE (t) = 1;
02597       break;
02598     }
02599 
02600   return t;
02601 }
02602 
02603 #define PROCESS_ARG(N)      \
02604   do {          \
02605     TREE_OPERAND (t, N) = arg##N; \
02606     if (arg##N &&!TYPE_P (arg##N))  \
02607       {         \
02608         if (TREE_SIDE_EFFECTS (arg##N)) \
02609     side_effects = 1;   \
02610         if (!TREE_READONLY (arg##N))  \
02611     read_only = 0;    \
02612         if (!TREE_CONSTANT (arg##N))  \
02613     constant = 0;     \
02614   if (!TREE_INVARIANT (arg##N)) \
02615     invariant = 0;    \
02616       }         \
02617   } while (0)
02618 
02619 tree
02620 build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
02621 {
02622   bool constant, read_only, side_effects, invariant;
02623   tree t;
02624 
02625   gcc_assert (TREE_CODE_LENGTH (code) == 2);
02626 
02627   t = make_node_stat (code PASS_MEM_STAT);
02628   TREE_TYPE (t) = tt;
02629 
02630   /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_READONLY for the
02631      result based on those same flags for the arguments.  But if the
02632      arguments aren't really even `tree' expressions, we shouldn't be trying
02633      to do this.  */
02634 
02635   /* Expressions without side effects may be constant if their
02636      arguments are as well.  */
02637   constant = (TREE_CODE_CLASS (code) == tcc_comparison
02638         || TREE_CODE_CLASS (code) == tcc_binary);
02639   read_only = 1;
02640   side_effects = TREE_SIDE_EFFECTS (t);
02641   invariant = constant;
02642 
02643   PROCESS_ARG(0);
02644   PROCESS_ARG(1);
02645 
02646   TREE_READONLY (t) = read_only;
02647   TREE_CONSTANT (t) = constant;
02648   TREE_INVARIANT (t) = invariant;
02649   TREE_SIDE_EFFECTS (t) = side_effects;
02650   TREE_THIS_VOLATILE (t)
02651     = (TREE_CODE_CLASS (code) == tcc_reference
02652        && arg0 && TREE_THIS_VOLATILE (arg0));
02653 
02654   return t;
02655 }
02656 
02657 tree
02658 build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
02659        tree arg2 MEM_STAT_DECL)
02660 {
02661   bool constant, read_only, side_effects, invariant;
02662   tree t;
02663 
02664   gcc_assert (TREE_CODE_LENGTH (code) == 3);
02665 
02666   t = make_node_stat (code PASS_MEM_STAT);
02667   TREE_TYPE (t) = tt;
02668 
02669   side_effects = TREE_SIDE_EFFECTS (t);
02670 
02671   PROCESS_ARG(0);
02672   PROCESS_ARG(1);
02673   PROCESS_ARG(2);
02674 
02675   if (code == CALL_EXPR && !side_effects)
02676     {
02677       tree node;
02678       int i;
02679 
02680       /* Calls have side-effects, except those to const or
02681    pure functions.  */
02682       i = call_expr_flags (t);
02683       if (!(i & (ECF_CONST | ECF_PURE)))
02684   side_effects = 1;
02685 
02686       /* And even those have side-effects if their arguments do.  */
02687       else for (node = arg1; node; node = TREE_CHAIN (node))
02688   if (TREE_SIDE_EFFECTS (TREE_VALUE (node)))
02689     {
02690       side_effects = 1;
02691       break;
02692     }
02693     }
02694 
02695   TREE_SIDE_EFFECTS (t) = side_effects;
02696   TREE_THIS_VOLATILE (t)
02697     = (TREE_CODE_CLASS (code) == tcc_reference
02698        && arg0 && TREE_THIS_VOLATILE (arg0));
02699 
02700   return t;
02701 }
02702 
02703 tree
02704 build4_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
02705        tree arg2, tree arg3 MEM_STAT_DECL)
02706 {
02707   bool constant, read_only, side_effects, invariant;
02708   tree t;
02709 
02710   gcc_assert (TREE_CODE_LENGTH (code) == 4);
02711 
02712   t = make_node_stat (code PASS_MEM_STAT);
02713   TREE_TYPE (t) = tt;
02714 
02715   side_effects = TREE_SIDE_EFFECTS (t);
02716 
02717   PROCESS_ARG(0);
02718   PROCESS_ARG(1);
02719   PROCESS_ARG(2);
02720   PROCESS_ARG(3);
02721 
02722   TREE_SIDE_EFFECTS (t) = side_effects;
02723   TREE_THIS_VOLATILE (t)
02724     = (TREE_CODE_CLASS (code) == tcc_reference
02725        && arg0 && TREE_THIS_VOLATILE (arg0));
02726 
02727   return t;
02728 }
02729 
02730 /* Backup definition for non-gcc build compilers.  */
02731 
02732 tree
02733 (build) (enum tree_code code, tree tt, ...)
02734 {
02735   tree t, arg0, arg1, arg2, arg3;
02736   int length = TREE_CODE_LENGTH (code);
02737   va_list p;
02738 
02739   va_start (p, tt);
02740   switch (length)
02741     {
02742     case 0:
02743       t = build0 (code, tt);
02744       break;
02745     case 1:
02746       arg0 = va_arg (p, tree);
02747       t = build1 (code, tt, arg0);
02748       break;
02749     case 2:
02750       arg0 = va_arg (p, tree);
02751       arg1 = va_arg (p, tree);
02752       t = build2 (code, tt, arg0, arg1);
02753       break;
02754     case 3:
02755       arg0 = va_arg (p, tree);
02756       arg1 = va_arg (p, tree);
02757       arg2 = va_arg (p, tree);
02758       t = build3 (code, tt, arg0, arg1, arg2);
02759       break;
02760     case 4:
02761       arg0 = va_arg (p, tree);
02762       arg1 = va_arg (p, tree);
02763       arg2 = va_arg (p, tree);
02764       arg3 = va_arg (p, tree);
02765       t = build4 (code, tt, arg0, arg1, arg2, arg3);
02766       break;
02767     default:
02768       gcc_unreachable ();
02769     }
02770   va_end (p);
02771 
02772   return t;
02773 }
02774 
02775 /* Similar except don't specify the TREE_TYPE
02776    and leave the TREE_SIDE_EFFECTS as 0.
02777    It is permissible for arguments to be null,
02778    or even garbage if their values do not matter.  */
02779 
02780 tree
02781 build_nt (enum tree_code code, ...)
02782 {
02783   tree t;
02784   int length;
02785   int i;
02786   va_list p;
02787 
02788   va_start (p, code);
02789 
02790   t = make_node (code);
02791   length = TREE_CODE_LENGTH (code);
02792 
02793   for (i = 0; i < length; i++)
02794     TREE_OPERAND (t, i) = va_arg (p, tree);
02795 
02796   va_end (p);
02797   return t;
02798 }
02799 
02800 /* Create a DECL_... node of code CODE, name NAME and data type TYPE.
02801    We do NOT enter this node in any sort of symbol table.
02802 
02803    layout_decl is used to set up the decl's storage layout.
02804    Other slots are initialized to 0 or null pointers.  */
02805 
02806 tree
02807 build_decl_stat (enum tree_code code, tree name, tree type MEM_STAT_DECL)
02808 {
02809   tree t;
02810 
02811   t = make_node_stat (code PASS_MEM_STAT);
02812 
02813 /*  if (type == error_mark_node)
02814     type = integer_type_node; */
02815 /* That is not done, deliberately, so that having error_mark_node
02816    as the type can suppress useless errors in the use of this variable.  */
02817 
02818   DECL_NAME (t) = name;
02819   TREE_TYPE (t) = type;
02820 
02821   if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
02822     layout_decl (t, 0);
02823   else if (code == FUNCTION_DECL)
02824     DECL_MODE (t) = FUNCTION_MODE;
02825 
02826   /* Set default visibility to whatever the user supplied with
02827      visibility_specified depending on #pragma GCC visibility.  */
02828   DECL_VISIBILITY (t) = default_visibility;
02829   DECL_VISIBILITY_SPECIFIED (t) = visibility_options.inpragma;
02830 
02831   return t;
02832 }
02833 
02834 /* BLOCK nodes are used to represent the structure of binding contours
02835    and declarations, once those contours have been exited and their contents
02836    compiled.  This information is used for outputting debugging info.  */
02837 
02838 tree
02839 build_block (tree vars, tree tags ATTRIBUTE_UNUSED, tree subblocks,
02840        tree supercontext, tree chain)
02841 {
02842   tree block = make_node (BLOCK);
02843 
02844   BLOCK_VARS (block) = vars;
02845   BLOCK_SUBBLOCKS (block) = subblocks;
02846   BLOCK_SUPERCONTEXT (block) = supercontext;
02847   BLOCK_CHAIN (block) = chain;
02848   return block;
02849 }
02850 
02851 #if 1 /* ! defined(USE_MAPPED_LOCATION) */
02852 /* ??? gengtype doesn't handle conditionals */
02853 static GTY(()) tree last_annotated_node;
02854 #endif
02855 
02856 #ifdef USE_MAPPED_LOCATION
02857 
02858 expanded_location
02859 expand_location (source_location loc)
02860 {
02861   expanded_location xloc;
02862   if (loc == 0) { xloc.file = NULL; xloc.line = 0;  xloc.column = 0; }
02863   else
02864     {
02865       const struct line_map *map = linemap_lookup (&line_table, loc);
02866       xloc.file = map->to_file;
02867       xloc.line = SOURCE_LINE (map, loc);
02868       xloc.column = SOURCE_COLUMN (map, loc);
02869     };
02870   return xloc;
02871 }
02872 
02873 #else
02874 
02875 /* Record the exact location where an expression or an identifier were
02876    encountered.  */
02877 
02878 void
02879 annotate_with_file_line (tree node, const char *file, int line)
02880 {
02881   /* Roughly one percent of the calls to this function are to annotate
02882      a node with the same information already attached to that node!
02883      Just return instead of wasting memory.  */
02884   if (EXPR_LOCUS (node)
02885       && (EXPR_FILENAME (node) == file
02886     || ! strcmp (EXPR_FILENAME (node), file))
02887       && EXPR_LINENO (node) == line)
02888     {
02889       last_annotated_node = node;
02890       return;
02891     }
02892 
02893   /* In heavily macroized code (such as GCC itself) this single
02894      entry cache can reduce the number of allocations by more
02895      than half.  */
02896   if (last_annotated_node
02897       && EXPR_LOCUS (last_annotated_node)
02898       && (EXPR_FILENAME (last_annotated_node) == file
02899     || ! strcmp (EXPR_FILENAME (last_annotated_node), file))
02900       && EXPR_LINENO (last_annotated_node) == line)
02901     {
02902       SET_EXPR_LOCUS (node, EXPR_LOCUS (last_annotated_node));
02903       return;
02904     }
02905 
02906   SET_EXPR_LOCUS (node, ggc_alloc (sizeof (location_t)));
02907   EXPR_LINENO (node) = line;
02908   EXPR_FILENAME (node) = file;
02909   last_annotated_node = node;
02910 }
02911 
02912 void
02913 annotate_with_locus (tree node, location_t locus)
02914 {
02915   annotate_with_file_line (node, locus.file, locus.line);
02916 }
02917 #endif
02918 
02919 /* Return a declaration like DDECL except that its DECL_ATTRIBUTES
02920    is ATTRIBUTE.  */
02921 
02922 tree
02923 build_decl_attribute_variant (tree ddecl, tree attribute)
02924 {
02925   DECL_ATTRIBUTES (ddecl) = attribute;
02926   return ddecl;
02927 }
02928 
02929 /* Borrowed from hashtab.c iterative_hash implementation.  */
02930 #define mix(a,b,c) \
02931 { \
02932   a -= b; a -= c; a ^= (c>>13); \
02933   b -= c; b -= a; b ^= (a<< 8); \
02934   c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
02935   a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
02936   b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
02937   c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
02938   a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
02939   b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
02940   c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
02941 }
02942 
02943 
02944 /* Produce good hash value combining VAL and VAL2.  */
02945 static inline hashval_t
02946 iterative_hash_hashval_t (hashval_t val, hashval_t val2)
02947 {
02948   /* the golden ratio; an arbitrary value.  */
02949   hashval_t a = 0x9e3779b9;
02950 
02951   mix (a, val, val2);
02952   return val2;
02953 }
02954 
02955 /* Produce good hash value combining PTR and VAL2.  */
02956 static inline hashval_t
02957 iterative_hash_pointer (void *ptr, hashval_t val2)
02958 {
02959   if (sizeof (ptr) == sizeof (hashval_t))
02960     return iterative_hash_hashval_t ((size_t) ptr, val2);
02961   else
02962     {
02963       hashval_t a = (hashval_t) (size_t) ptr;
02964       /* Avoid warnings about shifting of more than the width of the type on
02965          hosts that won't execute this path.  */
02966       int zero = 0;
02967       hashval_t b = (hashval_t) ((size_t) ptr >> (sizeof (hashval_t) * 8 + zero));
02968       mix (a, b, val2);
02969       return val2;
02970     }
02971 }
02972 
02973 /* Produce good hash value combining VAL and VAL2.  */
02974 static inline hashval_t
02975 iterative_hash_host_wide_int (HOST_WIDE_INT val, hashval_t val2)
02976 {
02977   if (sizeof (HOST_WIDE_INT) == sizeof (hashval_t))
02978     return iterative_hash_hashval_t (val, val2);
02979   else
02980     {
02981       hashval_t a = (hashval_t) val;
02982       /* Avoid warnings about shifting of more than the width of the type on
02983          hosts that won't execute this path.  */
02984       int zero = 0;
02985       hashval_t b = (hashval_t) (val >> (sizeof (hashval_t) * 8 + zero));
02986       mix (a, b, val2);
02987       if (sizeof (HOST_WIDE_INT) > 2 * sizeof (hashval_t))
02988   {
02989     hashval_t a = (hashval_t) (val >> (sizeof (hashval_t) * 16 + zero));
02990     hashval_t b = (hashval_t) (val >> (sizeof (hashval_t) * 24 + zero));
02991     mix (a, b, val2);
02992   }
02993       return val2;
02994     }
02995 }
02996 
02997 /* Return a type like TTYPE except that its TYPE_ATTRIBUTE
02998    is ATTRIBUTE.
02999 
03000    Record such modified types already made so we don't make duplicates.  */
03001 
03002 tree
03003 build_type_attribute_variant (tree ttype, tree attribute)
03004 {
03005   if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute))
03006     {
03007       hashval_t hashcode = 0;
03008       tree ntype;
03009       enum tree_code code = TREE_CODE (ttype);
03010 
03011       ntype = copy_node (ttype);
03012 
03013       TYPE_POINTER_TO (ntype) = 0;
03014       TYPE_REFERENCE_TO (ntype) = 0;
03015       TYPE_ATTRIBUTES (ntype) = attribute;
03016 
03017       /* Create a new main variant of TYPE.  */
03018       TYPE_MAIN_VARIANT (ntype) = ntype;
03019       TYPE_NEXT_VARIANT (ntype) = 0;
03020       set_type_quals (ntype, TYPE_UNQUALIFIED);
03021 
03022       hashcode = iterative_hash_object (code, hashcode);
03023       if (TREE_TYPE (ntype))
03024   hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (ntype)),
03025             hashcode);
03026       hashcode = attribute_hash_list (attribute, hashcode);
03027 
03028       switch (TREE_CODE (ntype))
03029   {
03030   case FUNCTION_TYPE:
03031     hashcode = type_hash_list (TYPE_ARG_TYPES (ntype), hashcode);
03032     break;
03033   case ARRAY_TYPE:
03034     hashcode = iterative_hash_object (TYPE_HASH (TYPE_DOMAIN (ntype)),
03035               hashcode);
03036     break;
03037   case INTEGER_TYPE:
03038     hashcode = iterative_hash_object
03039       (TREE_INT_CST_LOW (TYPE_MAX_VALUE (ntype)), hashcode);
03040     hashcode = iterative_hash_object
03041       (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (ntype)), hashcode);
03042     break;
03043   case REAL_TYPE:
03044     {
03045       unsigned int precision = TYPE_PRECISION (ntype);
03046       hashcode = iterative_hash_object (precision, hashcode);
03047     }
03048     break;
03049   default:
03050     break;
03051   }
03052 
03053       ntype = type_hash_canon (hashcode, ntype);
03054       ttype = build_qualified_type (ntype, TYPE_QUALS (ttype));
03055     }
03056 
03057   return ttype;
03058 }
03059 
03060 
03061 /* Return nonzero if IDENT is a valid name for attribute ATTR,
03062    or zero if not.
03063 
03064    We try both `text' and `__text__', ATTR may be either one.  */
03065 /* ??? It might be a reasonable simplification to require ATTR to be only
03066    `text'.  One might then also require attribute lists to be stored in
03067    their canonicalized form.  */
03068 
03069 static int
03070 is_attribute_with_length_p (const char *attr, int attr_len, tree ident)
03071 {
03072   int ident_len;
03073   const char *p;
03074 
03075   if (TREE_CODE (ident) != IDENTIFIER_NODE)
03076     return 0;
03077   
03078   p = IDENTIFIER_POINTER (ident);
03079   ident_len = IDENTIFIER_LENGTH (ident);
03080   
03081   if (ident_len == attr_len
03082       && strcmp (attr, p) == 0)
03083     return 1;
03084 
03085   /* If ATTR is `__text__', IDENT must be `text'; and vice versa.  */
03086   if (attr[0] == '_')
03087     {
03088       gcc_assert (attr[1] == '_');
03089       gcc_assert (attr[attr_len - 2] == '_');
03090       gcc_assert (attr[attr_len - 1] == '_');
03091       gcc_assert (attr[1] == '_');
03092       if (ident_len == attr_len - 4
03093     && strncmp (attr + 2, p, attr_len - 4) == 0)
03094   return 1;
03095     }
03096   else
03097     {
03098       if (ident_len == attr_len + 4
03099     && p[0] == '_' && p[1] == '_'
03100     && p[ident_len - 2] == '_' && p[ident_len - 1] == '_'
03101     && strncmp (attr, p + 2, attr_len) == 0)
03102   return 1;
03103     }
03104 
03105   return 0;
03106 }
03107 
03108 /* Return nonzero if IDENT is a valid name for attribute ATTR,
03109    or zero if not.
03110 
03111    We try both `text' and `__text__', ATTR may be either one.  */
03112 
03113 int
03114 is_attribute_p (const char *attr, tree ident)
03115 {
03116   return is_attribute_with_length_p (attr, strlen (attr), ident);
03117 }
03118 
03119 /* Given an attribute name and a list of attributes, return a pointer to the
03120    attribute's list element if the attribute is part of the list, or NULL_TREE
03121    if not found.  If the attribute appears more than once, this only
03122    returns the first occurrence; the TREE_CHAIN of the return value should
03123    be passed back in if further occurrences are wanted.  */
03124 
03125 tree
03126 lookup_attribute (const char *attr_name, tree list)
03127 {
03128   tree l;
03129   size_t attr_len = strlen (attr_name);
03130 
03131   for (l = list; l; l = TREE_CHAIN (l))
03132     {
03133       gcc_assert (TREE_CODE (TREE_PURPOSE (l)) == IDENTIFIER_NODE);
03134       if (is_attribute_with_length_p (attr_name, attr_len, TREE_PURPOSE (l)))
03135   return l;
03136     }
03137 
03138   return NULL_TREE;
03139 }
03140 
03141 /* Return an attribute list that is the union of a1 and a2.  */
03142 
03143 tree
03144 merge_attributes (tree a1, tree a2)
03145 {
03146   tree attributes;
03147 
03148   /* Either one unset?  Take the set one.  */
03149 
03150   if ((attributes = a1) == 0)
03151     attributes = a2;
03152 
03153   /* One that completely contains the other?  Take it.  */
03154 
03155   else if (a2 != 0 && ! attribute_list_contained (a1, a2))
03156     {
03157       if (attribute_list_contained (a2, a1))
03158   attributes = a2;
03159       else
03160   {
03161     /* Pick the longest list, and hang on the other list.  */
03162 
03163     if (list_length (a1) < list_length (a2))
03164       attributes = a2, a2 = a1;
03165 
03166     for (; a2 != 0; a2 = TREE_CHAIN (a2))
03167       {
03168         tree a;
03169         for (a = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
03170            attributes);
03171        a != NULL_TREE;
03172        a = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
03173            TREE_CHAIN (a)))
03174     {
03175       if (simple_cst_equal (TREE_VALUE (a), TREE_VALUE (a2)) == 1)
03176         break;
03177     }
03178         if (a == NULL_TREE)
03179     {
03180       a1 = copy_node (a2);
03181       TREE_CHAIN (a1) = attributes;
03182       attributes = a1;
03183     }
03184       }
03185   }
03186     }
03187   return attributes;
03188 }
03189 
03190 /* Given types T1 and T2, merge their attributes and return
03191   the result.  */
03192 
03193 tree
03194 merge_type_attributes (tree t1, tree t2)
03195 {
03196   return merge_attributes (TYPE_ATTRIBUTES (t1),
03197          TYPE_ATTRIBUTES (t2));
03198 }
03199 
03200 /* Given decls OLDDECL and NEWDECL, merge their attributes and return
03201    the result.  */
03202 
03203 tree
03204 merge_decl_attributes (tree olddecl, tree newdecl)
03205 {
03206   return merge_attributes (DECL_ATTRIBUTES (olddecl),
03207          DECL_ATTRIBUTES (newdecl));
03208 }
03209 
03210 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
03211 
03212 /* Specialization of merge_decl_attributes for various Windows targets.
03213 
03214    This handles the following situation:
03215 
03216      __declspec (dllimport) int foo;
03217      int foo;
03218 
03219    The second instance of `foo' nullifies the dllimport.  */
03220 
03221 tree
03222 merge_dllimport_decl_attributes (tree old, tree new)
03223 {
03224   tree a;
03225   int delete_dllimport_p;
03226 
03227   old = DECL_ATTRIBUTES (old);
03228   new = DECL_ATTRIBUTES (new);
03229 
03230   /* What we need to do here is remove from `old' dllimport if it doesn't
03231      appear in `new'.  dllimport behaves like extern: if a declaration is
03232      marked dllimport and a definition appears later, then the object
03233      is not dllimport'd.  */
03234   if (lookup_attribute ("dllimport", old) != NULL_TREE
03235       && lookup_attribute ("dllimport", new) == NULL_TREE)
03236     delete_dllimport_p = 1;
03237   else
03238     delete_dllimport_p = 0;
03239 
03240   a = merge_attributes (old, new);
03241 
03242   if (delete_dllimport_p)
03243     {
03244       tree prev, t;
03245 
03246       /* Scan the list for dllimport and delete it.  */
03247       for (prev = NULL_TREE, t = a; t; prev = t, t = TREE_CHAIN (t))
03248   {
03249     if (is_attribute_p ("dllimport", TREE_PURPOSE (t)))
03250       {
03251         if (prev == NULL_TREE)
03252     a = TREE_CHAIN (a);
03253         else
03254     TREE_CHAIN (prev) = TREE_CHAIN (t);
03255         break;
03256       }
03257   }
03258     }
03259 
03260   return a;
03261 }
03262 
03263 /* Handle a "dllimport" or "dllexport" attribute; arguments as in
03264    struct attribute_spec.handler.  */
03265 
03266 tree
03267 handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
03268           bool *no_add_attrs)
03269 {
03270   tree node = *pnode;
03271 
03272   /* These attributes may apply to structure and union types being created,
03273      but otherwise should pass to the declaration involved.  */
03274   if (!DECL_P (node))
03275     {
03276       if (flags & ((int) ATTR_FLAG_DECL_NEXT | (int) ATTR_FLAG_FUNCTION_NEXT
03277        | (int) ATTR_FLAG_ARRAY_NEXT))
03278   {
03279     *no_add_attrs = true;
03280     return tree_cons (name, args, NULL_TREE);
03281   }
03282       if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE)
03283   {
03284     warning ("%qs attribute ignored", IDENTIFIER_POINTER (name));
03285     *no_add_attrs = true;
03286   }
03287 
03288       return NULL_TREE;
03289     }
03290 
03291   /* Report error on dllimport ambiguities seen now before they cause
03292      any damage.  */
03293   if (is_attribute_p ("dllimport", name))
03294     {
03295       /* Like MS, treat definition of dllimported variables and
03296    non-inlined functions on declaration as syntax errors.  We
03297    allow the attribute for function definitions if declared
03298    inline.  */
03299       if (TREE_CODE (node) == FUNCTION_DECL  && DECL_INITIAL (node)
03300           && !DECL_DECLARED_INLINE_P (node))
03301   {
03302     error ("%Jfunction %qD definition is marked dllimport.", node, node);
03303     *no_add_attrs = true;
03304   }
03305 
03306       else if (TREE_CODE (node) == VAR_DECL)
03307   {
03308     if (DECL_INITIAL (node))
03309       {
03310         error ("%Jvariable %qD definition is marked dllimport.",
03311          node, node);
03312         *no_add_attrs = true;
03313       }
03314 
03315     /* `extern' needn't be specified with dllimport.
03316        Specify `extern' now and hope for the best.  Sigh.  */
03317     DECL_EXTERNAL (node) = 1;
03318     /* Also, implicitly give dllimport'd variables declared within
03319        a function global scope, unless declared static.  */
03320     if (current_function_decl != NULL_TREE && !TREE_STATIC (node))
03321       TREE_PUBLIC (node) = 1;
03322   }
03323     }
03324 
03325   /*  Report error if symbol is not accessible at global scope.  */
03326   if (!TREE_PUBLIC (node)
03327       && (TREE_CODE (node) == VAR_DECL
03328     || TREE_CODE (node) == FUNCTION_DECL))
03329     {
03330       error ("%Jexternal linkage required for symbol %qD because of "
03331        "%qs attribute.", node, node, IDENTIFIER_POINTER (name));
03332       *no_add_attrs = true;
03333     }
03334 
03335   return NULL_TREE;
03336 }
03337 
03338 #endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES  */
03339 
03340 /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
03341    of the various TYPE_QUAL values.  */
03342 
03343 static void
03344 set_type_quals (tree type, int type_quals)
03345 {
03346   TYPE_READONLY (type) = (type_quals & TYPE_QUAL_CONST) != 0;
03347   TYPE_VOLATILE (type) = (type_quals & TYPE_QUAL_VOLATILE) != 0;
03348   TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
03349 }
03350 
03351 /* Returns true iff cand is equivalent to base with type_quals.  */
03352 
03353 bool
03354 check_qualified_type (tree cand, tree base, int type_quals)
03355 {
03356   return (TYPE_QUALS (cand) == type_quals
03357     && TYPE_NAME (cand) == TYPE_NAME (base)
03358     /* Apparently this is needed for Objective-C.  */
03359     && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
03360     && attribute_list_equal (TYPE_ATTRIBUTES (cand),
03361            TYPE_ATTRIBUTES (base)));
03362 }
03363 
03364 /* Return a version of the TYPE, qualified as indicated by the
03365    TYPE_QUALS, if one exists.  If no qualified version exists yet,
03366    return NULL_TREE.  */
03367 
03368 tree
03369 get_qualified_type (tree type, int type_quals)
03370 {
03371   tree t;
03372 
03373   if (TYPE_QUALS (type) == type_quals)
03374     return type;
03375 
03376   /* Search the chain of variants to see if there is already one there just
03377      like the one we need to have.  If so, use that existing one.  We must
03378      preserve the TYPE_NAME, since there is code that depends on this.  */
03379   for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
03380     if (check_qualified_type (t, type, type_quals))
03381       return t;
03382 
03383   return NULL_TREE;
03384 }
03385 
03386 /* Like get_qualified_type, but creates the type if it does not
03387    exist.  This function never returns NULL_TREE.  */
03388 
03389 tree
03390 build_qualified_type (tree type, int type_quals)
03391 {
03392   tree t;
03393 
03394   /* See if we already have the appropriate qualified variant.  */
03395   t = get_qualified_type (type, type_quals);
03396 
03397   /* If not, build it.  */
03398   if (!t)
03399     {
03400       t = build_variant_type_copy (type);
03401       set_type_quals (t, type_quals);
03402     }
03403 
03404   return t;
03405 }
03406 
03407 /* Create a new distinct copy of TYPE.  The new type is made its own
03408    MAIN_VARIANT.  */
03409 
03410 tree
03411 build_distinct_type_copy (tree type)
03412 {
03413   tree t = copy_node (type);
03414   
03415   TYPE_POINTER_TO (t) = 0;
03416   TYPE_REFERENCE_TO (t) = 0;
03417 
03418   /* Make it its own variant.  */
03419   TYPE_MAIN_VARIANT (t) = t;
03420   TYPE_NEXT_VARIANT (t) = 0;
03421   
03422   return t;
03423 }
03424 
03425 /* Create a new variant of TYPE, equivalent but distinct.
03426    This is so the caller can modify it.  */
03427 
03428 tree
03429 build_variant_type_copy (tree type)
03430 {
03431   tree t, m = TYPE_MAIN_VARIANT (type);
03432 
03433   t = build_distinct_type_copy (type);
03434   
03435   /* Add the new type to the chain of variants of TYPE.  */
03436   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
03437   TYPE_NEXT_VARIANT (m) = t;
03438   TYPE_MAIN_VARIANT (t) = m;
03439 
03440   return t;
03441 }
03442 
03443 /* Hashing of types so that we don't make duplicates.
03444    The entry point is `type_hash_canon'.  */
03445 
03446 /* Compute a hash code for a list of types (chain of TREE_LIST nodes
03447    with types in the TREE_VALUE slots), by adding the hash codes
03448    of the individual types.  */
03449 
03450 unsigned int
03451 type_hash_list (tree list, hashval_t hashcode)
03452 {
03453   tree tail;
03454 
03455   for (tail = list; tail; tail = TREE_CHAIN (tail))
03456     if (TREE_VALUE (tail) != error_mark_node)
03457       hashcode = iterative_hash_object (TYPE_HASH (TREE_VALUE (tail)),
03458           hashcode);
03459 
03460   return hashcode;
03461 }
03462 
03463 /* These are the Hashtable callback functions.  */
03464 
03465 /* Returns true iff the types are equivalent.  */
03466 
03467 static int
03468 type_hash_eq (const void *va, const void *vb)
03469 {
03470   const struct type_hash *a = va, *b = vb;
03471 
03472   /* First test the things that are the same for all types.  */
03473   if (a->hash != b->hash
03474       || TREE_CODE (a->type) != TREE_CODE (b->type)
03475       || TREE_TYPE (a->type) != TREE_TYPE (b->type)
03476       || !attribute_list_equal (TYPE_ATTRIBUTES (a->type),
03477          TYPE_ATTRIBUTES (b->type))
03478       || TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type)
03479       || TYPE_MODE (a->type) != TYPE_MODE (b->type))
03480     return 0;
03481 
03482   switch (TREE_CODE (a->type))
03483     {
03484     case VOID_TYPE:
03485     case COMPLEX_TYPE:
03486     case POINTER_TYPE:
03487     case REFERENCE_TYPE:
03488       return 1;
03489 
03490     case VECTOR_TYPE:
03491       return TYPE_VECTOR_SUBPARTS (a->type) == TYPE_VECTOR_SUBPARTS (b->type);
03492 
03493     case ENUMERAL_TYPE:
03494       if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
03495     && !(TYPE_VALUES (a->type)
03496          && TREE_CODE (TYPE_VALUES (a->type)) == TREE_LIST
03497          && TYPE_VALUES (b->type)
03498          && TREE_CODE (TYPE_VALUES (b->type)) == TREE_LIST
03499          && type_list_equal (TYPE_VALUES (a->type),
03500            TYPE_VALUES (b->type))))
03501   return 0;
03502 
03503       /* ... fall through ... */
03504 
03505     case INTEGER_TYPE:
03506     case REAL_TYPE:
03507     case BOOLEAN_TYPE:
03508     case CHAR_TYPE:
03509       return ((TYPE_MAX_VALUE (a->type) == TYPE_MAX_VALUE (b->type)
03510          || tree_int_cst_equal (TYPE_MAX_VALUE (a->type),
03511               TYPE_MAX_VALUE (b->type)))
03512         && (TYPE_MIN_VALUE (a->type) == TYPE_MIN_VALUE (b->type)
03513       || tree_int_cst_equal (TYPE_MIN_VALUE (a->type),
03514            TYPE_MIN_VALUE (b->type))));
03515 
03516     case OFFSET_TYPE:
03517       return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type);
03518 
03519     case METHOD_TYPE:
03520       return (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type)
03521         && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
03522       || (TYPE_ARG_TYPES (a->type)
03523           && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
03524           && TYPE_ARG_TYPES (b->type)
03525           && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
03526           && type_list_equal (TYPE_ARG_TYPES (a->type),
03527             TYPE_ARG_TYPES (b->type)))));
03528 
03529     case ARRAY_TYPE:
03530       return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type);
03531 
03532     case RECORD_TYPE:
03533     case UNION_TYPE:
03534     case QUAL_UNION_TYPE:
03535       return (TYPE_FIELDS (a->type) == TYPE_FIELDS (b->type)
03536         || (TYPE_FIELDS (a->type)
03537       && TREE_CODE (TYPE_FIELDS (a->type)) == TREE_LIST
03538       && TYPE_FIELDS (b->type)
03539       && TREE_CODE (TYPE_FIELDS (b->type)) == TREE_LIST
03540       && type_list_equal (TYPE_FIELDS (a->type),
03541               TYPE_FIELDS (b->type))));
03542 
03543     case FUNCTION_TYPE:
03544       return (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
03545         || (TYPE_ARG_TYPES (a->type)
03546       && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
03547       && TYPE_ARG_TYPES (b->type)
03548       && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
03549       && type_list_equal (TYPE_ARG_TYPES (a->type),
03550               TYPE_ARG_TYPES (b->type))));
03551 
03552     default:
03553       return 0;
03554     }
03555 }
03556 
03557 /* Return the cached hash value.  */
03558 
03559 static hashval_t
03560 type_hash_hash (const void *item)
03561 {
03562   return ((const struct type_hash *) item)->hash;
03563 }
03564 
03565 /* Look in the type hash table for a type isomorphic to TYPE.
03566    If one is found, return it.  Otherwise return 0.  */
03567 
03568 tree
03569 type_hash_lookup (hashval_t hashcode, tree type)
03570 {
03571   struct type_hash *h, in;
03572 
03573   /* The TYPE_ALIGN field of a type is set by layout_type(), so we
03574      must call that routine before comparing TYPE_ALIGNs.  */
03575   layout_type (type);
03576 
03577   in.hash = hashcode;
03578   in.type = type;
03579 
03580   h = htab_find_with_hash (type_hash_table, &in, hashcode);
03581   if (h)
03582     return h->type;
03583   return NULL_TREE;
03584 }
03585 
03586 /* Add an entry to the type-hash-table
03587    for a type TYPE whose hash code is HASHCODE.  */
03588 
03589 void
03590 type_hash_add (hashval_t hashcode, tree type)
03591 {
03592   struct type_hash *h;
03593   void **loc;
03594 
03595   h = ggc_alloc (sizeof (struct type_hash));
03596   h->hash = hashcode;
03597   h->type = type;
03598   loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
03599   *(struct type_hash **) loc = h;
03600 }
03601 
03602 /* Given TYPE, and HASHCODE its hash code, return the canonical
03603    object for an identical type if one already exists.
03604    Otherwise, return TYPE, and record it as the canonical object.
03605 
03606    To use this function, first create a type of the sort you want.
03607    Then compute its hash code from the fields of the type that
03608    make it different from other similar types.
03609    Then call this function and use the value.  */
03610 
03611 tree
03612 type_hash_canon (unsigned int hashcode, tree type)
03613 {
03614   tree t1;
03615 
03616   /* The hash table only contains main variants, so ensure that's what we're
03617      being passed.  */
03618   gcc_assert (TYPE_MAIN_VARIANT (type) == type);
03619 
03620   if (!lang_hooks.types.hash_types)
03621     return type;
03622 
03623   /* See if the type is in the hash table already.  If so, return it.
03624      Otherwise, add the type.  */
03625   t1 = type_hash_lookup (hashcode, type);
03626   if (t1 != 0)
03627     {
03628 #ifdef GATHER_STATISTICS
03629       tree_node_counts[(int) t_kind]--;
03630       tree_node_sizes[(int) t_kind] -= sizeof (struct tree_type);
03631 #endif
03632       return t1;
03633     }
03634   else
03635     {
03636       type_hash_add (hashcode, type);
03637       return type;
03638     }
03639 }
03640 
03641 /* See if the data pointed to by the type hash table is marked.  We consider
03642    it marked if the type is marked or if a debug type number or symbol
03643    table entry has been made for the type.  This reduces the amount of
03644    debugging output and eliminates that dependency of the debug output on
03645    the number of garbage collections.  */
03646 
03647 static int
03648 type_hash_marked_p (const void *p)
03649 {
03650   tree type = ((struct type_hash *) p)->type;
03651 
03652   return ggc_marked_p (type) || TYPE_SYMTAB_POINTER (type);
03653 }
03654 
03655 static void
03656 print_type_hash_statistics (void)
03657 {
03658   fprintf (stderr, "Type hash: size %ld, %ld elements, %f collisions\n",
03659      (long) htab_size (type_hash_table),
03660      (long) htab_elements (type_hash_table),
03661      htab_collisions (type_hash_table));
03662 }
03663 
03664 /* Compute a hash code for a list of attributes (chain of TREE_LIST nodes
03665    with names in the TREE_PURPOSE slots and args in the TREE_VALUE slots),
03666    by adding the hash codes of the individual attributes.  */
03667 
03668 unsigned int
03669 attribute_hash_list (tree list, hashval_t hashcode)
03670 {
03671   tree tail;
03672 
03673   for (tail = list; tail; tail = TREE_CHAIN (tail))
03674     /* ??? Do we want to add in TREE_VALUE too? */
03675     hashcode = iterative_hash_object
03676       (IDENTIFIER_HASH_VALUE (TREE_PURPOSE (tail)), hashcode);
03677   return hashcode;
03678 }
03679 
03680 /* Given two lists of attributes, return true if list l2 is
03681    equivalent to l1.  */
03682 
03683 int
03684 attribute_list_equal (tree l1, tree l2)
03685 {
03686   return attribute_list_contained (l1, l2)
03687    && attribute_list_contained (l2, l1);
03688 }
03689 
03690 /* Given two lists of attributes, return true if list L2 is
03691    completely contained within L1.  */
03692 /* ??? This would be faster if attribute names were stored in a canonicalized
03693    form.  Otherwise, if L1 uses `foo' and L2 uses `__foo__', the long method
03694    must be used to show these elements are equivalent (which they are).  */
03695 /* ??? It's not clear that attributes with arguments will always be handled
03696    correctly.  */
03697 
03698 int
03699 attribute_list_contained (tree l1, tree l2)
03700 {
03701   tree t1, t2;
03702 
03703   /* First check the obvious, maybe the lists are identical.  */
03704   if (l1 == l2)
03705     return 1;
03706 
03707   /* Maybe the lists are similar.  */
03708   for (t1 = l1, t2 = l2;
03709        t1 != 0 && t2 != 0
03710         && TREE_PURPOSE (t1) == TREE_PURPOSE (t2)
03711         && TREE_VALUE (t1) == TREE_VALUE (t2);
03712        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2));
03713 
03714   /* Maybe the lists are equal.  */
03715   if (t1 == 0 && t2 == 0)
03716     return 1;
03717 
03718   for (; t2 != 0; t2 = TREE_CHAIN (t2))
03719     {
03720       tree attr;
03721       for (attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)), l1);
03722      attr != NULL_TREE;
03723      attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)),
03724             TREE_CHAIN (attr)))
03725   {
03726     if (simple_cst_equal (TREE_VALUE (t2), TREE_VALUE (attr)) == 1)
03727       break;
03728   }
03729 
03730       if (attr == 0)
03731   return 0;
03732 
03733       if (simple_cst_equal (TREE_VALUE (t2), TREE_VALUE (attr)) != 1)
03734   return 0;
03735     }
03736 
03737   return 1;
03738 }
03739 
03740 /* Given two lists of types
03741    (chains of TREE_LIST nodes with types in the TREE_VALUE slots)
03742    return 1 if the lists contain the same types in the same order.
03743    Also, the TREE_PURPOSEs must match.  */
03744 
03745 int
03746 type_list_equal (tree l1, tree l2)
03747 {
03748   tree t1, t2;
03749 
03750   for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
03751     if (TREE_VALUE (t1) != TREE_VALUE (t2)
03752   || (TREE_PURPOSE (t1) != TREE_PURPOSE (t2)
03753       && ! (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))
03754       && (TREE_TYPE (TREE_PURPOSE (t1))
03755           == TREE_TYPE (TREE_PURPOSE (t2))))))
03756       return 0;
03757 
03758   return t1 == t2;
03759 }
03760 
03761 /* Returns the number of arguments to the FUNCTION_TYPE or METHOD_TYPE
03762    given by TYPE.  If the argument list accepts variable arguments,
03763    then this function counts only the ordinary arguments.  */
03764 
03765 int
03766 type_num_arguments (tree type)
03767 {
03768   int i = 0;
03769   tree t;
03770 
03771   for (t = TYPE_ARG_TYPES (type); t; t = TREE_CHAIN (t))
03772     /* If the function does not take a variable number of arguments,
03773        the last element in the list will have type `void'.  */
03774     if (VOID_TYPE_P (TREE_VALUE (t)))
03775       break;
03776     else
03777       ++i;
03778 
03779   return i;
03780 }
03781 
03782 /* Nonzero if integer constants T1 and T2
03783    represent the same constant value.  */
03784 
03785 int
03786 tree_int_cst_equal (tree t1, tree t2)
03787 {
03788   if (t1 == t2)
03789     return 1;
03790 
03791   if (t1 == 0 || t2 == 0)
03792     return 0;
03793 
03794   if (TREE_CODE (t1) == INTEGER_CST
03795       && TREE_CODE (t2) == INTEGER_CST
03796       && TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
03797       && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2))
03798     return 1;
03799 
03800   return 0;
03801 }
03802 
03803 /* Nonzero if integer constants T1 and T2 represent values that satisfy <.
03804    The precise way of comparison depends on their data type.  */
03805 
03806 int
03807 tree_int_cst_lt (tree t1, tree t2)
03808 {
03809   if (t1 == t2)
03810     return 0;
03811 
03812   if (TYPE_UNSIGNED (TREE_TYPE (t1)) != TYPE_UNSIGNED (TREE_TYPE (t2)))
03813     {
03814       int t1_sgn = tree_int_cst_sgn (t1);
03815       int t2_sgn = tree_int_cst_sgn (t2);
03816 
03817       if (t1_sgn < t2_sgn)
03818   return 1;
03819       else if (t1_sgn > t2_sgn)
03820   return 0;
03821       /* Otherwise, both are non-negative, so we compare them as
03822    unsigned just in case one of them would overflow a signed
03823    type.  */
03824     }
03825   else if (!TYPE_UNSIGNED (TREE_TYPE (t1)))
03826     return INT_CST_LT (t1, t2);
03827 
03828   return INT_CST_LT_UNSIGNED (t1, t2);
03829 }
03830 
03831 /* Returns -1 if T1 < T2, 0 if T1 == T2, and 1 if T1 > T2.  */
03832 
03833 int
03834 tree_int_cst_compare (tree t1, tree t2)
03835 {
03836   if (tree_int_cst_lt (t1, t2))
03837     return -1;
03838   else if (tree_int_cst_lt (t2, t1))
03839     return 1;
03840   else
03841     return 0;
03842 }
03843 
03844 /* Return 1 if T is an INTEGER_CST that can be manipulated efficiently on
03845    the host.  If POS is zero, the value can be represented in a single
03846    HOST_WIDE_INT.  If POS is nonzero, the value must be positive and can
03847    be represented in a single unsigned HOST_WIDE_INT.  */
03848 
03849 int
03850 host_integerp (tree t, int pos)
03851 {
03852   return (TREE_CODE (t) == INTEGER_CST
03853     && ! TREE_OVERFLOW (t)
03854     && ((TREE_INT_CST_HIGH (t) == 0
03855          && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
03856         || (! pos && TREE_INT_CST_HIGH (t) == -1
03857       && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0
03858       && !TYPE_UNSIGNED (TREE_TYPE (t)))
03859         || (pos && TREE_INT_CST_HIGH (t) == 0)));
03860 }
03861 
03862 /* Return the HOST_WIDE_INT least significant bits of T if it is an
03863    INTEGER_CST and there is no overflow.  POS is nonzero if the result must
03864    be positive.  Abort if we cannot satisfy the above conditions.  */
03865 
03866 HOST_WIDE_INT
03867 tree_low_cst (tree t, int pos)
03868 {
03869   gcc_assert (host_integerp (t, pos));
03870   return TREE_INT_CST_LOW (t);
03871 }
03872 
03873 /* Return the most significant bit of the integer constant T.  */
03874 
03875 int
03876 tree_int_cst_msb (tree t)
03877 {
03878   int prec;
03879   HOST_WIDE_INT h;
03880   unsigned HOST_WIDE_INT l;
03881 
03882   /* Note that using TYPE_PRECISION here is wrong.  We care about the
03883      actual bits, not the (arbitrary) range of the type.  */
03884   prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t))) - 1;
03885   rshift_double (TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t), prec,
03886      2 * HOST_BITS_PER_WIDE_INT, &l, &h, 0);
03887   return (l & 1) == 1;
03888 }
03889 
03890 /* Return an indication of the sign of the integer constant T.
03891    The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
03892    Note that -1 will never be returned it T's type is unsigned.  */
03893 
03894 int
03895 tree_int_cst_sgn (tree t)
03896 {
03897   if (TREE_INT_CST_LOW (t) == 0 && TREE_INT_CST_HIGH (t) == 0)
03898     return 0;
03899   else if (TYPE_UNSIGNED (TREE_TYPE (t)))
03900     return 1;
03901   else if (TREE_INT_CST_HIGH (t) < 0)
03902     return -1;
03903   else
03904     return 1;
03905 }
03906 
03907 /* Compare two constructor-element-type constants.  Return 1 if the lists
03908    are known to be equal; otherwise return 0.  */
03909 
03910 int
03911 simple_cst_list_equal (tree l1, tree l2)
03912 {
03913   while (l1 != NULL_TREE && l2 != NULL_TREE)
03914     {
03915       if (simple_cst_equal (TREE_VALUE (l1), TREE_VALUE (l2)) != 1)
03916   return 0;
03917 
03918       l1 = TREE_CHAIN (l1);
03919       l2 = TREE_CHAIN (l2);
03920     }
03921 
03922   return l1 == l2;
03923 }
03924 
03925 /* Return truthvalue of whether T1 is the same tree structure as T2.
03926    Return 1 if they are the same.
03927    Return 0 if they are understandably different.
03928    Return -1 if either contains tree structure not understood by
03929    this function.  */
03930 
03931 int
03932 simple_cst_equal (tree t1, tree t2)
03933 {
03934   enum tree_code code1, code2;
03935   int cmp;
03936   int i;
03937 
03938   if (t1 == t2)
03939     return 1;
03940   if (t1 == 0 || t2 == 0)
03941     return 0;
03942 
03943   code1 = TREE_CODE (t1);
03944   code2 = TREE_CODE (t2);
03945 
03946   if (code1 == NOP_EXPR || code1 == CONVERT_EXPR || code1 == NON_LVALUE_EXPR)
03947     {
03948       if (code2 == NOP_EXPR || code2 == CONVERT_EXPR
03949     || code2 == NON_LVALUE_EXPR)
03950   return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
03951       else
03952   return simple_cst_equal (TREE_OPERAND (t1, 0), t2);
03953     }
03954 
03955   else if (code2 == NOP_EXPR || code2 == CONVERT_EXPR
03956      || code2 == NON_LVALUE_EXPR)
03957     return simple_cst_equal (t1, TREE_OPERAND (t2, 0));
03958 
03959   if (code1 != code2)
03960     return 0;
03961 
03962   switch (code1)
03963     {
03964     case INTEGER_CST:
03965       return (TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
03966         && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2));
03967 
03968     case REAL_CST:
03969       return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
03970 
03971     case STRING_CST:
03972       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
03973         && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
03974        TREE_STRING_LENGTH (t1)));
03975 
03976     case CONSTRUCTOR:
03977       return simple_cst_list_equal (CONSTRUCTOR_ELTS (t1),
03978                               CONSTRUCTOR_ELTS (t2));
03979 
03980     case SAVE_EXPR:
03981       return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
03982 
03983     case CALL_EXPR:
03984       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
03985       if (cmp <= 0)
03986   return cmp;
03987       return
03988   simple_cst_list_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
03989 
03990     case TARGET_EXPR:
03991       /* Special case: if either target is an unallocated VAR_DECL,
03992    it means that it's going to be unified with whatever the
03993    TARGET_EXPR is really supposed to initialize, so treat it
03994    as being equivalent to anything.  */
03995       if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
03996      && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
03997      && !DECL_RTL_SET_P (TREE_OPERAND (t1, 0)))
03998     || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
03999         && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
04000         && !DECL_RTL_SET_P (TREE_OPERAND (t2, 0))))
04001   cmp = 1;
04002       else
04003   cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
04004 
04005       if (cmp <= 0)
04006   return cmp;
04007 
04008       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
04009 
04010     case WITH_CLEANUP_EXPR:
04011       cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
04012       if (cmp <= 0)
04013   return cmp;
04014 
04015       return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
04016 
04017     case COMPONENT_REF:
04018       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
04019   return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
04020 
04021       return 0;
04022 
04023     case VAR_DECL:
04024     case PARM_DECL:
04025     case CONST_DECL:
04026     case FUNCTION_DECL:
04027       return 0;
04028 
04029     default:
04030       break;
04031     }
04032 
04033   /* This general rule works for most tree codes.  All exceptions should be
04034      handled above.  If this is a language-specific tree code, we can't
04035      trust what might be in the operand, so say we don't know
04036      the situation.  */
04037   if ((int) code1 >= (int) LAST_AND_UNUSED_TREE_CODE)
04038     return -1;
04039 
04040   switch (TREE_CODE_CLASS (code1))
04041     {
04042     case tcc_unary:
04043     case tcc_binary:
04044     case tcc_comparison:
04045     case tcc_expression:
04046     case tcc_reference:
04047     case tcc_statement:
04048       cmp = 1;
04049       for (i = 0; i < TREE_CODE_LENGTH (code1); i++)
04050   {
04051     cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
04052     if (cmp <= 0)
04053       return cmp;
04054   }
04055 
04056       return cmp;
04057 
04058     default:
04059       return -1;
04060     }
04061 }
04062 
04063 /* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value.
04064    Return -1, 0, or 1 if the value of T is less than, equal to, or greater
04065    than U, respectively.  */
04066 
04067 int
04068 compare_tree_int (tree t, unsigned HOST_WIDE_INT u)
04069 {
04070   if (tree_int_cst_sgn (t) < 0)
04071     return -1;
04072   else if (TREE_INT_CST_HIGH (t) != 0)
04073     return 1;
04074   else if (TREE_INT_CST_LOW (t) == u)
04075     return 0;
04076   else if (TREE_INT_CST_LOW (t) < u)
04077     return -1;
04078   else
04079     return 1;
04080 }
04081 
04082 /* Return true if CODE represents an associative tree code.  Otherwise
04083    return false.  */
04084 bool
04085 associative_tree_code (enum tree_code code)
04086 {
04087   switch (code)
04088     {
04089     case BIT_IOR_EXPR:
04090     case BIT_AND_EXPR:
04091     case BIT_XOR_EXPR:
04092     case PLUS_EXPR:
04093     case MULT_EXPR:
04094     case MIN_EXPR:
04095     case MAX_EXPR:
04096       return true;
04097 
04098     default:
04099       break;
04100     }
04101   return false;
04102 }
04103 
04104 /* Return true if CODE represents a commutative tree code.  Otherwise
04105    return false.  */
04106 bool
04107 commutative_tree_code (enum tree_code code)
04108 {
04109   switch (code)
04110     {
04111     case PLUS_EXPR:
04112     case MULT_EXPR:
04113     case MIN_EXPR:
04114     case MAX_EXPR:
04115     case BIT_IOR_EXPR:
04116     case BIT_XOR_EXPR:
04117     case BIT_AND_EXPR:
04118     case NE_EXPR:
04119     case EQ_EXPR:
04120     case UNORDERED_EXPR:
04121     case ORDERED_EXPR:
04122     case UNEQ_EXPR:
04123     case LTGT_EXPR:
04124     case TRUTH_AND_EXPR:
04125     case TRUTH_XOR_EXPR:
04126     case TRUTH_OR_EXPR:
04127       return true;
04128 
04129     default:
04130       break;
04131     }
04132   return false;
04133 }
04134 
04135 /* Generate a hash value for an expression.  This can be used iteratively
04136    by passing a previous result as the "val" argument.
04137 
04138    This function is intended to produce the same hash for expressions which
04139    would compare equal using operand_equal_p.  */
04140 
04141 hashval_t
04142 iterative_hash_expr (tree t, hashval_t val)
04143 {
04144   int i;
04145   enum tree_code code;
04146   char class;
04147 
04148   if (t == NULL_TREE)
04149     return iterative_hash_pointer (t, val);
04150 
04151   code = TREE_CODE (t);
04152 
04153   switch (code)
04154     {
04155     /* Alas, constants aren't shared, so we can't rely on pointer
04156        identity.  */
04157     case INTEGER_CST:
04158       val = iterative_hash_host_wide_int (TREE_INT_CST_LOW (t), val);
04159       return iterative_hash_host_wide_int (TREE_INT_CST_HIGH (t), val);
04160     case REAL_CST:
04161       {
04162   unsigned int val2 = real_hash (TREE_REAL_CST_PTR (t));
04163 
04164   return iterative_hash_hashval_t (val2, val);
04165       }
04166     case STRING_CST:
04167       return iterative_hash (TREE_STRING_POINTER (t),
04168            TREE_STRING_LENGTH (t), val);
04169     case COMPLEX_CST:
04170       val = iterative_hash_expr (TREE_REALPART (t), val);
04171       return iterative_hash_expr (TREE_IMAGPART (t), val);
04172     case VECTOR_CST:
04173       return iterative_hash_expr (TREE_VECTOR_CST_ELTS (t), val);
04174 
04175     case SSA_NAME:
04176     case VALUE_HANDLE:
04177       /* we can just compare by pointer.  */
04178       return iterative_hash_pointer (t, val);
04179 
04180     case TREE_LIST:
04181       /* A list of expressions, for a CALL_EXPR or as the elements of a
04182    VECTOR_CST.  */
04183       for (; t; t = TREE_CHAIN (t))
04184   val = iterative_hash_expr (TREE_VALUE (t), val);
04185       return val;
04186     case FUNCTION_DECL:
04187       /* When referring to a built-in FUNCTION_DECL, use the
04188    __builtin__ form.  Otherwise nodes that compare equal
04189    according to operand_equal_p might get different
04190    hash codes.  */
04191       if (DECL_BUILT_IN (t))
04192   {
04193     val = iterative_hash_pointer (built_in_decls[DECL_FUNCTION_CODE (t)], 
04194               val);
04195     return val;
04196   }
04197       /* else FALL THROUGH */
04198     default:
04199       class = TREE_CODE_CLASS (code);
04200 
04201       if (class == tcc_declaration)
04202   {
04203     /* Otherwise, we can just compare decls by pointer.  */
04204     val = iterative_hash_pointer (t, val);
04205   }
04206       else
04207   {
04208     gcc_assert (IS_EXPR_CODE_CLASS (class));
04209     
04210     val = iterative_hash_object (code, val);
04211 
04212     /* Don't hash the type, that can lead to having nodes which
04213        compare equal according to operand_equal_p, but which
04214        have different hash codes.  */
04215     if (code == NOP_EXPR
04216         || code == CONVERT_EXPR
04217         || code == NON_LVALUE_EXPR)
04218       {
04219         /* Make sure to include signness in the hash computation.  */
04220         val += TYPE_UNSIGNED (TREE_TYPE (t));
04221         val = iterative_hash_expr (TREE_OPERAND (t, 0), val);
04222       }
04223 
04224     else if (commutative_tree_code (code))
04225       {
04226         /* It's a commutative expression.  We want to hash it the same
04227      however it appears.  We do this by first hashing both operands
04228      and then rehashing based on the order of their independent
04229      hashes.  */
04230         hashval_t one = iterative_hash_expr (TREE_OPERAND (t, 0), 0);
04231         hashval_t two = iterative_hash_expr (TREE_OPERAND (t, 1), 0);
04232         hashval_t t;
04233 
04234         if (one > two)
04235     t = one, one = two, two = t;
04236 
04237         val = iterative_hash_hashval_t (one, val);
04238         val = iterative_hash_hashval_t (two, val);
04239       }
04240     else
04241       for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; --i)
04242         val = iterative_hash_expr (TREE_OPERAND (t, i), val);
04243   }
04244       return val;
04245       break;
04246     }
04247 }
04248 
04249 /* Constructors for pointer, array and function types.
04250    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
04251    constructed by language-dependent code, not here.)  */
04252 
04253 /* Construct, lay out and return the type of pointers to TO_TYPE with
04254    mode MODE.  If CAN_ALIAS_ALL is TRUE, indicate this type can
04255    reference all of memory. If such a type has already been
04256    constructed, reuse it.  */
04257 
04258 tree
04259 build_pointer_type_for_mode (tree to_type, enum machine_mode mode,
04260            bool can_alias_all)
04261 {
04262   tree t;
04263 
04264   if (to_type == error_mark_node)
04265     return error_mark_node;
04266 
04267   /* In some cases, languages will have things that aren't a POINTER_TYPE
04268      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
04269      In that case, return that type without regard to the rest of our
04270      operands.
04271 
04272      ??? This is a kludge, but consistent with the way this function has
04273      always operated and there doesn't seem to be a good way to avoid this
04274      at the moment.  */
04275   if (TYPE_POINTER_TO (to_type) != 0
04276       && TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
04277     return TYPE_POINTER_TO (to_type);
04278 
04279   /* First, if we already have a type for pointers to TO_TYPE and it's
04280      the proper mode, use it.  */
04281   for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
04282     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
04283       return t;
04284 
04285   t = make_node (POINTER_TYPE);
04286 
04287   TREE_TYPE (t) = to_type;
04288   TYPE_MODE (t) = mode;
04289   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
04290   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
04291   TYPE_POINTER_TO (to_type) = t;
04292 
04293   /* Lay out the type.  This function has many callers that are concerned
04294      with expression-construction, and this simplifies them all.  */
04295   layout_type (t);
04296 
04297   return t;
04298 }
04299 
04300 /* By default build pointers in ptr_mode.  */
04301 
04302 tree
04303 build_pointer_type (tree to_type)
04304 {
04305   return build_pointer_type_for_mode (to_type, ptr_mode, false);
04306 }
04307 
04308 /* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE.  */
04309 
04310 tree
04311 build_reference_type_for_mode (tree to_type, enum machine_mode mode,
04312              bool can_alias_all)
04313 {
04314   tree t;
04315 
04316   /* In some cases, languages will have things that aren't a REFERENCE_TYPE
04317      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_REFERENCE_TO.
04318      In that case, return that type without regard to the rest of our
04319      operands.
04320 
04321      ??? This is a kludge, but consistent with the way this function has
04322      always operated and there doesn't seem to be a good way to avoid this
04323      at the moment.  */
04324   if (TYPE_REFERENCE_TO (to_type) != 0
04325       && TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
04326     return TYPE_REFERENCE_TO (to_type);
04327 
04328   /* First, if we already have a type for pointers to TO_TYPE and it's
04329      the proper mode, use it.  */
04330   for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
04331     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
04332       return t;
04333 
04334   t = make_node (REFERENCE_TYPE);
04335 
04336   TREE_TYPE (t) = to_type;
04337   TYPE_MODE (t) = mode;
04338   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
04339   TYPE_NEXT_REF_TO (t) = TYPE_REFERENCE_TO (to_type);
04340   TYPE_REFERENCE_TO (to_type) = t;
04341 
04342   layout_type (t);
04343 
04344   return t;
04345 }
04346 
04347 
04348 /* Build the node for the type of references-to-TO_TYPE by default
04349    in ptr_mode.  */
04350 
04351 tree
04352 build_reference_type (tree to_type)
04353 {
04354   return build_reference_type_for_mode (to_type, ptr_mode, false);
04355 }
04356 
04357 /* Build a type that is compatible with t but has no cv quals anywhere
04358    in its type, thus
04359 
04360    const char *const *const *  ->  char ***.  */
04361 
04362 tree
04363 build_type_no_quals (tree t)
04364 {
04365   switch (TREE_CODE (t))
04366     {
04367     case POINTER_TYPE:
04368       return build_pointer_type_for_mode (build_type_no_quals (TREE_TYPE (t)),
04369             TYPE_MODE (t),
04370             TYPE_REF_CAN_ALIAS_ALL (t));
04371     case REFERENCE_TYPE:
04372       return
04373   build_reference_type_for_mode (build_type_no_quals (TREE_TYPE (t)),
04374                TYPE_MODE (t),
04375                TYPE_REF_CAN_ALIAS_ALL (t));
04376     default:
04377       return TYPE_MAIN_VARIANT (t);
04378     }
04379 }
04380 
04381 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
04382    MAXVAL should be the maximum value in the domain
04383    (one less than the length of the array).
04384 
04385    The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
04386    We don't enforce this limit, that is up to caller (e.g. language front end).
04387    The limit exists because the result is a signed type and we don't handle
04388    sizes that use more than one HOST_WIDE_INT.  */
04389 
04390 tree
04391 build_index_type (tree maxval)
04392 {
04393   tree itype = make_node (INTEGER_TYPE);
04394 
04395   TREE_TYPE (itype) = sizetype;
04396   TYPE_PRECISION (itype) = TYPE_PRECISION (sizetype);
04397   TYPE_MIN_VALUE (itype) = size_zero_node;
04398   TYPE_MAX_VALUE (itype) = fold_convert (sizetype, maxval);
04399   TYPE_MODE (itype) = TYPE_MODE (sizetype);
04400   TYPE_SIZE (itype) = TYPE_SIZE (sizetype);
04401   TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (sizetype);
04402   TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype);
04403   TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (sizetype);
04404 
04405   if (host_integerp (maxval, 1))
04406     return type_hash_canon (tree_low_cst (maxval, 1), itype);
04407   else
04408     return itype;
04409 }
04410 
04411 /* Builds a signed or unsigned integer type of precision PRECISION.
04412    Used for C bitfields whose precision does not match that of
04413    built-in target types.  */
04414 tree
04415 build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision,
04416         int unsignedp)
04417 {
04418   tree itype = make_node (INTEGER_TYPE);
04419 
04420   TYPE_PRECISION (itype) = precision;
04421 
04422   if (unsignedp)
04423     fixup_unsigned_type (itype);
04424   else
04425     fixup_signed_type (itype);
04426 
04427   if (host_integerp (TYPE_MAX_VALUE (itype), 1))
04428     return type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype);
04429 
04430   return itype;
04431 }
04432 
04433 /* Create a range of some discrete type TYPE (an INTEGER_TYPE,
04434    ENUMERAL_TYPE, BOOLEAN_TYPE, or CHAR_TYPE), with
04435    low bound LOWVAL and high bound HIGHVAL.
04436    if TYPE==NULL_TREE, sizetype is used.  */
04437 
04438 tree
04439 build_range_type (tree type, tree lowval, tree highval)
04440 {
04441   tree itype = make_node (INTEGER_TYPE);
04442 
04443   TREE_TYPE (itype) = type;
04444   if (type == NULL_TREE)
04445     type = sizetype;
04446 
04447   TYPE_MIN_VALUE (itype) = convert (type, lowval);
04448   TYPE_MAX_VALUE (itype) = highval ? convert (type, highval) : NULL;
04449 
04450   TYPE_PRECISION (itype) = TYPE_PRECISION (type);
04451   TYPE_MODE (itype) = TYPE_MODE (type);
04452   TYPE_SIZE (itype) = TYPE_SIZE (type);
04453   TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type);
04454   TYPE_ALIGN (itype) = TYPE_ALIGN (type);
04455   TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type);
04456 
04457   if (host_integerp (lowval, 0) && highval != 0 && host_integerp (highval, 0))
04458     return type_hash_canon (tree_low_cst (highval, 0)
04459           - tree_low_cst (lowval, 0),
04460           itype);
04461   else
04462     return itype;
04463 }
04464 
04465 /* Just like build_index_type, but takes lowval and highval instead
04466    of just highval (maxval).  */
04467 
04468 tree
04469 build_index_2_type (tree lowval, tree highval)
04470 {
04471   return build_range_type (sizetype, lowval, highval);
04472 }
04473 
04474 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE
04475    and number of elements specified by the range of values of INDEX_TYPE.
04476    If such a type has already been constructed, reuse it.  */
04477 
04478 tree
04479 build_array_type (tree elt_type, tree index_type)
04480 {
04481   tree t;
04482   hashval_t hashcode = 0;
04483 
04484   if (TREE_CODE (elt_type) == FUNCTION_TYPE)
04485     {
04486       error ("arrays of functions are not meaningful");
04487       elt_type = integer_type_node;
04488     }
04489 
04490   t = make_node (ARRAY_TYPE);
04491   TREE_TYPE (t) = elt_type;
04492   TYPE_DOMAIN (t) = index_type;
04493   
04494   if (index_type == 0)
04495     {
04496       layout_type (t);
04497       return t;
04498     }
04499 
04500   hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode);
04501   hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode);
04502   t = type_hash_canon (hashcode, t);
04503 
04504   if (!COMPLETE_TYPE_P (t))
04505     layout_type (t);
04506   return t;
04507 }
04508 
04509 /* Return the TYPE of the elements comprising
04510    the innermost dimension of ARRAY.  */
04511 
04512 tree
04513 get_inner_array_type (tree array)
04514 {
04515   tree type = TREE_TYPE (array);
04516 
04517   while (TREE_CODE (type) == ARRAY_TYPE)
04518     type = TREE_TYPE (type);
04519 
04520   return type;
04521 }
04522 
04523 /* Construct, lay out and return
04524    the type of functions returning type VALUE_TYPE
04525    given arguments of types ARG_TYPES.
04526    ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs
04527    are data type nodes for the arguments of the function.
04528    If such a type has already been constructed, reuse it.  */
04529 
04530 tree
04531 build_function_type (tree value_type, tree arg_types)
04532 {
04533   tree t;
04534   hashval_t hashcode = 0;
04535 
04536   if (TREE_CODE (value_type) == FUNCTION_TYPE)
04537     {
04538       error ("function return type cannot be function");
04539       value_type = integer_type_node;
04540     }
04541 
04542   /* Make a node of the sort we want.  */
04543   t = make_node (FUNCTION_TYPE);
04544   TREE_TYPE (t) = value_type;
04545   TYPE_ARG_TYPES (t) = arg_types;
04546 
04547   /* If we already have such a type, use the old one.  */
04548   hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode);
04549   hashcode = type_hash_list (arg_types, hashcode);
04550   t = type_hash_canon (hashcode, t);
04551 
04552   if (!COMPLETE_TYPE_P (t))
04553     layout_type (t);
04554   return t;
04555 }
04556 
04557 /* Build a function type.  The RETURN_TYPE is the type returned by the
04558    function.  If additional arguments are provided, they are
04559    additional argument types.  The list of argument types must always
04560    be terminated by NULL_TREE.  */
04561 
04562 tree
04563 build_function_type_list (tree return_type, ...)
04564 {
04565   tree t, args, last;
04566   va_list p;
04567 
04568   va_start (p, return_type);
04569 
04570   t = va_arg (p, tree);
04571   for (args = NULL_TREE; t != NULL_TREE; t = va_arg (p, tree))
04572     args = tree_cons (NULL_TREE, t, args);
04573 
04574   if (args == NULL_TREE)
04575     args = void_list_node;
04576   else
04577     {
04578       last = args;
04579       args = nreverse (args);
04580       TREE_CHAIN (last) = void_list_node;
04581     }
04582   args = build_function_type (return_type, args);
04583 
04584   va_end (p);
04585   return args;
04586 }
04587 
04588 /* Build a METHOD_TYPE for a member of BASETYPE.  The RETTYPE (a TYPE)
04589    and ARGTYPES (a TREE_LIST) are the return type and arguments types
04590    for the method.  An implicit additional parameter (of type
04591    pointer-to-BASETYPE) is added to the ARGTYPES.  */
04592 
04593 tree
04594 build_method_type_directly (tree basetype,
04595           tree rettype,
04596           tree argtypes)
04597 {
04598   tree t;
04599   tree ptype;
04600   int hashcode = 0;
04601 
04602   /* Make a node of the sort we want.  */
04603   t = make_node (METHOD_TYPE);
04604 
04605   TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
04606   TREE_TYPE (t) = rettype;
04607   ptype = build_pointer_type (basetype);
04608 
04609   /* The actual arglist for this function includes a "hidden" argument
04610      which is "this".  Put it into the list of argument types.  */
04611   argtypes = tree_cons (NULL_TREE, ptype, argtypes);
04612   TYPE_ARG_TYPES (t) = argtypes;
04613 
04614   /* If we already have such a type, use the old one.  */
04615   hashcode = iterative_hash_object (TYPE_HASH (basetype), hashcode);
04616   hashcode = iterative_hash_object (TYPE_HASH (rettype), hashcode);
04617   hashcode = type_hash_list (argtypes, hashcode);
04618   t = type_hash_canon (hashcode, t);
04619 
04620   if (!COMPLETE_TYPE_P (t))
04621     layout_type (t);
04622 
04623   return t;
04624 }
04625 
04626 /* Construct, lay out and return the type of methods belonging to class
04627    BASETYPE and whose arguments and values are described by TYPE.
04628    If that type exists already, reuse it.
04629    TYPE must be a FUNCTION_TYPE node.  */
04630 
04631 tree
04632 build_method_type (tree basetype, tree type)
04633 {
04634   gcc_assert (TREE_CODE (type) == FUNCTION_TYPE);
04635 
04636   return build_method_type_directly (basetype,
04637              TREE_TYPE (type),
04638              TYPE_ARG_TYPES (type));
04639 }
04640 
04641 /* Construct, lay out and return the type of offsets to a value
04642    of type TYPE, within an object of type BASETYPE.
04643    If a suitable offset type exists already, reuse it.  */
04644 
04645 tree
04646 build_offset_type (tree basetype, tree type)
04647 {
04648   tree t;
04649   hashval_t hashcode = 0;
04650 
04651   /* Make a node of the sort we want.  */
04652   t = make_node (OFFSET_TYPE);
04653 
04654   TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
04655   TREE_TYPE (t) = type;
04656 
04657   /* If we already have such a type, use the old one.  */
04658   hashcode = iterative_hash_object (TYPE_HASH (basetype), hashcode);
04659   hashcode = iterative_hash_object (TYPE_HASH (type), hashcode);
04660   t = type_hash_canon (hashcode, t);
04661 
04662   if (!COMPLETE_TYPE_P (t))
04663     layout_type (t);
04664 
04665   return t;
04666 }
04667 
04668 /* Create a complex type whose components are COMPONENT_TYPE.  */
04669 
04670 tree
04671 build_complex_type (tree component_type)
04672 {
04673   tree t;
04674   hashval_t hashcode;
04675 
04676   /* Make a node of the sort we want.  */
04677   t = make_node (COMPLEX_TYPE);
04678 
04679   TREE_TYPE (t) = TYPE_MAIN_VARIANT (component_type);
04680 
04681   /* If we already have such a type, use the old one.  */
04682   hashcode = iterative_hash_object (TYPE_HASH (component_type), 0);
04683   t = type_hash_canon (hashcode, t);
04684 
04685   if (!COMPLETE_TYPE_P (t))
04686     layout_type (t);
04687 
04688   /* If we are writing Dwarf2 output we need to create a name,
04689      since complex is a fundamental type.  */
04690   if ((write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
04691       && ! TYPE_NAME (t))
04692     {
04693       const char *name;
04694       if (component_type == char_type_node)
04695   name = "complex char";
04696       else if (component_type == signed_char_type_node)
04697   name = "complex signed char";
04698       else if (component_type == unsigned_char_type_node)
04699   name = "complex unsigned char";
04700       else if (component_type == short_integer_type_node)
04701   name = "complex short int";
04702       else if (component_type == short_unsigned_type_node)
04703   name = "complex short unsigned int";
04704       else if (component_type == integer_type_node)
04705   name = "complex int";
04706       else if (component_type == unsigned_type_node)
04707   name = "complex unsigned int";
04708       else if (component_type == long_integer_type_node)
04709   name = "complex long int";
04710       else if (component_type == long_unsigned_type_node)
04711   name = "complex long unsigned int";
04712       else if (component_type == long_long_integer_type_node)
04713   name = "complex long long int";
04714       else if (component_type == long_long_unsigned_type_node)
04715   name = "complex long long unsigned int";
04716       else
04717   name = 0;
04718 
04719       if (name != 0)
04720   TYPE_NAME (t) = get_identifier (name);
04721     }
04722 
04723   return build_qualified_type (t, TYPE_QUALS (component_type));
04724 }
04725 
04726 /* Return OP, stripped of any conversions to wider types as much as is safe.
04727    Converting the value back to OP's type makes a value equivalent to OP.
04728 
04729    If FOR_TYPE is nonzero, we return a value which, if converted to
04730    type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE.
04731 
04732    If FOR_TYPE is nonzero, unaligned bit-field references may be changed to the
04733    narrowest type that can hold the value, even if they don't exactly fit.
04734    Otherwise, bit-field references are changed to a narrower type
04735    only if they can be fetched directly from memory in that type.
04736 
04737    OP must have integer, real or enumeral type.  Pointers are not allowed!
04738 
04739    There are some cases where the obvious value we could return
04740    would regenerate to OP if converted to OP's type,
04741    but would not extend like OP to wider types.
04742    If FOR_TYPE indicates such extension is contemplated, we eschew such values.
04743    For example, if OP is (unsigned short)(signed char)-1,
04744    we avoid returning (signed char)-1 if FOR_TYPE is int,
04745    even though extending that to an unsigned short would regenerate OP,
04746    since the result of extending (signed char)-1 to (int)
04747    is different from (int) OP.  */
04748 
04749 tree
04750 get_unwidened (tree op, tree for_type)
04751 {
04752   /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension.  */
04753   tree type = TREE_TYPE (op);
04754   unsigned final_prec
04755     = TYPE_PRECISION (for_type != 0 ? for_type : type);
04756   int uns
04757     = (for_type != 0 && for_type != type
04758        && final_prec > TYPE_PRECISION (type)
04759        && TYPE_UNSIGNED (type));
04760   tree win = op;
04761 
04762   while (TREE_CODE (op) == NOP_EXPR
04763    || TREE_CODE (op) == CONVERT_EXPR)
04764     {
04765       int bitschange;
04766 
04767       /* TYPE_PRECISION on vector types has different meaning
04768    (TYPE_VECTOR_SUBPARTS) and casts from vectors are view conversions,
04769    so avoid them here.  */
04770       if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == VECTOR_TYPE)
04771   break;
04772 
04773       bitschange = TYPE_PRECISION (TREE_TYPE (op))
04774        - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
04775 
04776       /* Truncations are many-one so cannot be removed.
04777    Unless we are later going to truncate down even farther.  */
04778       if (bitschange < 0
04779     && final_prec > TYPE_PRECISION (TREE_TYPE (op)))
04780   break;
04781 
04782       /* See what's inside this conversion.  If we decide to strip it,
04783    we will set WIN.  */
04784       op = TREE_OPERAND (op, 0);
04785 
04786       /* If we have not stripped any zero-extensions (uns is 0),
04787    we can strip any kind of extension.
04788    If we have previously stripped a zero-extension,
04789    only zero-extensions can safely be stripped.
04790    Any extension can be stripped if the bits it would produce
04791    are all going to be discarded later by truncating to FOR_TYPE.  */
04792 
04793       if (bitschange > 0)
04794   {
04795     if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op)))
04796       win = op;
04797     /* TYPE_UNSIGNED says whether this is a zero-extension.
04798        Let's avoid computing it if it does not affect WIN
04799        and if UNS will not be needed again.  */
04800     if ((uns
04801          || TREE_CODE (op) == NOP_EXPR
04802          || TREE_CODE (op) == CONVERT_EXPR)
04803         && TYPE_UNSIGNED (TREE_TYPE (op)))
04804       {
04805         uns = 1;
04806         win = op;
04807       }
04808   }
04809     }
04810 
04811   if (TREE_CODE (op) == COMPONENT_REF
04812       /* Since type_for_size always gives an integer type.  */
04813       && TREE_CODE (type) != REAL_TYPE
04814       /* Don't crash if field not laid out yet.  */
04815       && DECL_SIZE (TREE_OPERAND (op, 1)) != 0
04816       && host_integerp (DECL_SIZE (TREE_OPERAND (op, 1)), 1))
04817     {
04818       unsigned int innerprec
04819   = tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
04820       int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
04821            || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
04822       type = lang_hooks.types.type_for_size (innerprec, unsignedp);
04823 
04824       /* We can get this structure field in the narrowest type it fits in.
04825    If FOR_TYPE is 0, do this only for a field that matches the
04826    narrower type exactly and is aligned for it
04827    The resulting extension to its nominal type (a fullword type)
04828    must fit the same conditions as for other extensions.  */
04829 
04830       if (type != 0
04831     && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (op)))
04832     && (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
04833     && (! uns || final_prec <= innerprec || unsignedp))
04834   {
04835     win = build3 (COMPONENT_REF, type, TREE_OPERAND (op, 0),
04836       TREE_OPERAND (op, 1), NULL_TREE);
04837     TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
04838     TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
04839   }
04840     }
04841 
04842   return win;
04843 }
04844 
04845 /* Return OP or a simpler expression for a narrower value
04846    which can be sign-extended or zero-extended to give back OP.
04847    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
04848    or 0 if the value should be sign-extended.  */
04849 
04850 tree
04851 get_narrower (tree op, int *unsignedp_ptr)
04852 {
04853   int uns = 0;
04854   int first = 1;
04855   tree win = op;
04856   bool integral_p = INTEGRAL_TYPE_P (TREE_TYPE (op));
04857 
04858   while (TREE_CODE (op) == NOP_EXPR)
04859     {
04860       int bitschange
04861   = (TYPE_PRECISION (TREE_TYPE (op))
04862      - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))));
04863 
04864       /* Truncations are many-one so cannot be removed.  */
04865       if (bitschange < 0)
04866   break;
04867 
04868       /* See what's inside this conversion.  If we decide to strip it,
04869    we will set WIN.  */
04870 
04871       if (bitschange > 0)
04872   {
04873     op = TREE_OPERAND (op, 0);
04874     /* An extension: the outermost one can be stripped,
04875        but remember whether it is zero or sign extension.  */
04876     if (first)
04877       uns = TYPE_UNSIGNED (TREE_TYPE (op));
04878     /* Otherwise, if a sign extension has been stripped,
04879        only sign extensions can now be stripped;
04880        if a zero extension has been stripped, only zero-extensions.  */
04881     else if (uns != TYPE_UNSIGNED (TREE_TYPE (op)))
04882       break;
04883     first = 0;
04884   }
04885       else /* bitschange == 0 */
04886   {
04887     /* A change in nominal type can always be stripped, but we must
04888        preserve the unsignedness.  */
04889     if (first)
04890       uns = TYPE_UNSIGNED (TREE_TYPE (op));
04891     first = 0;
04892     op = TREE_OPERAND (op, 0);
04893     /* Keep trying to narrow, but don't assign op to win if it
04894        would turn an integral type into something else.  */
04895     if (INTEGRAL_TYPE_P (TREE_TYPE (op)) != integral_p)
04896       continue;
04897   }
04898 
04899       win = op;
04900     }
04901 
04902   if (TREE_CODE (op) == COMPONENT_REF
04903       /* Since type_for_size always gives an integer type.  */
04904       && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE
04905       /* Ensure field is laid out already.  */
04906       && DECL_SIZE (TREE_OPERAND (op, 1)) != 0
04907       && host_integerp (DECL_SIZE (TREE_OPERAND (op, 1)), 1))
04908     {
04909       unsigned HOST_WIDE_INT innerprec
04910   = tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
04911       int unsignedp = (DECL_UNSIGNED (TREE_OPERAND (op, 1))
04912            || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
04913       tree type = lang_hooks.types.type_for_size (innerprec, unsignedp);
04914 
04915       /* We can get this structure field in a narrower type that fits it,
04916    but the resulting extension to its nominal type (a fullword type)
04917    must satisfy the same conditions as for other extensions.
04918 
04919    Do this only for fields that are aligned (not bit-fields),
04920    because when bit-field insns will be used there is no
04921    advantage in doing this.  */
04922 
04923       if (innerprec < TYPE_PRECISION (TREE_TYPE (op))
04924     && ! DECL_BIT_FIELD (TREE_OPERAND (op, 1))
04925     && (first || uns == DECL_UNSIGNED (TREE_OPERAND (op, 1)))
04926     && type != 0)
04927   {
04928     if (first)
04929       uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
04930     win = build3 (COMPONENT_REF, type, TREE_OPERAND (op, 0),
04931       TREE_OPERAND (op, 1), NULL_TREE);
04932     TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
04933     TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
04934   }
04935     }
04936   *unsignedp_ptr = uns;
04937   return win;
04938 }
04939 
04940 /* Nonzero if integer constant C has a value that is permissible
04941    for type TYPE (an INTEGER_TYPE).  */
04942 
04943 int
04944 int_fits_type_p (tree c, tree type)
04945 {
04946   tree type_low_bound = TYPE_MIN_VALUE (type);
04947   tree type_high_bound = TYPE_MAX_VALUE (type);
04948   bool ok_for_low_bound, ok_for_high_bound;
04949   tree tmp;
04950 
04951   /* If at least one bound of the type is a constant integer, we can check
04952      ourselves and maybe make a decision. If no such decision is possible, but
04953      this type is a subtype, try checking against that.  Otherwise, use
04954      force_fit_type, which checks against the precision.
04955 
04956      Compute the status for each possibly constant bound, and return if we see
04957      one does not match. Use ok_for_xxx_bound for this purpose, assigning -1
04958      for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
04959      for "constant known to fit".  */
04960 
04961   /* Check if C >= type_low_bound.  */
04962   if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST)
04963     {
04964       if (tree_int_cst_lt (c, type_low_bound))
04965   return 0;
04966       ok_for_low_bound = true;
04967     }
04968   else
04969     ok_for_low_bound = false;
04970 
04971   /* Check if c <= type_high_bound.  */
04972   if (type_high_bound && TREE_CODE (type_high_bound) == INTEGER_CST)
04973     {
04974       if (tree_int_cst_lt (type_high_bound, c))
04975   return 0;
04976       ok_for_high_bound = true;
04977     }
04978   else
04979     ok_for_high_bound = false;
04980 
04981   /* If the constant fits both bounds, the result is known.  */
04982   if (ok_for_low_bound && ok_for_high_bound)
04983     return 1;
04984 
04985   /* Perform some generic filtering which may allow making a decision
04986      even if the bounds are not constant.  First, negative integers
04987      never fit in unsigned types, */
04988   if (TYPE_UNSIGNED (type) && tree_int_cst_sgn (c) < 0)
04989     return 0;
04990 
04991   /* Second, narrower types always fit in wider ones.  */
04992   if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c)))
04993     return 1;
04994 
04995   /* Third, unsigned integers with top bit set never fit signed types.  */
04996   if (! TYPE_UNSIGNED (type)
04997       && TYPE_UNSIGNED (TREE_TYPE (c))
04998       && tree_int_cst_msb (c))
04999     return 0;
05000 
05001   /* If we haven't been able to decide at this point, there nothing more we
05002      can check ourselves here. Look at the base type if we have one.  */
05003   if (TREE_CODE (type) == INTEGER_TYPE && TREE_TYPE (type) != 0)
05004     return int_fits_type_p (c, TREE_TYPE (type));
05005 
05006   /* Or to force_fit_type, if nothing else.  */
05007   tmp = copy_node (c);
05008   TREE_TYPE (tmp) = type;
05009   tmp = force_fit_type (tmp, -1, false, false);
05010   return TREE_INT_CST_HIGH (tmp) == TREE_INT_CST_HIGH (c)
05011          && TREE_INT_CST_LOW (tmp) == TREE_INT_CST_LOW (c);
05012 }
05013 
05014 /* Subprogram of following function.  Called by walk_tree.
05015 
05016    Return *TP if it is an automatic variable or parameter of the
05017    function passed in as DATA.  */
05018 
05019 static tree
05020 find_var_from_fn (tree *tp, int *walk_subtrees, void *data)
05021 {
05022   tree fn = (tree) data;
05023 
05024   if (TYPE_P (*tp))
05025     *walk_subtrees = 0;
05026 
05027   else if (DECL_P (*tp)
05028      && lang_hooks.tree_inlining.auto_var_in_fn_p (*tp, fn))
05029     return *tp;
05030 
05031   return NULL_TREE;
05032 }
05033 
05034 /* Returns true if T is, contains, or refers to a type with variable
05035    size.  If FN is nonzero, only return true if a modifier of the type
05036    or position of FN is a variable or parameter inside FN.
05037 
05038    This concept is more general than that of C99 'variably modified types':
05039    in C99, a struct type is never variably modified because a VLA may not
05040    appear as a structure member.  However, in GNU C code like:
05041 
05042      struct S { int i[f()]; };
05043 
05044    is valid, and other languages may define similar constructs.  */
05045 
05046 bool
05047 variably_modified_type_p (tree type, tree fn)
05048 {
05049   tree t;
05050 
05051 /* Test if T is either variable (if FN is zero) or an expression containing
05052    a variable in FN.  */
05053 #define RETURN_TRUE_IF_VAR(T)           \
05054   do { tree _t = (T);             \
05055     if (_t && _t != error_mark_node && TREE_CODE (_t) != INTEGER_CST  \
05056         && (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL)))  \
05057       return true;  } while (0)
05058 
05059   if (type == error_mark_node)
05060     return false;
05061 
05062   /* If TYPE itself has variable size, it is variably modified.
05063 
05064      We do not yet have a representation of the C99 '[*]' syntax.
05065      When a representation is chosen, this function should be modified
05066      to test for that case as well.  */
05067   RETURN_TRUE_IF_VAR (TYPE_SIZE (type));
05068   RETURN_TRUE_IF_VAR (TYPE_SIZE_UNIT(type));
05069 
05070   switch (TREE_CODE (type))
05071     {
05072     case POINTER_TYPE:
05073     case REFERENCE_TYPE:
05074     case ARRAY_TYPE:
05075     case VECTOR_TYPE:
05076       if (variably_modified_type_p (TREE_TYPE (type), fn))
05077   return true;
05078       break;
05079 
05080     case FUNCTION_TYPE:
05081     case METHOD_TYPE:
05082       /* If TYPE is a function type, it is variably modified if any of the
05083          parameters or the return type are variably modified.  */
05084       if (variably_modified_type_p (TREE_TYPE (type), fn))
05085     return true;
05086 
05087       for (t = TYPE_ARG_TYPES (type);
05088      t && t != void_list_node;
05089      t = TREE_CHAIN (t))
05090   if (variably_modified_type_p (TREE_VALUE (t), fn))
05091     return true;
05092       break;
05093 
05094     case INTEGER_TYPE:
05095     case REAL_TYPE:
05096     case ENUMERAL_TYPE:
05097     case BOOLEAN_TYPE:
05098     case CHAR_TYPE:
05099       /* Scalar types are variably modified if their end points
05100    aren't constant.  */
05101       RETURN_TRUE_IF_VAR (TYPE_MIN_VALUE (type));
05102       RETURN_TRUE_IF_VAR (TYPE_MAX_VALUE (type));
05103       break;
05104 
05105     case RECORD_TYPE:
05106     case UNION_TYPE:
05107     case QUAL_UNION_TYPE:
05108       /* We can't see if any of the field are variably-modified by the
05109    definition we normally use, since that would produce infinite
05110    recursion via pointers.  */
05111       /* This is variably modified if some field's type is.  */
05112       for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t))
05113   if (TREE_CODE (t) == FIELD_DECL)
05114     {
05115       RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t));
05116       RETURN_TRUE_IF_VAR (DECL_SIZE (t));
05117       RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t));
05118 
05119       if (TREE_CODE (type) == QUAL_UNION_TYPE)
05120         RETURN_TRUE_IF_VAR (DECL_QUALIFIER (t));
05121     }
05122   break;
05123 
05124     default:
05125       break;
05126     }
05127 
05128   /* The current language may have other cases to check, but in general,
05129      all other types are not variably modified.  */
05130   return lang_hooks.tree_inlining.var_mod_type_p (type, fn);
05131 
05132 #undef RETURN_TRUE_IF_VAR
05133 }
05134 
05135 /* Given a DECL or TYPE, return the scope in which it was declared, or
05136    NULL_TREE if there is no containing scope.  */
05137 
05138 tree
05139 get_containing_scope (tree t)
05140 {
05141   return (TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t));
05142 }
05143 
05144 /* Return the innermost context enclosing DECL that is
05145    a FUNCTION_DECL, or zero if none.  */
05146 
05147 tree
05148 decl_function_context (tree decl)
05149 {
05150   tree context;
05151 
05152   if (TREE_CODE (decl) == ERROR_MARK)
05153     return 0;
05154 
05155   /* C++ virtual functions use DECL_CONTEXT for the class of the vtable
05156      where we look up the function at runtime.  Such functions always take
05157      a first argument of type 'pointer to real context'.
05158 
05159      C++ should really be fixed to use DECL_CONTEXT for the real context,
05160      and use something else for the "virtual context".  */
05161   else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VINDEX (decl))
05162     context
05163       = TYPE_MAIN_VARIANT
05164   (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
05165   else
05166     context = DECL_CONTEXT (decl);
05167 
05168   while (context && TREE_CODE (context) != FUNCTION_DECL)
05169     {
05170       if (TREE_CODE (context) == BLOCK)
05171   context = BLOCK_SUPERCONTEXT (context);
05172       else
05173   context = get_containing_scope (context);
05174     }
05175 
05176   return context;
05177 }
05178 
05179 /* Return the innermost context enclosing DECL that is
05180    a RECORD_TYPE, UNION_TYPE or QUAL_UNION_TYPE, or zero if none.
05181    TYPE_DECLs and FUNCTION_DECLs are transparent to this function.  */
05182 
05183 tree
05184 decl_type_context (tree decl)
05185 {
05186   tree context = DECL_CONTEXT (decl);
05187 
05188   while (context)
05189     switch (TREE_CODE (context))
05190       {
05191       case NAMESPACE_DECL:
05192       case TRANSLATION_UNIT_DECL:
05193   return NULL_TREE;
05194 
05195       case RECORD_TYPE:
05196       case UNION_TYPE:
05197       case QUAL_UNION_TYPE:
05198   return context;
05199 
05200       case TYPE_DECL:
05201       case FUNCTION_DECL:
05202   context = DECL_CONTEXT (context);
05203   break;
05204 
05205       case BLOCK:
05206   context = BLOCK_SUPERCONTEXT (context);
05207   break;
05208 
05209       default:
05210   gcc_unreachable ();
05211       }
05212 
05213   return NULL_TREE;
05214 }
05215 
05216 /* CALL is a CALL_EXPR.  Return the declaration for the function
05217    called, or NULL_TREE if the called function cannot be
05218    determined.  */
05219 
05220 tree
05221 get_callee_fndecl (tree call)
05222 {
05223   tree addr;
05224 
05225   /* It's invalid to call this function with anything but a
05226      CALL_EXPR.  */
05227   gcc_assert (TREE_CODE (call) == CALL_EXPR);
05228 
05229   /* The first operand to the CALL is the address of the function
05230      called.  */
05231   addr = TREE_OPERAND (call, 0);
05232 
05233   STRIP_NOPS (addr);
05234 
05235   /* If this is a readonly function pointer, extract its initial value.  */
05236   if (DECL_P (addr) && TREE_CODE (addr) != FUNCTION_DECL
05237       && TREE_READONLY (addr) && ! TREE_THIS_VOLATILE (addr)
05238       && DECL_INITIAL (addr))
05239     addr = DECL_INITIAL (addr);
05240 
05241   /* If the address is just `&f' for some function `f', then we know
05242      that `f' is being called.  */
05243   if (TREE_CODE (addr) == ADDR_EXPR
05244       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
05245     return TREE_OPERAND (addr, 0);
05246 
05247   /* We couldn't figure out what was being called.  Maybe the front
05248      end has some idea.  */
05249   return lang_hooks.lang_get_callee_fndecl (call);
05250 }
05251 
05252 /* Print debugging information about tree nodes generated during the compile,
05253    and any language-specific information.  */
05254 
05255 void
05256 dump_tree_statistics (void)
05257 {
05258 #ifdef GATHER_STATISTICS
05259   int i;
05260   int total_nodes, total_bytes;
05261 #endif
05262 
05263   fprintf (stderr, "\n??? tree nodes created\n\n");
05264 #ifdef GATHER_STATISTICS
05265   fprintf (stderr, "Kind                   Nodes      Bytes\n");
05266   fprintf (stderr, "---------------------------------------\n");
05267   total_nodes = total_bytes = 0;
05268   for (i = 0; i < (int) all_kinds; i++)
05269     {
05270       fprintf (stderr, "%-20s %7d %10d\n", tree_node_kind_names[i],
05271          tree_node_counts[i], tree_node_sizes[i]);
05272       total_nodes += tree_node_counts[i];
05273       total_bytes += tree_node_sizes[i];
05274     }
05275   fprintf (stderr, "---------------------------------------\n");
05276   fprintf (stderr, "%-20s %7d %10d\n", "Total", total_nodes, total_bytes);
05277   fprintf (stderr, "---------------------------------------\n");
05278   ssanames_print_statistics ();
05279   phinodes_print_statistics ();
05280 #else
05281   fprintf (stderr, "(No per-node statistics)\n");
05282 #endif
05283   print_type_hash_statistics ();
05284   lang_hooks.print_statistics ();
05285 }
05286 
05287 #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s"
05288 
05289 /* Generate a crc32 of a string.  */
05290 
05291 unsigned
05292 crc32_string (unsigned chksum, const char *string)
05293 {
05294   do
05295     {
05296       unsigned value = *string << 24;
05297       unsigned ix;
05298 
05299       for (ix = 8; ix--; value <<= 1)
05300     {
05301       unsigned feedback;
05302 
05303       feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0;
05304     chksum <<= 1;
05305     chksum ^= feedback;
05306     }
05307     }
05308   while (*string++);
05309   return chksum;
05310 }
05311 
05312 /* P is a string that will be used in a symbol.  Mask out any characters
05313    that are not valid in that context.  */
05314 
05315 void
05316 clean_symbol_name (char *p)
05317 {
05318   for (; *p; p++)
05319     if (! (ISALNUM (*p)
05320 #ifndef NO_DOLLAR_IN_LABEL  /* this for `$'; unlikely, but... -- kr */
05321       || *p == '$'
05322 #endif
05323 #ifndef NO_DOT_IN_LABEL   /* this for `.'; unlikely, but...  */
05324       || *p == '.'
05325 #endif
05326      ))
05327       *p = '_';
05328 }
05329 
05330 /* Generate a name for a function unique to this translation unit.
05331    TYPE is some string to identify the purpose of this function to the
05332    linker or collect2.  */
05333 
05334 tree
05335 get_file_function_name_long (const char *type)
05336 {
05337   char *buf;
05338   const char *p;
05339   char *q;
05340 
05341   if (first_global_object_name)
05342     p = first_global_object_name;
05343   else
05344     {
05345       /* We don't have anything that we know to be unique to this translation
05346    unit, so use what we do have and throw in some randomness.  */
05347       unsigned len;
05348       const char *name = weak_global_object_name;
05349       const char *file = main_input_filename;
05350 
05351       if (! name)
05352   name = "";
05353       if (! file)
05354   file = input_filename;
05355 
05356       len = strlen (file);
05357       q = alloca (9 * 2 + len + 1);
05358       memcpy (q, file, len + 1);
05359       clean_symbol_name (q);
05360 
05361       sprintf (q + len, "_%08X_%08X", crc32_string (0, name),
05362          crc32_string (0, flag_random_seed));
05363 
05364       p = q;
05365     }
05366 
05367   buf = alloca (sizeof (FILE_FUNCTION_FORMAT) + strlen (p) + strlen (type));
05368 
05369   /* Set up the name of the file-level functions we may need.
05370      Use a global object (which is already required to be unique over
05371      the program) rather than the file name (which imposes extra
05372      constraints).  */
05373   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
05374 
05375   return get_identifier (buf);
05376 }
05377 
05378 /* If KIND=='I', return a suitable global initializer (constructor) name.
05379    If KIND=='D', return a suitable global clean-up (destructor) name.  */
05380 
05381 tree
05382 get_file_function_name (int kind)
05383 {
05384   char p[2];
05385 
05386   p[0] = kind;
05387   p[1] = 0;
05388 
05389   return get_file_function_name_long (p);
05390 }
05391 
05392 /* Expand (the constant part of) a SET_TYPE CONSTRUCTOR node.
05393    The result is placed in BUFFER (which has length BIT_SIZE),
05394    with one bit in each char ('\000' or '\001').
05395 
05396    If the constructor is constant, NULL_TREE is returned.
05397    Otherwise, a TREE_LIST of the non-constant elements is emitted.  */
05398 
05399 tree
05400 get_set_constructor_bits (tree init, char *buffer, int bit_size)
05401 {
05402   int i;
05403   tree vals;
05404   HOST_WIDE_INT domain_min
05405     = tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (init))), 0);
05406   tree non_const_bits = NULL_TREE;
05407 
05408   for (i = 0; i < bit_size; i++)
05409     buffer[i] = 0;
05410 
05411   for (vals = TREE_OPERAND (init, 1);
05412        vals != NULL_TREE; vals = TREE_CHAIN (vals))
05413     {
05414       if (!host_integerp (TREE_VALUE (vals), 0)
05415     || (TREE_PURPOSE (vals) != NULL_TREE
05416         && !host_integerp (TREE_PURPOSE (vals), 0)))
05417   non_const_bits
05418     = tree_cons (TREE_PURPOSE (vals), TREE_VALUE (vals), non_const_bits);
05419       else if (TREE_PURPOSE (vals) != NULL_TREE)
05420   {
05421     /* Set a range of bits to ones.  */
05422     HOST_WIDE_INT lo_index
05423       = tree_low_cst (TREE_PURPOSE (vals), 0) - domain_min;
05424     HOST_WIDE_INT hi_index
05425       = tree_low_cst (TREE_VALUE (vals), 0) - domain_min;
05426 
05427     gcc_assert (lo_index >= 0);
05428     gcc_assert (lo_index < bit_size);
05429     gcc_assert (hi_index >= 0);
05430     gcc_assert (hi_index < bit_size);
05431     for (; lo_index <= hi_index; lo_index++)
05432       buffer[lo_index] = 1;
05433   }
05434       else
05435   {
05436     /* Set a single bit to one.  */
05437     HOST_WIDE_INT index
05438       = tree_low_cst (TREE_VALUE (vals), 0) - domain_min;
05439     if (index < 0 || index >= bit_size)
05440       {
05441         error ("invalid initializer for bit string");
05442         return NULL_TREE;
05443       }
05444     buffer[index] = 1;
05445   }
05446     }
05447   return non_const_bits;
05448 }
05449 
05450 /* Expand (the constant part of) a SET_TYPE CONSTRUCTOR node.
05451    The result is placed in BUFFER (which is an array of bytes).
05452    If the constructor is constant, NULL_TREE is returned.
05453    Otherwise, a TREE_LIST of the non-constant elements is emitted.  */
05454 
05455 tree
05456 get_set_constructor_bytes (tree init, unsigned char *buffer, int wd_size)
05457 {
05458   int i;
05459   int set_word_size = BITS_PER_UNIT;
05460   int bit_size = wd_size * set_word_size;
05461   int bit_pos = 0;
05462   unsigned char *bytep = buffer;
05463   char *bit_buffer = alloca (bit_size);
05464   tree non_const_bits = get_set_constructor_bits (init, bit_buffer, bit_size);
05465 
05466   for (i = 0; i < wd_size; i++)
05467     buffer[i] = 0;
05468 
05469   for (i = 0; i < bit_size; i++)
05470     {
05471       if (bit_buffer[i])
05472   {
05473     if (BYTES_BIG_ENDIAN)
05474       *bytep |= (1 << (set_word_size - 1 - bit_pos));
05475     else
05476       *bytep |= 1 << bit_pos;
05477   }
05478       bit_pos++;
05479       if (bit_pos >= set_word_size)
05480   bit_pos = 0, bytep++;
05481     }
05482   return non_const_bits;
05483 }
05484 
05485 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
05486 
05487 /* Complain that the tree code of NODE does not match the expected 0
05488    terminated list of trailing codes. The trailing code list can be
05489    empty, for a more vague error message.  FILE, LINE, and FUNCTION
05490    are of the caller.  */
05491 
05492 void
05493 tree_check_failed (const tree node, const char *file,
05494        int line, const char *function, ...)
05495 {
05496   va_list args;
05497   char *buffer;
05498   unsigned length = 0;
05499   int code;
05500 
05501   va_start (args, function);
05502   while ((code = va_arg (args, int)))
05503     length += 4 + strlen (tree_code_name[code]);
05504   va_end (args);
05505   if (length)
05506     {
05507       va_start (args, function);
05508       length += strlen ("expected ");
05509       buffer = alloca (length);
05510       length = 0;
05511       while ((code = va_arg (args, int)))
05512   {
05513     const char *prefix = length ? " or " : "expected ";
05514     
05515     strcpy (buffer + length, prefix);
05516     length += strlen (prefix);
05517     strcpy (buffer + length, tree_code_name[code]);
05518     length += strlen (tree_code_name[code]);
05519   }
05520       va_end (args);
05521     }
05522   else
05523     buffer = (char *)"unexpected node";
05524 
05525   internal_error ("tree check: %s, have %s in %s, at %s:%d",
05526       buffer, tree_code_name[TREE_CODE (node)],
05527       function, trim_filename (file), line);
05528 }
05529 
05530 /* Complain that the tree code of NODE does match the expected 0
05531    terminated list of trailing codes. FILE, LINE, and FUNCTION are of
05532    the caller.  */
05533 
05534 void
05535 tree_not_check_failed (const tree node, const char *file,
05536            int line, const char *function, ...)
05537 {
05538   va_list args;
05539   char *buffer;
05540   unsigned length = 0;
05541   int code;
05542 
05543   va_start (args, function);
05544   while ((code = va_arg (args, int)))
05545     length += 4 + strlen (tree_code_name[code]);
05546   va_end (args);
05547   va_start (args, function);
05548   buffer = alloca (length);
05549   length = 0;
05550   while ((code = va_arg (args, int)))
05551     {
05552       if (length)
05553   {
05554     strcpy (buffer + length, " or ");
05555     length += 4;
05556   }
05557       strcpy (buffer + length, tree_code_name[code]);
05558       length += strlen (tree_code_name[code]);
05559     }
05560   va_end (args);
05561 
05562   internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d",
05563       buffer, tree_code_name[TREE_CODE (node)],
05564       function, trim_filename (file), line);
05565 }
05566 
05567 /* Similar to tree_check_failed, except that we check for a class of tree
05568    code, given in CL.  */
05569 
05570 void
05571 tree_class_check_failed (const tree node, const enum tree_code_class cl,
05572        const char *file, int line, const char *function)
05573 {
05574   internal_error
05575     ("tree check: expected class %qs, have %qs (%s) in %s, at %s:%d",
05576      TREE_CODE_CLASS_STRING (cl),
05577      TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
05578      tree_code_name[TREE_CODE (node)], function, trim_filename (file), line);
05579 }
05580 
05581 /* Similar to above, except that the check is for the bounds of a TREE_VEC's
05582    (dynamically sized) vector.  */
05583 
05584 void
05585 tree_vec_elt_check_failed (int idx, int len, const char *file, int line,
05586          const char *function)
05587 {
05588   internal_error
05589     ("tree check: accessed elt %d of tree_vec with %d elts in %s, at %s:%d",
05590      idx + 1, len, function, trim_filename (file), line);
05591 }
05592 
05593 /* Similar to above, except that the check is for the bounds of a PHI_NODE's
05594    (dynamically sized) vector.  */
05595 
05596 void
05597 phi_node_elt_check_failed (int idx, int len, const char *file, int line,
05598           const char *function)
05599 {
05600   internal_error
05601     ("tree check: accessed elt %d of phi_node with %d elts in %s, at %s:%d",
05602      idx + 1, len, function, trim_filename (file), line);
05603 }
05604 
05605 /* Similar to above, except that the check is for the bounds of the operand
05606    vector of an expression node.  */
05607 
05608 void
05609 tree_operand_check_failed (int idx, enum tree_code code, const char *file,
05610          int line, const char *function)
05611 {
05612   internal_error
05613     ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d",
05614      idx + 1, tree_code_name[code], TREE_CODE_LENGTH (code),
05615      function, trim_filename (file), line);
05616 }
05617 #endif /* ENABLE_TREE_CHECKING */
05618 
05619 /* Create a new vector type node holding SUBPARTS units of type INNERTYPE,
05620    and mapped to the machine mode MODE.  Initialize its fields and build
05621    the information necessary for debugging output.  */
05622 
05623 static tree
05624 make_vector_type (tree innertype, int nunits, enum machine_mode mode)
05625 {
05626   tree t = make_node (VECTOR_TYPE);
05627 
05628   TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
05629   TYPE_VECTOR_SUBPARTS (t) = nunits;
05630   TYPE_MODE (t) = mode;
05631   TYPE_READONLY (t) = TYPE_READONLY (innertype);
05632   TYPE_VOLATILE (t) = TYPE_VOLATILE (innertype);
05633 
05634   layout_type (t);
05635 
05636   {
05637     tree index = build_int_cst (NULL_TREE, nunits - 1);
05638     tree array = build_array_type (innertype, build_index_type (index));
05639     tree rt = make_node (RECORD_TYPE);
05640 
05641     TYPE_FIELDS (rt) = build_decl (FIELD_DECL, get_identifier ("f"), array);
05642     DECL_CONTEXT (TYPE_FIELDS (rt)) = rt;
05643     layout_type (rt);
05644     TYPE_DEBUG_REPRESENTATION_TYPE (t) = rt;
05645     /* In dwarfout.c, type lookup uses TYPE_UID numbers.  We want to output
05646        the representation type, and we want to find that die when looking up
05647        the vector type.  This is most easily achieved by making the TYPE_UID
05648        numbers equal.  */
05649     TYPE_UID (rt) = TYPE_UID (t);
05650   }
05651 
05652   /* Build our main variant, based on the main variant of the inner type.  */
05653   if (TYPE_MAIN_VARIANT (innertype) != innertype)
05654     {
05655       tree innertype_main_variant = TYPE_MAIN_VARIANT (innertype);
05656       unsigned int hash = TYPE_HASH (innertype_main_variant);
05657       TYPE_MAIN_VARIANT (t)
05658         = type_hash_canon (hash, make_vector_type (innertype_main_variant,
05659                nunits, mode));
05660     }
05661 
05662   return t;
05663 }
05664 
05665 static tree
05666 make_or_reuse_type (unsigned size, int unsignedp)
05667 {
05668   if (size == INT_TYPE_SIZE)
05669     return unsignedp ? unsigned_type_node : integer_type_node;
05670   if (size == CHAR_TYPE_SIZE)
05671     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
05672   if (size == SHORT_TYPE_SIZE)
05673     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
05674   if (size == LONG_TYPE_SIZE)
05675     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
05676   if (size == LONG_LONG_TYPE_SIZE)
05677     return (unsignedp ? long_long_unsigned_type_node
05678             : long_long_integer_type_node);
05679 
05680   if (unsignedp)
05681     return make_unsigned_type (size);
05682   else
05683     return make_signed_type (size);
05684 }
05685 
05686 /* Create nodes for all integer types (and error_mark_node) using the sizes
05687    of C datatypes.  The caller should call set_sizetype soon after calling
05688    this function to select one of the types as sizetype.  */
05689 
05690 void
05691 build_common_tree_nodes (bool signed_char, bool signed_sizetype)
05692 {
05693   error_mark_node = make_node (ERROR_MARK);
05694   TREE_TYPE (error_mark_node) = error_mark_node;
05695 
05696   initialize_sizetypes (signed_sizetype);
05697 
05698   /* Define both `signed char' and `unsigned char'.  */
05699   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
05700   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
05701 
05702   /* Define `char', which is like either `signed char' or `unsigned char'
05703      but not the same as either.  */
05704   char_type_node
05705     = (signed_char
05706        ? make_signed_type (CHAR_TYPE_SIZE)
05707        : make_unsigned_type (CHAR_TYPE_SIZE));
05708 
05709   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
05710   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
05711   integer_type_node = make_signed_type (INT_TYPE_SIZE);
05712   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
05713   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
05714   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
05715   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
05716   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
05717 
05718   /* Define a boolean type.  This type only represents boolean values but
05719      may be larger than char depending on the value of BOOL_TYPE_SIZE.
05720      Front ends which want to override this size (i.e. Java) can redefine
05721      boolean_type_node before calling build_common_tree_nodes_2.  */
05722   boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
05723   TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
05724   TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1);
05725   TYPE_PRECISION (boolean_type_node) = 1;
05726 
05727   /* Fill in the rest of the sized types.  Reuse existing type nodes
05728      when possible.  */
05729   intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 0);
05730   intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 0);
05731   intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 0);
05732   intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 0);
05733   intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 0);
05734 
05735   unsigned_intQI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (QImode), 1);
05736   unsigned_intHI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (HImode), 1);
05737   unsigned_intSI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (SImode), 1);
05738   unsigned_intDI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (DImode), 1);
05739   unsigned_intTI_type_node = make_or_reuse_type (GET_MODE_BITSIZE (TImode), 1);
05740 
05741   access_public_node = get_identifier ("public");
05742   access_protected_node = get_identifier ("protected");
05743   access_private_node = get_identifier ("private");
05744 }
05745 
05746 /* Call this function after calling build_common_tree_nodes and set_sizetype.
05747    It will create several other common tree nodes.  */
05748 
05749 void
05750 build_common_tree_nodes_2 (int short_double)
05751 {
05752   /* Define these next since types below may used them.  */
05753   integer_zero_node = build_int_cst (NULL_TREE, 0);
05754   integer_one_node = build_int_cst (NULL_TREE, 1);
05755   integer_minus_one_node = build_int_cst (NULL_TREE, -1);
05756 
05757   size_zero_node = size_int (0);
05758   size_one_node = size_int (1);
05759   bitsize_zero_node = bitsize_int (0);
05760   bitsize_one_node = bitsize_int (1);
05761   bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
05762 
05763   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
05764   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
05765 
05766   void_type_node = make_node (VOID_TYPE);
05767   layout_type (void_type_node);
05768 
05769   /* We are not going to have real types in C with less than byte alignment,
05770      so we might as well not have any types that claim to have it.  */
05771   TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
05772   TYPE_USER_ALIGN (void_type_node) = 0;
05773 
05774   null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
05775   layout_type (TREE_TYPE (null_pointer_node));
05776 
05777   ptr_type_node = build_pointer_type (void_type_node);
05778   const_ptr_type_node
05779     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
05780   fileptr_type_node = ptr_type_node;
05781 
05782   float_type_node = make_node (REAL_TYPE);
05783   TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
05784   layout_type (float_type_node);
05785 
05786   double_type_node = make_node (REAL_TYPE);
05787   if (short_double)
05788     TYPE_PRECISION (double_type_node) = FLOAT_TYPE_SIZE;
05789   else
05790     TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
05791   layout_type (double_type_node);
05792 
05793   long_double_type_node = make_node (REAL_TYPE);
05794   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
05795   layout_type (long_double_type_node);
05796 
05797   float_ptr_type_node = build_pointer_type (float_type_node);
05798   double_ptr_type_node = build_pointer_type (double_type_node);
05799   long_double_ptr_type_node = build_pointer_type (long_double_type_node);
05800   integer_ptr_type_node = build_pointer_type (integer_type_node);
05801 
05802   complex_integer_type_node = make_node (COMPLEX_TYPE);
05803   TREE_TYPE (complex_integer_type_node) = integer_type_node;
05804   layout_type (complex_integer_type_node);
05805 
05806   complex_float_type_node = make_node (COMPLEX_TYPE);
05807   TREE_TYPE (complex_float_type_node) = float_type_node;
05808   layout_type (complex_float_type_node);
05809 
05810   complex_double_type_node = make_node (COMPLEX_TYPE);
05811   TREE_TYPE (complex_double_type_node) = double_type_node;
05812   layout_type (complex_double_type_node);
05813 
05814   complex_long_double_type_node = make_node (COMPLEX_TYPE);
05815   TREE_TYPE (complex_long_double_type_node) = long_double_type_node;
05816   layout_type (complex_long_double_type_node);
05817 
05818   {
05819     tree t = targetm.build_builtin_va_list ();
05820 
05821     /* Many back-ends define record types without setting TYPE_NAME.
05822        If we copied the record type here, we'd keep the original
05823        record type without a name.  This breaks name mangling.  So,
05824        don't copy record types and let c_common_nodes_and_builtins()
05825        declare the type to be __builtin_va_list.  */
05826     if (TREE_CODE (t) != RECORD_TYPE)
05827       t = build_variant_type_copy (t);
05828 
05829     va_list_type_node = t;
05830   }
05831 }
05832 
05833 /* A subroutine of build_common_builtin_nodes.  Define a builtin function.  */
05834 
05835 static void
05836 local_define_builtin (const char *name, tree type, enum built_in_function code,
05837                       const char *library_name, int ecf_flags)
05838 {
05839   tree decl;
05840 
05841   decl = lang_hooks.builtin_function (name, type, code, BUILT_IN_NORMAL,
05842               library_name, NULL_TREE);
05843   if (ecf_flags & ECF_CONST)
05844     TREE_READONLY (decl) = 1;
05845   if (ecf_flags & ECF_PURE)
05846     DECL_IS_PURE (decl) = 1;
05847   if (ecf_flags & ECF_NORETURN)
05848     TREE_THIS_VOLATILE (decl) = 1;
05849   if (ecf_flags & ECF_NOTHROW)
05850     TREE_NOTHROW (decl) = 1;
05851   if (ecf_flags & ECF_MALLOC)
05852     DECL_IS_MALLOC (decl) = 1;
05853 
05854   built_in_decls[code] = decl;
05855   implicit_built_in_decls[code] = decl;
05856 }
05857 
05858 /* Call this function after instantiating all builtins that the language
05859    front end cares about.  This will build the rest of the builtins that
05860    are relied upon by the tree optimizers and the middle-end.  */
05861 
05862 void
05863 build_common_builtin_nodes (void)
05864 {
05865   tree tmp, ftype;
05866 
05867   if (built_in_decls[BUILT_IN_MEMCPY] == NULL
05868       || built_in_decls[BUILT_IN_MEMMOVE] == NULL)
05869     {
05870       tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
05871       tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
05872       tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
05873       ftype = build_function_type (ptr_type_node, tmp);
05874 
05875       if (built_in_decls[BUILT_IN_MEMCPY] == NULL)
05876   local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
05877             "memcpy", ECF_NOTHROW);
05878       if (built_in_decls[BUILT_IN_MEMMOVE] == NULL)
05879   local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
05880             "memmove", ECF_NOTHROW);
05881     }
05882 
05883   if (built_in_decls[BUILT_IN_MEMCMP] == NULL)
05884     {
05885       tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
05886       tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
05887       tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
05888       ftype = build_function_type (integer_type_node, tmp);
05889       local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
05890           "memcmp", ECF_PURE | ECF_NOTHROW);
05891     }
05892 
05893   if (built_in_decls[BUILT_IN_MEMSET] == NULL)
05894     {
05895       tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
05896       tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
05897       tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
05898       ftype = build_function_type (ptr_type_node, tmp);
05899       local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
05900           "memset", ECF_NOTHROW);
05901     }
05902 
05903   if (built_in_decls[BUILT_IN_ALLOCA] == NULL)
05904     {
05905       tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
05906       ftype = build_function_type (ptr_type_node, tmp);
05907       local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
05908           "alloca", ECF_NOTHROW | ECF_MALLOC);
05909     }
05910 
05911   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
05912   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
05913   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
05914   ftype = build_function_type (void_type_node, tmp);
05915   local_define_builtin ("__builtin_init_trampoline", ftype,
05916       BUILT_IN_INIT_TRAMPOLINE,
05917       "__builtin_init_trampoline", ECF_NOTHROW);
05918 
05919   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
05920   ftype = build_function_type (ptr_type_node, tmp);
05921   local_define_builtin ("__builtin_adjust_trampoline", ftype,
05922       BUILT_IN_ADJUST_TRAMPOLINE,
05923       "__builtin_adjust_trampoline",
05924       ECF_CONST | ECF_NOTHROW);
05925 
05926   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
05927   tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
05928   ftype = build_function_type (void_type_node, tmp);
05929   local_define_builtin ("__builtin_nonlocal_goto", ftype,
05930       BUILT_IN_NONLOCAL_GOTO,
05931       "__builtin_nonlocal_goto",
05932       ECF_NORETURN | ECF_NOTHROW);
05933 
05934   ftype = build_function_type (ptr_type_node, void_list_node);
05935   local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
05936       "__builtin_stack_save", ECF_NOTHROW);
05937 
05938   tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
05939   ftype = build_function_type (void_type_node, tmp);
05940   local_define_builtin ("__builtin_stack_restore", ftype,
05941       BUILT_IN_STACK_RESTORE,
05942       "__builtin_stack_restore", ECF_NOTHROW);
05943 
05944   ftype = build_function_type (void_type_node, void_list_node);
05945   local_define_builtin ("__builtin_profile_func_enter", ftype,
05946       BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0);
05947   local_define_builtin ("__builtin_profile_func_exit", ftype,
05948       BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
05949 
05950   /* Complex multiplication and division.  These are handled as builtins
05951      rather than optabs because emit_library_call_value doesn't support
05952      complex.  Further, we can do slightly better with folding these 
05953      beasties if the real and complex parts of the arguments are separate.  */
05954   {
05955     enum machine_mode mode;
05956 
05957     for (mode = MIN_MODE_COMPLEX_FLOAT; mode <= MAX_MODE_COMPLEX_FLOAT; ++mode)
05958       {
05959   char mode_name_buf[4], *q;
05960   const char *p;
05961   enum built_in_function mcode, dcode;
05962   tree type, inner_type;
05963 
05964   type = lang_hooks.types.type_for_mode (mode, 0);
05965   if (type == NULL)
05966     continue;
05967   inner_type = TREE_TYPE (type);
05968 
05969   tmp = tree_cons (NULL_TREE, inner_type, void_list_node);
05970   tmp = tree_cons (NULL_TREE, inner_type, tmp);
05971   tmp = tree_cons (NULL_TREE, inner_type, tmp);
05972   tmp = tree_cons (NULL_TREE, inner_type, tmp);
05973   ftype = build_function_type (type, tmp);
05974 
05975         mcode = BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
05976         dcode = BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT;
05977 
05978         for (p = GET_MODE_NAME (mode), q = mode_name_buf; *p; p++, q++)
05979     *q = TOLOWER (*p);
05980   *q = '\0';
05981 
05982   built_in_names[mcode] = concat ("__mul", mode_name_buf, "3", NULL);
05983         local_define_builtin (built_in_names[mcode], ftype, mcode,
05984             built_in_names[mcode], ECF_CONST | ECF_NOTHROW);
05985 
05986   built_in_names[dcode] = concat ("__div", mode_name_buf, "3", NULL);
05987         local_define_builtin (built_in_names[dcode], ftype, dcode,
05988             built_in_names[dcode], ECF_CONST | ECF_NOTHROW);
05989       }
05990   }
05991 }
05992 
05993 /* HACK.  GROSS.  This is absolutely disgusting.  I wish there was a
05994    better way.
05995 
05996    If we requested a pointer to a vector, build up the pointers that
05997    we stripped off while looking for the inner type.  Similarly for
05998    return values from functions.
05999 
06000    The argument TYPE is the top of the chain, and BOTTOM is the
06001    new type which we will point to.  */
06002 
06003 tree
06004 reconstruct_complex_type (tree type, tree bottom)
06005 {
06006   tree inner, outer;
06007 
06008   if (POINTER_TYPE_P (type))
06009     {
06010       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
06011       outer = build_pointer_type (inner);
06012     }
06013   else if (TREE_CODE (type) == ARRAY_TYPE)
06014     {
06015       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
06016       outer = build_array_type (inner, TYPE_DOMAIN (type));
06017     }
06018   else if (TREE_CODE (type) == FUNCTION_TYPE)
06019     {
06020       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
06021       outer = build_function_type (inner, TYPE_ARG_TYPES (type));
06022     }
06023   else if (TREE_CODE (type) == METHOD_TYPE)
06024     {
06025       tree argtypes;
06026       inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
06027       /* The build_method_type_directly() routine prepends 'this' to argument list,
06028          so we must compensate by getting rid of it.  */
06029       argtypes = TYPE_ARG_TYPES (type);
06030       outer = build_method_type_directly (TYPE_METHOD_BASETYPE (type),
06031             inner,
06032             TYPE_ARG_TYPES (type));
06033       TYPE_ARG_TYPES (outer) = argtypes;
06034     }
06035   else
06036     return bottom;
06037 
06038   TYPE_READONLY (outer) = TYPE_READONLY (type);
06039   TYPE_VOLATILE (outer) = TYPE_VOLATILE (type);
06040 
06041   return outer;
06042 }
06043 
06044 /* Returns a vector tree node given a mode (integer, vector, or BLKmode) and
06045    the inner type.  */
06046 tree
06047 build_vector_type_for_mode (tree innertype, enum machine_mode mode)
06048 {
06049   int nunits;
06050 
06051   switch (GET_MODE_CLASS (mode))
06052     {
06053     case MODE_VECTOR_INT:
06054     case MODE_VECTOR_FLOAT:
06055       nunits = GET_MODE_NUNITS (mode);
06056       break;
06057 
06058     case MODE_INT:
06059       /* Check that there are no leftover bits.  */
06060       gcc_assert (GET_MODE_BITSIZE (mode)
06061       % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0);
06062 
06063       nunits = GET_MODE_BITSIZE (mode)
06064          / TREE_INT_CST_LOW (TYPE_SIZE (innertype));
06065       break;
06066 
06067     default:
06068       gcc_unreachable ();
06069     }
06070 
06071   return make_vector_type (innertype, nunits, mode);
06072 }
06073 
06074 /* Similarly, but takes the inner type and number of units, which must be
06075    a power of two.  */
06076 
06077 tree
06078 build_vector_type (tree innertype, int nunits)
06079 {
06080   return make_vector_type (innertype, nunits, VOIDmode);
06081 }
06082 
06083 /* Given an initializer INIT, return TRUE if INIT is zero or some
06084    aggregate of zeros.  Otherwise return FALSE.  */
06085 bool
06086 initializer_zerop (tree init)
06087 {
06088   tree elt;
06089 
06090   STRIP_NOPS (init);
06091 
06092   switch (TREE_CODE (init))
06093     {
06094     case INTEGER_CST:
06095       return integer_zerop (init);
06096 
06097     case REAL_CST:
06098       /* ??? Note that this is not correct for C4X float formats.  There,
06099    a bit pattern of all zeros is 1.0; 0.0 is encoded with the most
06100    negative exponent.  */
06101       return real_zerop (init)
06102   && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init));
06103 
06104     case COMPLEX_CST:
06105       return integer_zerop (init)
06106   || (real_zerop (init)
06107       && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
06108       && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init))));
06109 
06110     case VECTOR_CST:
06111       for (elt = TREE_VECTOR_CST_ELTS (init); elt; elt = TREE_CHAIN (elt))
06112   if (!initializer_zerop (TREE_VALUE (elt)))
06113     return false;
06114       return true;
06115 
06116     case CONSTRUCTOR:
06117       elt = CONSTRUCTOR_ELTS (init);
06118       if (elt == NULL_TREE)
06119   return true;
06120 
06121       for (; elt ; elt = TREE_CHAIN (elt))
06122   if (! initializer_zerop (TREE_VALUE (elt)))
06123     return false;
06124       return true;
06125 
06126     default:
06127       return false;
06128     }
06129 }
06130 
06131 void
06132 add_var_to_bind_expr (tree bind_expr, tree var)
06133 {
06134   BIND_EXPR_VARS (bind_expr)
06135     = chainon (BIND_EXPR_VARS (bind_expr), var);
06136   if (BIND_EXPR_BLOCK (bind_expr))
06137     BLOCK_VARS (BIND_EXPR_BLOCK (bind_expr))
06138       = BIND_EXPR_VARS (bind_expr);
06139 }
06140 
06141 /* Build an empty statement.  */
06142 
06143 tree
06144 build_empty_stmt (void)
06145 {
06146   return build1 (NOP_EXPR, void_type_node, size_zero_node);
06147 }
06148 
06149 
06150 /* Returns true if it is possible to prove that the index of
06151    an array access REF (an ARRAY_REF expression) falls into the
06152    array bounds.  */
06153 
06154 bool
06155 in_array_bounds_p (tree ref)
06156 {
06157   tree idx = TREE_OPERAND (ref, 1);
06158   tree min, max;
06159 
06160   if (TREE_CODE (idx) != INTEGER_CST)
06161     return false;
06162 
06163   min = array_ref_low_bound (ref);
06164   max = array_ref_up_bound (ref);
06165   if (!min
06166       || !max
06167       || TREE_CODE (min) != INTEGER_CST
06168       || TREE_CODE (max) != INTEGER_CST)
06169     return false;
06170 
06171   if (tree_int_cst_lt (idx, min)
06172       || tree_int_cst_lt (max, idx))
06173     return false;
06174 
06175   return true;
06176 }
06177 
06178 /* Return true if T (assumed to be a DECL) is a global variable.  */
06179 
06180 bool
06181 is_global_var (tree t)
06182 {
06183   return (TREE_STATIC (t) || DECL_EXTERNAL (t));
06184 }
06185 
06186 /* Return true if T (assumed to be a DECL) must be assigned a memory
06187    location.  */
06188 
06189 bool
06190 needs_to_live_in_memory (tree t)
06191 {
06192   return (TREE_ADDRESSABLE (t)
06193     || is_global_var (t)
06194     || (TREE_CODE (t) == RESULT_DECL
06195         && aggregate_value_p (t, current_function_decl)));
06196 }
06197 
06198 /* There are situations in which a language considers record types
06199    compatible which have different field lists.  Decide if two fields
06200    are compatible.  It is assumed that the parent records are compatible.  */
06201 
06202 bool
06203 fields_compatible_p (tree f1, tree f2)
06204 {
06205   if (!operand_equal_p (DECL_FIELD_BIT_OFFSET (f1),
06206       DECL_FIELD_BIT_OFFSET (f2), OEP_ONLY_CONST))
06207     return false;
06208 
06209   if (!operand_equal_p (DECL_FIELD_OFFSET (f1),
06210                         DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
06211     return false;
06212 
06213   if (!lang_hooks.types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
06214     return false;
06215 
06216   return true;
06217 }
06218 
06219 /* Locate within RECORD a field that is compatible with ORIG_FIELD.  */
06220 
06221 tree
06222 find_compatible_field (tree record, tree orig_field)
06223 {
06224   tree f;
06225 
06226   for (f = TYPE_FIELDS (record); f ; f = TREE_CHAIN (f))
06227     if (TREE_CODE (f) == FIELD_DECL
06228   && fields_compatible_p (f, orig_field))
06229       return f;
06230 
06231   /* ??? Why isn't this on the main fields list?  */
06232   f = TYPE_VFIELD (record);
06233   if (f && TREE_CODE (f) == FIELD_DECL
06234       && fields_compatible_p (f, orig_field))
06235     return f;
06236 
06237   /* ??? We should abort here, but Java appears to do Bad Things
06238      with inherited fields.  */
06239   return orig_field;
06240 }
06241 
06242 /* Return value of a constant X.  */
06243 
06244 HOST_WIDE_INT
06245 int_cst_value (tree x)
06246 {
06247   unsigned bits = TYPE_PRECISION (TREE_TYPE (x));
06248   unsigned HOST_WIDE_INT val = TREE_INT_CST_LOW (x);
06249   bool negative = ((val >> (bits - 1)) & 1) != 0;
06250 
06251   gcc_assert (bits <= HOST_BITS_PER_WIDE_INT);
06252 
06253   if (negative)
06254     val |= (~(unsigned HOST_WIDE_INT) 0) << (bits - 1) << 1;
06255   else
06256     val &= ~((~(unsigned HOST_WIDE_INT) 0) << (bits - 1) << 1);
06257 
06258   return val;
06259 }
06260 
06261 /* Returns the greatest common divisor of A and B, which must be
06262    INTEGER_CSTs.  */
06263 
06264 tree
06265 tree_fold_gcd (tree a, tree b)
06266 {
06267   tree a_mod_b;
06268   tree type = TREE_TYPE (a);
06269 
06270   gcc_assert (TREE_CODE (a) == INTEGER_CST);
06271   gcc_assert (TREE_CODE (b) == INTEGER_CST);
06272 
06273   if (integer_zerop (a))
06274     return b;
06275 
06276   if (integer_zerop (b))
06277     return a;
06278 
06279   if (tree_int_cst_sgn (a) == -1)
06280     a = fold (build2 (MULT_EXPR, type, a,
06281           convert (type, integer_minus_one_node)));
06282 
06283   if (tree_int_cst_sgn (b) == -1)
06284     b = fold (build2 (MULT_EXPR, type, b,
06285           convert (type, integer_minus_one_node)));
06286 
06287   while (1)
06288     {
06289       a_mod_b = fold (build2 (FLOOR_MOD_EXPR, type, a, b));
06290 
06291       if (!TREE_INT_CST_LOW (a_mod_b)
06292     && !TREE_INT_CST_HIGH (a_mod_b))
06293   return b;
06294 
06295       a = b;
06296       b = a_mod_b;
06297     }
06298 }
06299 
06300 /* Returns unsigned variant of TYPE.  */
06301 
06302 tree
06303 unsigned_type_for (tree type)
06304 {
06305   return lang_hooks.types.unsigned_type (type);
06306 }
06307 
06308 /* Returns signed variant of TYPE.  */
06309 
06310 tree
06311 signed_type_for (tree type)
06312 {
06313   return lang_hooks.types.signed_type (type);
06314 }
06315 
06316 /* Returns the largest value obtainable by casting something in INNER type to
06317    OUTER type.  */
06318 
06319 tree
06320 upper_bound_in_type (tree outer, tree inner)
06321 {
06322   unsigned HOST_WIDE_INT lo, hi;
06323   unsigned bits = TYPE_PRECISION (inner);
06324 
06325   if (TYPE_UNSIGNED (outer) || TYPE_UNSIGNED (inner))
06326     {
06327       /* Zero extending in these cases.  */
06328       if (bits <= HOST_BITS_PER_WIDE_INT)
06329   {
06330     hi = 0;
06331     lo = (~(unsigned HOST_WIDE_INT) 0)
06332       >> (HOST_BITS_PER_WIDE_INT - bits);
06333   }
06334       else
06335   {
06336     hi = (~(unsigned HOST_WIDE_INT) 0)
06337       >> (2 * HOST_BITS_PER_WIDE_INT - bits);
06338     lo = ~(unsigned HOST_WIDE_INT) 0;
06339   }
06340     }
06341   else
06342     {
06343       /* Sign extending in these cases.  */
06344       if (bits <= HOST_BITS_PER_WIDE_INT)
06345   {
06346     hi = 0;
06347     lo = (~(unsigned HOST_WIDE_INT) 0)
06348       >> (HOST_BITS_PER_WIDE_INT - bits) >> 1;
06349   }
06350       else
06351   {
06352     hi = (~(unsigned HOST_WIDE_INT) 0)
06353       >> (2 * HOST_BITS_PER_WIDE_INT - bits) >> 1;
06354     lo = ~(unsigned HOST_WIDE_INT) 0;
06355   }
06356     }
06357 
06358   return fold_convert (outer,
06359            build_int_cst_wide (inner, lo, hi));
06360 }
06361 
06362 /* Returns the smallest value obtainable by casting something in INNER type to
06363    OUTER type.  */
06364 
06365 tree
06366 lower_bound_in_type (tree outer, tree inner)
06367 {
06368   unsigned HOST_WIDE_INT lo, hi;
06369   unsigned bits = TYPE_PRECISION (inner);
06370 
06371   if (TYPE_UNSIGNED (outer) || TYPE_UNSIGNED (inner))
06372     lo = hi = 0;
06373   else if (bits <= HOST_BITS_PER_WIDE_INT)
06374     {
06375       hi = ~(unsigned HOST_WIDE_INT) 0;
06376       lo = (~(unsigned HOST_WIDE_INT) 0) << (bits - 1);
06377     }
06378   else
06379     {
06380       hi = (~(unsigned HOST_WIDE_INT) 0) << (bits - HOST_BITS_PER_WIDE_INT - 1);
06381       lo = 0;
06382     }
06383 
06384   return fold_convert (outer,
06385            build_int_cst_wide (inner, lo, hi));
06386 }
06387 
06388 /* Return nonzero if two operands that are suitable for PHI nodes are
06389    necessarily equal.  Specifically, both ARG0 and ARG1 must be either
06390    SSA_NAME or invariant.  Note that this is strictly an optimization.
06391    That is, callers of this function can directly call operand_equal_p
06392    and get the same result, only slower.  */
06393 
06394 int
06395 operand_equal_for_phi_arg_p (tree arg0, tree arg1)
06396 {
06397   if (arg0 == arg1)
06398     return 1;
06399   if (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME)
06400     return 0;
06401   return operand_equal_p (arg0, arg1, 0);
06402 }
06403 
06404 /* Returns number of zeros at the end of binary representation of X.
06405    
06406    ??? Use ffs if available?  */
06407 
06408 tree
06409 num_ending_zeros (tree x)
06410 {
06411   unsigned HOST_WIDE_INT fr, nfr;
06412   unsigned num, abits;
06413   tree type = TREE_TYPE (x);
06414 
06415   if (TREE_INT_CST_LOW (x) == 0)
06416     {
06417       num = HOST_BITS_PER_WIDE_INT;
06418       fr = TREE_INT_CST_HIGH (x);
06419     }
06420   else
06421     {
06422       num = 0;
06423       fr = TREE_INT_CST_LOW (x);
06424     }
06425 
06426   for (abits = HOST_BITS_PER_WIDE_INT / 2; abits; abits /= 2)
06427     {
06428       nfr = fr >> abits;
06429       if (nfr << abits == fr)
06430   {
06431     num += abits;
06432     fr = nfr;
06433   }
06434     }
06435 
06436   if (num > TYPE_PRECISION (type))
06437     num = TYPE_PRECISION (type);
06438 
06439   return build_int_cst_type (type, num);
06440 }
06441 
06442 #include "gt-tree.h"
06443 #include "cp/cp-tree.h"
06444 
06445 extern void lang_check_failed (const char* file, int line, const char* function);
06446 
06447 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
06448 /* Complain that some language-specific thing hanging off a tree
06449    node has been accessed improperly.  */
06450                                                                                                                                                     
06451 static void
06452 lang_check_failed (const char* file, int line, const char* function)
06453 {
06454   internal_error ("lang_* check: failed in %s, at %s:%d",
06455                   function, trim_filename (file), line);
06456 }
06457 #endif /* ENABLE_TREE_CHECKING */
06458 
06459 #include "gspin-gcc-interface.h"
06460 
06461 /* Bug 1392 */
06462 #include <stdlib.h>
06463 #include <ctype.h>
06464 #include "c-common.h" 
06465 
06466 enum language { C, CPP };
06467 enum language language = C;
06468 #define CPR() (language == CPP)
06469 #define CR()  (language == C)
06470 
06471 // C++ Dummy Variables Section Begins.
06472 tree global_namespace; // CP_DECL_CONTEXT () references this variable in cp/name-lookup.c
06473 int (*p_uses_template_parms) (tree);
06474 tree (*p_most_general_template) (tree);
06475 int (*p_copy_fn_p) (tree);
06476 int (*p_is_empty_class) (tree);
06477 tree (*p_namespace_binding) (tree, tree);
06478 // tree p_complete_ctor_identifier;
06479 tree cp_global_trees[CPTI_MAX];
06480 tree (*p_get_tinfo_decl) (tree);
06481 // C++ Dummy Variables Section Ends.
06482 
06483 // GSPIN stuff follows:
06484 
06485 static inline gs_code_t
06486 gcc2gs (int code)
06487 {
06488  switch (code) {
06489  
06490  // GCC Specific tree codes: return ;
06491 
06492    case ABS_EXPR: return GS_ABS_EXPR;
06493    case ADDR_EXPR: return GS_ADDR_EXPR;
06494    case AGGR_INIT_EXPR: return GS_AGGR_INIT_EXPR;
06495    case ALIGNOF_EXPR: return GS_ALIGNOF_EXPR;
06496    case ALIGN_INDIRECT_REF: return GS_ALIGN_INDIRECT_REF;
06497    case ARRAY_RANGE_REF: return GS_ARRAY_RANGE_REF;
06498    case ARRAY_REF: return GS_ARRAY_REF;
06499    case ARRAY_TYPE: return GS_ARRAY_TYPE;
06500    case ARROW_EXPR: return GS_ARROW_EXPR;
06501    case ASM_EXPR: return GS_ASM_EXPR;
06502    case BASELINK: return GS_BASELINK;
06503    case BIND_EXPR: return GS_BIND_EXPR;
06504    case BIT_AND_EXPR: return GS_BIT_AND_EXPR;
06505    case BIT_FIELD_REF: return GS_BIT_FIELD_REF;
06506    case BIT_IOR_EXPR: return GS_BIT_IOR_EXPR;
06507    case BIT_NOT_EXPR: return GS_BIT_NOT_EXPR;
06508    case BIT_XOR_EXPR: return GS_BIT_XOR_EXPR;
06509    case BLOCK: return GS_BLOCK;
06510    case BOOLEAN_TYPE: return GS_BOOLEAN_TYPE;
06511    case BOUND_TEMPLATE_TEMPLATE_PARM: 
06512      return GS_BOUND_TEMPLATE_TEMPLATE_PARM;
06513    case BREAK_STMT: return GS_BREAK_STMT;
06514    case CALL_EXPR: return GS_CALL_EXPR;
06515    case CAST_EXPR: return GS_CAST_EXPR;
06516    case CONST_CAST_EXPR: return GS_CONST_CAST_EXPR;
06517    case CASE_LABEL_EXPR: return GS_CASE_LABEL_EXPR;
06518    case CATCH_EXPR: return GS_CATCH_EXPR;
06519    case CEIL_DIV_EXPR: return GS_CEIL_DIV_EXPR;
06520    case CEIL_MOD_EXPR: return GS_CEIL_MOD_EXPR;
06521    case CHAR_TYPE: return GS_CHAR_TYPE;
06522    case CLEANUP_STMT: return GS_CLEANUP_STMT;
06523    case CLEANUP_POINT_EXPR: return GS_CLEANUP_POINT_EXPR;
06524    case COMPLEX_CST: return GS_COMPLEX_CST;
06525    case COMPLEX_EXPR: return GS_COMPLEX_EXPR;
06526    case COMPLEX_TYPE: return GS_COMPLEX_TYPE;
06527    case COMPONENT_REF: return GS_COMPONENT_REF;
06528    case COMPOUND_EXPR: return GS_COMPOUND_EXPR;
06529    case COMPOUND_LITERAL_EXPR: return GS_COMPOUND_LITERAL_EXPR;
06530    case COND_EXPR: return GS_COND_EXPR;
06531    case CONJ_EXPR: return GS_CONJ_EXPR;
06532    case CONSTRUCTOR: return GS_CONSTRUCTOR;
06533    case CONST_DECL: return GS_CONST_DECL;
06534    case CONTINUE_STMT: return GS_CONTINUE_STMT;
06535    case CONVERT_EXPR: return GS_CONVERT_EXPR;
06536    case CTOR_INITIALIZER: return GS_CTOR_INITIALIZER;
06537    case DECL_EXPR: return GS_DECL_EXPR;
06538    case DELETE_EXPR: return GS_DELETE_EXPR;
06539    case DEFAULT_ARG: return GS_DEFAULT_ARG;
06540    case DYNAMIC_CAST_EXPR: return GS_DYNAMIC_CAST_EXPR;
06541    case DO_STMT: return GS_DO_STMT;
06542    case DOTSTAR_EXPR: return GS_DOTSTAR_EXPR;
06543    case EH_FILTER_EXPR: return GS_EH_FILTER_EXPR;
06544    case EMPTY_CLASS_EXPR: return GS_EMPTY_CLASS_EXPR;
06545    case ENUMERAL_TYPE: return GS_ENUMERAL_TYPE;
06546    case EQ_EXPR: return GS_EQ_EXPR;
06547    case ERROR_MARK: return GS_ERROR_MARK;
06548    case EXACT_DIV_EXPR: return GS_EXACT_DIV_EXPR;
06549    case EXC_PTR_EXPR: return GS_EXC_PTR_EXPR;
06550    case EXIT_EXPR: return GS_EXIT_EXPR;
06551    case EXPR_STMT: return GS_EXPR_STMT;
06552    case EH_SPEC_BLOCK: return GS_EH_SPEC_BLOCK;
06553    case FDESC_EXPR: return GS_FDESC_EXPR;
06554    case FIELD_DECL: return GS_FIELD_DECL;
06555    case FILE_TYPE: return GS_FILE_TYPE;
06556    case FILTER_EXPR: return GS_FILTER_EXPR;
06557    case FIX_CEIL_EXPR: return GS_FIX_CEIL_EXPR;
06558    case FIX_FLOOR_EXPR: return GS_FIX_FLOOR_EXPR;
06559    case FIX_ROUND_EXPR: return GS_FIX_ROUND_EXPR;
06560    case FIX_TRUNC_EXPR: return GS_FIX_TRUNC_EXPR;
06561    case FLOAT_EXPR: return GS_FLOAT_EXPR;
06562    case FLOOR_DIV_EXPR: return GS_FLOOR_DIV_EXPR;
06563    case FLOOR_MOD_EXPR: return GS_FLOOR_MOD_EXPR;
06564    case FOR_STMT: return GS_FOR_STMT;
06565    case FUNCTION_DECL: return GS_FUNCTION_DECL;
06566    case FUNCTION_TYPE: return GS_FUNCTION_TYPE;
06567    case GE_EXPR: return GS_GE_EXPR;
06568    case GOTO_EXPR: return GS_GOTO_EXPR;
06569    case GT_EXPR: return GS_GT_EXPR;
06570    case HANDLER: return GS_HANDLER;
06571    case IDENTIFIER_NODE: return GS_IDENTIFIER_NODE;
06572    case IF_STMT: return GS_IF_STMT;
06573    case IMAGPART_EXPR: return GS_IMAGPART_EXPR;
06574    case INDIRECT_REF: return GS_INDIRECT_REF;
06575    case INIT_EXPR: return GS_INIT_EXPR;
06576    case INTEGER_CST: return GS_INTEGER_CST;
06577    case INTEGER_TYPE: return GS_INTEGER_TYPE;
06578    case LABEL_DECL: return GS_LABEL_DECL;
06579    case LABEL_EXPR: return GS_LABEL_EXPR;
06580    case LANG_TYPE: return GS_LANG_TYPE;
06581    case LE_EXPR: return GS_LE_EXPR;
06582    case LOOP_EXPR: return GS_LOOP_EXPR;
06583    case LROTATE_EXPR: return GS_LROTATE_EXPR;
06584    case LSHIFT_EXPR: return GS_LSHIFT_EXPR;
06585    case LTGT_EXPR: return GS_LTGT_EXPR;
06586    case LT_EXPR: return GS_LT_EXPR;
06587    case MAX_EXPR: return GS_MAX_EXPR;
06588    case MEMBER_REF: return GS_MEMBER_REF;
06589    case METHOD_TYPE: return GS_METHOD_TYPE;
06590    case MINUS_EXPR: return GS_MINUS_EXPR;
06591    case MIN_EXPR: return GS_MIN_EXPR;
06592    case MISALIGNED_INDIRECT_REF: return GS_MISALIGNED_INDIRECT_REF;
06593    case MODOP_EXPR: return GS_MODOP_EXPR;
06594    case MODIFY_EXPR: return GS_MODIFY_EXPR;
06595    case MULT_EXPR: return GS_MULT_EXPR;
06596    case MUST_NOT_THROW_EXPR: return GS_MUST_NOT_THROW_EXPR;
06597    case NAMESPACE_DECL: return GS_NAMESPACE_DECL;
06598    case NE_EXPR: return GS_NE_EXPR;
06599    case NEGATE_EXPR: return GS_NEGATE_EXPR;
06600    case NEW_EXPR: return GS_NEW_EXPR;
06601    case NON_LVALUE_EXPR: return GS_NON_LVALUE_EXPR;
06602    case NOP_EXPR: return GS_NOP_EXPR;
06603    case NON_DEPENDENT_EXPR: return GS_NON_DEPENDENT_EXPR;
06604    case OBJ_TYPE_REF: return GS_OBJ_TYPE_REF;
06605    case OFFSET_REF: return GS_OFFSET_REF;
06606    case OFFSET_TYPE: return GS_OFFSET_TYPE;
06607    case OFFSETOF_EXPR: return GS_OFFSETOF_EXPR;
06608    case ORDERED_EXPR: return GS_ORDERED_EXPR;
06609    case OVERLOAD: return GS_OVERLOAD;
06610    case PARM_DECL: return GS_PARM_DECL;
06611    case PHI_NODE: return GS_PHI_NODE;
06612    case PLACEHOLDER_EXPR: return GS_PLACEHOLDER_EXPR;
06613    case PLUS_EXPR: return GS_PLUS_EXPR;
06614    case POINTER_TYPE: return GS_POINTER_TYPE;
06615    case POLYNOMIAL_CHREC: return GS_POLYNOMIAL_CHREC;
06616    case POSTDECREMENT_EXPR: return GS_POSTDECREMENT_EXPR;
06617    case POSTINCREMENT_EXPR: return GS_POSTINCREMENT_EXPR;
06618    case PREDECREMENT_EXPR: return GS_PREDECREMENT_EXPR;
06619    case PREINCREMENT_EXPR: return GS_PREINCREMENT_EXPR;
06620    case PTRMEM_CST: return GS_PTRMEM_CST;
06621    case PSEUDO_DTOR_EXPR: return GS_PSEUDO_DTOR_EXPR;
06622    case QUAL_UNION_TYPE: return GS_QUAL_UNION_TYPE;
06623    case RANGE_EXPR: return GS_RANGE_EXPR;
06624    case RDIV_EXPR: return GS_RDIV_EXPR;
06625    case REALIGN_LOAD_EXPR: return GS_REALIGN_LOAD_EXPR;
06626    case REALPART_EXPR: return GS_REALPART_EXPR;
06627    case REAL_CST: return GS_REAL_CST;
06628    case REAL_TYPE: return GS_REAL_TYPE;
06629    case RECORD_TYPE: return GS_RECORD_TYPE;
06630    case REINTERPRET_CAST_EXPR: return GS_REINTERPRET_CAST_EXPR;
06631    case REFERENCE_TYPE: return GS_REFERENCE_TYPE;
06632    case RESULT_DECL: return GS_RESULT_DECL;
06633    case RESX_EXPR: return GS_RESX_EXPR;
06634    case RETURN_EXPR: return GS_RETURN_EXPR;
06635    case ROUND_DIV_EXPR: return GS_ROUND_DIV_EXPR;
06636    case ROUND_MOD_EXPR: return GS_ROUND_MOD_EXPR;
06637    case RROTATE_EXPR: return GS_RROTATE_EXPR;
06638    case RSHIFT_EXPR: return GS_RSHIFT_EXPR;
06639    case SAVE_EXPR: return GS_SAVE_EXPR;
06640    case SCEV_KNOWN: return GS_SCEV_KNOWN;
06641    case SCEV_NOT_KNOWN: return GS_SCEV_NOT_KNOWN;
06642    case SCOPE_REF: return GS_SCOPE_REF;
06643    case SIZEOF_EXPR: return GS_SIZEOF_EXPR;
06644    case SSA_NAME: return GS_SSA_NAME;
06645    case STATEMENT_LIST: return GS_STATEMENT_LIST;
06646    case STATIC_CAST_EXPR: return GS_STATIC_CAST_EXPR;
06647    case STMT_EXPR: return GS_STMT_EXPR;
06648    case STRING_CST: return GS_STRING_CST;
06649    case SWITCH_EXPR: return GS_SWITCH_EXPR;
06650    case SWITCH_STMT: return GS_SWITCH_STMT;
06651    case TARGET_EXPR: return GS_TARGET_EXPR;
06652    case TAG_DEFN: return GS_TAG_DEFN;
06653    case TEMPLATE_DECL:  return GS_TEMPLATE_DECL;
06654    case TEMPLATE_ID_EXPR:  return GS_TEMPLATE_ID_EXPR;
06655    case TEMPLATE_PARM_INDEX:  return GS_TEMPLATE_PARM_INDEX;
06656    case TEMPLATE_TYPE_PARM:  return GS_TEMPLATE_TYPE_PARM;
06657    case THROW_EXPR: return GS_THROW_EXPR;
06658    case TINST_LEVEL: return GS_TINST_LEVEL;
06659    case TRANSLATION_UNIT_DECL: return GS_TRANSLATION_UNIT_DECL;
06660    case TREE_BINFO: return GS_TREE_BINFO;
06661    case TREE_LIST: return GS_TREE_LIST;
06662    case TREE_VEC: return GS_TREE_VEC;
06663    case TRUNC_DIV_EXPR: return GS_TRUNC_DIV_EXPR;
06664    case TRUNC_MOD_EXPR: return GS_TRUNC_MOD_EXPR;
06665    case TRUTH_ANDIF_EXPR: return GS_TRUTH_ANDIF_EXPR;
06666    case TRUTH_AND_EXPR: return GS_TRUTH_AND_EXPR;
06667    case TRUTH_NOT_EXPR: return GS_TRUTH_NOT_EXPR;
06668    case TRUTH_ORIF_EXPR: return GS_TRUTH_ORIF_EXPR;
06669    case TRUTH_OR_EXPR: return GS_TRUTH_OR_EXPR;
06670    case TRUTH_XOR_EXPR: return GS_TRUTH_XOR_EXPR;
06671    case TRY_BLOCK: return GS_TRY_BLOCK;
06672    case TRY_CATCH_EXPR: return GS_TRY_CATCH_EXPR;
06673    case TRY_FINALLY_EXPR: return GS_TRY_FINALLY_EXPR;
06674    case TYPEOF_TYPE: return GS_TYPEOF_TYPE;
06675    case TYPENAME_TYPE: return GS_TYPENAME_TYPE;
06676    case TYPE_DECL: return GS_TYPE_DECL;
06677    case TYPE_EXPR: return GS_TYPE_EXPR;
06678    case TYPEID_EXPR: return GS_TYPEID_EXPR;
06679    case USING_DECL: return GS_USING_DECL;
06680    case USING_STMT: return GS_USING_STMT;
06681    case UNBOUND_CLASS_TEMPLATE: return GS_UNBOUND_CLASS_TEMPLATE;
06682    case UNEQ_EXPR: return GS_UNEQ_EXPR;
06683    case UNGE_EXPR: return GS_UNGE_EXPR;
06684    case UNGT_EXPR: return GS_UNGT_EXPR;
06685    case UNION_TYPE: return GS_UNION_TYPE;
06686    case UNLE_EXPR: return GS_UNLE_EXPR;
06687    case UNLT_EXPR: return GS_UNLT_EXPR;
06688    case UNORDERED_EXPR: return GS_UNORDERED_EXPR;
06689    case VALUE_HANDLE: return GS_VALUE_HANDLE;
06690    case VAR_DECL: return GS_VAR_DECL;
06691    case VA_ARG_EXPR: return GS_VA_ARG_EXPR;
06692    case VECTOR_CST: return GS_VECTOR_CST;
06693    case VECTOR_TYPE: return GS_VECTOR_TYPE;
06694    case VEC_COND_EXPR: return GS_VEC_COND_EXPR;
06695    case VEC_DELETE_EXPR: return GS_VEC_DELETE_EXPR;
06696    case VEC_NEW_EXPR: return GS_VEC_NEW_EXPR;
06697    case VIEW_CONVERT_EXPR: return GS_VIEW_CONVERT_EXPR;
06698    case VOID_TYPE: return GS_VOID_TYPE;
06699    case WHILE_STMT: return GS_WHILE_STMT;
06700    case WITH_CLEANUP_EXPR: return GS_WITH_CLEANUP_EXPR;
06701    case WITH_SIZE_EXPR: return GS_WITH_SIZE_EXPR;
06702    case TEMPLATE_TEMPLATE_PARM: return GS_TEMPLATE_TEMPLATE_PARM;
06703  }
06704  gcc_assert(0);
06705  return (gs_code_t) 0;
06706 }
06707 
06708 static inline gs_tree_code_class_t
06709 gcc_class2gs_class (int class) 
06710 {
06711   switch (class) {
06712     case tcc_exceptional: return GS_TCC_EXCEPTIONAL;
06713     case tcc_constant: return GS_TCC_CONSTANT;
06714     case tcc_type: return GS_TCC_TYPE;     
06715     case tcc_declaration: return GS_TCC_DECLARATION;
06716     case tcc_reference: return GS_TCC_REFERENCE; 
06717     case tcc_comparison: return GS_TCC_COMPARISON;
06718     case tcc_unary: return GS_TCC_UNARY;
06719     case tcc_binary: return GS_TCC_BINARY;  
06720     case tcc_statement: return GS_TCC_STATEMENT;
06721     case tcc_expression: return GS_TCC_EXPRESSION;
06722   }
06723   gcc_assert (0);
06724   return (gs_tree_code_class_t) 0;
06725 }
06726 
06727 static inline gsbi_t
06728 gcc_built_in2gsbi (enum built_in_function code)
06729 {
06730   switch (code) {
06731 
06732     case BUILT_IN_ACOS: return GSBI_BUILT_IN_ACOS;
06733     case BUILT_IN_ACOSF: return GSBI_BUILT_IN_ACOSF;
06734     case BUILT_IN_ACOSH: return GSBI_BUILT_IN_ACOSH;
06735     case BUILT_IN_ACOSHF: return GSBI_BUILT_IN_ACOSHF;
06736     case BUILT_IN_ACOSHL: return GSBI_BUILT_IN_ACOSHL;
06737     case BUILT_IN_ACOSL: return GSBI_BUILT_IN_ACOSL;
06738     case BUILT_IN_ASIN: return GSBI_BUILT_IN_ASIN;
06739     case BUILT_IN_ASINF: return GSBI_BUILT_IN_ASINF;
06740     case BUILT_IN_ASINH: return GSBI_BUILT_IN_ASINH;
06741     case BUILT_IN_ASINHF: return GSBI_BUILT_IN_ASINHF;
06742     case BUILT_IN_ASINHL: return GSBI_BUILT_IN_ASINHL;
06743     case BUILT_IN_ASINL: return GSBI_BUILT_IN_ASINL;
06744     case BUILT_IN_ATAN: return GSBI_BUILT_IN_ATAN;
06745     case BUILT_IN_ATAN2: return GSBI_BUILT_IN_ATAN2;
06746     case BUILT_IN_ATAN2F: return GSBI_BUILT_IN_ATAN2F;
06747     case BUILT_IN_ATAN2L: return GSBI_BUILT_IN_ATAN2L;
06748     case BUILT_IN_ATANF: return GSBI_BUILT_IN_ATANF;
06749     case BUILT_IN_ATANH: return GSBI_BUILT_IN_ATANH;
06750     case BUILT_IN_ATANHF: return GSBI_BUILT_IN_ATANHF;
06751     case BUILT_IN_ATANHL: return GSBI_BUILT_IN_ATANHL;
06752     case BUILT_IN_ATANL: return GSBI_BUILT_IN_ATANL;
06753     case BUILT_IN_CBRT: return GSBI_BUILT_IN_CBRT;
06754     case BUILT_IN_CBRTF: return GSBI_BUILT_IN_CBRTF;
06755     case BUILT_IN_CBRTL: return GSBI_BUILT_IN_CBRTL;
06756     case BUILT_IN_CEIL: return GSBI_BUILT_IN_CEIL;
06757     case BUILT_IN_CEILF: return GSBI_BUILT_IN_CEILF;
06758     case BUILT_IN_CEILL: return GSBI_BUILT_IN_CEILL;
06759     case BUILT_IN_COPYSIGN: return GSBI_BUILT_IN_COPYSIGN;
06760     case BUILT_IN_COPYSIGNF: return GSBI_BUILT_IN_COPYSIGNF;
06761     case BUILT_IN_COPYSIGNL: return GSBI_BUILT_IN_COPYSIGNL;
06762     case BUILT_IN_COS: return GSBI_BUILT_IN_COS;
06763     case BUILT_IN_COSF: return GSBI_BUILT_IN_COSF;
06764     case BUILT_IN_COSH: return GSBI_BUILT_IN_COSH;
06765     case BUILT_IN_COSHF: return GSBI_BUILT_IN_COSHF;
06766     case BUILT_IN_COSHL: return GSBI_BUILT_IN_COSHL;
06767     case BUILT_IN_COSL: return GSBI_BUILT_IN_COSL;
06768     case BUILT_IN_DREM: return GSBI_BUILT_IN_DREM;
06769     case BUILT_IN_DREMF: return GSBI_BUILT_IN_DREMF;
06770     case BUILT_IN_DREML: return GSBI_BUILT_IN_DREML;
06771     case BUILT_IN_ERF: return GSBI_BUILT_IN_ERF;
06772     case BUILT_IN_ERFC: return GSBI_BUILT_IN_ERFC;
06773     case BUILT_IN_ERFCF: return GSBI_BUILT_IN_ERFCF;
06774     case BUILT_IN_ERFCL: return GSBI_BUILT_IN_ERFCL;
06775     case BUILT_IN_ERFF: return GSBI_BUILT_IN_ERFF;
06776     case BUILT_IN_ERFL: return GSBI_BUILT_IN_ERFL;
06777     case BUILT_IN_EXP: return GSBI_BUILT_IN_EXP;
06778     case BUILT_IN_EXP10: return GSBI_BUILT_IN_EXP10;
06779     case BUILT_IN_EXP10F: return GSBI_BUILT_IN_EXP10F;
06780     case BUILT_IN_EXP10L: return GSBI_BUILT_IN_EXP10L;
06781     case BUILT_IN_EXP2: return GSBI_BUILT_IN_EXP2;
06782     case BUILT_IN_EXP2F: return GSBI_BUILT_IN_EXP2F;
06783     case BUILT_IN_EXP2L: return GSBI_BUILT_IN_EXP2L;
06784     case BUILT_IN_EXPF: return GSBI_BUILT_IN_EXPF;
06785     case BUILT_IN_EXPL: return GSBI_BUILT_IN_EXPL;
06786     case BUILT_IN_EXPM1: return GSBI_BUILT_IN_EXPM1;
06787     case BUILT_IN_EXPM1F: return GSBI_BUILT_IN_EXPM1F;
06788     case BUILT_IN_EXPM1L: return GSBI_BUILT_IN_EXPM1L;
06789     case BUILT_IN_FABS: return GSBI_BUILT_IN_FABS;
06790     case BUILT_IN_FABSF: return GSBI_BUILT_IN_FABSF;
06791     case BUILT_IN_FABSL: return GSBI_BUILT_IN_FABSL;
06792     case BUILT_IN_FDIM: return GSBI_BUILT_IN_FDIM;
06793     case BUILT_IN_FDIMF: return GSBI_BUILT_IN_FDIMF;
06794     case BUILT_IN_FDIML: return GSBI_BUILT_IN_FDIML;
06795     case BUILT_IN_FLOOR: return GSBI_BUILT_IN_FLOOR;
06796     case BUILT_IN_FLOORF: return GSBI_BUILT_IN_FLOORF;
06797     case BUILT_IN_FLOORL: return GSBI_BUILT_IN_FLOORL;
06798     case BUILT_IN_FMA: return GSBI_BUILT_IN_FMA;
06799     case BUILT_IN_FMAF: return GSBI_BUILT_IN_FMAF;
06800     case BUILT_IN_FMAL: return GSBI_BUILT_IN_FMAL;
06801     case BUILT_IN_FMAX: return GSBI_BUILT_IN_FMAX;
06802     case BUILT_IN_FMAXF: return GSBI_BUILT_IN_FMAXF;
06803     case BUILT_IN_FMAXL: return GSBI_BUILT_IN_FMAXL;
06804     case BUILT_IN_FMIN: return GSBI_BUILT_IN_FMIN;
06805     case BUILT_IN_FMINF: return GSBI_BUILT_IN_FMINF;
06806     case BUILT_IN_FMINL: return GSBI_BUILT_IN_FMINL;
06807     case BUILT_IN_FMOD: return GSBI_BUILT_IN_FMOD;
06808     case BUILT_IN_FMODF: return GSBI_BUILT_IN_FMODF;
06809     case BUILT_IN_FMODL: return GSBI_BUILT_IN_FMODL;
06810     case BUILT_IN_FREXP: return GSBI_BUILT_IN_FREXP;
06811     case BUILT_IN_FREXPF: return GSBI_BUILT_IN_FREXPF;
06812     case BUILT_IN_FREXPL: return GSBI_BUILT_IN_FREXPL;
06813     case BUILT_IN_GAMMA: return GSBI_BUILT_IN_GAMMA;
06814     case BUILT_IN_GAMMAF: return GSBI_BUILT_IN_GAMMAF;
06815     case BUILT_IN_GAMMAL: return GSBI_BUILT_IN_GAMMAL;
06816     case BUILT_IN_HUGE_VAL: return GSBI_BUILT_IN_HUGE_VAL;
06817     case BUILT_IN_HUGE_VALF: return GSBI_BUILT_IN_HUGE_VALF;
06818     case BUILT_IN_HUGE_VALL: return GSBI_BUILT_IN_HUGE_VALL;
06819     case BUILT_IN_HYPOT: return GSBI_BUILT_IN_HYPOT;
06820     case BUILT_IN_HYPOTF: return GSBI_BUILT_IN_HYPOTF;
06821     case BUILT_IN_HYPOTL: return GSBI_BUILT_IN_HYPOTL;
06822     case BUILT_IN_ILOGB: return GSBI_BUILT_IN_ILOGB;
06823     case BUILT_IN_ILOGBF: return GSBI_BUILT_IN_ILOGBF;
06824     case BUILT_IN_ILOGBL: return GSBI_BUILT_IN_ILOGBL;
06825     case BUILT_IN_INF: return GSBI_BUILT_IN_INF;
06826     case BUILT_IN_INFF: return GSBI_BUILT_IN_INFF;
06827     case BUILT_IN_INFL: return GSBI_BUILT_IN_INFL;
06828     case BUILT_IN_J0: return GSBI_BUILT_IN_J0;
06829     case BUILT_IN_J0F: return GSBI_BUILT_IN_J0F;
06830     case BUILT_IN_J0L: return GSBI_BUILT_IN_J0L;
06831     case BUILT_IN_J1: return GSBI_BUILT_IN_J1;
06832     case BUILT_IN_J1F: return GSBI_BUILT_IN_J1F;
06833     case BUILT_IN_J1L: return GSBI_BUILT_IN_J1L;
06834     case BUILT_IN_JN: return GSBI_BUILT_IN_JN;
06835     case BUILT_IN_JNF: return GSBI_BUILT_IN_JNF;
06836     case BUILT_IN_JNL: return GSBI_BUILT_IN_JNL;
06837     case BUILT_IN_LDEXP: return GSBI_BUILT_IN_LDEXP;
06838     case BUILT_IN_LDEXPF: return GSBI_BUILT_IN_LDEXPF;
06839     case BUILT_IN_LDEXPL: return GSBI_BUILT_IN_LDEXPL;
06840     case BUILT_IN_LGAMMA: return GSBI_BUILT_IN_LGAMMA;
06841     case BUILT_IN_LGAMMAF: return GSBI_BUILT_IN_LGAMMAF;
06842     case BUILT_IN_LGAMMAL: return GSBI_BUILT_IN_LGAMMAL;
06843     case BUILT_IN_LLRINT: return GSBI_BUILT_IN_LLRINT;
06844     case BUILT_IN_LLRINTF: return GSBI_BUILT_IN_LLRINTF;
06845     case BUILT_IN_LLRINTL: return GSBI_BUILT_IN_LLRINTL;
06846     case BUILT_IN_LLROUND: return GSBI_BUILT_IN_LLROUND;
06847     case BUILT_IN_LLROUNDF: return GSBI_BUILT_IN_LLROUNDF;
06848     case BUILT_IN_LLROUNDL: return GSBI_BUILT_IN_LLROUNDL;
06849     case BUILT_IN_LOG: return GSBI_BUILT_IN_LOG;
06850     case BUILT_IN_LOG10: return GSBI_BUILT_IN_LOG10;
06851     case BUILT_IN_LOG10F: return GSBI_BUILT_IN_LOG10F;
06852     case BUILT_IN_LOG10L: return GSBI_BUILT_IN_LOG10L;
06853     case BUILT_IN_LOG1P: return GSBI_BUILT_IN_LOG1P;
06854     case BUILT_IN_LOG1PF: return GSBI_BUILT_IN_LOG1PF;
06855     case BUILT_IN_LOG1PL: return GSBI_BUILT_IN_LOG1PL;
06856     case BUILT_IN_LOG2: return GSBI_BUILT_IN_LOG2;
06857     case BUILT_IN_LOG2F: return GSBI_BUILT_IN_LOG2F;
06858     case BUILT_IN_LOG2L: return GSBI_BUILT_IN_LOG2L;
06859     case BUILT_IN_LOGB: return GSBI_BUILT_IN_LOGB;
06860     case BUILT_IN_LOGBF: return GSBI_BUILT_IN_LOGBF;
06861     case BUILT_IN_LOGBL: return GSBI_BUILT_IN_LOGBL;
06862     case BUILT_IN_LOGF: return GSBI_BUILT_IN_LOGF;
06863     case BUILT_IN_LOGL: return GSBI_BUILT_IN_LOGL;
06864     case BUILT_IN_LRINT: return GSBI_BUILT_IN_LRINT;
06865     case BUILT_IN_LRINTF: return GSBI_BUILT_IN_LRINTF;
06866     case BUILT_IN_LRINTL: return GSBI_BUILT_IN_LRINTL;
06867     case BUILT_IN_LROUND: return GSBI_BUILT_IN_LROUND;
06868     case BUILT_IN_LROUNDF: return GSBI_BUILT_IN_LROUNDF;
06869     case BUILT_IN_LROUNDL: return GSBI_BUILT_IN_LROUNDL;
06870     case BUILT_IN_MODF: return GSBI_BUILT_IN_MODF;
06871     case BUILT_IN_MODFF: return GSBI_BUILT_IN_MODFF;
06872     case BUILT_IN_MODFL: return GSBI_BUILT_IN_MODFL;
06873     case BUILT_IN_NAN: return GSBI_BUILT_IN_NAN;
06874     case BUILT_IN_NANF: return GSBI_BUILT_IN_NANF;
06875     case BUILT_IN_NANL: return GSBI_BUILT_IN_NANL;
06876     case BUILT_IN_NANS: return GSBI_BUILT_IN_NANS;
06877     case BUILT_IN_NANSF: return GSBI_BUILT_IN_NANSF;
06878     case BUILT_IN_NANSL: return GSBI_BUILT_IN_NANSL;
06879     case BUILT_IN_NEARBYINT: return GSBI_BUILT_IN_NEARBYINT;
06880     case BUILT_IN_NEARBYINTF: return GSBI_BUILT_IN_NEARBYINTF;
06881     case BUILT_IN_NEARBYINTL: return GSBI_BUILT_IN_NEARBYINTL;
06882     case BUILT_IN_NEXTAFTER: return GSBI_BUILT_IN_NEXTAFTER;
06883     case BUILT_IN_NEXTAFTERF: return GSBI_BUILT_IN_NEXTAFTERF;
06884     case BUILT_IN_NEXTAFTERL: return GSBI_BUILT_IN_NEXTAFTERL;
06885     case BUILT_IN_NEXTTOWARD: return GSBI_BUILT_IN_NEXTTOWARD;
06886     case BUILT_IN_NEXTTOWARDF: return GSBI_BUILT_IN_NEXTTOWARDF;
06887     case BUILT_IN_NEXTTOWARDL: return GSBI_BUILT_IN_NEXTTOWARDL;
06888     case BUILT_IN_POW: return GSBI_BUILT_IN_POW;
06889     case BUILT_IN_POW10: return GSBI_BUILT_IN_POW10;
06890     case BUILT_IN_POW10F: return GSBI_BUILT_IN_POW10F;
06891     case BUILT_IN_POW10L: return GSBI_BUILT_IN_POW10L;
06892     case BUILT_IN_POWF: return GSBI_BUILT_IN_POWF;
06893     case BUILT_IN_POWI: return GSBI_BUILT_IN_POWI;
06894     case BUILT_IN_POWIF: return GSBI_BUILT_IN_POWIF;
06895     case BUILT_IN_POWIL: return GSBI_BUILT_IN_POWIL;
06896     case BUILT_IN_POWL: return GSBI_BUILT_IN_POWL;
06897     case BUILT_IN_REMAINDER: return GSBI_BUILT_IN_REMAINDER;
06898     case BUILT_IN_REMAINDERF: return GSBI_BUILT_IN_REMAINDERF;
06899     case BUILT_IN_REMAINDERL: return GSBI_BUILT_IN_REMAINDERL;
06900     case BUILT_IN_REMQUO: return GSBI_BUILT_IN_REMQUO;
06901     case BUILT_IN_REMQUOF: return GSBI_BUILT_IN_REMQUOF;
06902     case BUILT_IN_REMQUOL: return GSBI_BUILT_IN_REMQUOL;
06903     case BUILT_IN_RINT: return GSBI_BUILT_IN_RINT;
06904     case BUILT_IN_RINTF: return GSBI_BUILT_IN_RINTF;
06905     case BUILT_IN_RINTL: return GSBI_BUILT_IN_RINTL;
06906     case BUILT_IN_ROUND: return GSBI_BUILT_IN_ROUND;
06907     case BUILT_IN_ROUNDF: return GSBI_BUILT_IN_ROUNDF;
06908     case BUILT_IN_ROUNDL: return GSBI_BUILT_IN_ROUNDL;
06909     case BUILT_IN_SCALB: return GSBI_BUILT_IN_SCALB;
06910     case BUILT_IN_SCALBF: return GSBI_BUILT_IN_SCALBF;
06911     case BUILT_IN_SCALBL: return GSBI_BUILT_IN_SCALBL;
06912     case BUILT_IN_SCALBLN: return GSBI_BUILT_IN_SCALBLN;
06913     case BUILT_IN_SCALBLNF: return GSBI_BUILT_IN_SCALBLNF;
06914     case BUILT_IN_SCALBLNL: return GSBI_BUILT_IN_SCALBLNL;
06915     case BUILT_IN_SCALBN: return GSBI_BUILT_IN_SCALBN;
06916     case BUILT_IN_SCALBNF: return GSBI_BUILT_IN_SCALBNF;
06917     case BUILT_IN_SCALBNL: return GSBI_BUILT_IN_SCALBNL;
06918     case BUILT_IN_SIGNBIT: return GSBI_BUILT_IN_SIGNBIT;
06919     case BUILT_IN_SIGNBITF: return GSBI_BUILT_IN_SIGNBITF;
06920     case BUILT_IN_SIGNBITL: return GSBI_BUILT_IN_SIGNBITL;
06921     case BUILT_IN_SIGNIFICAND: return GSBI_BUILT_IN_SIGNIFICAND;
06922     case BUILT_IN_SIGNIFICANDF: return GSBI_BUILT_IN_SIGNIFICANDF;
06923     case BUILT_IN_SIGNIFICANDL: return GSBI_BUILT_IN_SIGNIFICANDL;
06924     case BUILT_IN_SIN: return GSBI_BUILT_IN_SIN;
06925     case BUILT_IN_SINCOS: return GSBI_BUILT_IN_SINCOS;
06926     case BUILT_IN_SINCOSF: return GSBI_BUILT_IN_SINCOSF;
06927     case BUILT_IN_SINCOSL: return GSBI_BUILT_IN_SINCOSL;
06928     case BUILT_IN_SINF: return GSBI_BUILT_IN_SINF;
06929     case BUILT_IN_SINH: return GSBI_BUILT_IN_SINH;
06930     case BUILT_IN_SINHF: return GSBI_BUILT_IN_SINHF;
06931     case BUILT_IN_SINHL: return GSBI_BUILT_IN_SINHL;
06932     case BUILT_IN_SINL: return GSBI_BUILT_IN_SINL;
06933     case BUILT_IN_SQRT: return GSBI_BUILT_IN_SQRT;
06934     case BUILT_IN_SQRTF: return GSBI_BUILT_IN_SQRTF;
06935     case BUILT_IN_SQRTL: return GSBI_BUILT_IN_SQRTL;
06936     case BUILT_IN_TAN: return GSBI_BUILT_IN_TAN;
06937     case BUILT_IN_TANF: return GSBI_BUILT_IN_TANF;
06938     case BUILT_IN_TANH: return GSBI_BUILT_IN_TANH;
06939     case BUILT_IN_TANHF: return GSBI_BUILT_IN_TANHF;
06940     case BUILT_IN_TANHL: return GSBI_BUILT_IN_TANHL;
06941     case BUILT_IN_TANL: return GSBI_BUILT_IN_TANL;
06942     case BUILT_IN_TGAMMA: return GSBI_BUILT_IN_TGAMMA;
06943     case BUILT_IN_TGAMMAF: return GSBI_BUILT_IN_TGAMMAF;
06944     case BUILT_IN_TGAMMAL: return GSBI_BUILT_IN_TGAMMAL;
06945     case BUILT_IN_TRUNC: return GSBI_BUILT_IN_TRUNC;
06946     case BUILT_IN_TRUNCF: return GSBI_BUILT_IN_TRUNCF;
06947     case BUILT_IN_TRUNCL: return GSBI_BUILT_IN_TRUNCL;
06948     case BUILT_IN_Y0: return GSBI_BUILT_IN_Y0;
06949     case BUILT_IN_Y0F: return GSBI_BUILT_IN_Y0F;
06950     case BUILT_IN_Y0L: return GSBI_BUILT_IN_Y0L;
06951     case BUILT_IN_Y1: return GSBI_BUILT_IN_Y1;
06952     case BUILT_IN_Y1F: return GSBI_BUILT_IN_Y1F;
06953     case BUILT_IN_Y1L: return GSBI_BUILT_IN_Y1L;
06954     case BUILT_IN_YN: return GSBI_BUILT_IN_YN;
06955     case BUILT_IN_YNF: return GSBI_BUILT_IN_YNF;
06956     case BUILT_IN_YNL: return GSBI_BUILT_IN_YNL;
06957     case BUILT_IN_CABS: return GSBI_BUILT_IN_CABS;
06958     case BUILT_IN_CABSF: return GSBI_BUILT_IN_CABSF;
06959     case BUILT_IN_CABSL: return GSBI_BUILT_IN_CABSL;
06960     case BUILT_IN_CACOS: return GSBI_BUILT_IN_CACOS;
06961     case BUILT_IN_CACOSF: return GSBI_BUILT_IN_CACOSF;
06962     case BUILT_IN_CACOSH: return GSBI_BUILT_IN_CACOSH;
06963     case BUILT_IN_CACOSHF: return GSBI_BUILT_IN_CACOSHF;
06964     case BUILT_IN_CACOSHL: return GSBI_BUILT_IN_CACOSHL;
06965     case BUILT_IN_CACOSL: return GSBI_BUILT_IN_CACOSL;
06966     case BUILT_IN_CARG: return GSBI_BUILT_IN_CARG;
06967     case BUILT_IN_CARGF: return GSBI_BUILT_IN_CARGF;
06968     case BUILT_IN_CARGL: return GSBI_BUILT_IN_CARGL;
06969     case BUILT_IN_CASIN: return GSBI_BUILT_IN_CASIN;
06970     case BUILT_IN_CASINF: return GSBI_BUILT_IN_CASINF;
06971     case BUILT_IN_CASINH: return GSBI_BUILT_IN_CASINH;
06972     case BUILT_IN_CASINHF: return GSBI_BUILT_IN_CASINHF;
06973     case BUILT_IN_CASINHL: return GSBI_BUILT_IN_CASINHL;
06974     case BUILT_IN_CASINL: return GSBI_BUILT_IN_CASINL;
06975     case BUILT_IN_CATAN: return GSBI_BUILT_IN_CATAN;
06976     case BUILT_IN_CATANF: return GSBI_BUILT_IN_CATANF;
06977     case BUILT_IN_CATANH: return GSBI_BUILT_IN_CATANH;
06978     case BUILT_IN_CATANHF: return GSBI_BUILT_IN_CATANHF;
06979     case BUILT_IN_CATANHL: return GSBI_BUILT_IN_CATANHL;
06980     case BUILT_IN_CATANL: return GSBI_BUILT_IN_CATANL;
06981     case BUILT_IN_CCOS: return GSBI_BUILT_IN_CCOS;
06982     case BUILT_IN_CCOSF: return GSBI_BUILT_IN_CCOSF;
06983     case BUILT_IN_CCOSH: return GSBI_BUILT_IN_CCOSH;
06984     case BUILT_IN_CCOSHF: return GSBI_BUILT_IN_CCOSHF;
06985     case BUILT_IN_CCOSHL: return GSBI_BUILT_IN_CCOSHL;
06986     case BUILT_IN_CCOSL: return GSBI_BUILT_IN_CCOSL;
06987     case BUILT_IN_CEXP: return GSBI_BUILT_IN_CEXP;
06988     case BUILT_IN_CEXPF: return GSBI_BUILT_IN_CEXPF;
06989     case BUILT_IN_CEXPL: return GSBI_BUILT_IN_CEXPL;
06990     case BUILT_IN_CIMAG: return GSBI_BUILT_IN_CIMAG;
06991     case BUILT_IN_CIMAGF: return GSBI_BUILT_IN_CIMAGF;
06992     case BUILT_IN_CIMAGL: return GSBI_BUILT_IN_CIMAGL;
06993     case BUILT_IN_CLOG: return GSBI_BUILT_IN_CLOG;
06994     case BUILT_IN_CLOGF: return GSBI_BUILT_IN_CLOGF;
06995     case BUILT_IN_CLOGL: return GSBI_BUILT_IN_CLOGL;
06996     case BUILT_IN_CONJ: return GSBI_BUILT_IN_CONJ;
06997     case BUILT_IN_CONJF: return GSBI_BUILT_IN_CONJF;
06998     case BUILT_IN_CONJL: return GSBI_BUILT_IN_CONJL;
06999     case BUILT_IN_CPOW: return GSBI_BUILT_IN_CPOW;
07000     case BUILT_IN_CPOWF: return GSBI_BUILT_IN_CPOWF;
07001     case BUILT_IN_CPOWL: return GSBI_BUILT_IN_CPOWL;
07002     case BUILT_IN_CPROJ: return GSBI_BUILT_IN_CPROJ;
07003     case BUILT_IN_CPROJF: return GSBI_BUILT_IN_CPROJF;
07004     case BUILT_IN_CPROJL: return GSBI_BUILT_IN_CPROJL;
07005     case BUILT_IN_CREAL: return GSBI_BUILT_IN_CREAL;
07006     case BUILT_IN_CREALF: return GSBI_BUILT_IN_CREALF;
07007     case BUILT_IN_CREALL: return GSBI_BUILT_IN_CREALL;
07008     case BUILT_IN_CSIN: return GSBI_BUILT_IN_CSIN;
07009     case BUILT_IN_CSINF: return GSBI_BUILT_IN_CSINF;
07010     case BUILT_IN_CSINH: return GSBI_BUILT_IN_CSINH;
07011     case BUILT_IN_CSINHF: return GSBI_BUILT_IN_CSINHF;
07012     case BUILT_IN_CSINHL: return GSBI_BUILT_IN_CSINHL;
07013     case BUILT_IN_CSINL: return GSBI_BUILT_IN_CSINL;
07014     case BUILT_IN_CSQRT: return GSBI_BUILT_IN_CSQRT;
07015     case BUILT_IN_CSQRTF: return GSBI_BUILT_IN_CSQRTF;
07016     case BUILT_IN_CSQRTL: return GSBI_BUILT_IN_CSQRTL;
07017     case BUILT_IN_CTAN: return GSBI_BUILT_IN_CTAN;
07018     case BUILT_IN_CTANF: return GSBI_BUILT_IN_CTANF;
07019     case BUILT_IN_CTANH: return GSBI_BUILT_IN_CTANH;
07020     case BUILT_IN_CTANHF: return GSBI_BUILT_IN_CTANHF;
07021     case BUILT_IN_CTANHL: return GSBI_BUILT_IN_CTANHL;
07022     case BUILT_IN_CTANL: return GSBI_BUILT_IN_CTANL;
07023     case BUILT_IN_BCMP: return GSBI_BUILT_IN_BCMP;
07024     case BUILT_IN_BCOPY: return GSBI_BUILT_IN_BCOPY;
07025     case BUILT_IN_BZERO: return GSBI_BUILT_IN_BZERO;
07026     case BUILT_IN_INDEX: return GSBI_BUILT_IN_INDEX;
07027     case BUILT_IN_MEMCMP: return GSBI_BUILT_IN_MEMCMP;
07028     case BUILT_IN_MEMCPY: return GSBI_BUILT_IN_MEMCPY;
07029     case BUILT_IN_MEMMOVE: return GSBI_BUILT_IN_MEMMOVE;
07030     case BUILT_IN_MEMPCPY: return GSBI_BUILT_IN_MEMPCPY;
07031     case BUILT_IN_MEMSET: return GSBI_BUILT_IN_MEMSET;
07032     case BUILT_IN_RINDEX: return GSBI_BUILT_IN_RINDEX;
07033     case BUILT_IN_STPCPY: return GSBI_BUILT_IN_STPCPY;
07034     case BUILT_IN_STRCAT: return GSBI_BUILT_IN_STRCAT;
07035     case BUILT_IN_STRCHR: return GSBI_BUILT_IN_STRCHR;
07036     case BUILT_IN_STRCMP: return GSBI_BUILT_IN_STRCMP;
07037     case BUILT_IN_STRCPY: return GSBI_BUILT_IN_STRCPY;
07038     case BUILT_IN_STRCSPN: return GSBI_BUILT_IN_STRCSPN;
07039     case BUILT_IN_STRDUP: return GSBI_BUILT_IN_STRDUP;
07040     case BUILT_IN_STRLEN: return GSBI_BUILT_IN_STRLEN;
07041     case BUILT_IN_STRNCAT: return GSBI_BUILT_IN_STRNCAT;
07042     case BUILT_IN_STRNCMP: return GSBI_BUILT_IN_STRNCMP;
07043     case BUILT_IN_STRNC