Home | History | Annotate | Line # | Download | only in gcc
      1  1.1  mrg /* Gimple IR support functions.
      2  1.1  mrg 
      3  1.1  mrg    Copyright (C) 2007-2022 Free Software Foundation, Inc.
      4  1.1  mrg    Contributed by Aldy Hernandez <aldyh (at) redhat.com>
      5  1.1  mrg 
      6  1.1  mrg This file is part of GCC.
      7  1.1  mrg 
      8  1.1  mrg GCC is free software; you can redistribute it and/or modify it under
      9  1.1  mrg the terms of the GNU General Public License as published by the Free
     10  1.1  mrg Software Foundation; either version 3, or (at your option) any later
     11  1.1  mrg version.
     12  1.1  mrg 
     13  1.1  mrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
     14  1.1  mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
     15  1.1  mrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     16  1.1  mrg for more details.
     17  1.1  mrg 
     18  1.1  mrg You should have received a copy of the GNU General Public License
     19  1.1  mrg along with GCC; see the file COPYING3.  If not see
     20  1.1  mrg <http://www.gnu.org/licenses/>.  */
     21  1.1  mrg 
     22  1.1  mrg #include "config.h"
     23  1.1  mrg #include "system.h"
     24  1.1  mrg #include "coretypes.h"
     25  1.1  mrg #include "backend.h"
     26  1.1  mrg #include "tree.h"
     27  1.1  mrg #include "gimple.h"
     28  1.1  mrg #include "ssa.h"
     29  1.1  mrg #include "cgraph.h"
     30  1.1  mrg #include "diagnostic.h"
     31  1.1  mrg #include "alias.h"
     32  1.1  mrg #include "fold-const.h"
     33  1.1  mrg #include "calls.h"
     34  1.1  mrg #include "stor-layout.h"
     35  1.1  mrg #include "internal-fn.h"
     36  1.1  mrg #include "tree-eh.h"
     37  1.1  mrg #include "gimple-iterator.h"
     38  1.1  mrg #include "gimple-walk.h"
     39  1.1  mrg #include "gimplify.h"
     40  1.1  mrg #include "target.h"
     41  1.1  mrg #include "builtins.h"
     42  1.1  mrg #include "selftest.h"
     43  1.1  mrg #include "gimple-pretty-print.h"
     44  1.1  mrg #include "stringpool.h"
     45  1.1  mrg #include "attribs.h"
     46  1.1  mrg #include "asan.h"
     47  1.1  mrg #include "langhooks.h"
     48  1.1  mrg #include "attr-fnspec.h"
     49  1.1  mrg #include "ipa-modref-tree.h"
     50  1.1  mrg #include "ipa-modref.h"
     51  1.1  mrg #include "dbgcnt.h"
     52  1.1  mrg 
     53  1.1  mrg /* All the tuples have their operand vector (if present) at the very bottom
     54  1.1  mrg    of the structure.  Therefore, the offset required to find the
     55  1.1  mrg    operands vector the size of the structure minus the size of the 1
     56  1.1  mrg    element tree array at the end (see gimple_ops).  */
     57  1.1  mrg #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) \
     58  1.1  mrg 	(HAS_TREE_OP ? sizeof (struct STRUCT) - sizeof (tree) : 0),
     59  1.1  mrg EXPORTED_CONST size_t gimple_ops_offset_[] = {
     60  1.1  mrg #include "gsstruct.def"
     61  1.1  mrg };
     62  1.1  mrg #undef DEFGSSTRUCT
     63  1.1  mrg 
     64  1.1  mrg #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) sizeof (struct STRUCT),
     65  1.1  mrg static const size_t gsstruct_code_size[] = {
     66  1.1  mrg #include "gsstruct.def"
     67  1.1  mrg };
     68  1.1  mrg #undef DEFGSSTRUCT
     69  1.1  mrg 
     70  1.1  mrg #define DEFGSCODE(SYM, NAME, GSSCODE)	NAME,
     71  1.1  mrg const char *const gimple_code_name[] = {
     72  1.1  mrg #include "gimple.def"
     73  1.1  mrg };
     74  1.1  mrg #undef DEFGSCODE
     75  1.1  mrg 
     76  1.1  mrg #define DEFGSCODE(SYM, NAME, GSSCODE)	GSSCODE,
     77  1.1  mrg EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = {
     78  1.1  mrg #include "gimple.def"
     79  1.1  mrg };
     80  1.1  mrg #undef DEFGSCODE
     81  1.1  mrg 
     82  1.1  mrg /* Gimple stats.  */
     83  1.1  mrg 
     84  1.1  mrg uint64_t gimple_alloc_counts[(int) gimple_alloc_kind_all];
     85  1.1  mrg uint64_t gimple_alloc_sizes[(int) gimple_alloc_kind_all];
     86  1.1  mrg 
     87  1.1  mrg /* Keep in sync with gimple.h:enum gimple_alloc_kind.  */
     88  1.1  mrg static const char * const gimple_alloc_kind_names[] = {
     89  1.1  mrg     "assignments",
     90  1.1  mrg     "phi nodes",
     91  1.1  mrg     "conditionals",
     92  1.1  mrg     "everything else"
     93  1.1  mrg };
     94  1.1  mrg 
     95  1.1  mrg /* Static gimple tuple members.  */
     96  1.1  mrg const enum gimple_code gassign::code_;
     97  1.1  mrg const enum gimple_code gcall::code_;
     98  1.1  mrg const enum gimple_code gcond::code_;
     99  1.1  mrg 
    100  1.1  mrg 
    101  1.1  mrg /* Gimple tuple constructors.
    102  1.1  mrg    Note: Any constructor taking a ``gimple_seq'' as a parameter, can
    103  1.1  mrg    be passed a NULL to start with an empty sequence.  */
    104  1.1  mrg 
    105  1.1  mrg /* Set the code for statement G to CODE.  */
    106  1.1  mrg 
    107  1.1  mrg static inline void
    108  1.1  mrg gimple_set_code (gimple *g, enum gimple_code code)
    109  1.1  mrg {
    110  1.1  mrg   g->code = code;
    111  1.1  mrg }
    112  1.1  mrg 
    113  1.1  mrg /* Return the number of bytes needed to hold a GIMPLE statement with
    114  1.1  mrg    code CODE.  */
    115  1.1  mrg 
    116  1.1  mrg size_t
    117  1.1  mrg gimple_size (enum gimple_code code, unsigned num_ops)
    118  1.1  mrg {
    119  1.1  mrg   size_t size = gsstruct_code_size[gss_for_code (code)];
    120  1.1  mrg   if (num_ops > 0)
    121  1.1  mrg     size += (sizeof (tree) * (num_ops - 1));
    122  1.1  mrg   return size;
    123  1.1  mrg }
    124  1.1  mrg 
    125  1.1  mrg /* Initialize GIMPLE statement G with CODE and NUM_OPS.  */
    126  1.1  mrg 
    127  1.1  mrg void
    128  1.1  mrg gimple_init (gimple *g, enum gimple_code code, unsigned num_ops)
    129  1.1  mrg {
    130  1.1  mrg   gimple_set_code (g, code);
    131  1.1  mrg   gimple_set_num_ops (g, num_ops);
    132  1.1  mrg 
    133  1.1  mrg   /* Do not call gimple_set_modified here as it has other side
    134  1.1  mrg      effects and this tuple is still not completely built.  */
    135  1.1  mrg   g->modified = 1;
    136  1.1  mrg   gimple_init_singleton (g);
    137  1.1  mrg }
    138  1.1  mrg 
    139  1.1  mrg /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS
    140  1.1  mrg    operands.  */
    141  1.1  mrg 
    142  1.1  mrg gimple *
    143  1.1  mrg gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL)
    144  1.1  mrg {
    145  1.1  mrg   size_t size;
    146  1.1  mrg   gimple *stmt;
    147  1.1  mrg 
    148  1.1  mrg   size = gimple_size (code, num_ops);
    149  1.1  mrg   if (GATHER_STATISTICS)
    150  1.1  mrg     {
    151  1.1  mrg       enum gimple_alloc_kind kind = gimple_alloc_kind (code);
    152  1.1  mrg       gimple_alloc_counts[(int) kind]++;
    153  1.1  mrg       gimple_alloc_sizes[(int) kind] += size;
    154  1.1  mrg     }
    155  1.1  mrg 
    156  1.1  mrg   stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT);
    157  1.1  mrg   gimple_init (stmt, code, num_ops);
    158  1.1  mrg   return stmt;
    159  1.1  mrg }
    160  1.1  mrg 
    161  1.1  mrg /* Set SUBCODE to be the code of the expression computed by statement G.  */
    162  1.1  mrg 
    163  1.1  mrg static inline void
    164  1.1  mrg gimple_set_subcode (gimple *g, unsigned subcode)
    165  1.1  mrg {
    166  1.1  mrg   /* We only have 16 bits for the RHS code.  Assert that we are not
    167  1.1  mrg      overflowing it.  */
    168  1.1  mrg   gcc_assert (subcode < (1 << 16));
    169  1.1  mrg   g->subcode = subcode;
    170  1.1  mrg }
    171  1.1  mrg 
    172  1.1  mrg 
    173  1.1  mrg 
    174  1.1  mrg /* Build a tuple with operands.  CODE is the statement to build (which
    175  1.1  mrg    must be one of the GIMPLE_WITH_OPS tuples).  SUBCODE is the subcode
    176  1.1  mrg    for the new tuple.  NUM_OPS is the number of operands to allocate.  */
    177  1.1  mrg 
    178  1.1  mrg #define gimple_build_with_ops(c, s, n) \
    179  1.1  mrg   gimple_build_with_ops_stat (c, s, n MEM_STAT_INFO)
    180  1.1  mrg 
    181  1.1  mrg static gimple *
    182  1.1  mrg gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode,
    183  1.1  mrg 		            unsigned num_ops MEM_STAT_DECL)
    184  1.1  mrg {
    185  1.1  mrg   gimple *s = gimple_alloc (code, num_ops PASS_MEM_STAT);
    186  1.1  mrg   gimple_set_subcode (s, subcode);
    187  1.1  mrg 
    188  1.1  mrg   return s;
    189  1.1  mrg }
    190  1.1  mrg 
    191  1.1  mrg 
    192  1.1  mrg /* Build a GIMPLE_RETURN statement returning RETVAL.  */
    193  1.1  mrg 
    194  1.1  mrg greturn *
    195  1.1  mrg gimple_build_return (tree retval)
    196  1.1  mrg {
    197  1.1  mrg   greturn *s
    198  1.1  mrg     = as_a <greturn *> (gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK,
    199  1.1  mrg 					       2));
    200  1.1  mrg   if (retval)
    201  1.1  mrg     gimple_return_set_retval (s, retval);
    202  1.1  mrg   return s;
    203  1.1  mrg }
    204  1.1  mrg 
    205  1.1  mrg /* Reset alias information on call S.  */
    206  1.1  mrg 
    207  1.1  mrg void
    208  1.1  mrg gimple_call_reset_alias_info (gcall *s)
    209  1.1  mrg {
    210  1.1  mrg   if (gimple_call_flags (s) & ECF_CONST)
    211  1.1  mrg     memset (gimple_call_use_set (s), 0, sizeof (struct pt_solution));
    212  1.1  mrg   else
    213  1.1  mrg     pt_solution_reset (gimple_call_use_set (s));
    214  1.1  mrg   if (gimple_call_flags (s) & (ECF_CONST|ECF_PURE|ECF_NOVOPS))
    215  1.1  mrg     memset (gimple_call_clobber_set (s), 0, sizeof (struct pt_solution));
    216  1.1  mrg   else
    217  1.1  mrg     pt_solution_reset (gimple_call_clobber_set (s));
    218  1.1  mrg }
    219  1.1  mrg 
    220  1.1  mrg /* Helper for gimple_build_call, gimple_build_call_valist,
    221  1.1  mrg    gimple_build_call_vec and gimple_build_call_from_tree.  Build the basic
    222  1.1  mrg    components of a GIMPLE_CALL statement to function FN with NARGS
    223  1.1  mrg    arguments.  */
    224  1.1  mrg 
    225  1.1  mrg static inline gcall *
    226  1.1  mrg gimple_build_call_1 (tree fn, unsigned nargs)
    227  1.1  mrg {
    228  1.1  mrg   gcall *s
    229  1.1  mrg     = as_a <gcall *> (gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
    230  1.1  mrg 					     nargs + 3));
    231  1.1  mrg   if (TREE_CODE (fn) == FUNCTION_DECL)
    232  1.1  mrg     fn = build_fold_addr_expr (fn);
    233  1.1  mrg   gimple_set_op (s, 1, fn);
    234  1.1  mrg   gimple_call_set_fntype (s, TREE_TYPE (TREE_TYPE (fn)));
    235  1.1  mrg   gimple_call_reset_alias_info (s);
    236  1.1  mrg   return s;
    237  1.1  mrg }
    238  1.1  mrg 
    239  1.1  mrg 
    240  1.1  mrg /* Build a GIMPLE_CALL statement to function FN with the arguments
    241  1.1  mrg    specified in vector ARGS.  */
    242  1.1  mrg 
    243  1.1  mrg gcall *
    244  1.1  mrg gimple_build_call_vec (tree fn, const vec<tree> &args)
    245  1.1  mrg {
    246  1.1  mrg   unsigned i;
    247  1.1  mrg   unsigned nargs = args.length ();
    248  1.1  mrg   gcall *call = gimple_build_call_1 (fn, nargs);
    249  1.1  mrg 
    250  1.1  mrg   for (i = 0; i < nargs; i++)
    251  1.1  mrg     gimple_call_set_arg (call, i, args[i]);
    252  1.1  mrg 
    253  1.1  mrg   return call;
    254  1.1  mrg }
    255  1.1  mrg 
    256  1.1  mrg 
    257  1.1  mrg /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
    258  1.1  mrg    arguments.  The ... are the arguments.  */
    259  1.1  mrg 
    260  1.1  mrg gcall *
    261  1.1  mrg gimple_build_call (tree fn, unsigned nargs, ...)
    262  1.1  mrg {
    263  1.1  mrg   va_list ap;
    264  1.1  mrg   gcall *call;
    265  1.1  mrg   unsigned i;
    266  1.1  mrg 
    267  1.1  mrg   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
    268  1.1  mrg 
    269  1.1  mrg   call = gimple_build_call_1 (fn, nargs);
    270  1.1  mrg 
    271  1.1  mrg   va_start (ap, nargs);
    272  1.1  mrg   for (i = 0; i < nargs; i++)
    273  1.1  mrg     gimple_call_set_arg (call, i, va_arg (ap, tree));
    274  1.1  mrg   va_end (ap);
    275  1.1  mrg 
    276  1.1  mrg   return call;
    277  1.1  mrg }
    278  1.1  mrg 
    279  1.1  mrg 
    280  1.1  mrg /* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
    281  1.1  mrg    arguments.  AP contains the arguments.  */
    282  1.1  mrg 
    283  1.1  mrg gcall *
    284  1.1  mrg gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
    285  1.1  mrg {
    286  1.1  mrg   gcall *call;
    287  1.1  mrg   unsigned i;
    288  1.1  mrg 
    289  1.1  mrg   gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
    290  1.1  mrg 
    291  1.1  mrg   call = gimple_build_call_1 (fn, nargs);
    292  1.1  mrg 
    293  1.1  mrg   for (i = 0; i < nargs; i++)
    294  1.1  mrg     gimple_call_set_arg (call, i, va_arg (ap, tree));
    295  1.1  mrg 
    296  1.1  mrg   return call;
    297  1.1  mrg }
    298  1.1  mrg 
    299  1.1  mrg 
    300  1.1  mrg /* Helper for gimple_build_call_internal and gimple_build_call_internal_vec.
    301  1.1  mrg    Build the basic components of a GIMPLE_CALL statement to internal
    302  1.1  mrg    function FN with NARGS arguments.  */
    303  1.1  mrg 
    304  1.1  mrg static inline gcall *
    305  1.1  mrg gimple_build_call_internal_1 (enum internal_fn fn, unsigned nargs)
    306  1.1  mrg {
    307  1.1  mrg   gcall *s
    308  1.1  mrg     = as_a <gcall *> (gimple_build_with_ops (GIMPLE_CALL, ERROR_MARK,
    309  1.1  mrg 					     nargs + 3));
    310  1.1  mrg   s->subcode |= GF_CALL_INTERNAL;
    311  1.1  mrg   gimple_call_set_internal_fn (s, fn);
    312  1.1  mrg   gimple_call_reset_alias_info (s);
    313  1.1  mrg   return s;
    314  1.1  mrg }
    315  1.1  mrg 
    316  1.1  mrg 
    317  1.1  mrg /* Build a GIMPLE_CALL statement to internal function FN.  NARGS is
    318  1.1  mrg    the number of arguments.  The ... are the arguments.  */
    319  1.1  mrg 
    320  1.1  mrg gcall *
    321  1.1  mrg gimple_build_call_internal (enum internal_fn fn, unsigned nargs, ...)
    322  1.1  mrg {
    323  1.1  mrg   va_list ap;
    324  1.1  mrg   gcall *call;
    325  1.1  mrg   unsigned i;
    326  1.1  mrg 
    327  1.1  mrg   call = gimple_build_call_internal_1 (fn, nargs);
    328  1.1  mrg   va_start (ap, nargs);
    329  1.1  mrg   for (i = 0; i < nargs; i++)
    330  1.1  mrg     gimple_call_set_arg (call, i, va_arg (ap, tree));
    331  1.1  mrg   va_end (ap);
    332  1.1  mrg 
    333  1.1  mrg   return call;
    334  1.1  mrg }
    335  1.1  mrg 
    336  1.1  mrg 
    337  1.1  mrg /* Build a GIMPLE_CALL statement to internal function FN with the arguments
    338  1.1  mrg    specified in vector ARGS.  */
    339  1.1  mrg 
    340  1.1  mrg gcall *
    341  1.1  mrg gimple_build_call_internal_vec (enum internal_fn fn, const vec<tree> &args)
    342  1.1  mrg {
    343  1.1  mrg   unsigned i, nargs;
    344  1.1  mrg   gcall *call;
    345  1.1  mrg 
    346  1.1  mrg   nargs = args.length ();
    347  1.1  mrg   call = gimple_build_call_internal_1 (fn, nargs);
    348  1.1  mrg   for (i = 0; i < nargs; i++)
    349  1.1  mrg     gimple_call_set_arg (call, i, args[i]);
    350  1.1  mrg 
    351  1.1  mrg   return call;
    352  1.1  mrg }
    353  1.1  mrg 
    354  1.1  mrg 
    355  1.1  mrg /* Build a GIMPLE_CALL statement from CALL_EXPR T.  Note that T is
    356  1.1  mrg    assumed to be in GIMPLE form already.  Minimal checking is done of
    357  1.1  mrg    this fact.  */
    358  1.1  mrg 
    359  1.1  mrg gcall *
    360  1.1  mrg gimple_build_call_from_tree (tree t, tree fnptrtype)
    361  1.1  mrg {
    362  1.1  mrg   unsigned i, nargs;
    363  1.1  mrg   gcall *call;
    364  1.1  mrg 
    365  1.1  mrg   gcc_assert (TREE_CODE (t) == CALL_EXPR);
    366  1.1  mrg 
    367  1.1  mrg   nargs = call_expr_nargs (t);
    368  1.1  mrg 
    369  1.1  mrg   tree fndecl = NULL_TREE;
    370  1.1  mrg   if (CALL_EXPR_FN (t) == NULL_TREE)
    371  1.1  mrg     call = gimple_build_call_internal_1 (CALL_EXPR_IFN (t), nargs);
    372  1.1  mrg   else
    373  1.1  mrg     {
    374  1.1  mrg       fndecl = get_callee_fndecl (t);
    375  1.1  mrg       call = gimple_build_call_1 (fndecl ? fndecl : CALL_EXPR_FN (t), nargs);
    376  1.1  mrg     }
    377  1.1  mrg 
    378  1.1  mrg   for (i = 0; i < nargs; i++)
    379  1.1  mrg     gimple_call_set_arg (call, i, CALL_EXPR_ARG (t, i));
    380  1.1  mrg 
    381  1.1  mrg   gimple_set_block (call, TREE_BLOCK (t));
    382  1.1  mrg   gimple_set_location (call, EXPR_LOCATION (t));
    383  1.1  mrg 
    384  1.1  mrg   /* Carry all the CALL_EXPR flags to the new GIMPLE_CALL.  */
    385  1.1  mrg   gimple_call_set_chain (call, CALL_EXPR_STATIC_CHAIN (t));
    386  1.1  mrg   gimple_call_set_tail (call, CALL_EXPR_TAILCALL (t));
    387  1.1  mrg   gimple_call_set_must_tail (call, CALL_EXPR_MUST_TAIL_CALL (t));
    388  1.1  mrg   gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t));
    389  1.1  mrg   if (fndecl
    390  1.1  mrg       && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    391  1.1  mrg       && ALLOCA_FUNCTION_CODE_P (DECL_FUNCTION_CODE (fndecl)))
    392  1.1  mrg     gimple_call_set_alloca_for_var (call, CALL_ALLOCA_FOR_VAR_P (t));
    393  1.1  mrg   else if (fndecl
    394  1.1  mrg 	   && (DECL_IS_OPERATOR_NEW_P (fndecl)
    395  1.1  mrg 	       || DECL_IS_OPERATOR_DELETE_P (fndecl)))
    396  1.1  mrg     gimple_call_set_from_new_or_delete (call, CALL_FROM_NEW_OR_DELETE_P (t));
    397  1.1  mrg   else
    398  1.1  mrg     gimple_call_set_from_thunk (call, CALL_FROM_THUNK_P (t));
    399  1.1  mrg   gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t));
    400  1.1  mrg   gimple_call_set_nothrow (call, TREE_NOTHROW (t));
    401  1.1  mrg   gimple_call_set_by_descriptor (call, CALL_EXPR_BY_DESCRIPTOR (t));
    402  1.1  mrg   copy_warning (call, t);
    403  1.1  mrg 
    404  1.1  mrg   if (fnptrtype)
    405  1.1  mrg     {
    406  1.1  mrg       gimple_call_set_fntype (call, TREE_TYPE (fnptrtype));
    407  1.1  mrg 
    408  1.1  mrg       /* Check if it's an indirect CALL and the type has the
    409  1.1  mrg  	 nocf_check attribute. In that case propagate the information
    410  1.1  mrg 	 to the gimple CALL insn.  */
    411  1.1  mrg       if (!fndecl)
    412  1.1  mrg 	{
    413  1.1  mrg 	  gcc_assert (POINTER_TYPE_P (fnptrtype));
    414  1.1  mrg 	  tree fntype = TREE_TYPE (fnptrtype);
    415  1.1  mrg 
    416  1.1  mrg 	  if (lookup_attribute ("nocf_check", TYPE_ATTRIBUTES (fntype)))
    417  1.1  mrg 	    gimple_call_set_nocf_check (call, TRUE);
    418  1.1  mrg 	}
    419  1.1  mrg     }
    420  1.1  mrg 
    421  1.1  mrg   return call;
    422  1.1  mrg }
    423  1.1  mrg 
    424  1.1  mrg 
    425  1.1  mrg /* Build a GIMPLE_ASSIGN statement.
    426  1.1  mrg 
    427  1.1  mrg    LHS of the assignment.
    428  1.1  mrg    RHS of the assignment which can be unary or binary.  */
    429  1.1  mrg 
    430  1.1  mrg gassign *
    431  1.1  mrg gimple_build_assign (tree lhs, tree rhs MEM_STAT_DECL)
    432  1.1  mrg {
    433  1.1  mrg   enum tree_code subcode;
    434  1.1  mrg   tree op1, op2, op3;
    435  1.1  mrg 
    436  1.1  mrg   extract_ops_from_tree (rhs, &subcode, &op1, &op2, &op3);
    437  1.1  mrg   return gimple_build_assign (lhs, subcode, op1, op2, op3 PASS_MEM_STAT);
    438  1.1  mrg }
    439  1.1  mrg 
    440  1.1  mrg 
    441  1.1  mrg /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
    442  1.1  mrg    OP1, OP2 and OP3.  */
    443  1.1  mrg 
    444  1.1  mrg static inline gassign *
    445  1.1  mrg gimple_build_assign_1 (tree lhs, enum tree_code subcode, tree op1,
    446  1.1  mrg 		       tree op2, tree op3 MEM_STAT_DECL)
    447  1.1  mrg {
    448  1.1  mrg   unsigned num_ops;
    449  1.1  mrg   gassign *p;
    450  1.1  mrg 
    451  1.1  mrg   /* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the
    452  1.1  mrg      code).  */
    453  1.1  mrg   num_ops = get_gimple_rhs_num_ops (subcode) + 1;
    454  1.1  mrg 
    455  1.1  mrg   p = as_a <gassign *> (
    456  1.1  mrg         gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
    457  1.1  mrg 				    PASS_MEM_STAT));
    458  1.1  mrg   gimple_assign_set_lhs (p, lhs);
    459  1.1  mrg   gimple_assign_set_rhs1 (p, op1);
    460  1.1  mrg   if (op2)
    461  1.1  mrg     {
    462  1.1  mrg       gcc_assert (num_ops > 2);
    463  1.1  mrg       gimple_assign_set_rhs2 (p, op2);
    464  1.1  mrg     }
    465  1.1  mrg 
    466  1.1  mrg   if (op3)
    467  1.1  mrg     {
    468  1.1  mrg       gcc_assert (num_ops > 3);
    469  1.1  mrg       gimple_assign_set_rhs3 (p, op3);
    470  1.1  mrg     }
    471  1.1  mrg 
    472  1.1  mrg   return p;
    473  1.1  mrg }
    474  1.1  mrg 
    475  1.1  mrg /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
    476  1.1  mrg    OP1, OP2 and OP3.  */
    477  1.1  mrg 
    478  1.1  mrg gassign *
    479  1.1  mrg gimple_build_assign (tree lhs, enum tree_code subcode, tree op1,
    480  1.1  mrg 		     tree op2, tree op3 MEM_STAT_DECL)
    481  1.1  mrg {
    482  1.1  mrg   return gimple_build_assign_1 (lhs, subcode, op1, op2, op3 PASS_MEM_STAT);
    483  1.1  mrg }
    484  1.1  mrg 
    485  1.1  mrg /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operands
    486  1.1  mrg    OP1 and OP2.  */
    487  1.1  mrg 
    488  1.1  mrg gassign *
    489  1.1  mrg gimple_build_assign (tree lhs, enum tree_code subcode, tree op1,
    490  1.1  mrg 		     tree op2 MEM_STAT_DECL)
    491  1.1  mrg {
    492  1.1  mrg   return gimple_build_assign_1 (lhs, subcode, op1, op2, NULL_TREE
    493  1.1  mrg 				PASS_MEM_STAT);
    494  1.1  mrg }
    495  1.1  mrg 
    496  1.1  mrg /* Build a GIMPLE_ASSIGN statement with subcode SUBCODE and operand OP1.  */
    497  1.1  mrg 
    498  1.1  mrg gassign *
    499  1.1  mrg gimple_build_assign (tree lhs, enum tree_code subcode, tree op1 MEM_STAT_DECL)
    500  1.1  mrg {
    501  1.1  mrg   return gimple_build_assign_1 (lhs, subcode, op1, NULL_TREE, NULL_TREE
    502  1.1  mrg 				PASS_MEM_STAT);
    503  1.1  mrg }
    504  1.1  mrg 
    505  1.1  mrg 
    506  1.1  mrg /* Build a GIMPLE_COND statement.
    507  1.1  mrg 
    508  1.1  mrg    PRED is the condition used to compare LHS and the RHS.
    509  1.1  mrg    T_LABEL is the label to jump to if the condition is true.
    510  1.1  mrg    F_LABEL is the label to jump to otherwise.  */
    511  1.1  mrg 
    512  1.1  mrg gcond *
    513  1.1  mrg gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs,
    514  1.1  mrg 		   tree t_label, tree f_label)
    515  1.1  mrg {
    516  1.1  mrg   gcond *p;
    517  1.1  mrg 
    518  1.1  mrg   gcc_assert (TREE_CODE_CLASS (pred_code) == tcc_comparison);
    519  1.1  mrg   p = as_a <gcond *> (gimple_build_with_ops (GIMPLE_COND, pred_code, 4));
    520  1.1  mrg   gimple_cond_set_lhs (p, lhs);
    521  1.1  mrg   gimple_cond_set_rhs (p, rhs);
    522  1.1  mrg   gimple_cond_set_true_label (p, t_label);
    523  1.1  mrg   gimple_cond_set_false_label (p, f_label);
    524  1.1  mrg   return p;
    525  1.1  mrg }
    526  1.1  mrg 
    527  1.1  mrg /* Build a GIMPLE_COND statement from the conditional expression tree
    528  1.1  mrg    COND.  T_LABEL and F_LABEL are as in gimple_build_cond.  */
    529  1.1  mrg 
    530  1.1  mrg gcond *
    531  1.1  mrg gimple_build_cond_from_tree (tree cond, tree t_label, tree f_label)
    532  1.1  mrg {
    533  1.1  mrg   enum tree_code code;
    534  1.1  mrg   tree lhs, rhs;
    535  1.1  mrg 
    536  1.1  mrg   gimple_cond_get_ops_from_tree (cond, &code, &lhs, &rhs);
    537  1.1  mrg   return gimple_build_cond (code, lhs, rhs, t_label, f_label);
    538  1.1  mrg }
    539  1.1  mrg 
    540  1.1  mrg /* Set code, lhs, and rhs of a GIMPLE_COND from a suitable
    541  1.1  mrg    boolean expression tree COND.  */
    542  1.1  mrg 
    543  1.1  mrg void
    544  1.1  mrg gimple_cond_set_condition_from_tree (gcond *stmt, tree cond)
    545  1.1  mrg {
    546  1.1  mrg   enum tree_code code;
    547  1.1  mrg   tree lhs, rhs;
    548  1.1  mrg 
    549  1.1  mrg   gimple_cond_get_ops_from_tree (cond, &code, &lhs, &rhs);
    550  1.1  mrg   gimple_cond_set_condition (stmt, code, lhs, rhs);
    551  1.1  mrg }
    552  1.1  mrg 
    553  1.1  mrg /* Build a GIMPLE_LABEL statement for LABEL.  */
    554  1.1  mrg 
    555  1.1  mrg glabel *
    556  1.1  mrg gimple_build_label (tree label)
    557  1.1  mrg {
    558  1.1  mrg   glabel *p
    559  1.1  mrg     = as_a <glabel *> (gimple_build_with_ops (GIMPLE_LABEL, ERROR_MARK, 1));
    560  1.1  mrg   gimple_label_set_label (p, label);
    561  1.1  mrg   return p;
    562  1.1  mrg }
    563  1.1  mrg 
    564  1.1  mrg /* Build a GIMPLE_GOTO statement to label DEST.  */
    565  1.1  mrg 
    566  1.1  mrg ggoto *
    567  1.1  mrg gimple_build_goto (tree dest)
    568  1.1  mrg {
    569  1.1  mrg   ggoto *p
    570  1.1  mrg     = as_a <ggoto *> (gimple_build_with_ops (GIMPLE_GOTO, ERROR_MARK, 1));
    571  1.1  mrg   gimple_goto_set_dest (p, dest);
    572  1.1  mrg   return p;
    573  1.1  mrg }
    574  1.1  mrg 
    575  1.1  mrg 
    576  1.1  mrg /* Build a GIMPLE_NOP statement.  */
    577  1.1  mrg 
    578  1.1  mrg gimple *
    579  1.1  mrg gimple_build_nop (void)
    580  1.1  mrg {
    581  1.1  mrg   return gimple_alloc (GIMPLE_NOP, 0);
    582  1.1  mrg }
    583  1.1  mrg 
    584  1.1  mrg 
    585  1.1  mrg /* Build a GIMPLE_BIND statement.
    586  1.1  mrg    VARS are the variables in BODY.
    587  1.1  mrg    BLOCK is the containing block.  */
    588  1.1  mrg 
    589  1.1  mrg gbind *
    590  1.1  mrg gimple_build_bind (tree vars, gimple_seq body, tree block)
    591  1.1  mrg {
    592  1.1  mrg   gbind *p = as_a <gbind *> (gimple_alloc (GIMPLE_BIND, 0));
    593  1.1  mrg   gimple_bind_set_vars (p, vars);
    594  1.1  mrg   if (body)
    595  1.1  mrg     gimple_bind_set_body (p, body);
    596  1.1  mrg   if (block)
    597  1.1  mrg     gimple_bind_set_block (p, block);
    598  1.1  mrg   return p;
    599  1.1  mrg }
    600  1.1  mrg 
    601  1.1  mrg /* Helper function to set the simple fields of a asm stmt.
    602  1.1  mrg 
    603  1.1  mrg    STRING is a pointer to a string that is the asm blocks assembly code.
    604  1.1  mrg    NINPUT is the number of register inputs.
    605  1.1  mrg    NOUTPUT is the number of register outputs.
    606  1.1  mrg    NCLOBBERS is the number of clobbered registers.
    607  1.1  mrg    */
    608  1.1  mrg 
    609  1.1  mrg static inline gasm *
    610  1.1  mrg gimple_build_asm_1 (const char *string, unsigned ninputs, unsigned noutputs,
    611  1.1  mrg                     unsigned nclobbers, unsigned nlabels)
    612  1.1  mrg {
    613  1.1  mrg   gasm *p;
    614  1.1  mrg   int size = strlen (string);
    615  1.1  mrg 
    616  1.1  mrg   p = as_a <gasm *> (
    617  1.1  mrg         gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK,
    618  1.1  mrg 			       ninputs + noutputs + nclobbers + nlabels));
    619  1.1  mrg 
    620  1.1  mrg   p->ni = ninputs;
    621  1.1  mrg   p->no = noutputs;
    622  1.1  mrg   p->nc = nclobbers;
    623  1.1  mrg   p->nl = nlabels;
    624  1.1  mrg   p->string = ggc_alloc_string (string, size);
    625  1.1  mrg 
    626  1.1  mrg   if (GATHER_STATISTICS)
    627  1.1  mrg     gimple_alloc_sizes[(int) gimple_alloc_kind (GIMPLE_ASM)] += size;
    628  1.1  mrg 
    629  1.1  mrg   return p;
    630  1.1  mrg }
    631  1.1  mrg 
    632  1.1  mrg /* Build a GIMPLE_ASM statement.
    633  1.1  mrg 
    634  1.1  mrg    STRING is the assembly code.
    635  1.1  mrg    NINPUT is the number of register inputs.
    636  1.1  mrg    NOUTPUT is the number of register outputs.
    637  1.1  mrg    NCLOBBERS is the number of clobbered registers.
    638  1.1  mrg    INPUTS is a vector of the input register parameters.
    639  1.1  mrg    OUTPUTS is a vector of the output register parameters.
    640  1.1  mrg    CLOBBERS is a vector of the clobbered register parameters.
    641  1.1  mrg    LABELS is a vector of destination labels.  */
    642  1.1  mrg 
    643  1.1  mrg gasm *
    644  1.1  mrg gimple_build_asm_vec (const char *string, vec<tree, va_gc> *inputs,
    645  1.1  mrg                       vec<tree, va_gc> *outputs, vec<tree, va_gc> *clobbers,
    646  1.1  mrg 		      vec<tree, va_gc> *labels)
    647  1.1  mrg {
    648  1.1  mrg   gasm *p;
    649  1.1  mrg   unsigned i;
    650  1.1  mrg 
    651  1.1  mrg   p = gimple_build_asm_1 (string,
    652  1.1  mrg                           vec_safe_length (inputs),
    653  1.1  mrg                           vec_safe_length (outputs),
    654  1.1  mrg                           vec_safe_length (clobbers),
    655  1.1  mrg 			  vec_safe_length (labels));
    656  1.1  mrg 
    657  1.1  mrg   for (i = 0; i < vec_safe_length (inputs); i++)
    658  1.1  mrg     gimple_asm_set_input_op (p, i, (*inputs)[i]);
    659  1.1  mrg 
    660  1.1  mrg   for (i = 0; i < vec_safe_length (outputs); i++)
    661  1.1  mrg     gimple_asm_set_output_op (p, i, (*outputs)[i]);
    662  1.1  mrg 
    663  1.1  mrg   for (i = 0; i < vec_safe_length (clobbers); i++)
    664  1.1  mrg     gimple_asm_set_clobber_op (p, i, (*clobbers)[i]);
    665  1.1  mrg 
    666  1.1  mrg   for (i = 0; i < vec_safe_length (labels); i++)
    667  1.1  mrg     gimple_asm_set_label_op (p, i, (*labels)[i]);
    668  1.1  mrg 
    669  1.1  mrg   return p;
    670  1.1  mrg }
    671  1.1  mrg 
    672  1.1  mrg /* Build a GIMPLE_CATCH statement.
    673  1.1  mrg 
    674  1.1  mrg   TYPES are the catch types.
    675  1.1  mrg   HANDLER is the exception handler.  */
    676  1.1  mrg 
    677  1.1  mrg gcatch *
    678  1.1  mrg gimple_build_catch (tree types, gimple_seq handler)
    679  1.1  mrg {
    680  1.1  mrg   gcatch *p = as_a <gcatch *> (gimple_alloc (GIMPLE_CATCH, 0));
    681  1.1  mrg   gimple_catch_set_types (p, types);
    682  1.1  mrg   if (handler)
    683  1.1  mrg     gimple_catch_set_handler (p, handler);
    684  1.1  mrg 
    685  1.1  mrg   return p;
    686  1.1  mrg }
    687  1.1  mrg 
    688  1.1  mrg /* Build a GIMPLE_EH_FILTER statement.
    689  1.1  mrg 
    690  1.1  mrg    TYPES are the filter's types.
    691  1.1  mrg    FAILURE is the filter's failure action.  */
    692  1.1  mrg 
    693  1.1  mrg geh_filter *
    694  1.1  mrg gimple_build_eh_filter (tree types, gimple_seq failure)
    695  1.1  mrg {
    696  1.1  mrg   geh_filter *p = as_a <geh_filter *> (gimple_alloc (GIMPLE_EH_FILTER, 0));
    697  1.1  mrg   gimple_eh_filter_set_types (p, types);
    698  1.1  mrg   if (failure)
    699  1.1  mrg     gimple_eh_filter_set_failure (p, failure);
    700  1.1  mrg 
    701  1.1  mrg   return p;
    702  1.1  mrg }
    703  1.1  mrg 
    704  1.1  mrg /* Build a GIMPLE_EH_MUST_NOT_THROW statement.  */
    705  1.1  mrg 
    706  1.1  mrg geh_mnt *
    707  1.1  mrg gimple_build_eh_must_not_throw (tree decl)
    708  1.1  mrg {
    709  1.1  mrg   geh_mnt *p = as_a <geh_mnt *> (gimple_alloc (GIMPLE_EH_MUST_NOT_THROW, 0));
    710  1.1  mrg 
    711  1.1  mrg   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
    712  1.1  mrg   gcc_assert (flags_from_decl_or_type (decl) & ECF_NORETURN);
    713  1.1  mrg   gimple_eh_must_not_throw_set_fndecl (p, decl);
    714  1.1  mrg 
    715  1.1  mrg   return p;
    716  1.1  mrg }
    717  1.1  mrg 
    718  1.1  mrg /* Build a GIMPLE_EH_ELSE statement.  */
    719  1.1  mrg 
    720  1.1  mrg geh_else *
    721  1.1  mrg gimple_build_eh_else (gimple_seq n_body, gimple_seq e_body)
    722  1.1  mrg {
    723  1.1  mrg   geh_else *p = as_a <geh_else *> (gimple_alloc (GIMPLE_EH_ELSE, 0));
    724  1.1  mrg   gimple_eh_else_set_n_body (p, n_body);
    725  1.1  mrg   gimple_eh_else_set_e_body (p, e_body);
    726  1.1  mrg   return p;
    727  1.1  mrg }
    728  1.1  mrg 
    729  1.1  mrg /* Build a GIMPLE_TRY statement.
    730  1.1  mrg 
    731  1.1  mrg    EVAL is the expression to evaluate.
    732  1.1  mrg    CLEANUP is the cleanup expression.
    733  1.1  mrg    KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on
    734  1.1  mrg    whether this is a try/catch or a try/finally respectively.  */
    735  1.1  mrg 
    736  1.1  mrg gtry *
    737  1.1  mrg gimple_build_try (gimple_seq eval, gimple_seq cleanup,
    738  1.1  mrg     		  enum gimple_try_flags kind)
    739  1.1  mrg {
    740  1.1  mrg   gtry *p;
    741  1.1  mrg 
    742  1.1  mrg   gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY);
    743  1.1  mrg   p = as_a <gtry *> (gimple_alloc (GIMPLE_TRY, 0));
    744  1.1  mrg   gimple_set_subcode (p, kind);
    745  1.1  mrg   if (eval)
    746  1.1  mrg     gimple_try_set_eval (p, eval);
    747  1.1  mrg   if (cleanup)
    748  1.1  mrg     gimple_try_set_cleanup (p, cleanup);
    749  1.1  mrg 
    750  1.1  mrg   return p;
    751  1.1  mrg }
    752  1.1  mrg 
    753  1.1  mrg /* Construct a GIMPLE_WITH_CLEANUP_EXPR statement.
    754  1.1  mrg 
    755  1.1  mrg    CLEANUP is the cleanup expression.  */
    756  1.1  mrg 
    757  1.1  mrg gimple *
    758  1.1  mrg gimple_build_wce (gimple_seq cleanup)
    759  1.1  mrg {
    760  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_WITH_CLEANUP_EXPR, 0);
    761  1.1  mrg   if (cleanup)
    762  1.1  mrg     gimple_wce_set_cleanup (p, cleanup);
    763  1.1  mrg 
    764  1.1  mrg   return p;
    765  1.1  mrg }
    766  1.1  mrg 
    767  1.1  mrg 
    768  1.1  mrg /* Build a GIMPLE_RESX statement.  */
    769  1.1  mrg 
    770  1.1  mrg gresx *
    771  1.1  mrg gimple_build_resx (int region)
    772  1.1  mrg {
    773  1.1  mrg   gresx *p
    774  1.1  mrg     = as_a <gresx *> (gimple_build_with_ops (GIMPLE_RESX, ERROR_MARK, 0));
    775  1.1  mrg   p->region = region;
    776  1.1  mrg   return p;
    777  1.1  mrg }
    778  1.1  mrg 
    779  1.1  mrg 
    780  1.1  mrg /* The helper for constructing a gimple switch statement.
    781  1.1  mrg    INDEX is the switch's index.
    782  1.1  mrg    NLABELS is the number of labels in the switch excluding the default.
    783  1.1  mrg    DEFAULT_LABEL is the default label for the switch statement.  */
    784  1.1  mrg 
    785  1.1  mrg gswitch *
    786  1.1  mrg gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label)
    787  1.1  mrg {
    788  1.1  mrg   /* nlabels + 1 default label + 1 index.  */
    789  1.1  mrg   gcc_checking_assert (default_label);
    790  1.1  mrg   gswitch *p = as_a <gswitch *> (gimple_build_with_ops (GIMPLE_SWITCH,
    791  1.1  mrg 							ERROR_MARK,
    792  1.1  mrg 							1 + 1 + nlabels));
    793  1.1  mrg   gimple_switch_set_index (p, index);
    794  1.1  mrg   gimple_switch_set_default_label (p, default_label);
    795  1.1  mrg   return p;
    796  1.1  mrg }
    797  1.1  mrg 
    798  1.1  mrg /* Build a GIMPLE_SWITCH statement.
    799  1.1  mrg 
    800  1.1  mrg    INDEX is the switch's index.
    801  1.1  mrg    DEFAULT_LABEL is the default label
    802  1.1  mrg    ARGS is a vector of labels excluding the default.  */
    803  1.1  mrg 
    804  1.1  mrg gswitch *
    805  1.1  mrg gimple_build_switch (tree index, tree default_label, const vec<tree> &args)
    806  1.1  mrg {
    807  1.1  mrg   unsigned i, nlabels = args.length ();
    808  1.1  mrg 
    809  1.1  mrg   gswitch *p = gimple_build_switch_nlabels (nlabels, index, default_label);
    810  1.1  mrg 
    811  1.1  mrg   /* Copy the labels from the vector to the switch statement.  */
    812  1.1  mrg   for (i = 0; i < nlabels; i++)
    813  1.1  mrg     gimple_switch_set_label (p, i + 1, args[i]);
    814  1.1  mrg 
    815  1.1  mrg   return p;
    816  1.1  mrg }
    817  1.1  mrg 
    818  1.1  mrg /* Build a GIMPLE_EH_DISPATCH statement.  */
    819  1.1  mrg 
    820  1.1  mrg geh_dispatch *
    821  1.1  mrg gimple_build_eh_dispatch (int region)
    822  1.1  mrg {
    823  1.1  mrg   geh_dispatch *p
    824  1.1  mrg     = as_a <geh_dispatch *> (
    825  1.1  mrg 	gimple_build_with_ops (GIMPLE_EH_DISPATCH, ERROR_MARK, 0));
    826  1.1  mrg   p->region = region;
    827  1.1  mrg   return p;
    828  1.1  mrg }
    829  1.1  mrg 
    830  1.1  mrg /* Build a new GIMPLE_DEBUG_BIND statement.
    831  1.1  mrg 
    832  1.1  mrg    VAR is bound to VALUE; block and location are taken from STMT.  */
    833  1.1  mrg 
    834  1.1  mrg gdebug *
    835  1.1  mrg gimple_build_debug_bind (tree var, tree value, gimple *stmt MEM_STAT_DECL)
    836  1.1  mrg {
    837  1.1  mrg   gdebug *p
    838  1.1  mrg     = as_a <gdebug *> (gimple_build_with_ops_stat (GIMPLE_DEBUG,
    839  1.1  mrg 						   (unsigned)GIMPLE_DEBUG_BIND, 2
    840  1.1  mrg 						   PASS_MEM_STAT));
    841  1.1  mrg   gimple_debug_bind_set_var (p, var);
    842  1.1  mrg   gimple_debug_bind_set_value (p, value);
    843  1.1  mrg   if (stmt)
    844  1.1  mrg     gimple_set_location (p, gimple_location (stmt));
    845  1.1  mrg 
    846  1.1  mrg   return p;
    847  1.1  mrg }
    848  1.1  mrg 
    849  1.1  mrg 
    850  1.1  mrg /* Build a new GIMPLE_DEBUG_SOURCE_BIND statement.
    851  1.1  mrg 
    852  1.1  mrg    VAR is bound to VALUE; block and location are taken from STMT.  */
    853  1.1  mrg 
    854  1.1  mrg gdebug *
    855  1.1  mrg gimple_build_debug_source_bind (tree var, tree value,
    856  1.1  mrg 				     gimple *stmt MEM_STAT_DECL)
    857  1.1  mrg {
    858  1.1  mrg   gdebug *p
    859  1.1  mrg     = as_a <gdebug *> (
    860  1.1  mrg         gimple_build_with_ops_stat (GIMPLE_DEBUG,
    861  1.1  mrg 				    (unsigned)GIMPLE_DEBUG_SOURCE_BIND, 2
    862  1.1  mrg 				    PASS_MEM_STAT));
    863  1.1  mrg 
    864  1.1  mrg   gimple_debug_source_bind_set_var (p, var);
    865  1.1  mrg   gimple_debug_source_bind_set_value (p, value);
    866  1.1  mrg   if (stmt)
    867  1.1  mrg     gimple_set_location (p, gimple_location (stmt));
    868  1.1  mrg 
    869  1.1  mrg   return p;
    870  1.1  mrg }
    871  1.1  mrg 
    872  1.1  mrg 
    873  1.1  mrg /* Build a new GIMPLE_DEBUG_BEGIN_STMT statement in BLOCK at
    874  1.1  mrg    LOCATION.  */
    875  1.1  mrg 
    876  1.1  mrg gdebug *
    877  1.1  mrg gimple_build_debug_begin_stmt (tree block, location_t location
    878  1.1  mrg 				    MEM_STAT_DECL)
    879  1.1  mrg {
    880  1.1  mrg   gdebug *p
    881  1.1  mrg     = as_a <gdebug *> (
    882  1.1  mrg         gimple_build_with_ops_stat (GIMPLE_DEBUG,
    883  1.1  mrg 				    (unsigned)GIMPLE_DEBUG_BEGIN_STMT, 0
    884  1.1  mrg 				    PASS_MEM_STAT));
    885  1.1  mrg 
    886  1.1  mrg   gimple_set_location (p, location);
    887  1.1  mrg   gimple_set_block (p, block);
    888  1.1  mrg   cfun->debug_marker_count++;
    889  1.1  mrg 
    890  1.1  mrg   return p;
    891  1.1  mrg }
    892  1.1  mrg 
    893  1.1  mrg 
    894  1.1  mrg /* Build a new GIMPLE_DEBUG_INLINE_ENTRY statement in BLOCK at
    895  1.1  mrg    LOCATION.  The BLOCK links to the inlined function.  */
    896  1.1  mrg 
    897  1.1  mrg gdebug *
    898  1.1  mrg gimple_build_debug_inline_entry (tree block, location_t location
    899  1.1  mrg 				      MEM_STAT_DECL)
    900  1.1  mrg {
    901  1.1  mrg   gdebug *p
    902  1.1  mrg     = as_a <gdebug *> (
    903  1.1  mrg         gimple_build_with_ops_stat (GIMPLE_DEBUG,
    904  1.1  mrg 				    (unsigned)GIMPLE_DEBUG_INLINE_ENTRY, 0
    905  1.1  mrg 				    PASS_MEM_STAT));
    906  1.1  mrg 
    907  1.1  mrg   gimple_set_location (p, location);
    908  1.1  mrg   gimple_set_block (p, block);
    909  1.1  mrg   cfun->debug_marker_count++;
    910  1.1  mrg 
    911  1.1  mrg   return p;
    912  1.1  mrg }
    913  1.1  mrg 
    914  1.1  mrg 
    915  1.1  mrg /* Build a GIMPLE_OMP_CRITICAL statement.
    916  1.1  mrg 
    917  1.1  mrg    BODY is the sequence of statements for which only one thread can execute.
    918  1.1  mrg    NAME is optional identifier for this critical block.
    919  1.1  mrg    CLAUSES are clauses for this critical block.  */
    920  1.1  mrg 
    921  1.1  mrg gomp_critical *
    922  1.1  mrg gimple_build_omp_critical (gimple_seq body, tree name, tree clauses)
    923  1.1  mrg {
    924  1.1  mrg   gomp_critical *p
    925  1.1  mrg     = as_a <gomp_critical *> (gimple_alloc (GIMPLE_OMP_CRITICAL, 0));
    926  1.1  mrg   gimple_omp_critical_set_name (p, name);
    927  1.1  mrg   gimple_omp_critical_set_clauses (p, clauses);
    928  1.1  mrg   if (body)
    929  1.1  mrg     gimple_omp_set_body (p, body);
    930  1.1  mrg 
    931  1.1  mrg   return p;
    932  1.1  mrg }
    933  1.1  mrg 
    934  1.1  mrg /* Build a GIMPLE_OMP_FOR statement.
    935  1.1  mrg 
    936  1.1  mrg    BODY is sequence of statements inside the for loop.
    937  1.1  mrg    KIND is the `for' variant.
    938  1.1  mrg    CLAUSES are any of the construct's clauses.
    939  1.1  mrg    COLLAPSE is the collapse count.
    940  1.1  mrg    PRE_BODY is the sequence of statements that are loop invariant.  */
    941  1.1  mrg 
    942  1.1  mrg gomp_for *
    943  1.1  mrg gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
    944  1.1  mrg 		      gimple_seq pre_body)
    945  1.1  mrg {
    946  1.1  mrg   gomp_for *p = as_a <gomp_for *> (gimple_alloc (GIMPLE_OMP_FOR, 0));
    947  1.1  mrg   if (body)
    948  1.1  mrg     gimple_omp_set_body (p, body);
    949  1.1  mrg   gimple_omp_for_set_clauses (p, clauses);
    950  1.1  mrg   gimple_omp_for_set_kind (p, kind);
    951  1.1  mrg   p->collapse = collapse;
    952  1.1  mrg   p->iter =  ggc_cleared_vec_alloc<gimple_omp_for_iter> (collapse);
    953  1.1  mrg 
    954  1.1  mrg   if (pre_body)
    955  1.1  mrg     gimple_omp_for_set_pre_body (p, pre_body);
    956  1.1  mrg 
    957  1.1  mrg   return p;
    958  1.1  mrg }
    959  1.1  mrg 
    960  1.1  mrg 
    961  1.1  mrg /* Build a GIMPLE_OMP_PARALLEL statement.
    962  1.1  mrg 
    963  1.1  mrg    BODY is sequence of statements which are executed in parallel.
    964  1.1  mrg    CLAUSES are the OMP parallel construct's clauses.
    965  1.1  mrg    CHILD_FN is the function created for the parallel threads to execute.
    966  1.1  mrg    DATA_ARG are the shared data argument(s).  */
    967  1.1  mrg 
    968  1.1  mrg gomp_parallel *
    969  1.1  mrg gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
    970  1.1  mrg 			   tree data_arg)
    971  1.1  mrg {
    972  1.1  mrg   gomp_parallel *p
    973  1.1  mrg     = as_a <gomp_parallel *> (gimple_alloc (GIMPLE_OMP_PARALLEL, 0));
    974  1.1  mrg   if (body)
    975  1.1  mrg     gimple_omp_set_body (p, body);
    976  1.1  mrg   gimple_omp_parallel_set_clauses (p, clauses);
    977  1.1  mrg   gimple_omp_parallel_set_child_fn (p, child_fn);
    978  1.1  mrg   gimple_omp_parallel_set_data_arg (p, data_arg);
    979  1.1  mrg 
    980  1.1  mrg   return p;
    981  1.1  mrg }
    982  1.1  mrg 
    983  1.1  mrg 
    984  1.1  mrg /* Build a GIMPLE_OMP_TASK statement.
    985  1.1  mrg 
    986  1.1  mrg    BODY is sequence of statements which are executed by the explicit task.
    987  1.1  mrg    CLAUSES are the OMP task construct's clauses.
    988  1.1  mrg    CHILD_FN is the function created for the parallel threads to execute.
    989  1.1  mrg    DATA_ARG are the shared data argument(s).
    990  1.1  mrg    COPY_FN is the optional function for firstprivate initialization.
    991  1.1  mrg    ARG_SIZE and ARG_ALIGN are size and alignment of the data block.  */
    992  1.1  mrg 
    993  1.1  mrg gomp_task *
    994  1.1  mrg gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn,
    995  1.1  mrg 		       tree data_arg, tree copy_fn, tree arg_size,
    996  1.1  mrg 		       tree arg_align)
    997  1.1  mrg {
    998  1.1  mrg   gomp_task *p = as_a <gomp_task *> (gimple_alloc (GIMPLE_OMP_TASK, 0));
    999  1.1  mrg   if (body)
   1000  1.1  mrg     gimple_omp_set_body (p, body);
   1001  1.1  mrg   gimple_omp_task_set_clauses (p, clauses);
   1002  1.1  mrg   gimple_omp_task_set_child_fn (p, child_fn);
   1003  1.1  mrg   gimple_omp_task_set_data_arg (p, data_arg);
   1004  1.1  mrg   gimple_omp_task_set_copy_fn (p, copy_fn);
   1005  1.1  mrg   gimple_omp_task_set_arg_size (p, arg_size);
   1006  1.1  mrg   gimple_omp_task_set_arg_align (p, arg_align);
   1007  1.1  mrg 
   1008  1.1  mrg   return p;
   1009  1.1  mrg }
   1010  1.1  mrg 
   1011  1.1  mrg 
   1012  1.1  mrg /* Build a GIMPLE_OMP_SECTION statement for a sections statement.
   1013  1.1  mrg 
   1014  1.1  mrg    BODY is the sequence of statements in the section.  */
   1015  1.1  mrg 
   1016  1.1  mrg gimple *
   1017  1.1  mrg gimple_build_omp_section (gimple_seq body)
   1018  1.1  mrg {
   1019  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_SECTION, 0);
   1020  1.1  mrg   if (body)
   1021  1.1  mrg     gimple_omp_set_body (p, body);
   1022  1.1  mrg 
   1023  1.1  mrg   return p;
   1024  1.1  mrg }
   1025  1.1  mrg 
   1026  1.1  mrg 
   1027  1.1  mrg /* Build a GIMPLE_OMP_MASTER statement.
   1028  1.1  mrg 
   1029  1.1  mrg    BODY is the sequence of statements to be executed by just the master.  */
   1030  1.1  mrg 
   1031  1.1  mrg gimple *
   1032  1.1  mrg gimple_build_omp_master (gimple_seq body)
   1033  1.1  mrg {
   1034  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_MASTER, 0);
   1035  1.1  mrg   if (body)
   1036  1.1  mrg     gimple_omp_set_body (p, body);
   1037  1.1  mrg 
   1038  1.1  mrg   return p;
   1039  1.1  mrg }
   1040  1.1  mrg 
   1041  1.1  mrg /* Build a GIMPLE_OMP_MASKED statement.
   1042  1.1  mrg 
   1043  1.1  mrg    BODY is the sequence of statements to be executed by the selected thread(s).  */
   1044  1.1  mrg 
   1045  1.1  mrg gimple *
   1046  1.1  mrg gimple_build_omp_masked (gimple_seq body, tree clauses)
   1047  1.1  mrg {
   1048  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_MASKED, 0);
   1049  1.1  mrg   gimple_omp_masked_set_clauses (p, clauses);
   1050  1.1  mrg   if (body)
   1051  1.1  mrg     gimple_omp_set_body (p, body);
   1052  1.1  mrg 
   1053  1.1  mrg   return p;
   1054  1.1  mrg }
   1055  1.1  mrg 
   1056  1.1  mrg /* Build a GIMPLE_OMP_TASKGROUP statement.
   1057  1.1  mrg 
   1058  1.1  mrg    BODY is the sequence of statements to be executed by the taskgroup
   1059  1.1  mrg    construct.
   1060  1.1  mrg    CLAUSES are any of the construct's clauses.  */
   1061  1.1  mrg 
   1062  1.1  mrg gimple *
   1063  1.1  mrg gimple_build_omp_taskgroup (gimple_seq body, tree clauses)
   1064  1.1  mrg {
   1065  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0);
   1066  1.1  mrg   gimple_omp_taskgroup_set_clauses (p, clauses);
   1067  1.1  mrg   if (body)
   1068  1.1  mrg     gimple_omp_set_body (p, body);
   1069  1.1  mrg 
   1070  1.1  mrg   return p;
   1071  1.1  mrg }
   1072  1.1  mrg 
   1073  1.1  mrg 
   1074  1.1  mrg /* Build a GIMPLE_OMP_CONTINUE statement.
   1075  1.1  mrg 
   1076  1.1  mrg    CONTROL_DEF is the definition of the control variable.
   1077  1.1  mrg    CONTROL_USE is the use of the control variable.  */
   1078  1.1  mrg 
   1079  1.1  mrg gomp_continue *
   1080  1.1  mrg gimple_build_omp_continue (tree control_def, tree control_use)
   1081  1.1  mrg {
   1082  1.1  mrg   gomp_continue *p
   1083  1.1  mrg     = as_a <gomp_continue *> (gimple_alloc (GIMPLE_OMP_CONTINUE, 0));
   1084  1.1  mrg   gimple_omp_continue_set_control_def (p, control_def);
   1085  1.1  mrg   gimple_omp_continue_set_control_use (p, control_use);
   1086  1.1  mrg   return p;
   1087  1.1  mrg }
   1088  1.1  mrg 
   1089  1.1  mrg /* Build a GIMPLE_OMP_ORDERED statement.
   1090  1.1  mrg 
   1091  1.1  mrg    BODY is the sequence of statements inside a loop that will executed in
   1092  1.1  mrg    sequence.
   1093  1.1  mrg    CLAUSES are clauses for this statement.  */
   1094  1.1  mrg 
   1095  1.1  mrg gomp_ordered *
   1096  1.1  mrg gimple_build_omp_ordered (gimple_seq body, tree clauses)
   1097  1.1  mrg {
   1098  1.1  mrg   gomp_ordered *p
   1099  1.1  mrg     = as_a <gomp_ordered *> (gimple_alloc (GIMPLE_OMP_ORDERED, 0));
   1100  1.1  mrg   gimple_omp_ordered_set_clauses (p, clauses);
   1101  1.1  mrg   if (body)
   1102  1.1  mrg     gimple_omp_set_body (p, body);
   1103  1.1  mrg 
   1104  1.1  mrg   return p;
   1105  1.1  mrg }
   1106  1.1  mrg 
   1107  1.1  mrg 
   1108  1.1  mrg /* Build a GIMPLE_OMP_RETURN statement.
   1109  1.1  mrg    WAIT_P is true if this is a non-waiting return.  */
   1110  1.1  mrg 
   1111  1.1  mrg gimple *
   1112  1.1  mrg gimple_build_omp_return (bool wait_p)
   1113  1.1  mrg {
   1114  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0);
   1115  1.1  mrg   if (wait_p)
   1116  1.1  mrg     gimple_omp_return_set_nowait (p);
   1117  1.1  mrg 
   1118  1.1  mrg   return p;
   1119  1.1  mrg }
   1120  1.1  mrg 
   1121  1.1  mrg 
   1122  1.1  mrg /* Build a GIMPLE_OMP_SCAN statement.
   1123  1.1  mrg 
   1124  1.1  mrg    BODY is the sequence of statements to be executed by the scan
   1125  1.1  mrg    construct.
   1126  1.1  mrg    CLAUSES are any of the construct's clauses.  */
   1127  1.1  mrg 
   1128  1.1  mrg gomp_scan *
   1129  1.1  mrg gimple_build_omp_scan (gimple_seq body, tree clauses)
   1130  1.1  mrg {
   1131  1.1  mrg   gomp_scan *p
   1132  1.1  mrg     = as_a <gomp_scan *> (gimple_alloc (GIMPLE_OMP_SCAN, 0));
   1133  1.1  mrg   gimple_omp_scan_set_clauses (p, clauses);
   1134  1.1  mrg   if (body)
   1135  1.1  mrg     gimple_omp_set_body (p, body);
   1136  1.1  mrg 
   1137  1.1  mrg   return p;
   1138  1.1  mrg }
   1139  1.1  mrg 
   1140  1.1  mrg 
   1141  1.1  mrg /* Build a GIMPLE_OMP_SECTIONS statement.
   1142  1.1  mrg 
   1143  1.1  mrg    BODY is a sequence of section statements.
   1144  1.1  mrg    CLAUSES are any of the OMP sections contsruct's clauses: private,
   1145  1.1  mrg    firstprivate, lastprivate, reduction, and nowait.  */
   1146  1.1  mrg 
   1147  1.1  mrg gomp_sections *
   1148  1.1  mrg gimple_build_omp_sections (gimple_seq body, tree clauses)
   1149  1.1  mrg {
   1150  1.1  mrg   gomp_sections *p
   1151  1.1  mrg     = as_a <gomp_sections *> (gimple_alloc (GIMPLE_OMP_SECTIONS, 0));
   1152  1.1  mrg   if (body)
   1153  1.1  mrg     gimple_omp_set_body (p, body);
   1154  1.1  mrg   gimple_omp_sections_set_clauses (p, clauses);
   1155  1.1  mrg 
   1156  1.1  mrg   return p;
   1157  1.1  mrg }
   1158  1.1  mrg 
   1159  1.1  mrg 
   1160  1.1  mrg /* Build a GIMPLE_OMP_SECTIONS_SWITCH.  */
   1161  1.1  mrg 
   1162  1.1  mrg gimple *
   1163  1.1  mrg gimple_build_omp_sections_switch (void)
   1164  1.1  mrg {
   1165  1.1  mrg   return gimple_alloc (GIMPLE_OMP_SECTIONS_SWITCH, 0);
   1166  1.1  mrg }
   1167  1.1  mrg 
   1168  1.1  mrg 
   1169  1.1  mrg /* Build a GIMPLE_OMP_SINGLE statement.
   1170  1.1  mrg 
   1171  1.1  mrg    BODY is the sequence of statements that will be executed once.
   1172  1.1  mrg    CLAUSES are any of the OMP single construct's clauses: private, firstprivate,
   1173  1.1  mrg    copyprivate, nowait.  */
   1174  1.1  mrg 
   1175  1.1  mrg gomp_single *
   1176  1.1  mrg gimple_build_omp_single (gimple_seq body, tree clauses)
   1177  1.1  mrg {
   1178  1.1  mrg   gomp_single *p
   1179  1.1  mrg     = as_a <gomp_single *> (gimple_alloc (GIMPLE_OMP_SINGLE, 0));
   1180  1.1  mrg   if (body)
   1181  1.1  mrg     gimple_omp_set_body (p, body);
   1182  1.1  mrg   gimple_omp_single_set_clauses (p, clauses);
   1183  1.1  mrg 
   1184  1.1  mrg   return p;
   1185  1.1  mrg }
   1186  1.1  mrg 
   1187  1.1  mrg 
   1188  1.1  mrg /* Build a GIMPLE_OMP_SCOPE statement.
   1189  1.1  mrg 
   1190  1.1  mrg    BODY is the sequence of statements that will be executed once.
   1191  1.1  mrg    CLAUSES are any of the OMP scope construct's clauses: private, reduction,
   1192  1.1  mrg    nowait.  */
   1193  1.1  mrg 
   1194  1.1  mrg gimple *
   1195  1.1  mrg gimple_build_omp_scope (gimple_seq body, tree clauses)
   1196  1.1  mrg {
   1197  1.1  mrg   gimple *p = gimple_alloc (GIMPLE_OMP_SCOPE, 0);
   1198  1.1  mrg   gimple_omp_scope_set_clauses (p, clauses);
   1199  1.1  mrg   if (body)
   1200  1.1  mrg     gimple_omp_set_body (p, body);
   1201  1.1  mrg 
   1202  1.1  mrg   return p;
   1203  1.1  mrg }
   1204  1.1  mrg 
   1205  1.1  mrg 
   1206  1.1  mrg /* Build a GIMPLE_OMP_TARGET statement.
   1207  1.1  mrg 
   1208  1.1  mrg    BODY is the sequence of statements that will be executed.
   1209  1.1  mrg    KIND is the kind of the region.
   1210  1.1  mrg    CLAUSES are any of the construct's clauses.  */
   1211  1.1  mrg 
   1212  1.1  mrg gomp_target *
   1213  1.1  mrg gimple_build_omp_target (gimple_seq body, int kind, tree clauses)
   1214  1.1  mrg {
   1215  1.1  mrg   gomp_target *p
   1216  1.1  mrg     = as_a <gomp_target *> (gimple_alloc (GIMPLE_OMP_TARGET, 0));
   1217  1.1  mrg   if (body)
   1218  1.1  mrg     gimple_omp_set_body (p, body);
   1219  1.1  mrg   gimple_omp_target_set_clauses (p, clauses);
   1220  1.1  mrg   gimple_omp_target_set_kind (p, kind);
   1221  1.1  mrg 
   1222  1.1  mrg   return p;
   1223  1.1  mrg }
   1224  1.1  mrg 
   1225  1.1  mrg 
   1226  1.1  mrg /* Build a GIMPLE_OMP_TEAMS statement.
   1227  1.1  mrg 
   1228  1.1  mrg    BODY is the sequence of statements that will be executed.
   1229  1.1  mrg    CLAUSES are any of the OMP teams construct's clauses.  */
   1230  1.1  mrg 
   1231  1.1  mrg gomp_teams *
   1232  1.1  mrg gimple_build_omp_teams (gimple_seq body, tree clauses)
   1233  1.1  mrg {
   1234  1.1  mrg   gomp_teams *p = as_a <gomp_teams *> (gimple_alloc (GIMPLE_OMP_TEAMS, 0));
   1235  1.1  mrg   if (body)
   1236  1.1  mrg     gimple_omp_set_body (p, body);
   1237  1.1  mrg   gimple_omp_teams_set_clauses (p, clauses);
   1238  1.1  mrg 
   1239  1.1  mrg   return p;
   1240  1.1  mrg }
   1241  1.1  mrg 
   1242  1.1  mrg 
   1243  1.1  mrg /* Build a GIMPLE_OMP_ATOMIC_LOAD statement.  */
   1244  1.1  mrg 
   1245  1.1  mrg gomp_atomic_load *
   1246  1.1  mrg gimple_build_omp_atomic_load (tree lhs, tree rhs, enum omp_memory_order mo)
   1247  1.1  mrg {
   1248  1.1  mrg   gomp_atomic_load *p
   1249  1.1  mrg     = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0));
   1250  1.1  mrg   gimple_omp_atomic_load_set_lhs (p, lhs);
   1251  1.1  mrg   gimple_omp_atomic_load_set_rhs (p, rhs);
   1252  1.1  mrg   gimple_omp_atomic_set_memory_order (p, mo);
   1253  1.1  mrg   return p;
   1254  1.1  mrg }
   1255  1.1  mrg 
   1256  1.1  mrg /* Build a GIMPLE_OMP_ATOMIC_STORE statement.
   1257  1.1  mrg 
   1258  1.1  mrg    VAL is the value we are storing.  */
   1259  1.1  mrg 
   1260  1.1  mrg gomp_atomic_store *
   1261  1.1  mrg gimple_build_omp_atomic_store (tree val, enum omp_memory_order mo)
   1262  1.1  mrg {
   1263  1.1  mrg   gomp_atomic_store *p
   1264  1.1  mrg     = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0));
   1265  1.1  mrg   gimple_omp_atomic_store_set_val (p, val);
   1266  1.1  mrg   gimple_omp_atomic_set_memory_order (p, mo);
   1267  1.1  mrg   return p;
   1268  1.1  mrg }
   1269  1.1  mrg 
   1270  1.1  mrg /* Build a GIMPLE_TRANSACTION statement.  */
   1271  1.1  mrg 
   1272  1.1  mrg gtransaction *
   1273  1.1  mrg gimple_build_transaction (gimple_seq body)
   1274  1.1  mrg {
   1275  1.1  mrg   gtransaction *p
   1276  1.1  mrg     = as_a <gtransaction *> (gimple_alloc (GIMPLE_TRANSACTION, 0));
   1277  1.1  mrg   gimple_transaction_set_body (p, body);
   1278  1.1  mrg   gimple_transaction_set_label_norm (p, 0);
   1279  1.1  mrg   gimple_transaction_set_label_uninst (p, 0);
   1280  1.1  mrg   gimple_transaction_set_label_over (p, 0);
   1281  1.1  mrg   return p;
   1282  1.1  mrg }
   1283  1.1  mrg 
   1284  1.1  mrg #if defined ENABLE_GIMPLE_CHECKING
   1285  1.1  mrg /* Complain of a gimple type mismatch and die.  */
   1286  1.1  mrg 
   1287  1.1  mrg void
   1288  1.1  mrg gimple_check_failed (const gimple *gs, const char *file, int line,
   1289  1.1  mrg 		     const char *function, enum gimple_code code,
   1290  1.1  mrg 		     enum tree_code subcode)
   1291  1.1  mrg {
   1292  1.1  mrg   internal_error ("gimple check: expected %s(%s), have %s(%s) in %s, at %s:%d",
   1293  1.1  mrg       		  gimple_code_name[code],
   1294  1.1  mrg 		  get_tree_code_name (subcode),
   1295  1.1  mrg 		  gimple_code_name[gimple_code (gs)],
   1296  1.1  mrg 		  gs->subcode > 0
   1297  1.1  mrg 		    ? get_tree_code_name ((enum tree_code) gs->subcode)
   1298  1.1  mrg 		    : "",
   1299  1.1  mrg 		  function, trim_filename (file), line);
   1300  1.1  mrg }
   1301  1.1  mrg #endif /* ENABLE_GIMPLE_CHECKING */
   1302  1.1  mrg 
   1303  1.1  mrg 
   1304  1.1  mrg /* Link gimple statement GS to the end of the sequence *SEQ_P.  If
   1305  1.1  mrg    *SEQ_P is NULL, a new sequence is allocated.  */
   1306  1.1  mrg 
   1307  1.1  mrg void
   1308  1.1  mrg gimple_seq_add_stmt (gimple_seq *seq_p, gimple *gs)
   1309  1.1  mrg {
   1310  1.1  mrg   gimple_stmt_iterator si;
   1311  1.1  mrg   if (gs == NULL)
   1312  1.1  mrg     return;
   1313  1.1  mrg 
   1314  1.1  mrg   si = gsi_last (*seq_p);
   1315  1.1  mrg   gsi_insert_after (&si, gs, GSI_NEW_STMT);
   1316  1.1  mrg }
   1317  1.1  mrg 
   1318  1.1  mrg /* Link gimple statement GS to the end of the sequence *SEQ_P.  If
   1319  1.1  mrg    *SEQ_P is NULL, a new sequence is allocated.  This function is
   1320  1.1  mrg    similar to gimple_seq_add_stmt, but does not scan the operands.
   1321  1.1  mrg    During gimplification, we need to manipulate statement sequences
   1322  1.1  mrg    before the def/use vectors have been constructed.  */
   1323  1.1  mrg 
   1324  1.1  mrg void
   1325  1.1  mrg gimple_seq_add_stmt_without_update (gimple_seq *seq_p, gimple *gs)
   1326  1.1  mrg {
   1327  1.1  mrg   gimple_stmt_iterator si;
   1328  1.1  mrg 
   1329  1.1  mrg   if (gs == NULL)
   1330  1.1  mrg     return;
   1331  1.1  mrg 
   1332  1.1  mrg   si = gsi_last (*seq_p);
   1333  1.1  mrg   gsi_insert_after_without_update (&si, gs, GSI_NEW_STMT);
   1334  1.1  mrg }
   1335  1.1  mrg 
   1336  1.1  mrg /* Append sequence SRC to the end of sequence *DST_P.  If *DST_P is
   1337  1.1  mrg    NULL, a new sequence is allocated.  */
   1338  1.1  mrg 
   1339  1.1  mrg void
   1340  1.1  mrg gimple_seq_add_seq (gimple_seq *dst_p, gimple_seq src)
   1341  1.1  mrg {
   1342  1.1  mrg   gimple_stmt_iterator si;
   1343  1.1  mrg   if (src == NULL)
   1344  1.1  mrg     return;
   1345  1.1  mrg 
   1346  1.1  mrg   si = gsi_last (*dst_p);
   1347  1.1  mrg   gsi_insert_seq_after (&si, src, GSI_NEW_STMT);
   1348  1.1  mrg }
   1349  1.1  mrg 
   1350  1.1  mrg /* Append sequence SRC to the end of sequence *DST_P.  If *DST_P is
   1351  1.1  mrg    NULL, a new sequence is allocated.  This function is
   1352  1.1  mrg    similar to gimple_seq_add_seq, but does not scan the operands.  */
   1353  1.1  mrg 
   1354  1.1  mrg void
   1355  1.1  mrg gimple_seq_add_seq_without_update (gimple_seq *dst_p, gimple_seq src)
   1356  1.1  mrg {
   1357  1.1  mrg   gimple_stmt_iterator si;
   1358  1.1  mrg   if (src == NULL)
   1359  1.1  mrg     return;
   1360  1.1  mrg 
   1361  1.1  mrg   si = gsi_last (*dst_p);
   1362  1.1  mrg   gsi_insert_seq_after_without_update (&si, src, GSI_NEW_STMT);
   1363  1.1  mrg }
   1364  1.1  mrg 
   1365  1.1  mrg /* Determine whether to assign a location to the statement GS.  */
   1366  1.1  mrg 
   1367  1.1  mrg static bool
   1368  1.1  mrg should_carry_location_p (gimple *gs)
   1369  1.1  mrg {
   1370  1.1  mrg   /* Don't emit a line note for a label.  We particularly don't want to
   1371  1.1  mrg      emit one for the break label, since it doesn't actually correspond
   1372  1.1  mrg      to the beginning of the loop/switch.  */
   1373  1.1  mrg   if (gimple_code (gs) == GIMPLE_LABEL)
   1374  1.1  mrg     return false;
   1375  1.1  mrg 
   1376  1.1  mrg   return true;
   1377  1.1  mrg }
   1378  1.1  mrg 
   1379  1.1  mrg /* Set the location for gimple statement GS to LOCATION.  */
   1380  1.1  mrg 
   1381  1.1  mrg static void
   1382  1.1  mrg annotate_one_with_location (gimple *gs, location_t location)
   1383  1.1  mrg {
   1384  1.1  mrg   if (!gimple_has_location (gs)
   1385  1.1  mrg       && !gimple_do_not_emit_location_p (gs)
   1386  1.1  mrg       && should_carry_location_p (gs))
   1387  1.1  mrg     gimple_set_location (gs, location);
   1388  1.1  mrg }
   1389  1.1  mrg 
   1390  1.1  mrg /* Set LOCATION for all the statements after iterator GSI in sequence
   1391  1.1  mrg    SEQ.  If GSI is pointing to the end of the sequence, start with the
   1392  1.1  mrg    first statement in SEQ.  */
   1393  1.1  mrg 
   1394  1.1  mrg void
   1395  1.1  mrg annotate_all_with_location_after (gimple_seq seq, gimple_stmt_iterator gsi,
   1396  1.1  mrg 				  location_t location)
   1397  1.1  mrg {
   1398  1.1  mrg   if (gsi_end_p (gsi))
   1399  1.1  mrg     gsi = gsi_start (seq);
   1400  1.1  mrg   else
   1401  1.1  mrg     gsi_next (&gsi);
   1402  1.1  mrg 
   1403  1.1  mrg   for (; !gsi_end_p (gsi); gsi_next (&gsi))
   1404  1.1  mrg     annotate_one_with_location (gsi_stmt (gsi), location);
   1405  1.1  mrg }
   1406  1.1  mrg 
   1407  1.1  mrg /* Set the location for all the statements in a sequence STMT_P to LOCATION.  */
   1408  1.1  mrg 
   1409  1.1  mrg void
   1410  1.1  mrg annotate_all_with_location (gimple_seq stmt_p, location_t location)
   1411  1.1  mrg {
   1412  1.1  mrg   gimple_stmt_iterator i;
   1413  1.1  mrg 
   1414  1.1  mrg   if (gimple_seq_empty_p (stmt_p))
   1415  1.1  mrg     return;
   1416  1.1  mrg 
   1417  1.1  mrg   for (i = gsi_start (stmt_p); !gsi_end_p (i); gsi_next (&i))
   1418  1.1  mrg     {
   1419  1.1  mrg       gimple *gs = gsi_stmt (i);
   1420  1.1  mrg       annotate_one_with_location (gs, location);
   1421  1.1  mrg     }
   1422  1.1  mrg }
   1423  1.1  mrg 
   1424  1.1  mrg /* Helper function of empty_body_p.  Return true if STMT is an empty
   1425  1.1  mrg    statement.  */
   1426  1.1  mrg 
   1427  1.1  mrg static bool
   1428  1.1  mrg empty_stmt_p (gimple *stmt)
   1429  1.1  mrg {
   1430  1.1  mrg   if (gimple_code (stmt) == GIMPLE_NOP)
   1431  1.1  mrg     return true;
   1432  1.1  mrg   if (gbind *bind_stmt = dyn_cast <gbind *> (stmt))
   1433  1.1  mrg     return empty_body_p (gimple_bind_body (bind_stmt));
   1434  1.1  mrg   return false;
   1435  1.1  mrg }
   1436  1.1  mrg 
   1437  1.1  mrg 
   1438  1.1  mrg /* Return true if BODY contains nothing but empty statements.  */
   1439  1.1  mrg 
   1440  1.1  mrg bool
   1441  1.1  mrg empty_body_p (gimple_seq body)
   1442  1.1  mrg {
   1443  1.1  mrg   gimple_stmt_iterator i;
   1444  1.1  mrg 
   1445  1.1  mrg   if (gimple_seq_empty_p (body))
   1446  1.1  mrg     return true;
   1447  1.1  mrg   for (i = gsi_start (body); !gsi_end_p (i); gsi_next (&i))
   1448  1.1  mrg     if (!empty_stmt_p (gsi_stmt (i))
   1449  1.1  mrg 	&& !is_gimple_debug (gsi_stmt (i)))
   1450  1.1  mrg       return false;
   1451  1.1  mrg 
   1452  1.1  mrg   return true;
   1453  1.1  mrg }
   1454  1.1  mrg 
   1455  1.1  mrg 
   1456  1.1  mrg /* Perform a deep copy of sequence SRC and return the result.  */
   1457  1.1  mrg 
   1458  1.1  mrg gimple_seq
   1459  1.1  mrg gimple_seq_copy (gimple_seq src)
   1460  1.1  mrg {
   1461  1.1  mrg   gimple_stmt_iterator gsi;
   1462  1.1  mrg   gimple_seq new_seq = NULL;
   1463  1.1  mrg   gimple *stmt;
   1464  1.1  mrg 
   1465  1.1  mrg   for (gsi = gsi_start (src); !gsi_end_p (gsi); gsi_next (&gsi))
   1466  1.1  mrg     {
   1467  1.1  mrg       stmt = gimple_copy (gsi_stmt (gsi));
   1468  1.1  mrg       gimple_seq_add_stmt (&new_seq, stmt);
   1469  1.1  mrg     }
   1470  1.1  mrg 
   1471  1.1  mrg   return new_seq;
   1472  1.1  mrg }
   1473  1.1  mrg 
   1474  1.1  mrg 
   1475  1.1  mrg 
   1476  1.1  mrg /* Return true if calls C1 and C2 are known to go to the same function.  */
   1477  1.1  mrg 
   1478  1.1  mrg bool
   1479  1.1  mrg gimple_call_same_target_p (const gimple *c1, const gimple *c2)
   1480  1.1  mrg {
   1481  1.1  mrg   if (gimple_call_internal_p (c1))
   1482  1.1  mrg     return (gimple_call_internal_p (c2)
   1483  1.1  mrg 	    && gimple_call_internal_fn (c1) == gimple_call_internal_fn (c2)
   1484  1.1  mrg 	    && (!gimple_call_internal_unique_p (as_a <const gcall *> (c1))
   1485  1.1  mrg 		|| c1 == c2));
   1486  1.1  mrg   else
   1487  1.1  mrg     return (gimple_call_fn (c1) == gimple_call_fn (c2)
   1488  1.1  mrg 	    || (gimple_call_fndecl (c1)
   1489  1.1  mrg 		&& gimple_call_fndecl (c1) == gimple_call_fndecl (c2)));
   1490  1.1  mrg }
   1491  1.1  mrg 
   1492  1.1  mrg /* Detect flags from a GIMPLE_CALL.  This is just like
   1493  1.1  mrg    call_expr_flags, but for gimple tuples.  */
   1494  1.1  mrg 
   1495  1.1  mrg int
   1496  1.1  mrg gimple_call_flags (const gimple *stmt)
   1497  1.1  mrg {
   1498  1.1  mrg   int flags = 0;
   1499  1.1  mrg 
   1500  1.1  mrg   if (gimple_call_internal_p (stmt))
   1501  1.1  mrg     flags = internal_fn_flags (gimple_call_internal_fn (stmt));
   1502  1.1  mrg   else
   1503  1.1  mrg     {
   1504  1.1  mrg       tree decl = gimple_call_fndecl (stmt);
   1505  1.1  mrg       if (decl)
   1506  1.1  mrg 	flags = flags_from_decl_or_type (decl);
   1507  1.1  mrg       flags |= flags_from_decl_or_type (gimple_call_fntype (stmt));
   1508  1.1  mrg     }
   1509  1.1  mrg 
   1510  1.1  mrg   if (stmt->subcode & GF_CALL_NOTHROW)
   1511  1.1  mrg     flags |= ECF_NOTHROW;
   1512  1.1  mrg 
   1513  1.1  mrg   if (stmt->subcode & GF_CALL_BY_DESCRIPTOR)
   1514  1.1  mrg     flags |= ECF_BY_DESCRIPTOR;
   1515  1.1  mrg 
   1516  1.1  mrg   return flags;
   1517  1.1  mrg }
   1518  1.1  mrg 
   1519  1.1  mrg /* Return the "fn spec" string for call STMT.  */
   1520  1.1  mrg 
   1521  1.1  mrg attr_fnspec
   1522  1.1  mrg gimple_call_fnspec (const gcall *stmt)
   1523  1.1  mrg {
   1524  1.1  mrg   tree type, attr;
   1525  1.1  mrg 
   1526  1.1  mrg   if (gimple_call_internal_p (stmt))
   1527  1.1  mrg     {
   1528  1.1  mrg       const_tree spec = internal_fn_fnspec (gimple_call_internal_fn (stmt));
   1529  1.1  mrg       if (spec)
   1530  1.1  mrg 	return spec;
   1531  1.1  mrg       else
   1532  1.1  mrg 	return "";
   1533  1.1  mrg     }
   1534  1.1  mrg 
   1535  1.1  mrg   type = gimple_call_fntype (stmt);
   1536  1.1  mrg   if (type)
   1537  1.1  mrg     {
   1538  1.1  mrg       attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type));
   1539  1.1  mrg       if (attr)
   1540  1.1  mrg 	return TREE_VALUE (TREE_VALUE (attr));
   1541  1.1  mrg     }
   1542  1.1  mrg   if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
   1543  1.1  mrg     return builtin_fnspec (gimple_call_fndecl (stmt));
   1544  1.1  mrg   tree fndecl = gimple_call_fndecl (stmt);
   1545  1.1  mrg   /* If the call is to a replaceable operator delete and results
   1546  1.1  mrg      from a delete expression as opposed to a direct call to
   1547  1.1  mrg      such operator, then we can treat it as free.  */
   1548  1.1  mrg   if (fndecl
   1549  1.1  mrg       && DECL_IS_OPERATOR_DELETE_P (fndecl)
   1550  1.1  mrg       && DECL_IS_REPLACEABLE_OPERATOR (fndecl)
   1551  1.1  mrg       && gimple_call_from_new_or_delete (stmt))
   1552  1.1  mrg     return ". o ";
   1553  1.1  mrg   /* Similarly operator new can be treated as malloc.  */
   1554  1.1  mrg   if (fndecl
   1555  1.1  mrg       && DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
   1556  1.1  mrg       && gimple_call_from_new_or_delete (stmt))
   1557  1.1  mrg     return "m ";
   1558  1.1  mrg   return "";
   1559  1.1  mrg }
   1560  1.1  mrg 
   1561  1.1  mrg /* Detects argument flags for argument number ARG on call STMT.  */
   1562  1.1  mrg 
   1563  1.1  mrg int
   1564  1.1  mrg gimple_call_arg_flags (const gcall *stmt, unsigned arg)
   1565  1.1  mrg {
   1566  1.1  mrg   attr_fnspec fnspec = gimple_call_fnspec (stmt);
   1567  1.1  mrg   int flags = 0;
   1568  1.1  mrg 
   1569  1.1  mrg   if (fnspec.known_p ())
   1570  1.1  mrg     flags = fnspec.arg_eaf_flags (arg);
   1571  1.1  mrg   tree callee = gimple_call_fndecl (stmt);
   1572  1.1  mrg   if (callee)
   1573  1.1  mrg     {
   1574  1.1  mrg       cgraph_node *node = cgraph_node::get (callee);
   1575  1.1  mrg       modref_summary *summary = node ? get_modref_function_summary (node)
   1576  1.1  mrg 				: NULL;
   1577  1.1  mrg 
   1578  1.1  mrg       if (summary && summary->arg_flags.length () > arg)
   1579  1.1  mrg 	{
   1580  1.1  mrg 	  int modref_flags = summary->arg_flags[arg];
   1581  1.1  mrg 
   1582  1.1  mrg 	  /* We have possibly optimized out load.  Be conservative here.  */
   1583  1.1  mrg 	  if (!node->binds_to_current_def_p ())
   1584  1.1  mrg 	    modref_flags = interposable_eaf_flags (modref_flags, flags);
   1585  1.1  mrg 	  if (dbg_cnt (ipa_mod_ref_pta))
   1586  1.1  mrg 	    flags |= modref_flags;
   1587  1.1  mrg 	}
   1588  1.1  mrg     }
   1589  1.1  mrg   return flags;
   1590  1.1  mrg }
   1591  1.1  mrg 
   1592  1.1  mrg /* Detects argument flags for return slot on call STMT.  */
   1593  1.1  mrg 
   1594  1.1  mrg int
   1595  1.1  mrg gimple_call_retslot_flags (const gcall *stmt)
   1596  1.1  mrg {
   1597  1.1  mrg   int flags = implicit_retslot_eaf_flags;
   1598  1.1  mrg 
   1599  1.1  mrg   tree callee = gimple_call_fndecl (stmt);
   1600  1.1  mrg   if (callee)
   1601  1.1  mrg     {
   1602  1.1  mrg       cgraph_node *node = cgraph_node::get (callee);
   1603  1.1  mrg       modref_summary *summary = node ? get_modref_function_summary (node)
   1604  1.1  mrg 				: NULL;
   1605  1.1  mrg 
   1606  1.1  mrg       if (summary)
   1607  1.1  mrg 	{
   1608  1.1  mrg 	  int modref_flags = summary->retslot_flags;
   1609  1.1  mrg 
   1610  1.1  mrg 	  /* We have possibly optimized out load.  Be conservative here.  */
   1611  1.1  mrg 	  if (!node->binds_to_current_def_p ())
   1612  1.1  mrg 	    modref_flags = interposable_eaf_flags (modref_flags, flags);
   1613  1.1  mrg 	  if (dbg_cnt (ipa_mod_ref_pta))
   1614  1.1  mrg 	    flags |= modref_flags;
   1615  1.1  mrg 	}
   1616  1.1  mrg     }
   1617  1.1  mrg   return flags;
   1618  1.1  mrg }
   1619  1.1  mrg 
   1620  1.1  mrg /* Detects argument flags for static chain on call STMT.  */
   1621  1.1  mrg 
   1622  1.1  mrg int
   1623  1.1  mrg gimple_call_static_chain_flags (const gcall *stmt)
   1624  1.1  mrg {
   1625  1.1  mrg   int flags = 0;
   1626  1.1  mrg 
   1627  1.1  mrg   tree callee = gimple_call_fndecl (stmt);
   1628  1.1  mrg   if (callee)
   1629  1.1  mrg     {
   1630  1.1  mrg       cgraph_node *node = cgraph_node::get (callee);
   1631  1.1  mrg       modref_summary *summary = node ? get_modref_function_summary (node)
   1632  1.1  mrg 				: NULL;
   1633  1.1  mrg 
   1634  1.1  mrg       /* Nested functions should always bind to current def since
   1635  1.1  mrg 	 there is no public ABI for them.  */
   1636  1.1  mrg       gcc_checking_assert (node->binds_to_current_def_p ());
   1637  1.1  mrg       if (summary)
   1638  1.1  mrg 	{
   1639  1.1  mrg 	  int modref_flags = summary->static_chain_flags;
   1640  1.1  mrg 
   1641  1.1  mrg 	  if (dbg_cnt (ipa_mod_ref_pta))
   1642  1.1  mrg 	    flags |= modref_flags;
   1643  1.1  mrg 	}
   1644  1.1  mrg     }
   1645  1.1  mrg   return flags;
   1646  1.1  mrg }
   1647  1.1  mrg 
   1648  1.1  mrg /* Detects return flags for the call STMT.  */
   1649  1.1  mrg 
   1650  1.1  mrg int
   1651  1.1  mrg gimple_call_return_flags (const gcall *stmt)
   1652  1.1  mrg {
   1653  1.1  mrg   if (gimple_call_flags (stmt) & ECF_MALLOC)
   1654  1.1  mrg     return ERF_NOALIAS;
   1655  1.1  mrg 
   1656  1.1  mrg   attr_fnspec fnspec = gimple_call_fnspec (stmt);
   1657  1.1  mrg 
   1658  1.1  mrg   unsigned int arg_no;
   1659  1.1  mrg   if (fnspec.returns_arg (&arg_no))
   1660  1.1  mrg     return ERF_RETURNS_ARG | arg_no;
   1661  1.1  mrg 
   1662  1.1  mrg   if (fnspec.returns_noalias_p ())
   1663  1.1  mrg     return ERF_NOALIAS;
   1664  1.1  mrg   return 0;
   1665  1.1  mrg }
   1666  1.1  mrg 
   1667  1.1  mrg 
   1668  1.1  mrg /* Return true if call STMT is known to return a non-zero result.  */
   1669  1.1  mrg 
   1670  1.1  mrg bool
   1671  1.1  mrg gimple_call_nonnull_result_p (gcall *call)
   1672  1.1  mrg {
   1673  1.1  mrg   tree fndecl = gimple_call_fndecl (call);
   1674  1.1  mrg   if (!fndecl)
   1675  1.1  mrg     return false;
   1676  1.1  mrg   if (flag_delete_null_pointer_checks && !flag_check_new
   1677  1.1  mrg       && DECL_IS_OPERATOR_NEW_P (fndecl)
   1678  1.1  mrg       && !TREE_NOTHROW (fndecl))
   1679  1.1  mrg     return true;
   1680  1.1  mrg 
   1681  1.1  mrg   /* References are always non-NULL.  */
   1682  1.1  mrg   if (flag_delete_null_pointer_checks
   1683  1.1  mrg       && TREE_CODE (TREE_TYPE (fndecl)) == REFERENCE_TYPE)
   1684  1.1  mrg     return true;
   1685  1.1  mrg 
   1686  1.1  mrg   if (flag_delete_null_pointer_checks
   1687  1.1  mrg       && lookup_attribute ("returns_nonnull",
   1688  1.1  mrg 			   TYPE_ATTRIBUTES (gimple_call_fntype (call))))
   1689  1.1  mrg     return true;
   1690  1.1  mrg   return gimple_alloca_call_p (call);
   1691  1.1  mrg }
   1692  1.1  mrg 
   1693  1.1  mrg 
   1694  1.1  mrg /* If CALL returns a non-null result in an argument, return that arg.  */
   1695  1.1  mrg 
   1696  1.1  mrg tree
   1697  1.1  mrg gimple_call_nonnull_arg (gcall *call)
   1698  1.1  mrg {
   1699  1.1  mrg   tree fndecl = gimple_call_fndecl (call);
   1700  1.1  mrg   if (!fndecl)
   1701  1.1  mrg     return NULL_TREE;
   1702  1.1  mrg 
   1703  1.1  mrg   unsigned rf = gimple_call_return_flags (call);
   1704  1.1  mrg   if (rf & ERF_RETURNS_ARG)
   1705  1.1  mrg     {
   1706  1.1  mrg       unsigned argnum = rf & ERF_RETURN_ARG_MASK;
   1707  1.1  mrg       if (argnum < gimple_call_num_args (call))
   1708  1.1  mrg 	{
   1709  1.1  mrg 	  tree arg = gimple_call_arg (call, argnum);
   1710  1.1  mrg 	  if (SSA_VAR_P (arg)
   1711  1.1  mrg 	      && infer_nonnull_range_by_attribute (call, arg))
   1712  1.1  mrg 	    return arg;
   1713  1.1  mrg 	}
   1714  1.1  mrg     }
   1715  1.1  mrg   return NULL_TREE;
   1716  1.1  mrg }
   1717  1.1  mrg 
   1718  1.1  mrg 
   1719  1.1  mrg /* Return true if GS is a copy assignment.  */
   1720  1.1  mrg 
   1721  1.1  mrg bool
   1722  1.1  mrg gimple_assign_copy_p (gimple *gs)
   1723  1.1  mrg {
   1724  1.1  mrg   return (gimple_assign_single_p (gs)
   1725  1.1  mrg 	  && is_gimple_val (gimple_op (gs, 1)));
   1726  1.1  mrg }
   1727  1.1  mrg 
   1728  1.1  mrg 
   1729  1.1  mrg /* Return true if GS is a SSA_NAME copy assignment.  */
   1730  1.1  mrg 
   1731  1.1  mrg bool
   1732  1.1  mrg gimple_assign_ssa_name_copy_p (gimple *gs)
   1733  1.1  mrg {
   1734  1.1  mrg   return (gimple_assign_single_p (gs)
   1735  1.1  mrg 	  && TREE_CODE (gimple_assign_lhs (gs)) == SSA_NAME
   1736  1.1  mrg 	  && TREE_CODE (gimple_assign_rhs1 (gs)) == SSA_NAME);
   1737  1.1  mrg }
   1738  1.1  mrg 
   1739  1.1  mrg 
   1740  1.1  mrg /* Return true if GS is an assignment with a unary RHS, but the
   1741  1.1  mrg    operator has no effect on the assigned value.  The logic is adapted
   1742  1.1  mrg    from STRIP_NOPS.  This predicate is intended to be used in tuplifying
   1743  1.1  mrg    instances in which STRIP_NOPS was previously applied to the RHS of
   1744  1.1  mrg    an assignment.
   1745  1.1  mrg 
   1746  1.1  mrg    NOTE: In the use cases that led to the creation of this function
   1747  1.1  mrg    and of gimple_assign_single_p, it is typical to test for either
   1748  1.1  mrg    condition and to proceed in the same manner.  In each case, the
   1749  1.1  mrg    assigned value is represented by the single RHS operand of the
   1750  1.1  mrg    assignment.  I suspect there may be cases where gimple_assign_copy_p,
   1751  1.1  mrg    gimple_assign_single_p, or equivalent logic is used where a similar
   1752  1.1  mrg    treatment of unary NOPs is appropriate.  */
   1753  1.1  mrg 
   1754  1.1  mrg bool
   1755  1.1  mrg gimple_assign_unary_nop_p (gimple *gs)
   1756  1.1  mrg {
   1757  1.1  mrg   return (is_gimple_assign (gs)
   1758  1.1  mrg           && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (gs))
   1759  1.1  mrg               || gimple_assign_rhs_code (gs) == NON_LVALUE_EXPR)
   1760  1.1  mrg           && gimple_assign_rhs1 (gs) != error_mark_node
   1761  1.1  mrg           && (TYPE_MODE (TREE_TYPE (gimple_assign_lhs (gs)))
   1762  1.1  mrg               == TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (gs)))));
   1763  1.1  mrg }
   1764  1.1  mrg 
   1765  1.1  mrg /* Set BB to be the basic block holding G.  */
   1766  1.1  mrg 
   1767  1.1  mrg void
   1768  1.1  mrg gimple_set_bb (gimple *stmt, basic_block bb)
   1769  1.1  mrg {
   1770  1.1  mrg   stmt->bb = bb;
   1771  1.1  mrg 
   1772  1.1  mrg   if (gimple_code (stmt) != GIMPLE_LABEL)
   1773  1.1  mrg     return;
   1774  1.1  mrg 
   1775  1.1  mrg   /* If the statement is a label, add the label to block-to-labels map
   1776  1.1  mrg      so that we can speed up edge creation for GIMPLE_GOTOs.  */
   1777  1.1  mrg   if (cfun->cfg)
   1778  1.1  mrg     {
   1779  1.1  mrg       tree t;
   1780  1.1  mrg       int uid;
   1781  1.1  mrg 
   1782  1.1  mrg       t = gimple_label_label (as_a <glabel *> (stmt));
   1783  1.1  mrg       uid = LABEL_DECL_UID (t);
   1784  1.1  mrg       if (uid == -1)
   1785  1.1  mrg 	{
   1786  1.1  mrg 	  unsigned old_len =
   1787  1.1  mrg 	    vec_safe_length (label_to_block_map_for_fn (cfun));
   1788  1.1  mrg 	  LABEL_DECL_UID (t) = uid = cfun->cfg->last_label_uid++;
   1789  1.1  mrg 	  if (old_len <= (unsigned) uid)
   1790  1.1  mrg 	    vec_safe_grow_cleared (label_to_block_map_for_fn (cfun), uid + 1);
   1791  1.1  mrg 	}
   1792  1.1  mrg 
   1793  1.1  mrg       (*label_to_block_map_for_fn (cfun))[uid] = bb;
   1794  1.1  mrg     }
   1795  1.1  mrg }
   1796  1.1  mrg 
   1797  1.1  mrg 
   1798  1.1  mrg /* Modify the RHS of the assignment pointed-to by GSI using the
   1799  1.1  mrg    operands in the expression tree EXPR.
   1800  1.1  mrg 
   1801  1.1  mrg    NOTE: The statement pointed-to by GSI may be reallocated if it
   1802  1.1  mrg    did not have enough operand slots.
   1803  1.1  mrg 
   1804  1.1  mrg    This function is useful to convert an existing tree expression into
   1805  1.1  mrg    the flat representation used for the RHS of a GIMPLE assignment.
   1806  1.1  mrg    It will reallocate memory as needed to expand or shrink the number
   1807  1.1  mrg    of operand slots needed to represent EXPR.
   1808  1.1  mrg 
   1809  1.1  mrg    NOTE: If you find yourself building a tree and then calling this
   1810  1.1  mrg    function, you are most certainly doing it the slow way.  It is much
   1811  1.1  mrg    better to build a new assignment or to use the function
   1812  1.1  mrg    gimple_assign_set_rhs_with_ops, which does not require an
   1813  1.1  mrg    expression tree to be built.  */
   1814  1.1  mrg 
   1815  1.1  mrg void
   1816  1.1  mrg gimple_assign_set_rhs_from_tree (gimple_stmt_iterator *gsi, tree expr)
   1817  1.1  mrg {
   1818  1.1  mrg   enum tree_code subcode;
   1819  1.1  mrg   tree op1, op2, op3;
   1820  1.1  mrg 
   1821  1.1  mrg   extract_ops_from_tree (expr, &subcode, &op1, &op2, &op3);
   1822  1.1  mrg   gimple_assign_set_rhs_with_ops (gsi, subcode, op1, op2, op3);
   1823  1.1  mrg }
   1824  1.1  mrg 
   1825  1.1  mrg 
   1826  1.1  mrg /* Set the RHS of assignment statement pointed-to by GSI to CODE with
   1827  1.1  mrg    operands OP1, OP2 and OP3.
   1828  1.1  mrg 
   1829  1.1  mrg    NOTE: The statement pointed-to by GSI may be reallocated if it
   1830  1.1  mrg    did not have enough operand slots.  */
   1831  1.1  mrg 
   1832  1.1  mrg void
   1833  1.1  mrg gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
   1834  1.1  mrg 				tree op1, tree op2, tree op3)
   1835  1.1  mrg {
   1836  1.1  mrg   unsigned new_rhs_ops = get_gimple_rhs_num_ops (code);
   1837  1.1  mrg   gimple *stmt = gsi_stmt (*gsi);
   1838  1.1  mrg   gimple *old_stmt = stmt;
   1839  1.1  mrg 
   1840  1.1  mrg   /* If the new CODE needs more operands, allocate a new statement.  */
   1841  1.1  mrg   if (gimple_num_ops (stmt) < new_rhs_ops + 1)
   1842  1.1  mrg     {
   1843  1.1  mrg       tree lhs = gimple_assign_lhs (old_stmt);
   1844  1.1  mrg       stmt = gimple_alloc (gimple_code (old_stmt), new_rhs_ops + 1);
   1845  1.1  mrg       memcpy (stmt, old_stmt, gimple_size (gimple_code (old_stmt)));
   1846  1.1  mrg       gimple_init_singleton (stmt);
   1847  1.1  mrg 
   1848  1.1  mrg       /* The LHS needs to be reset as this also changes the SSA name
   1849  1.1  mrg 	 on the LHS.  */
   1850  1.1  mrg       gimple_assign_set_lhs (stmt, lhs);
   1851  1.1  mrg     }
   1852  1.1  mrg 
   1853  1.1  mrg   gimple_set_num_ops (stmt, new_rhs_ops + 1);
   1854  1.1  mrg   gimple_set_subcode (stmt, code);
   1855  1.1  mrg   gimple_assign_set_rhs1 (stmt, op1);
   1856  1.1  mrg   if (new_rhs_ops > 1)
   1857  1.1  mrg     gimple_assign_set_rhs2 (stmt, op2);
   1858  1.1  mrg   if (new_rhs_ops > 2)
   1859  1.1  mrg     gimple_assign_set_rhs3 (stmt, op3);
   1860  1.1  mrg   if (stmt != old_stmt)
   1861  1.1  mrg     gsi_replace (gsi, stmt, false);
   1862  1.1  mrg }
   1863  1.1  mrg 
   1864  1.1  mrg 
   1865  1.1  mrg /* Return the LHS of a statement that performs an assignment,
   1866  1.1  mrg    either a GIMPLE_ASSIGN or a GIMPLE_CALL.  Returns NULL_TREE
   1867  1.1  mrg    for a call to a function that returns no value, or for a
   1868  1.1  mrg    statement other than an assignment or a call.  */
   1869  1.1  mrg 
   1870  1.1  mrg tree
   1871  1.1  mrg gimple_get_lhs (const gimple *stmt)
   1872  1.1  mrg {
   1873  1.1  mrg   enum gimple_code code = gimple_code (stmt);
   1874  1.1  mrg 
   1875  1.1  mrg   if (code == GIMPLE_ASSIGN)
   1876  1.1  mrg     return gimple_assign_lhs (stmt);
   1877  1.1  mrg   else if (code == GIMPLE_CALL)
   1878  1.1  mrg     return gimple_call_lhs (stmt);
   1879  1.1  mrg   else if (code == GIMPLE_PHI)
   1880  1.1  mrg     return gimple_phi_result (stmt);
   1881  1.1  mrg   else
   1882  1.1  mrg     return NULL_TREE;
   1883  1.1  mrg }
   1884  1.1  mrg 
   1885  1.1  mrg 
   1886  1.1  mrg /* Set the LHS of a statement that performs an assignment,
   1887  1.1  mrg    either a GIMPLE_ASSIGN or a GIMPLE_CALL.  */
   1888  1.1  mrg 
   1889  1.1  mrg void
   1890  1.1  mrg gimple_set_lhs (gimple *stmt, tree lhs)
   1891  1.1  mrg {
   1892  1.1  mrg   enum gimple_code code = gimple_code (stmt);
   1893  1.1  mrg 
   1894  1.1  mrg   if (code == GIMPLE_ASSIGN)
   1895  1.1  mrg     gimple_assign_set_lhs (stmt, lhs);
   1896  1.1  mrg   else if (code == GIMPLE_CALL)
   1897  1.1  mrg     gimple_call_set_lhs (stmt, lhs);
   1898  1.1  mrg   else
   1899  1.1  mrg     gcc_unreachable ();
   1900  1.1  mrg }
   1901  1.1  mrg 
   1902  1.1  mrg 
   1903  1.1  mrg /* Return a deep copy of statement STMT.  All the operands from STMT
   1904  1.1  mrg    are reallocated and copied using unshare_expr.  The DEF, USE, VDEF
   1905  1.1  mrg    and VUSE operand arrays are set to empty in the new copy.  The new
   1906  1.1  mrg    copy isn't part of any sequence.  */
   1907  1.1  mrg 
   1908  1.1  mrg gimple *
   1909  1.1  mrg gimple_copy (gimple *stmt)
   1910  1.1  mrg {
   1911  1.1  mrg   enum gimple_code code = gimple_code (stmt);
   1912  1.1  mrg   unsigned num_ops = gimple_num_ops (stmt);
   1913  1.1  mrg   gimple *copy = gimple_alloc (code, num_ops);
   1914  1.1  mrg   unsigned i;
   1915  1.1  mrg 
   1916  1.1  mrg   /* Shallow copy all the fields from STMT.  */
   1917  1.1  mrg   memcpy (copy, stmt, gimple_size (code));
   1918  1.1  mrg   gimple_init_singleton (copy);
   1919  1.1  mrg 
   1920  1.1  mrg   /* If STMT has sub-statements, deep-copy them as well.  */
   1921  1.1  mrg   if (gimple_has_substatements (stmt))
   1922  1.1  mrg     {
   1923  1.1  mrg       gimple_seq new_seq;
   1924  1.1  mrg       tree t;
   1925  1.1  mrg 
   1926  1.1  mrg       switch (gimple_code (stmt))
   1927  1.1  mrg 	{
   1928  1.1  mrg 	case GIMPLE_BIND:
   1929  1.1  mrg 	  {
   1930  1.1  mrg 	    gbind *bind_stmt = as_a <gbind *> (stmt);
   1931  1.1  mrg 	    gbind *bind_copy = as_a <gbind *> (copy);
   1932  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_bind_body (bind_stmt));
   1933  1.1  mrg 	    gimple_bind_set_body (bind_copy, new_seq);
   1934  1.1  mrg 	    gimple_bind_set_vars (bind_copy,
   1935  1.1  mrg 				  unshare_expr (gimple_bind_vars (bind_stmt)));
   1936  1.1  mrg 	    gimple_bind_set_block (bind_copy, gimple_bind_block (bind_stmt));
   1937  1.1  mrg 	  }
   1938  1.1  mrg 	  break;
   1939  1.1  mrg 
   1940  1.1  mrg 	case GIMPLE_CATCH:
   1941  1.1  mrg 	  {
   1942  1.1  mrg 	    gcatch *catch_stmt = as_a <gcatch *> (stmt);
   1943  1.1  mrg 	    gcatch *catch_copy = as_a <gcatch *> (copy);
   1944  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_catch_handler (catch_stmt));
   1945  1.1  mrg 	    gimple_catch_set_handler (catch_copy, new_seq);
   1946  1.1  mrg 	    t = unshare_expr (gimple_catch_types (catch_stmt));
   1947  1.1  mrg 	    gimple_catch_set_types (catch_copy, t);
   1948  1.1  mrg 	  }
   1949  1.1  mrg 	  break;
   1950  1.1  mrg 
   1951  1.1  mrg 	case GIMPLE_EH_FILTER:
   1952  1.1  mrg 	  {
   1953  1.1  mrg 	    geh_filter *eh_filter_stmt = as_a <geh_filter *> (stmt);
   1954  1.1  mrg 	    geh_filter *eh_filter_copy = as_a <geh_filter *> (copy);
   1955  1.1  mrg 	    new_seq
   1956  1.1  mrg 	      = gimple_seq_copy (gimple_eh_filter_failure (eh_filter_stmt));
   1957  1.1  mrg 	    gimple_eh_filter_set_failure (eh_filter_copy, new_seq);
   1958  1.1  mrg 	    t = unshare_expr (gimple_eh_filter_types (eh_filter_stmt));
   1959  1.1  mrg 	    gimple_eh_filter_set_types (eh_filter_copy, t);
   1960  1.1  mrg 	  }
   1961  1.1  mrg 	  break;
   1962  1.1  mrg 
   1963  1.1  mrg 	case GIMPLE_EH_ELSE:
   1964  1.1  mrg 	  {
   1965  1.1  mrg 	    geh_else *eh_else_stmt = as_a <geh_else *> (stmt);
   1966  1.1  mrg 	    geh_else *eh_else_copy = as_a <geh_else *> (copy);
   1967  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_eh_else_n_body (eh_else_stmt));
   1968  1.1  mrg 	    gimple_eh_else_set_n_body (eh_else_copy, new_seq);
   1969  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_eh_else_e_body (eh_else_stmt));
   1970  1.1  mrg 	    gimple_eh_else_set_e_body (eh_else_copy, new_seq);
   1971  1.1  mrg 	  }
   1972  1.1  mrg 	  break;
   1973  1.1  mrg 
   1974  1.1  mrg 	case GIMPLE_TRY:
   1975  1.1  mrg 	  {
   1976  1.1  mrg 	    gtry *try_stmt = as_a <gtry *> (stmt);
   1977  1.1  mrg 	    gtry *try_copy = as_a <gtry *> (copy);
   1978  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_try_eval (try_stmt));
   1979  1.1  mrg 	    gimple_try_set_eval (try_copy, new_seq);
   1980  1.1  mrg 	    new_seq = gimple_seq_copy (gimple_try_cleanup (try_stmt));
   1981  1.1  mrg 	    gimple_try_set_cleanup (try_copy, new_seq);
   1982  1.1  mrg 	  }
   1983  1.1  mrg 	  break;
   1984  1.1  mrg 
   1985  1.1  mrg 	case GIMPLE_OMP_FOR:
   1986  1.1  mrg 	  new_seq = gimple_seq_copy (gimple_omp_for_pre_body (stmt));
   1987  1.1  mrg 	  gimple_omp_for_set_pre_body (copy, new_seq);
   1988  1.1  mrg 	  t = unshare_expr (gimple_omp_for_clauses (stmt));
   1989  1.1  mrg 	  gimple_omp_for_set_clauses (copy, t);
   1990  1.1  mrg 	  {
   1991  1.1  mrg 	    gomp_for *omp_for_copy = as_a <gomp_for *> (copy);
   1992  1.1  mrg 	    omp_for_copy->iter = ggc_vec_alloc<gimple_omp_for_iter>
   1993  1.1  mrg 	      ( gimple_omp_for_collapse (stmt));
   1994  1.1  mrg           }
   1995  1.1  mrg 	  for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
   1996  1.1  mrg 	    {
   1997  1.1  mrg 	      gimple_omp_for_set_cond (copy, i,
   1998  1.1  mrg 				       gimple_omp_for_cond (stmt, i));
   1999  1.1  mrg 	      gimple_omp_for_set_index (copy, i,
   2000  1.1  mrg 					gimple_omp_for_index (stmt, i));
   2001  1.1  mrg 	      t = unshare_expr (gimple_omp_for_initial (stmt, i));
   2002  1.1  mrg 	      gimple_omp_for_set_initial (copy, i, t);
   2003  1.1  mrg 	      t = unshare_expr (gimple_omp_for_final (stmt, i));
   2004  1.1  mrg 	      gimple_omp_for_set_final (copy, i, t);
   2005  1.1  mrg 	      t = unshare_expr (gimple_omp_for_incr (stmt, i));
   2006  1.1  mrg 	      gimple_omp_for_set_incr (copy, i, t);
   2007  1.1  mrg 	    }
   2008  1.1  mrg 	  goto copy_omp_body;
   2009  1.1  mrg 
   2010  1.1  mrg 	case GIMPLE_OMP_PARALLEL:
   2011  1.1  mrg 	  {
   2012  1.1  mrg 	    gomp_parallel *omp_par_stmt = as_a <gomp_parallel *> (stmt);
   2013  1.1  mrg 	    gomp_parallel *omp_par_copy = as_a <gomp_parallel *> (copy);
   2014  1.1  mrg 	    t = unshare_expr (gimple_omp_parallel_clauses (omp_par_stmt));
   2015  1.1  mrg 	    gimple_omp_parallel_set_clauses (omp_par_copy, t);
   2016  1.1  mrg 	    t = unshare_expr (gimple_omp_parallel_child_fn (omp_par_stmt));
   2017  1.1  mrg 	    gimple_omp_parallel_set_child_fn (omp_par_copy, t);
   2018  1.1  mrg 	    t = unshare_expr (gimple_omp_parallel_data_arg (omp_par_stmt));
   2019  1.1  mrg 	    gimple_omp_parallel_set_data_arg (omp_par_copy, t);
   2020  1.1  mrg 	  }
   2021  1.1  mrg 	  goto copy_omp_body;
   2022  1.1  mrg 
   2023  1.1  mrg 	case GIMPLE_OMP_TASK:
   2024  1.1  mrg 	  t = unshare_expr (gimple_omp_task_clauses (stmt));
   2025  1.1  mrg 	  gimple_omp_task_set_clauses (copy, t);
   2026  1.1  mrg 	  t = unshare_expr (gimple_omp_task_child_fn (stmt));
   2027  1.1  mrg 	  gimple_omp_task_set_child_fn (copy, t);
   2028  1.1  mrg 	  t = unshare_expr (gimple_omp_task_data_arg (stmt));
   2029  1.1  mrg 	  gimple_omp_task_set_data_arg (copy, t);
   2030  1.1  mrg 	  t = unshare_expr (gimple_omp_task_copy_fn (stmt));
   2031  1.1  mrg 	  gimple_omp_task_set_copy_fn (copy, t);
   2032  1.1  mrg 	  t = unshare_expr (gimple_omp_task_arg_size (stmt));
   2033  1.1  mrg 	  gimple_omp_task_set_arg_size (copy, t);
   2034  1.1  mrg 	  t = unshare_expr (gimple_omp_task_arg_align (stmt));
   2035  1.1  mrg 	  gimple_omp_task_set_arg_align (copy, t);
   2036  1.1  mrg 	  goto copy_omp_body;
   2037  1.1  mrg 
   2038  1.1  mrg 	case GIMPLE_OMP_CRITICAL:
   2039  1.1  mrg 	  t = unshare_expr (gimple_omp_critical_name
   2040  1.1  mrg 				(as_a <gomp_critical *> (stmt)));
   2041  1.1  mrg 	  gimple_omp_critical_set_name (as_a <gomp_critical *> (copy), t);
   2042  1.1  mrg 	  t = unshare_expr (gimple_omp_critical_clauses
   2043  1.1  mrg 				(as_a <gomp_critical *> (stmt)));
   2044  1.1  mrg 	  gimple_omp_critical_set_clauses (as_a <gomp_critical *> (copy), t);
   2045  1.1  mrg 	  goto copy_omp_body;
   2046  1.1  mrg 
   2047  1.1  mrg 	case GIMPLE_OMP_ORDERED:
   2048  1.1  mrg 	  t = unshare_expr (gimple_omp_ordered_clauses
   2049  1.1  mrg 				(as_a <gomp_ordered *> (stmt)));
   2050  1.1  mrg 	  gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t);
   2051  1.1  mrg 	  goto copy_omp_body;
   2052  1.1  mrg 
   2053  1.1  mrg 	case GIMPLE_OMP_SCAN:
   2054  1.1  mrg 	  t = gimple_omp_scan_clauses (as_a <gomp_scan *> (stmt));
   2055  1.1  mrg 	  t = unshare_expr (t);
   2056  1.1  mrg 	  gimple_omp_scan_set_clauses (as_a <gomp_scan *> (copy), t);
   2057  1.1  mrg 	  goto copy_omp_body;
   2058  1.1  mrg 
   2059  1.1  mrg 	case GIMPLE_OMP_TASKGROUP:
   2060  1.1  mrg 	  t = unshare_expr (gimple_omp_taskgroup_clauses (stmt));
   2061  1.1  mrg 	  gimple_omp_taskgroup_set_clauses (copy, t);
   2062  1.1  mrg 	  goto copy_omp_body;
   2063  1.1  mrg 
   2064  1.1  mrg 	case GIMPLE_OMP_SECTIONS:
   2065  1.1  mrg 	  t = unshare_expr (gimple_omp_sections_clauses (stmt));
   2066  1.1  mrg 	  gimple_omp_sections_set_clauses (copy, t);
   2067  1.1  mrg 	  t = unshare_expr (gimple_omp_sections_control (stmt));
   2068  1.1  mrg 	  gimple_omp_sections_set_control (copy, t);
   2069  1.1  mrg 	  goto copy_omp_body;
   2070  1.1  mrg 
   2071  1.1  mrg 	case GIMPLE_OMP_SINGLE:
   2072  1.1  mrg 	  {
   2073  1.1  mrg 	    gomp_single *omp_single_copy = as_a <gomp_single *> (copy);
   2074  1.1  mrg 	    t = unshare_expr (gimple_omp_single_clauses (stmt));
   2075  1.1  mrg 	    gimple_omp_single_set_clauses (omp_single_copy, t);
   2076  1.1  mrg 	  }
   2077  1.1  mrg 	  goto copy_omp_body;
   2078  1.1  mrg 
   2079  1.1  mrg 	case GIMPLE_OMP_SCOPE:
   2080  1.1  mrg 	  t = unshare_expr (gimple_omp_scope_clauses (stmt));
   2081  1.1  mrg 	  gimple_omp_scope_set_clauses (copy, t);
   2082  1.1  mrg 	  goto copy_omp_body;
   2083  1.1  mrg 
   2084  1.1  mrg 	case GIMPLE_OMP_TARGET:
   2085  1.1  mrg 	  {
   2086  1.1  mrg 	    gomp_target *omp_target_stmt = as_a <gomp_target *> (stmt);
   2087  1.1  mrg 	    gomp_target *omp_target_copy = as_a <gomp_target *> (copy);
   2088  1.1  mrg 	    t = unshare_expr (gimple_omp_target_clauses (omp_target_stmt));
   2089  1.1  mrg 	    gimple_omp_target_set_clauses (omp_target_copy, t);
   2090  1.1  mrg 	    t = unshare_expr (gimple_omp_target_data_arg (omp_target_stmt));
   2091  1.1  mrg 	    gimple_omp_target_set_data_arg (omp_target_copy, t);
   2092  1.1  mrg 	  }
   2093  1.1  mrg 	  goto copy_omp_body;
   2094  1.1  mrg 
   2095  1.1  mrg 	case GIMPLE_OMP_TEAMS:
   2096  1.1  mrg 	  {
   2097  1.1  mrg 	    gomp_teams *omp_teams_copy = as_a <gomp_teams *> (copy);
   2098  1.1  mrg 	    t = unshare_expr (gimple_omp_teams_clauses (stmt));
   2099  1.1  mrg 	    gimple_omp_teams_set_clauses (omp_teams_copy, t);
   2100  1.1  mrg 	  }
   2101  1.1  mrg 	  /* FALLTHRU  */
   2102  1.1  mrg 
   2103  1.1  mrg 	case GIMPLE_OMP_SECTION:
   2104  1.1  mrg 	case GIMPLE_OMP_MASTER:
   2105  1.1  mrg 	copy_omp_body:
   2106  1.1  mrg 	  new_seq = gimple_seq_copy (gimple_omp_body (stmt));
   2107  1.1  mrg 	  gimple_omp_set_body (copy, new_seq);
   2108  1.1  mrg 	  break;
   2109  1.1  mrg 
   2110  1.1  mrg 	case GIMPLE_OMP_MASKED:
   2111  1.1  mrg 	  t = unshare_expr (gimple_omp_masked_clauses (stmt));
   2112  1.1  mrg 	  gimple_omp_masked_set_clauses (copy, t);
   2113  1.1  mrg 	  goto copy_omp_body;
   2114  1.1  mrg 
   2115  1.1  mrg 	case GIMPLE_TRANSACTION:
   2116  1.1  mrg 	  new_seq = gimple_seq_copy (gimple_transaction_body (
   2117  1.1  mrg 				       as_a <gtransaction *> (stmt)));
   2118  1.1  mrg 	  gimple_transaction_set_body (as_a <gtransaction *> (copy),
   2119  1.1  mrg 				       new_seq);
   2120  1.1  mrg 	  break;
   2121  1.1  mrg 
   2122  1.1  mrg 	case GIMPLE_WITH_CLEANUP_EXPR:
   2123  1.1  mrg 	  new_seq = gimple_seq_copy (gimple_wce_cleanup (stmt));
   2124  1.1  mrg 	  gimple_wce_set_cleanup (copy, new_seq);
   2125  1.1  mrg 	  break;
   2126  1.1  mrg 
   2127  1.1  mrg 	default:
   2128  1.1  mrg 	  gcc_unreachable ();
   2129  1.1  mrg 	}
   2130  1.1  mrg     }
   2131  1.1  mrg 
   2132  1.1  mrg   /* Make copy of operands.  */
   2133  1.1  mrg   for (i = 0; i < num_ops; i++)
   2134  1.1  mrg     gimple_set_op (copy, i, unshare_expr (gimple_op (stmt, i)));
   2135  1.1  mrg 
   2136  1.1  mrg   if (gimple_has_mem_ops (stmt))
   2137  1.1  mrg     {
   2138  1.1  mrg       gimple_set_vdef (copy, gimple_vdef (stmt));
   2139  1.1  mrg       gimple_set_vuse (copy, gimple_vuse (stmt));
   2140  1.1  mrg     }
   2141  1.1  mrg 
   2142  1.1  mrg   /* Clear out SSA operand vectors on COPY.  */
   2143  1.1  mrg   if (gimple_has_ops (stmt))
   2144  1.1  mrg     {
   2145  1.1  mrg       gimple_set_use_ops (copy, NULL);
   2146  1.1  mrg 
   2147  1.1  mrg       /* SSA operands need to be updated.  */
   2148  1.1  mrg       gimple_set_modified (copy, true);
   2149  1.1  mrg     }
   2150  1.1  mrg 
   2151  1.1  mrg   if (gimple_debug_nonbind_marker_p (stmt))
   2152  1.1  mrg     cfun->debug_marker_count++;
   2153  1.1  mrg 
   2154  1.1  mrg   return copy;
   2155  1.1  mrg }
   2156  1.1  mrg 
   2157  1.1  mrg /* Move OLD_STMT's vuse and vdef operands to NEW_STMT, on the assumption
   2158  1.1  mrg    that OLD_STMT is about to be removed.  */
   2159  1.1  mrg 
   2160  1.1  mrg void
   2161  1.1  mrg gimple_move_vops (gimple *new_stmt, gimple *old_stmt)
   2162  1.1  mrg {
   2163  1.1  mrg   tree vdef = gimple_vdef (old_stmt);
   2164  1.1  mrg   gimple_set_vuse (new_stmt, gimple_vuse (old_stmt));
   2165  1.1  mrg   gimple_set_vdef (new_stmt, vdef);
   2166  1.1  mrg   if (vdef && TREE_CODE (vdef) == SSA_NAME)
   2167  1.1  mrg     SSA_NAME_DEF_STMT (vdef) = new_stmt;
   2168  1.1  mrg }
   2169  1.1  mrg 
   2170  1.1  mrg /* Return true if statement S has side-effects.  We consider a
   2171  1.1  mrg    statement to have side effects if:
   2172  1.1  mrg 
   2173  1.1  mrg    - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST.
   2174  1.1  mrg    - Any of its operands are marked TREE_THIS_VOLATILE or TREE_SIDE_EFFECTS.  */
   2175  1.1  mrg 
   2176  1.1  mrg bool
   2177  1.1  mrg gimple_has_side_effects (const gimple *s)
   2178  1.1  mrg {
   2179  1.1  mrg   if (is_gimple_debug (s))
   2180  1.1  mrg     return false;
   2181  1.1  mrg 
   2182  1.1  mrg   /* We don't have to scan the arguments to check for
   2183  1.1  mrg      volatile arguments, though, at present, we still
   2184  1.1  mrg      do a scan to check for TREE_SIDE_EFFECTS.  */
   2185  1.1  mrg   if (gimple_has_volatile_ops (s))
   2186  1.1  mrg     return true;
   2187  1.1  mrg 
   2188  1.1  mrg   if (gimple_code (s) == GIMPLE_ASM
   2189  1.1  mrg       && gimple_asm_volatile_p (as_a <const gasm *> (s)))
   2190  1.1  mrg     return true;
   2191  1.1  mrg 
   2192  1.1  mrg   if (is_gimple_call (s))
   2193  1.1  mrg     {
   2194  1.1  mrg       int flags = gimple_call_flags (s);
   2195  1.1  mrg 
   2196  1.1  mrg       /* An infinite loop is considered a side effect.  */
   2197  1.1  mrg       if (!(flags & (ECF_CONST | ECF_PURE))
   2198  1.1  mrg 	  || (flags & ECF_LOOPING_CONST_OR_PURE))
   2199  1.1  mrg 	return true;
   2200  1.1  mrg 
   2201  1.1  mrg       return false;
   2202  1.1  mrg     }
   2203  1.1  mrg 
   2204  1.1  mrg   return false;
   2205  1.1  mrg }
   2206  1.1  mrg 
   2207  1.1  mrg /* Helper for gimple_could_trap_p and gimple_assign_rhs_could_trap_p.
   2208  1.1  mrg    Return true if S can trap.  When INCLUDE_MEM is true, check whether
   2209  1.1  mrg    the memory operations could trap.  When INCLUDE_STORES is true and
   2210  1.1  mrg    S is a GIMPLE_ASSIGN, the LHS of the assignment is also checked.  */
   2211  1.1  mrg 
   2212  1.1  mrg bool
   2213  1.1  mrg gimple_could_trap_p_1 (const gimple *s, bool include_mem, bool include_stores)
   2214  1.1  mrg {
   2215  1.1  mrg   tree t, div = NULL_TREE;
   2216  1.1  mrg   enum tree_code op;
   2217  1.1  mrg 
   2218  1.1  mrg   if (include_mem)
   2219  1.1  mrg     {
   2220  1.1  mrg       unsigned i, start = (is_gimple_assign (s) && !include_stores) ? 1 : 0;
   2221  1.1  mrg 
   2222  1.1  mrg       for (i = start; i < gimple_num_ops (s); i++)
   2223  1.1  mrg 	if (tree_could_trap_p (gimple_op (s, i)))
   2224  1.1  mrg 	  return true;
   2225  1.1  mrg     }
   2226  1.1  mrg 
   2227  1.1  mrg   switch (gimple_code (s))
   2228  1.1  mrg     {
   2229  1.1  mrg     case GIMPLE_ASM:
   2230  1.1  mrg       return gimple_asm_volatile_p (as_a <const gasm *> (s));
   2231  1.1  mrg 
   2232  1.1  mrg     case GIMPLE_CALL:
   2233  1.1  mrg       if (gimple_call_internal_p (s))
   2234  1.1  mrg 	return false;
   2235  1.1  mrg       t = gimple_call_fndecl (s);
   2236  1.1  mrg       /* Assume that indirect and calls to weak functions may trap.  */
   2237  1.1  mrg       if (!t || !DECL_P (t) || DECL_WEAK (t))
   2238  1.1  mrg 	return true;
   2239  1.1  mrg       return false;
   2240  1.1  mrg 
   2241  1.1  mrg     case GIMPLE_ASSIGN:
   2242  1.1  mrg       op = gimple_assign_rhs_code (s);
   2243  1.1  mrg 
   2244  1.1  mrg       /* For COND_EXPR only the condition may trap.  */
   2245  1.1  mrg       if (op == COND_EXPR)
   2246  1.1  mrg 	return tree_could_trap_p (gimple_assign_rhs1 (s));
   2247  1.1  mrg 
   2248  1.1  mrg       /* For comparisons we need to check rhs operand types instead of lhs type
   2249  1.1  mrg          (which is BOOLEAN_TYPE).  */
   2250  1.1  mrg       if (TREE_CODE_CLASS (op) == tcc_comparison)
   2251  1.1  mrg 	t = TREE_TYPE (gimple_assign_rhs1 (s));
   2252  1.1  mrg       else
   2253  1.1  mrg 	t = TREE_TYPE (gimple_assign_lhs (s));
   2254  1.1  mrg 
   2255  1.1  mrg       if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS)
   2256  1.1  mrg 	div = gimple_assign_rhs2 (s);
   2257  1.1  mrg 
   2258  1.1  mrg       return (operation_could_trap_p (op, FLOAT_TYPE_P (t),
   2259  1.1  mrg 				      (INTEGRAL_TYPE_P (t)
   2260  1.1  mrg 				       && TYPE_OVERFLOW_TRAPS (t)),
   2261  1.1  mrg 				      div));
   2262  1.1  mrg 
   2263  1.1  mrg     case GIMPLE_COND:
   2264  1.1  mrg       t = TREE_TYPE (gimple_cond_lhs (s));
   2265  1.1  mrg       return operation_could_trap_p (gimple_cond_code (s),
   2266  1.1  mrg 				     FLOAT_TYPE_P (t), false, NULL_TREE);
   2267  1.1  mrg 
   2268  1.1  mrg     default:
   2269  1.1  mrg       break;
   2270  1.1  mrg     }
   2271  1.1  mrg 
   2272  1.1  mrg   return false;
   2273  1.1  mrg }
   2274  1.1  mrg 
   2275  1.1  mrg /* Return true if statement S can trap.  */
   2276  1.1  mrg 
   2277  1.1  mrg bool
   2278  1.1  mrg gimple_could_trap_p (const gimple *s)
   2279  1.1  mrg {
   2280  1.1  mrg   return gimple_could_trap_p_1 (s, true, true);
   2281  1.1  mrg }
   2282  1.1  mrg 
   2283  1.1  mrg /* Return true if RHS of a GIMPLE_ASSIGN S can trap.  */
   2284  1.1  mrg 
   2285  1.1  mrg bool
   2286  1.1  mrg gimple_assign_rhs_could_trap_p (gimple *s)
   2287  1.1  mrg {
   2288  1.1  mrg   gcc_assert (is_gimple_assign (s));
   2289  1.1  mrg   return gimple_could_trap_p_1 (s, true, false);
   2290  1.1  mrg }
   2291  1.1  mrg 
   2292  1.1  mrg 
   2293  1.1  mrg /* Print debugging information for gimple stmts generated.  */
   2294  1.1  mrg 
   2295  1.1  mrg void
   2296  1.1  mrg dump_gimple_statistics (void)
   2297  1.1  mrg {
   2298  1.1  mrg   int i;
   2299  1.1  mrg   uint64_t total_tuples = 0, total_bytes = 0;
   2300  1.1  mrg 
   2301  1.1  mrg   if (! GATHER_STATISTICS)
   2302  1.1  mrg     {
   2303  1.1  mrg       fprintf (stderr, "No GIMPLE statistics\n");
   2304  1.1  mrg       return;
   2305  1.1  mrg     }
   2306  1.1  mrg 
   2307  1.1  mrg   fprintf (stderr, "\nGIMPLE statements\n");
   2308  1.1  mrg   fprintf (stderr, "Kind                   Stmts      Bytes\n");
   2309  1.1  mrg   fprintf (stderr, "---------------------------------------\n");
   2310  1.1  mrg   for (i = 0; i < (int) gimple_alloc_kind_all; ++i)
   2311  1.1  mrg     {
   2312  1.1  mrg       fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n",
   2313  1.1  mrg 	       gimple_alloc_kind_names[i],
   2314  1.1  mrg 	       SIZE_AMOUNT (gimple_alloc_counts[i]),
   2315  1.1  mrg 	       SIZE_AMOUNT (gimple_alloc_sizes[i]));
   2316  1.1  mrg       total_tuples += gimple_alloc_counts[i];
   2317  1.1  mrg       total_bytes += gimple_alloc_sizes[i];
   2318  1.1  mrg     }
   2319  1.1  mrg   fprintf (stderr, "---------------------------------------\n");
   2320  1.1  mrg   fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", "Total",
   2321  1.1  mrg 	   SIZE_AMOUNT (total_tuples), SIZE_AMOUNT (total_bytes));
   2322  1.1  mrg   fprintf (stderr, "---------------------------------------\n");
   2323  1.1  mrg }
   2324  1.1  mrg 
   2325  1.1  mrg 
   2326  1.1  mrg /* Return the number of operands needed on the RHS of a GIMPLE
   2327  1.1  mrg    assignment for an expression with tree code CODE.  */
   2328  1.1  mrg 
   2329  1.1  mrg unsigned
   2330  1.1  mrg get_gimple_rhs_num_ops (enum tree_code code)
   2331  1.1  mrg {
   2332  1.1  mrg   switch (get_gimple_rhs_class (code))
   2333  1.1  mrg     {
   2334  1.1  mrg     case GIMPLE_UNARY_RHS:
   2335  1.1  mrg     case GIMPLE_SINGLE_RHS:
   2336  1.1  mrg       return 1;
   2337  1.1  mrg     case GIMPLE_BINARY_RHS:
   2338  1.1  mrg       return 2;
   2339  1.1  mrg     case GIMPLE_TERNARY_RHS:
   2340  1.1  mrg       return 3;
   2341  1.1  mrg     default:
   2342  1.1  mrg       gcc_unreachable ();
   2343  1.1  mrg     }
   2344  1.1  mrg }
   2345  1.1  mrg 
   2346  1.1  mrg #define DEFTREECODE(SYM, STRING, TYPE, NARGS)   			    \
   2347  1.1  mrg   (unsigned char)							    \
   2348  1.1  mrg   ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS				    \
   2349  1.1  mrg    : ((TYPE) == tcc_binary						    \
   2350  1.1  mrg       || (TYPE) == tcc_comparison) ? GIMPLE_BINARY_RHS   		    \
   2351  1.1  mrg    : ((TYPE) == tcc_constant						    \
   2352  1.1  mrg       || (TYPE) == tcc_declaration					    \
   2353  1.1  mrg       || (TYPE) == tcc_reference) ? GIMPLE_SINGLE_RHS			    \
   2354  1.1  mrg    : ((SYM) == TRUTH_AND_EXPR						    \
   2355  1.1  mrg       || (SYM) == TRUTH_OR_EXPR						    \
   2356  1.1  mrg       || (SYM) == TRUTH_XOR_EXPR) ? GIMPLE_BINARY_RHS			    \
   2357  1.1  mrg    : (SYM) == TRUTH_NOT_EXPR ? GIMPLE_UNARY_RHS				    \
   2358  1.1  mrg    : ((SYM) == COND_EXPR						    \
   2359  1.1  mrg       || (SYM) == WIDEN_MULT_PLUS_EXPR					    \
   2360  1.1  mrg       || (SYM) == WIDEN_MULT_MINUS_EXPR					    \
   2361  1.1  mrg       || (SYM) == DOT_PROD_EXPR						    \
   2362  1.1  mrg       || (SYM) == SAD_EXPR						    \
   2363  1.1  mrg       || (SYM) == REALIGN_LOAD_EXPR					    \
   2364  1.1  mrg       || (SYM) == VEC_COND_EXPR						    \
   2365  1.1  mrg       || (SYM) == VEC_PERM_EXPR                                             \
   2366  1.1  mrg       || (SYM) == BIT_INSERT_EXPR) ? GIMPLE_TERNARY_RHS			    \
   2367  1.1  mrg    : ((SYM) == CONSTRUCTOR						    \
   2368  1.1  mrg       || (SYM) == OBJ_TYPE_REF						    \
   2369  1.1  mrg       || (SYM) == ASSERT_EXPR						    \
   2370  1.1  mrg       || (SYM) == ADDR_EXPR						    \
   2371  1.1  mrg       || (SYM) == WITH_SIZE_EXPR					    \
   2372  1.1  mrg       || (SYM) == SSA_NAME) ? GIMPLE_SINGLE_RHS				    \
   2373  1.1  mrg    : GIMPLE_INVALID_RHS),
   2374  1.1  mrg #define END_OF_BASE_TREE_CODES (unsigned char) GIMPLE_INVALID_RHS,
   2375  1.1  mrg 
   2376  1.1  mrg const unsigned char gimple_rhs_class_table[] = {
   2377  1.1  mrg #include "all-tree.def"
   2378  1.1  mrg };
   2379  1.1  mrg 
   2380  1.1  mrg #undef DEFTREECODE
   2381  1.1  mrg #undef END_OF_BASE_TREE_CODES
   2382  1.1  mrg 
   2383  1.1  mrg /* Canonicalize a tree T for use in a COND_EXPR as conditional.  Returns
   2384  1.1  mrg    a canonicalized tree that is valid for a COND_EXPR or NULL_TREE, if
   2385  1.1  mrg    we failed to create one.  */
   2386  1.1  mrg 
   2387  1.1  mrg tree
   2388  1.1  mrg canonicalize_cond_expr_cond (tree t)
   2389  1.1  mrg {
   2390  1.1  mrg   /* Strip conversions around boolean operations.  */
   2391  1.1  mrg   if (CONVERT_EXPR_P (t)
   2392  1.1  mrg       && (truth_value_p (TREE_CODE (TREE_OPERAND (t, 0)))
   2393  1.1  mrg           || TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0)))
   2394  1.1  mrg 	     == BOOLEAN_TYPE))
   2395  1.1  mrg     t = TREE_OPERAND (t, 0);
   2396  1.1  mrg 
   2397  1.1  mrg   /* For !x use x == 0.  */
   2398  1.1  mrg   if (TREE_CODE (t) == TRUTH_NOT_EXPR)
   2399  1.1  mrg     {
   2400  1.1  mrg       tree top0 = TREE_OPERAND (t, 0);
   2401  1.1  mrg       t = build2 (EQ_EXPR, TREE_TYPE (t),
   2402  1.1  mrg 		  top0, build_int_cst (TREE_TYPE (top0), 0));
   2403  1.1  mrg     }
   2404  1.1  mrg   /* For cmp ? 1 : 0 use cmp.  */
   2405  1.1  mrg   else if (TREE_CODE (t) == COND_EXPR
   2406  1.1  mrg 	   && COMPARISON_CLASS_P (TREE_OPERAND (t, 0))
   2407  1.1  mrg 	   && integer_onep (TREE_OPERAND (t, 1))
   2408  1.1  mrg 	   && integer_zerop (TREE_OPERAND (t, 2)))
   2409  1.1  mrg     {
   2410  1.1  mrg       tree top0 = TREE_OPERAND (t, 0);
   2411  1.1  mrg       t = build2 (TREE_CODE (top0), TREE_TYPE (t),
   2412  1.1  mrg 		  TREE_OPERAND (top0, 0), TREE_OPERAND (top0, 1));
   2413  1.1  mrg     }
   2414  1.1  mrg   /* For x ^ y use x != y.  */
   2415  1.1  mrg   else if (TREE_CODE (t) == BIT_XOR_EXPR)
   2416  1.1  mrg     t = build2 (NE_EXPR, TREE_TYPE (t),
   2417  1.1  mrg 		TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
   2418  1.1  mrg 
   2419  1.1  mrg   if (is_gimple_condexpr (t))
   2420  1.1  mrg     return t;
   2421  1.1  mrg 
   2422  1.1  mrg   return NULL_TREE;
   2423  1.1  mrg }
   2424  1.1  mrg 
   2425  1.1  mrg /* Build a GIMPLE_CALL identical to STMT but skipping the arguments in
   2426  1.1  mrg    the positions marked by the set ARGS_TO_SKIP.  */
   2427  1.1  mrg 
   2428  1.1  mrg gcall *
   2429  1.1  mrg gimple_call_copy_skip_args (gcall *stmt, bitmap args_to_skip)
   2430  1.1  mrg {
   2431  1.1  mrg   int i;
   2432  1.1  mrg   int nargs = gimple_call_num_args (stmt);
   2433  1.1  mrg   auto_vec<tree> vargs (nargs);
   2434  1.1  mrg   gcall *new_stmt;
   2435  1.1  mrg 
   2436  1.1  mrg   for (i = 0; i < nargs; i++)
   2437  1.1  mrg     if (!bitmap_bit_p (args_to_skip, i))
   2438  1.1  mrg       vargs.quick_push (gimple_call_arg (stmt, i));
   2439  1.1  mrg 
   2440  1.1  mrg   if (gimple_call_internal_p (stmt))
   2441  1.1  mrg     new_stmt = gimple_build_call_internal_vec (gimple_call_internal_fn (stmt),
   2442  1.1  mrg 					       vargs);
   2443  1.1  mrg   else
   2444  1.1  mrg     new_stmt = gimple_build_call_vec (gimple_call_fn (stmt), vargs);
   2445  1.1  mrg 
   2446  1.1  mrg   if (gimple_call_lhs (stmt))
   2447  1.1  mrg     gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
   2448  1.1  mrg 
   2449  1.1  mrg   gimple_set_vuse (new_stmt, gimple_vuse (stmt));
   2450  1.1  mrg   gimple_set_vdef (new_stmt, gimple_vdef (stmt));
   2451  1.1  mrg 
   2452  1.1  mrg   if (gimple_has_location (stmt))
   2453  1.1  mrg     gimple_set_location (new_stmt, gimple_location (stmt));
   2454  1.1  mrg   gimple_call_copy_flags (new_stmt, stmt);
   2455  1.1  mrg   gimple_call_set_chain (new_stmt, gimple_call_chain (stmt));
   2456  1.1  mrg 
   2457  1.1  mrg   gimple_set_modified (new_stmt, true);
   2458  1.1  mrg 
   2459  1.1  mrg   return new_stmt;
   2460  1.1  mrg }
   2461  1.1  mrg 
   2462  1.1  mrg 
   2463  1.1  mrg 
   2464  1.1  mrg /* Return true if the field decls F1 and F2 are at the same offset.
   2465  1.1  mrg 
   2466  1.1  mrg    This is intended to be used on GIMPLE types only.  */
   2467  1.1  mrg 
   2468  1.1  mrg bool
   2469  1.1  mrg gimple_compare_field_offset (tree f1, tree f2)
   2470  1.1  mrg {
   2471  1.1  mrg   if (DECL_OFFSET_ALIGN (f1) == DECL_OFFSET_ALIGN (f2))
   2472  1.1  mrg     {
   2473  1.1  mrg       tree offset1 = DECL_FIELD_OFFSET (f1);
   2474  1.1  mrg       tree offset2 = DECL_FIELD_OFFSET (f2);
   2475  1.1  mrg       return ((offset1 == offset2
   2476  1.1  mrg 	       /* Once gimplification is done, self-referential offsets are
   2477  1.1  mrg 		  instantiated as operand #2 of the COMPONENT_REF built for
   2478  1.1  mrg 		  each access and reset.  Therefore, they are not relevant
   2479  1.1  mrg 		  anymore and fields are interchangeable provided that they
   2480  1.1  mrg 		  represent the same access.  */
   2481  1.1  mrg 	       || (TREE_CODE (offset1) == PLACEHOLDER_EXPR
   2482  1.1  mrg 		   && TREE_CODE (offset2) == PLACEHOLDER_EXPR
   2483  1.1  mrg 		   && (DECL_SIZE (f1) == DECL_SIZE (f2)
   2484  1.1  mrg 		       || (TREE_CODE (DECL_SIZE (f1)) == PLACEHOLDER_EXPR
   2485  1.1  mrg 			   && TREE_CODE (DECL_SIZE (f2)) == PLACEHOLDER_EXPR)
   2486  1.1  mrg 		       || operand_equal_p (DECL_SIZE (f1), DECL_SIZE (f2), 0))
   2487  1.1  mrg 		   && DECL_ALIGN (f1) == DECL_ALIGN (f2))
   2488  1.1  mrg 	       || operand_equal_p (offset1, offset2, 0))
   2489  1.1  mrg 	      && tree_int_cst_equal (DECL_FIELD_BIT_OFFSET (f1),
   2490  1.1  mrg 				     DECL_FIELD_BIT_OFFSET (f2)));
   2491  1.1  mrg     }
   2492  1.1  mrg 
   2493  1.1  mrg   /* Fortran and C do not always agree on what DECL_OFFSET_ALIGN
   2494  1.1  mrg      should be, so handle differing ones specially by decomposing
   2495  1.1  mrg      the offset into a byte and bit offset manually.  */
   2496  1.1  mrg   if (tree_fits_shwi_p (DECL_FIELD_OFFSET (f1))
   2497  1.1  mrg       && tree_fits_shwi_p (DECL_FIELD_OFFSET (f2)))
   2498  1.1  mrg     {
   2499  1.1  mrg       unsigned HOST_WIDE_INT byte_offset1, byte_offset2;
   2500  1.1  mrg       unsigned HOST_WIDE_INT bit_offset1, bit_offset2;
   2501  1.1  mrg       bit_offset1 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f1));
   2502  1.1  mrg       byte_offset1 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f1))
   2503  1.1  mrg 		      + bit_offset1 / BITS_PER_UNIT);
   2504  1.1  mrg       bit_offset2 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f2));
   2505  1.1  mrg       byte_offset2 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f2))
   2506  1.1  mrg 		      + bit_offset2 / BITS_PER_UNIT);
   2507  1.1  mrg       if (byte_offset1 != byte_offset2)
   2508  1.1  mrg 	return false;
   2509  1.1  mrg       return bit_offset1 % BITS_PER_UNIT == bit_offset2 % BITS_PER_UNIT;
   2510  1.1  mrg     }
   2511  1.1  mrg 
   2512  1.1  mrg   return false;
   2513  1.1  mrg }
   2514  1.1  mrg 
   2515  1.1  mrg 
   2516  1.1  mrg /* Return a type the same as TYPE except unsigned or
   2517  1.1  mrg    signed according to UNSIGNEDP.  */
   2518  1.1  mrg 
   2519  1.1  mrg static tree
   2520  1.1  mrg gimple_signed_or_unsigned_type (bool unsignedp, tree type)
   2521  1.1  mrg {
   2522  1.1  mrg   tree type1;
   2523  1.1  mrg   int i;
   2524  1.1  mrg 
   2525  1.1  mrg   type1 = TYPE_MAIN_VARIANT (type);
   2526  1.1  mrg   if (type1 == signed_char_type_node
   2527  1.1  mrg       || type1 == char_type_node
   2528  1.1  mrg       || type1 == unsigned_char_type_node)
   2529  1.1  mrg     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
   2530  1.1  mrg   if (type1 == integer_type_node || type1 == unsigned_type_node)
   2531  1.1  mrg     return unsignedp ? unsigned_type_node : integer_type_node;
   2532  1.1  mrg   if (type1 == short_integer_type_node || type1 == short_unsigned_type_node)
   2533  1.1  mrg     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
   2534  1.1  mrg   if (type1 == long_integer_type_node || type1 == long_unsigned_type_node)
   2535  1.1  mrg     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
   2536  1.1  mrg   if (type1 == long_long_integer_type_node
   2537  1.1  mrg       || type1 == long_long_unsigned_type_node)
   2538  1.1  mrg     return unsignedp
   2539  1.1  mrg            ? long_long_unsigned_type_node
   2540  1.1  mrg 	   : long_long_integer_type_node;
   2541  1.1  mrg 
   2542  1.1  mrg   for (i = 0; i < NUM_INT_N_ENTS; i ++)
   2543  1.1  mrg     if (int_n_enabled_p[i]
   2544  1.1  mrg 	&& (type1 == int_n_trees[i].unsigned_type
   2545  1.1  mrg 	    || type1 == int_n_trees[i].signed_type))
   2546  1.1  mrg 	return unsignedp
   2547  1.1  mrg 	  ? int_n_trees[i].unsigned_type
   2548  1.1  mrg 	  : int_n_trees[i].signed_type;
   2549  1.1  mrg 
   2550  1.1  mrg #if HOST_BITS_PER_WIDE_INT >= 64
   2551  1.1  mrg   if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
   2552  1.1  mrg     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
   2553  1.1  mrg #endif
   2554  1.1  mrg   if (type1 == intDI_type_node || type1 == unsigned_intDI_type_node)
   2555  1.1  mrg     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
   2556  1.1  mrg   if (type1 == intSI_type_node || type1 == unsigned_intSI_type_node)
   2557  1.1  mrg     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
   2558  1.1  mrg   if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node)
   2559  1.1  mrg     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
   2560  1.1  mrg   if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
   2561  1.1  mrg     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
   2562  1.1  mrg 
   2563  1.1  mrg #define GIMPLE_FIXED_TYPES(NAME)	    \
   2564  1.1  mrg   if (type1 == short_ ## NAME ## _type_node \
   2565  1.1  mrg       || type1 == unsigned_short_ ## NAME ## _type_node) \
   2566  1.1  mrg     return unsignedp ? unsigned_short_ ## NAME ## _type_node \
   2567  1.1  mrg 		     : short_ ## NAME ## _type_node; \
   2568  1.1  mrg   if (type1 == NAME ## _type_node \
   2569  1.1  mrg       || type1 == unsigned_ ## NAME ## _type_node) \
   2570  1.1  mrg     return unsignedp ? unsigned_ ## NAME ## _type_node \
   2571  1.1  mrg 		     : NAME ## _type_node; \
   2572  1.1  mrg   if (type1 == long_ ## NAME ## _type_node \
   2573  1.1  mrg       || type1 == unsigned_long_ ## NAME ## _type_node) \
   2574  1.1  mrg     return unsignedp ? unsigned_long_ ## NAME ## _type_node \
   2575  1.1  mrg 		     : long_ ## NAME ## _type_node; \
   2576  1.1  mrg   if (type1 == long_long_ ## NAME ## _type_node \
   2577  1.1  mrg       || type1 == unsigned_long_long_ ## NAME ## _type_node) \
   2578  1.1  mrg     return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \
   2579  1.1  mrg 		     : long_long_ ## NAME ## _type_node;
   2580  1.1  mrg 
   2581  1.1  mrg #define GIMPLE_FIXED_MODE_TYPES(NAME) \
   2582  1.1  mrg   if (type1 == NAME ## _type_node \
   2583  1.1  mrg       || type1 == u ## NAME ## _type_node) \
   2584  1.1  mrg     return unsignedp ? u ## NAME ## _type_node \
   2585  1.1  mrg 		     : NAME ## _type_node;
   2586  1.1  mrg 
   2587  1.1  mrg #define GIMPLE_FIXED_TYPES_SAT(NAME) \
   2588  1.1  mrg   if (type1 == sat_ ## short_ ## NAME ## _type_node \
   2589  1.1  mrg       || type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \
   2590  1.1  mrg     return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \
   2591  1.1  mrg 		     : sat_ ## short_ ## NAME ## _type_node; \
   2592  1.1  mrg   if (type1 == sat_ ## NAME ## _type_node \
   2593  1.1  mrg       || type1 == sat_ ## unsigned_ ## NAME ## _type_node) \
   2594  1.1  mrg     return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \
   2595  1.1  mrg 		     : sat_ ## NAME ## _type_node; \
   2596  1.1  mrg   if (type1 == sat_ ## long_ ## NAME ## _type_node \
   2597  1.1  mrg       || type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \
   2598  1.1  mrg     return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \
   2599  1.1  mrg 		     : sat_ ## long_ ## NAME ## _type_node; \
   2600  1.1  mrg   if (type1 == sat_ ## long_long_ ## NAME ## _type_node \
   2601  1.1  mrg       || type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \
   2602  1.1  mrg     return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \
   2603  1.1  mrg 		     : sat_ ## long_long_ ## NAME ## _type_node;
   2604  1.1  mrg 
   2605  1.1  mrg #define GIMPLE_FIXED_MODE_TYPES_SAT(NAME)	\
   2606  1.1  mrg   if (type1 == sat_ ## NAME ## _type_node \
   2607  1.1  mrg       || type1 == sat_ ## u ## NAME ## _type_node) \
   2608  1.1  mrg     return unsignedp ? sat_ ## u ## NAME ## _type_node \
   2609  1.1  mrg 		     : sat_ ## NAME ## _type_node;
   2610  1.1  mrg 
   2611  1.1  mrg   GIMPLE_FIXED_TYPES (fract);
   2612  1.1  mrg   GIMPLE_FIXED_TYPES_SAT (fract);
   2613  1.1  mrg   GIMPLE_FIXED_TYPES (accum);
   2614  1.1  mrg   GIMPLE_FIXED_TYPES_SAT (accum);
   2615  1.1  mrg 
   2616  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (qq);
   2617  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (hq);
   2618  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (sq);
   2619  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (dq);
   2620  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (tq);
   2621  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (qq);
   2622  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (hq);
   2623  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (sq);
   2624  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (dq);
   2625  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (tq);
   2626  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (ha);
   2627  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (sa);
   2628  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (da);
   2629  1.1  mrg   GIMPLE_FIXED_MODE_TYPES (ta);
   2630  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (ha);
   2631  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (sa);
   2632  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (da);
   2633  1.1  mrg   GIMPLE_FIXED_MODE_TYPES_SAT (ta);
   2634  1.1  mrg 
   2635  1.1  mrg   /* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
   2636  1.1  mrg      the precision; they have precision set to match their range, but
   2637  1.1  mrg      may use a wider mode to match an ABI.  If we change modes, we may
   2638  1.1  mrg      wind up with bad conversions.  For INTEGER_TYPEs in C, must check
   2639  1.1  mrg      the precision as well, so as to yield correct results for
   2640  1.1  mrg      bit-field types.  C++ does not have these separate bit-field
   2641  1.1  mrg      types, and producing a signed or unsigned variant of an
   2642  1.1  mrg      ENUMERAL_TYPE may cause other problems as well.  */
   2643  1.1  mrg   if (!INTEGRAL_TYPE_P (type)
   2644  1.1  mrg       || TYPE_UNSIGNED (type) == unsignedp)
   2645  1.1  mrg     return type;
   2646  1.1  mrg 
   2647  1.1  mrg #define TYPE_OK(node)							    \
   2648  1.1  mrg   (TYPE_MODE (type) == TYPE_MODE (node)					    \
   2649  1.1  mrg    && TYPE_PRECISION (type) == TYPE_PRECISION (node))
   2650  1.1  mrg   if (TYPE_OK (signed_char_type_node))
   2651  1.1  mrg     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
   2652  1.1  mrg   if (TYPE_OK (integer_type_node))
   2653  1.1  mrg     return unsignedp ? unsigned_type_node : integer_type_node;
   2654  1.1  mrg   if (TYPE_OK (short_integer_type_node))
   2655  1.1  mrg     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
   2656  1.1  mrg   if (TYPE_OK (long_integer_type_node))
   2657  1.1  mrg     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
   2658  1.1  mrg   if (TYPE_OK (long_long_integer_type_node))
   2659  1.1  mrg     return (unsignedp
   2660  1.1  mrg 	    ? long_long_unsigned_type_node
   2661  1.1  mrg 	    : long_long_integer_type_node);
   2662  1.1  mrg 
   2663  1.1  mrg   for (i = 0; i < NUM_INT_N_ENTS; i ++)
   2664  1.1  mrg     if (int_n_enabled_p[i]
   2665  1.1  mrg 	&& TYPE_MODE (type) == int_n_data[i].m
   2666  1.1  mrg 	&& TYPE_PRECISION (type) == int_n_data[i].bitsize)
   2667  1.1  mrg 	return unsignedp
   2668  1.1  mrg 	  ? int_n_trees[i].unsigned_type
   2669  1.1  mrg 	  : int_n_trees[i].signed_type;
   2670  1.1  mrg 
   2671  1.1  mrg #if HOST_BITS_PER_WIDE_INT >= 64
   2672  1.1  mrg   if (TYPE_OK (intTI_type_node))
   2673  1.1  mrg     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
   2674  1.1  mrg #endif
   2675  1.1  mrg   if (TYPE_OK (intDI_type_node))
   2676  1.1  mrg     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
   2677  1.1  mrg   if (TYPE_OK (intSI_type_node))
   2678  1.1  mrg     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
   2679  1.1  mrg   if (TYPE_OK (intHI_type_node))
   2680  1.1  mrg     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
   2681  1.1  mrg   if (TYPE_OK (intQI_type_node))
   2682  1.1  mrg     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
   2683  1.1  mrg 
   2684  1.1  mrg #undef GIMPLE_FIXED_TYPES
   2685  1.1  mrg #undef GIMPLE_FIXED_MODE_TYPES
   2686  1.1  mrg #undef GIMPLE_FIXED_TYPES_SAT
   2687  1.1  mrg #undef GIMPLE_FIXED_MODE_TYPES_SAT
   2688  1.1  mrg #undef TYPE_OK
   2689  1.1  mrg 
   2690  1.1  mrg   return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
   2691  1.1  mrg }
   2692  1.1  mrg 
   2693  1.1  mrg 
   2694  1.1  mrg /* Return an unsigned type the same as TYPE in other respects.  */
   2695  1.1  mrg 
   2696  1.1  mrg tree
   2697  1.1  mrg gimple_unsigned_type (tree type)
   2698  1.1  mrg {
   2699  1.1  mrg   return gimple_signed_or_unsigned_type (true, type);
   2700  1.1  mrg }
   2701  1.1  mrg 
   2702  1.1  mrg 
   2703  1.1  mrg /* Return a signed type the same as TYPE in other respects.  */
   2704  1.1  mrg 
   2705  1.1  mrg tree
   2706  1.1  mrg gimple_signed_type (tree type)
   2707  1.1  mrg {
   2708  1.1  mrg   return gimple_signed_or_unsigned_type (false, type);
   2709  1.1  mrg }
   2710  1.1  mrg 
   2711  1.1  mrg 
   2712  1.1  mrg /* Return the typed-based alias set for T, which may be an expression
   2713  1.1  mrg    or a type.  Return -1 if we don't do anything special.  */
   2714  1.1  mrg 
   2715  1.1  mrg alias_set_type
   2716  1.1  mrg gimple_get_alias_set (tree t)
   2717  1.1  mrg {
   2718  1.1  mrg   /* That's all the expressions we handle specially.  */
   2719  1.1  mrg   if (!TYPE_P (t))
   2720  1.1  mrg     return -1;
   2721  1.1  mrg 
   2722  1.1  mrg   /* For convenience, follow the C standard when dealing with
   2723  1.1  mrg      character types.  Any object may be accessed via an lvalue that
   2724  1.1  mrg      has character type.  */
   2725  1.1  mrg   if (t == char_type_node
   2726  1.1  mrg       || t == signed_char_type_node
   2727  1.1  mrg       || t == unsigned_char_type_node)
   2728  1.1  mrg     return 0;
   2729  1.1  mrg 
   2730  1.1  mrg   /* Allow aliasing between signed and unsigned variants of the same
   2731  1.1  mrg      type.  We treat the signed variant as canonical.  */
   2732  1.1  mrg   if (TREE_CODE (t) == INTEGER_TYPE && TYPE_UNSIGNED (t))
   2733  1.1  mrg     {
   2734  1.1  mrg       tree t1 = gimple_signed_type (t);
   2735  1.1  mrg 
   2736  1.1  mrg       /* t1 == t can happen for boolean nodes which are always unsigned.  */
   2737  1.1  mrg       if (t1 != t)
   2738  1.1  mrg 	return get_alias_set (t1);
   2739  1.1  mrg     }
   2740  1.1  mrg 
   2741  1.1  mrg   /* Allow aliasing between enumeral types and the underlying
   2742  1.1  mrg      integer type.  This is required for C since those are
   2743  1.1  mrg      compatible types.  */
   2744  1.1  mrg   else if (TREE_CODE (t) == ENUMERAL_TYPE)
   2745  1.1  mrg     {
   2746  1.1  mrg       tree t1 = lang_hooks.types.type_for_size (tree_to_uhwi (TYPE_SIZE (t)),
   2747  1.1  mrg 						false /* short-cut above */);
   2748  1.1  mrg       return get_alias_set (t1);
   2749  1.1  mrg     }
   2750  1.1  mrg 
   2751  1.1  mrg   return -1;
   2752  1.1  mrg }
   2753  1.1  mrg 
   2754  1.1  mrg 
   2755  1.1  mrg /* Helper for gimple_ior_addresses_taken_1.  */
   2756  1.1  mrg 
   2757  1.1  mrg static bool
   2758  1.1  mrg gimple_ior_addresses_taken_1 (gimple *, tree addr, tree, void *data)
   2759  1.1  mrg {
   2760  1.1  mrg   bitmap addresses_taken = (bitmap)data;
   2761  1.1  mrg   addr = get_base_address (addr);
   2762  1.1  mrg   if (addr
   2763  1.1  mrg       && DECL_P (addr))
   2764  1.1  mrg     {
   2765  1.1  mrg       bitmap_set_bit (addresses_taken, DECL_UID (addr));
   2766  1.1  mrg       return true;
   2767  1.1  mrg     }
   2768  1.1  mrg   return false;
   2769  1.1  mrg }
   2770  1.1  mrg 
   2771  1.1  mrg /* Set the bit for the uid of all decls that have their address taken
   2772  1.1  mrg    in STMT in the ADDRESSES_TAKEN bitmap.  Returns true if there
   2773  1.1  mrg    were any in this stmt.  */
   2774  1.1  mrg 
   2775  1.1  mrg bool
   2776  1.1  mrg gimple_ior_addresses_taken (bitmap addresses_taken, gimple *stmt)
   2777  1.1  mrg {
   2778  1.1  mrg   return walk_stmt_load_store_addr_ops (stmt, addresses_taken, NULL, NULL,
   2779  1.1  mrg 					gimple_ior_addresses_taken_1);
   2780  1.1  mrg }
   2781  1.1  mrg 
   2782  1.1  mrg 
   2783  1.1  mrg /* Return true when STMTs arguments and return value match those of FNDECL,
   2784  1.1  mrg    a decl of a builtin function.  */
   2785  1.1  mrg 
   2786  1.1  mrg bool
   2787  1.1  mrg gimple_builtin_call_types_compatible_p (const gimple *stmt, tree fndecl)
   2788  1.1  mrg {
   2789  1.1  mrg   gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN);
   2790  1.1  mrg 
   2791  1.1  mrg   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
   2792  1.1  mrg     if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
   2793  1.1  mrg       fndecl = decl;
   2794  1.1  mrg 
   2795  1.1  mrg   tree ret = gimple_call_lhs (stmt);
   2796  1.1  mrg   if (ret
   2797  1.1  mrg       && !useless_type_conversion_p (TREE_TYPE (ret),
   2798  1.1  mrg 				     TREE_TYPE (TREE_TYPE (fndecl))))
   2799  1.1  mrg     return false;
   2800  1.1  mrg 
   2801  1.1  mrg   tree targs = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
   2802  1.1  mrg   unsigned nargs = gimple_call_num_args (stmt);
   2803  1.1  mrg   for (unsigned i = 0; i < nargs; ++i)
   2804  1.1  mrg     {
   2805  1.1  mrg       /* Variadic args follow.  */
   2806  1.1  mrg       if (!targs)
   2807  1.1  mrg 	return true;
   2808  1.1  mrg       tree arg = gimple_call_arg (stmt, i);
   2809  1.1  mrg       tree type = TREE_VALUE (targs);
   2810  1.1  mrg       if (!useless_type_conversion_p (type, TREE_TYPE (arg))
   2811  1.1  mrg 	  /* char/short integral arguments are promoted to int
   2812  1.1  mrg 	     by several frontends if targetm.calls.promote_prototypes
   2813  1.1  mrg 	     is true.  Allow such promotion too.  */
   2814  1.1  mrg 	  && !(INTEGRAL_TYPE_P (type)
   2815  1.1  mrg 	       && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
   2816  1.1  mrg 	       && targetm.calls.promote_prototypes (TREE_TYPE (fndecl))
   2817  1.1  mrg 	       && useless_type_conversion_p (integer_type_node,
   2818  1.1  mrg 					     TREE_TYPE (arg))))
   2819  1.1  mrg 	return false;
   2820  1.1  mrg       targs = TREE_CHAIN (targs);
   2821  1.1  mrg     }
   2822  1.1  mrg   if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
   2823  1.1  mrg     return false;
   2824  1.1  mrg   return true;
   2825  1.1  mrg }
   2826  1.1  mrg 
   2827  1.1  mrg /* Return true when STMT is operator a replaceable delete call.  */
   2828  1.1  mrg 
   2829  1.1  mrg bool
   2830  1.1  mrg gimple_call_operator_delete_p (const gcall *stmt)
   2831  1.1  mrg {
   2832  1.1  mrg   tree fndecl;
   2833  1.1  mrg 
   2834  1.1  mrg   if ((fndecl = gimple_call_fndecl (stmt)) != NULL_TREE)
   2835  1.1  mrg     return DECL_IS_OPERATOR_DELETE_P (fndecl);
   2836  1.1  mrg   return false;
   2837  1.1  mrg }
   2838  1.1  mrg 
   2839  1.1  mrg /* Return true when STMT is builtins call.  */
   2840  1.1  mrg 
   2841  1.1  mrg bool
   2842  1.1  mrg gimple_call_builtin_p (const gimple *stmt)
   2843  1.1  mrg {
   2844  1.1  mrg   tree fndecl;
   2845  1.1  mrg   if (is_gimple_call (stmt)
   2846  1.1  mrg       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
   2847  1.1  mrg       && DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN)
   2848  1.1  mrg     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   2849  1.1  mrg   return false;
   2850  1.1  mrg }
   2851  1.1  mrg 
   2852  1.1  mrg /* Return true when STMT is builtins call to CLASS.  */
   2853  1.1  mrg 
   2854  1.1  mrg bool
   2855  1.1  mrg gimple_call_builtin_p (const gimple *stmt, enum built_in_class klass)
   2856  1.1  mrg {
   2857  1.1  mrg   tree fndecl;
   2858  1.1  mrg   if (is_gimple_call (stmt)
   2859  1.1  mrg       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
   2860  1.1  mrg       && DECL_BUILT_IN_CLASS (fndecl) == klass)
   2861  1.1  mrg     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   2862  1.1  mrg   return false;
   2863  1.1  mrg }
   2864  1.1  mrg 
   2865  1.1  mrg /* Return true when STMT is builtins call to CODE of CLASS.  */
   2866  1.1  mrg 
   2867  1.1  mrg bool
   2868  1.1  mrg gimple_call_builtin_p (const gimple *stmt, enum built_in_function code)
   2869  1.1  mrg {
   2870  1.1  mrg   tree fndecl;
   2871  1.1  mrg   if (is_gimple_call (stmt)
   2872  1.1  mrg       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
   2873  1.1  mrg       && fndecl_built_in_p (fndecl, code))
   2874  1.1  mrg     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   2875  1.1  mrg   return false;
   2876  1.1  mrg }
   2877  1.1  mrg 
   2878  1.1  mrg /* If CALL is a call to a combined_fn (i.e. an internal function or
   2879  1.1  mrg    a normal built-in function), return its code, otherwise return
   2880  1.1  mrg    CFN_LAST.  */
   2881  1.1  mrg 
   2882  1.1  mrg combined_fn
   2883  1.1  mrg gimple_call_combined_fn (const gimple *stmt)
   2884  1.1  mrg {
   2885  1.1  mrg   if (const gcall *call = dyn_cast <const gcall *> (stmt))
   2886  1.1  mrg     {
   2887  1.1  mrg       if (gimple_call_internal_p (call))
   2888  1.1  mrg 	return as_combined_fn (gimple_call_internal_fn (call));
   2889  1.1  mrg 
   2890  1.1  mrg       tree fndecl = gimple_call_fndecl (stmt);
   2891  1.1  mrg       if (fndecl
   2892  1.1  mrg 	  && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
   2893  1.1  mrg 	  && gimple_builtin_call_types_compatible_p (stmt, fndecl))
   2894  1.1  mrg 	return as_combined_fn (DECL_FUNCTION_CODE (fndecl));
   2895  1.1  mrg     }
   2896  1.1  mrg   return CFN_LAST;
   2897  1.1  mrg }
   2898  1.1  mrg 
   2899  1.1  mrg /* Return true if STMT clobbers memory.  STMT is required to be a
   2900  1.1  mrg    GIMPLE_ASM.  */
   2901  1.1  mrg 
   2902  1.1  mrg bool
   2903  1.1  mrg gimple_asm_clobbers_memory_p (const gasm *stmt)
   2904  1.1  mrg {
   2905  1.1  mrg   unsigned i;
   2906  1.1  mrg 
   2907  1.1  mrg   for (i = 0; i < gimple_asm_nclobbers (stmt); i++)
   2908  1.1  mrg     {
   2909  1.1  mrg       tree op = gimple_asm_clobber_op (stmt, i);
   2910  1.1  mrg       if (strcmp (TREE_STRING_POINTER (TREE_VALUE (op)), "memory") == 0)
   2911  1.1  mrg 	return true;
   2912  1.1  mrg     }
   2913  1.1  mrg 
   2914  1.1  mrg   /* Non-empty basic ASM implicitly clobbers memory.  */
   2915  1.1  mrg   if (gimple_asm_input_p (stmt) && strlen (gimple_asm_string (stmt)) != 0)
   2916  1.1  mrg     return true;
   2917  1.1  mrg 
   2918  1.1  mrg   return false;
   2919  1.1  mrg }
   2920  1.1  mrg 
   2921  1.1  mrg /* Dump bitmap SET (assumed to contain VAR_DECLs) to FILE.  */
   2922  1.1  mrg 
   2923  1.1  mrg void
   2924  1.1  mrg dump_decl_set (FILE *file, bitmap set)
   2925  1.1  mrg {
   2926  1.1  mrg   if (set)
   2927  1.1  mrg     {
   2928  1.1  mrg       bitmap_iterator bi;
   2929  1.1  mrg       unsigned i;
   2930  1.1  mrg 
   2931  1.1  mrg       fprintf (file, "{ ");
   2932  1.1  mrg 
   2933  1.1  mrg       EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
   2934  1.1  mrg 	{
   2935  1.1  mrg 	  fprintf (file, "D.%u", i);
   2936  1.1  mrg 	  fprintf (file, " ");
   2937  1.1  mrg 	}
   2938  1.1  mrg 
   2939  1.1  mrg       fprintf (file, "}");
   2940  1.1  mrg     }
   2941  1.1  mrg   else
   2942  1.1  mrg     fprintf (file, "NIL");
   2943  1.1  mrg }
   2944  1.1  mrg 
   2945  1.1  mrg /* Return true when CALL is a call stmt that definitely doesn't
   2946  1.1  mrg    free any memory or makes it unavailable otherwise.  */
   2947  1.1  mrg bool
   2948  1.1  mrg nonfreeing_call_p (gimple *call)
   2949  1.1  mrg {
   2950  1.1  mrg   if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
   2951  1.1  mrg       && gimple_call_flags (call) & ECF_LEAF)
   2952  1.1  mrg     switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
   2953  1.1  mrg       {
   2954  1.1  mrg 	/* Just in case these become ECF_LEAF in the future.  */
   2955  1.1  mrg 	case BUILT_IN_FREE:
   2956  1.1  mrg 	case BUILT_IN_TM_FREE:
   2957  1.1  mrg 	case BUILT_IN_REALLOC:
   2958  1.1  mrg 	case BUILT_IN_STACK_RESTORE:
   2959  1.1  mrg 	  return false;
   2960  1.1  mrg 	default:
   2961  1.1  mrg 	  return true;
   2962  1.1  mrg       }
   2963  1.1  mrg   else if (gimple_call_internal_p (call))
   2964  1.1  mrg     switch (gimple_call_internal_fn (call))
   2965  1.1  mrg       {
   2966  1.1  mrg       case IFN_ABNORMAL_DISPATCHER:
   2967  1.1  mrg         return true;
   2968  1.1  mrg       case IFN_ASAN_MARK:
   2969  1.1  mrg 	return tree_to_uhwi (gimple_call_arg (call, 0)) == ASAN_MARK_UNPOISON;
   2970  1.1  mrg       default:
   2971  1.1  mrg 	if (gimple_call_flags (call) & ECF_LEAF)
   2972  1.1  mrg 	  return true;
   2973  1.1  mrg 	return false;
   2974  1.1  mrg       }
   2975  1.1  mrg 
   2976  1.1  mrg   tree fndecl = gimple_call_fndecl (call);
   2977  1.1  mrg   if (!fndecl)
   2978  1.1  mrg     return false;
   2979  1.1  mrg   struct cgraph_node *n = cgraph_node::get (fndecl);
   2980  1.1  mrg   if (!n)
   2981  1.1  mrg     return false;
   2982  1.1  mrg   enum availability availability;
   2983  1.1  mrg   n = n->function_symbol (&availability);
   2984  1.1  mrg   if (!n || availability <= AVAIL_INTERPOSABLE)
   2985  1.1  mrg     return false;
   2986  1.1  mrg   return n->nonfreeing_fn;
   2987  1.1  mrg }
   2988  1.1  mrg 
   2989  1.1  mrg /* Return true when CALL is a call stmt that definitely need not
   2990  1.1  mrg    be considered to be a memory barrier.  */
   2991  1.1  mrg bool
   2992  1.1  mrg nonbarrier_call_p (gimple *call)
   2993  1.1  mrg {
   2994  1.1  mrg   if (gimple_call_flags (call) & (ECF_PURE | ECF_CONST))
   2995  1.1  mrg     return true;
   2996  1.1  mrg   /* Should extend this to have a nonbarrier_fn flag, just as above in
   2997  1.1  mrg      the nonfreeing case.  */
   2998  1.1  mrg   return false;
   2999  1.1  mrg }
   3000  1.1  mrg 
   3001  1.1  mrg /* Callback for walk_stmt_load_store_ops.
   3002  1.1  mrg 
   3003  1.1  mrg    Return TRUE if OP will dereference the tree stored in DATA, FALSE
   3004  1.1  mrg    otherwise.
   3005  1.1  mrg 
   3006  1.1  mrg    This routine only makes a superficial check for a dereference.  Thus
   3007  1.1  mrg    it must only be used if it is safe to return a false negative.  */
   3008  1.1  mrg static bool
   3009  1.1  mrg check_loadstore (gimple *, tree op, tree, void *data)
   3010  1.1  mrg {
   3011  1.1  mrg   if (TREE_CODE (op) == MEM_REF || TREE_CODE (op) == TARGET_MEM_REF)
   3012  1.1  mrg     {
   3013  1.1  mrg       /* Some address spaces may legitimately dereference zero.  */
   3014  1.1  mrg       addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (op));
   3015  1.1  mrg       if (targetm.addr_space.zero_address_valid (as))
   3016  1.1  mrg 	return false;
   3017  1.1  mrg 
   3018  1.1  mrg       return operand_equal_p (TREE_OPERAND (op, 0), (tree)data, 0);
   3019  1.1  mrg     }
   3020  1.1  mrg   return false;
   3021  1.1  mrg }
   3022  1.1  mrg 
   3023  1.1  mrg 
   3024  1.1  mrg /* Return true if OP can be inferred to be non-NULL after STMT executes,
   3025  1.1  mrg    either by using a pointer dereference or attributes.  */
   3026  1.1  mrg bool
   3027  1.1  mrg infer_nonnull_range (gimple *stmt, tree op)
   3028  1.1  mrg {
   3029  1.1  mrg   return (infer_nonnull_range_by_dereference (stmt, op)
   3030  1.1  mrg 	  || infer_nonnull_range_by_attribute (stmt, op));
   3031  1.1  mrg }
   3032  1.1  mrg 
   3033  1.1  mrg /* Return true if OP can be inferred to be non-NULL after STMT
   3034  1.1  mrg    executes by using a pointer dereference.  */
   3035  1.1  mrg bool
   3036  1.1  mrg infer_nonnull_range_by_dereference (gimple *stmt, tree op)
   3037  1.1  mrg {
   3038  1.1  mrg   /* We can only assume that a pointer dereference will yield
   3039  1.1  mrg      non-NULL if -fdelete-null-pointer-checks is enabled.  */
   3040  1.1  mrg   if (!flag_delete_null_pointer_checks
   3041  1.1  mrg       || !POINTER_TYPE_P (TREE_TYPE (op))
   3042  1.1  mrg       || gimple_code (stmt) == GIMPLE_ASM
   3043  1.1  mrg       || gimple_clobber_p (stmt))
   3044  1.1  mrg     return false;
   3045  1.1  mrg 
   3046  1.1  mrg   if (walk_stmt_load_store_ops (stmt, (void *)op,
   3047  1.1  mrg 				check_loadstore, check_loadstore))
   3048  1.1  mrg     return true;
   3049  1.1  mrg 
   3050  1.1  mrg   return false;
   3051  1.1  mrg }
   3052  1.1  mrg 
   3053  1.1  mrg /* Return true if OP can be inferred to be a non-NULL after STMT
   3054  1.1  mrg    executes by using attributes.  */
   3055  1.1  mrg bool
   3056  1.1  mrg infer_nonnull_range_by_attribute (gimple *stmt, tree op)
   3057  1.1  mrg {
   3058  1.1  mrg   /* We can only assume that a pointer dereference will yield
   3059  1.1  mrg      non-NULL if -fdelete-null-pointer-checks is enabled.  */
   3060  1.1  mrg   if (!flag_delete_null_pointer_checks
   3061  1.1  mrg       || !POINTER_TYPE_P (TREE_TYPE (op))
   3062  1.1  mrg       || gimple_code (stmt) == GIMPLE_ASM)
   3063  1.1  mrg     return false;
   3064  1.1  mrg 
   3065  1.1  mrg   if (is_gimple_call (stmt) && !gimple_call_internal_p (stmt))
   3066  1.1  mrg     {
   3067  1.1  mrg       tree fntype = gimple_call_fntype (stmt);
   3068  1.1  mrg       tree attrs = TYPE_ATTRIBUTES (fntype);
   3069  1.1  mrg       for (; attrs; attrs = TREE_CHAIN (attrs))
   3070  1.1  mrg 	{
   3071  1.1  mrg 	  attrs = lookup_attribute ("nonnull", attrs);
   3072  1.1  mrg 
   3073  1.1  mrg 	  /* If "nonnull" wasn't specified, we know nothing about
   3074  1.1  mrg 	     the argument.  */
   3075  1.1  mrg 	  if (attrs == NULL_TREE)
   3076  1.1  mrg 	    return false;
   3077  1.1  mrg 
   3078  1.1  mrg 	  /* If "nonnull" applies to all the arguments, then ARG
   3079  1.1  mrg 	     is non-null if it's in the argument list.  */
   3080  1.1  mrg 	  if (TREE_VALUE (attrs) == NULL_TREE)
   3081  1.1  mrg 	    {
   3082  1.1  mrg 	      for (unsigned int i = 0; i < gimple_call_num_args (stmt); i++)
   3083  1.1  mrg 		{
   3084  1.1  mrg 		  if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (stmt, i)))
   3085  1.1  mrg 		      && operand_equal_p (op, gimple_call_arg (stmt, i), 0))
   3086  1.1  mrg 		    return true;
   3087  1.1  mrg 		}
   3088  1.1  mrg 	      return false;
   3089  1.1  mrg 	    }
   3090  1.1  mrg 
   3091  1.1  mrg 	  /* Now see if op appears in the nonnull list.  */
   3092  1.1  mrg 	  for (tree t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t))
   3093  1.1  mrg 	    {
   3094  1.1  mrg 	      unsigned int idx = TREE_INT_CST_LOW (TREE_VALUE (t)) - 1;
   3095  1.1  mrg 	      if (idx < gimple_call_num_args (stmt))
   3096  1.1  mrg 		{
   3097  1.1  mrg 		  tree arg = gimple_call_arg (stmt, idx);
   3098  1.1  mrg 		  if (operand_equal_p (op, arg, 0))
   3099  1.1  mrg 		    return true;
   3100  1.1  mrg 		}
   3101  1.1  mrg 	    }
   3102  1.1  mrg 	}
   3103  1.1  mrg     }
   3104  1.1  mrg 
   3105  1.1  mrg   /* If this function is marked as returning non-null, then we can
   3106  1.1  mrg      infer OP is non-null if it is used in the return statement.  */
   3107  1.1  mrg   if (greturn *return_stmt = dyn_cast <greturn *> (stmt))
   3108  1.1  mrg     if (gimple_return_retval (return_stmt)
   3109  1.1  mrg 	&& operand_equal_p (gimple_return_retval (return_stmt), op, 0)
   3110  1.1  mrg 	&& lookup_attribute ("returns_nonnull",
   3111  1.1  mrg 			     TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl))))
   3112  1.1  mrg       return true;
   3113  1.1  mrg 
   3114  1.1  mrg   return false;
   3115  1.1  mrg }
   3116  1.1  mrg 
   3117  1.1  mrg /* Compare two case labels.  Because the front end should already have
   3118  1.1  mrg    made sure that case ranges do not overlap, it is enough to only compare
   3119  1.1  mrg    the CASE_LOW values of each case label.  */
   3120  1.1  mrg 
   3121  1.1  mrg static int
   3122  1.1  mrg compare_case_labels (const void *p1, const void *p2)
   3123  1.1  mrg {
   3124  1.1  mrg   const_tree const case1 = *(const_tree const*)p1;
   3125  1.1  mrg   const_tree const case2 = *(const_tree const*)p2;
   3126  1.1  mrg 
   3127  1.1  mrg   /* The 'default' case label always goes first.  */
   3128  1.1  mrg   if (!CASE_LOW (case1))
   3129  1.1  mrg     return -1;
   3130  1.1  mrg   else if (!CASE_LOW (case2))
   3131  1.1  mrg     return 1;
   3132  1.1  mrg   else
   3133  1.1  mrg     return tree_int_cst_compare (CASE_LOW (case1), CASE_LOW (case2));
   3134  1.1  mrg }
   3135  1.1  mrg 
   3136  1.1  mrg /* Sort the case labels in LABEL_VEC in place in ascending order.  */
   3137  1.1  mrg 
   3138  1.1  mrg void
   3139  1.1  mrg sort_case_labels (vec<tree> &label_vec)
   3140  1.1  mrg {
   3141  1.1  mrg   label_vec.qsort (compare_case_labels);
   3142  1.1  mrg }
   3143  1.1  mrg 
   3144  1.1  mrg /* Prepare a vector of case labels to be used in a GIMPLE_SWITCH statement.
   3146  1.1  mrg 
   3147  1.1  mrg    LABELS is a vector that contains all case labels to look at.
   3148  1.1  mrg 
   3149  1.1  mrg    INDEX_TYPE is the type of the switch index expression.  Case labels
   3150  1.1  mrg    in LABELS are discarded if their values are not in the value range
   3151  1.1  mrg    covered by INDEX_TYPE.  The remaining case label values are folded
   3152  1.1  mrg    to INDEX_TYPE.
   3153  1.1  mrg 
   3154  1.1  mrg    If a default case exists in LABELS, it is removed from LABELS and
   3155  1.1  mrg    returned in DEFAULT_CASEP.  If no default case exists, but the
   3156  1.1  mrg    case labels already cover the whole range of INDEX_TYPE, a default
   3157  1.1  mrg    case is returned pointing to one of the existing case labels.
   3158  1.1  mrg    Otherwise DEFAULT_CASEP is set to NULL_TREE.
   3159  1.1  mrg 
   3160  1.1  mrg    DEFAULT_CASEP may be NULL, in which case the above comment doesn't
   3161  1.1  mrg    apply and no action is taken regardless of whether a default case is
   3162  1.1  mrg    found or not.  */
   3163  1.1  mrg 
   3164  1.1  mrg void
   3165  1.1  mrg preprocess_case_label_vec_for_gimple (vec<tree> &labels,
   3166  1.1  mrg 				      tree index_type,
   3167  1.1  mrg 				      tree *default_casep)
   3168  1.1  mrg {
   3169  1.1  mrg   tree min_value, max_value;
   3170  1.1  mrg   tree default_case = NULL_TREE;
   3171  1.1  mrg   size_t i, len;
   3172  1.1  mrg 
   3173  1.1  mrg   i = 0;
   3174  1.1  mrg   min_value = TYPE_MIN_VALUE (index_type);
   3175  1.1  mrg   max_value = TYPE_MAX_VALUE (index_type);
   3176  1.1  mrg   while (i < labels.length ())
   3177  1.1  mrg     {
   3178  1.1  mrg       tree elt = labels[i];
   3179  1.1  mrg       tree low = CASE_LOW (elt);
   3180  1.1  mrg       tree high = CASE_HIGH (elt);
   3181  1.1  mrg       bool remove_element = FALSE;
   3182  1.1  mrg 
   3183  1.1  mrg       if (low)
   3184  1.1  mrg 	{
   3185  1.1  mrg 	  gcc_checking_assert (TREE_CODE (low) == INTEGER_CST);
   3186  1.1  mrg 	  gcc_checking_assert (!high || TREE_CODE (high) == INTEGER_CST);
   3187  1.1  mrg 
   3188  1.1  mrg 	  /* This is a non-default case label, i.e. it has a value.
   3189  1.1  mrg 
   3190  1.1  mrg 	     See if the case label is reachable within the range of
   3191  1.1  mrg 	     the index type.  Remove out-of-range case values.  Turn
   3192  1.1  mrg 	     case ranges into a canonical form (high > low strictly)
   3193  1.1  mrg 	     and convert the case label values to the index type.
   3194  1.1  mrg 
   3195  1.1  mrg 	     NB: The type of gimple_switch_index() may be the promoted
   3196  1.1  mrg 	     type, but the case labels retain the original type.  */
   3197  1.1  mrg 
   3198  1.1  mrg 	  if (high)
   3199  1.1  mrg 	    {
   3200  1.1  mrg 	      /* This is a case range.  Discard empty ranges.
   3201  1.1  mrg 		 If the bounds or the range are equal, turn this
   3202  1.1  mrg 		 into a simple (one-value) case.  */
   3203  1.1  mrg 	      int cmp = tree_int_cst_compare (high, low);
   3204  1.1  mrg 	      if (cmp < 0)
   3205  1.1  mrg 		remove_element = TRUE;
   3206  1.1  mrg 	      else if (cmp == 0)
   3207  1.1  mrg 		high = NULL_TREE;
   3208  1.1  mrg 	    }
   3209  1.1  mrg 
   3210  1.1  mrg 	  if (! high)
   3211  1.1  mrg 	    {
   3212  1.1  mrg 	      /* If the simple case value is unreachable, ignore it.  */
   3213  1.1  mrg 	      if ((TREE_CODE (min_value) == INTEGER_CST
   3214  1.1  mrg 		   && tree_int_cst_compare (low, min_value) < 0)
   3215  1.1  mrg 		  || (TREE_CODE (max_value) == INTEGER_CST
   3216  1.1  mrg 		      && tree_int_cst_compare (low, max_value) > 0))
   3217  1.1  mrg 		remove_element = TRUE;
   3218  1.1  mrg 	      else
   3219  1.1  mrg 		low = fold_convert (index_type, low);
   3220  1.1  mrg 	    }
   3221  1.1  mrg 	  else
   3222  1.1  mrg 	    {
   3223  1.1  mrg 	      /* If the entire case range is unreachable, ignore it.  */
   3224  1.1  mrg 	      if ((TREE_CODE (min_value) == INTEGER_CST
   3225  1.1  mrg 		   && tree_int_cst_compare (high, min_value) < 0)
   3226  1.1  mrg 		  || (TREE_CODE (max_value) == INTEGER_CST
   3227  1.1  mrg 		      && tree_int_cst_compare (low, max_value) > 0))
   3228  1.1  mrg 		remove_element = TRUE;
   3229  1.1  mrg 	      else
   3230  1.1  mrg 		{
   3231  1.1  mrg 		  /* If the lower bound is less than the index type's
   3232  1.1  mrg 		     minimum value, truncate the range bounds.  */
   3233  1.1  mrg 		  if (TREE_CODE (min_value) == INTEGER_CST
   3234  1.1  mrg 		      && tree_int_cst_compare (low, min_value) < 0)
   3235  1.1  mrg 		    low = min_value;
   3236  1.1  mrg 		  low = fold_convert (index_type, low);
   3237  1.1  mrg 
   3238  1.1  mrg 		  /* If the upper bound is greater than the index type's
   3239  1.1  mrg 		     maximum value, truncate the range bounds.  */
   3240  1.1  mrg 		  if (TREE_CODE (max_value) == INTEGER_CST
   3241  1.1  mrg 		      && tree_int_cst_compare (high, max_value) > 0)
   3242  1.1  mrg 		    high = max_value;
   3243  1.1  mrg 		  high = fold_convert (index_type, high);
   3244  1.1  mrg 
   3245  1.1  mrg 		  /* We may have folded a case range to a one-value case.  */
   3246  1.1  mrg 		  if (tree_int_cst_equal (low, high))
   3247  1.1  mrg 		    high = NULL_TREE;
   3248  1.1  mrg 		}
   3249  1.1  mrg 	    }
   3250  1.1  mrg 
   3251  1.1  mrg 	  CASE_LOW (elt) = low;
   3252  1.1  mrg 	  CASE_HIGH (elt) = high;
   3253  1.1  mrg 	}
   3254  1.1  mrg       else
   3255  1.1  mrg 	{
   3256  1.1  mrg 	  gcc_assert (!default_case);
   3257  1.1  mrg 	  default_case = elt;
   3258  1.1  mrg 	  /* The default case must be passed separately to the
   3259  1.1  mrg 	     gimple_build_switch routine.  But if DEFAULT_CASEP
   3260  1.1  mrg 	     is NULL, we do not remove the default case (it would
   3261  1.1  mrg 	     be completely lost).  */
   3262  1.1  mrg 	  if (default_casep)
   3263  1.1  mrg 	    remove_element = TRUE;
   3264  1.1  mrg 	}
   3265  1.1  mrg 
   3266  1.1  mrg       if (remove_element)
   3267  1.1  mrg 	labels.ordered_remove (i);
   3268  1.1  mrg       else
   3269  1.1  mrg 	i++;
   3270  1.1  mrg     }
   3271  1.1  mrg   len = i;
   3272  1.1  mrg 
   3273  1.1  mrg   if (!labels.is_empty ())
   3274  1.1  mrg     sort_case_labels (labels);
   3275  1.1  mrg 
   3276  1.1  mrg   if (default_casep && !default_case)
   3277  1.1  mrg     {
   3278  1.1  mrg       /* If the switch has no default label, add one, so that we jump
   3279  1.1  mrg 	 around the switch body.  If the labels already cover the whole
   3280  1.1  mrg 	 range of the switch index_type, add the default label pointing
   3281  1.1  mrg 	 to one of the existing labels.  */
   3282  1.1  mrg       if (len
   3283  1.1  mrg 	  && TYPE_MIN_VALUE (index_type)
   3284  1.1  mrg 	  && TYPE_MAX_VALUE (index_type)
   3285  1.1  mrg 	  && tree_int_cst_equal (CASE_LOW (labels[0]),
   3286  1.1  mrg 				 TYPE_MIN_VALUE (index_type)))
   3287  1.1  mrg 	{
   3288  1.1  mrg 	  tree low, high = CASE_HIGH (labels[len - 1]);
   3289  1.1  mrg 	  if (!high)
   3290  1.1  mrg 	    high = CASE_LOW (labels[len - 1]);
   3291  1.1  mrg 	  if (tree_int_cst_equal (high, TYPE_MAX_VALUE (index_type)))
   3292  1.1  mrg 	    {
   3293  1.1  mrg 	      tree widest_label = labels[0];
   3294  1.1  mrg 	      for (i = 1; i < len; i++)
   3295  1.1  mrg 		{
   3296  1.1  mrg 		  high = CASE_LOW (labels[i]);
   3297  1.1  mrg 		  low = CASE_HIGH (labels[i - 1]);
   3298  1.1  mrg 		  if (!low)
   3299  1.1  mrg 		    low = CASE_LOW (labels[i - 1]);
   3300  1.1  mrg 
   3301  1.1  mrg 		  if (CASE_HIGH (labels[i]) != NULL_TREE
   3302  1.1  mrg 		      && (CASE_HIGH (widest_label) == NULL_TREE
   3303  1.1  mrg 			  || (wi::gtu_p
   3304  1.1  mrg 			      (wi::to_wide (CASE_HIGH (labels[i]))
   3305  1.1  mrg 			       - wi::to_wide (CASE_LOW (labels[i])),
   3306  1.1  mrg 			       wi::to_wide (CASE_HIGH (widest_label))
   3307  1.1  mrg 			       - wi::to_wide (CASE_LOW (widest_label))))))
   3308  1.1  mrg 		    widest_label = labels[i];
   3309  1.1  mrg 
   3310  1.1  mrg 		  if (wi::to_wide (low) + 1 != wi::to_wide (high))
   3311  1.1  mrg 		    break;
   3312  1.1  mrg 		}
   3313  1.1  mrg 	      if (i == len)
   3314  1.1  mrg 		{
   3315  1.1  mrg 		  /* Designate the label with the widest range to be the
   3316  1.1  mrg 		     default label.  */
   3317  1.1  mrg 		  tree label = CASE_LABEL (widest_label);
   3318  1.1  mrg 		  default_case = build_case_label (NULL_TREE, NULL_TREE,
   3319  1.1  mrg 						   label);
   3320  1.1  mrg 		}
   3321  1.1  mrg 	    }
   3322  1.1  mrg 	}
   3323  1.1  mrg     }
   3324  1.1  mrg 
   3325  1.1  mrg   if (default_casep)
   3326  1.1  mrg     *default_casep = default_case;
   3327  1.1  mrg }
   3328  1.1  mrg 
   3329  1.1  mrg /* Set the location of all statements in SEQ to LOC.  */
   3330  1.1  mrg 
   3331  1.1  mrg void
   3332  1.1  mrg gimple_seq_set_location (gimple_seq seq, location_t loc)
   3333  1.1  mrg {
   3334  1.1  mrg   for (gimple_stmt_iterator i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
   3335  1.1  mrg     gimple_set_location (gsi_stmt (i), loc);
   3336  1.1  mrg }
   3337  1.1  mrg 
   3338  1.1  mrg /* Release SSA_NAMEs in SEQ as well as the GIMPLE statements.  */
   3339  1.1  mrg 
   3340  1.1  mrg void
   3341  1.1  mrg gimple_seq_discard (gimple_seq seq)
   3342  1.1  mrg {
   3343  1.1  mrg   gimple_stmt_iterator gsi;
   3344  1.1  mrg 
   3345  1.1  mrg   for (gsi = gsi_start (seq); !gsi_end_p (gsi); )
   3346  1.1  mrg     {
   3347  1.1  mrg       gimple *stmt = gsi_stmt (gsi);
   3348  1.1  mrg       gsi_remove (&gsi, true);
   3349  1.1  mrg       release_defs (stmt);
   3350  1.1  mrg       ggc_free (stmt);
   3351  1.1  mrg     }
   3352  1.1  mrg }
   3353  1.1  mrg 
   3354  1.1  mrg /* See if STMT now calls function that takes no parameters and if so, drop
   3355  1.1  mrg    call arguments.  This is used when devirtualization machinery redirects
   3356  1.1  mrg    to __builtin_unreachable or __cxa_pure_virtual.  */
   3357  1.1  mrg 
   3358  1.1  mrg void
   3359  1.1  mrg maybe_remove_unused_call_args (struct function *fn, gimple *stmt)
   3360  1.1  mrg {
   3361  1.1  mrg   tree decl = gimple_call_fndecl (stmt);
   3362  1.1  mrg   if (TYPE_ARG_TYPES (TREE_TYPE (decl))
   3363  1.1  mrg       && TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))) == void_type_node
   3364  1.1  mrg       && gimple_call_num_args (stmt))
   3365  1.1  mrg     {
   3366  1.1  mrg       gimple_set_num_ops (stmt, 3);
   3367  1.1  mrg       update_stmt_fn (fn, stmt);
   3368  1.1  mrg     }
   3369  1.1  mrg }
   3370  1.1  mrg 
   3371  1.1  mrg /* Return false if STMT will likely expand to real function call.  */
   3372  1.1  mrg 
   3373  1.1  mrg bool
   3374  1.1  mrg gimple_inexpensive_call_p (gcall *stmt)
   3375  1.1  mrg {
   3376  1.1  mrg   if (gimple_call_internal_p (stmt))
   3377  1.1  mrg     return true;
   3378  1.1  mrg   tree decl = gimple_call_fndecl (stmt);
   3379  1.1  mrg   if (decl && is_inexpensive_builtin (decl))
   3380  1.1  mrg     return true;
   3381  1.1  mrg   return false;
   3382  1.1  mrg }
   3383  1.1  mrg 
   3384  1.1  mrg /* Return a non-artificial location for STMT.  If STMT does not have
   3385  1.1  mrg    location information, get the location from EXPR.  */
   3386  1.1  mrg 
   3387  1.1  mrg location_t
   3388  1.1  mrg gimple_or_expr_nonartificial_location (gimple *stmt, tree expr)
   3389  1.1  mrg {
   3390  1.1  mrg   location_t loc = gimple_nonartificial_location (stmt);
   3391  1.1  mrg   if (loc == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (expr))
   3392  1.1  mrg     loc = tree_nonartificial_location (expr);
   3393  1.1  mrg   return expansion_point_location_if_in_system_header (loc);
   3394  1.1  mrg }
   3395  1.1  mrg 
   3396  1.1  mrg 
   3397  1.1  mrg #if CHECKING_P
   3398  1.1  mrg 
   3399  1.1  mrg namespace selftest {
   3400  1.1  mrg 
   3401  1.1  mrg /* Selftests for core gimple structures.  */
   3402  1.1  mrg 
   3403  1.1  mrg /* Verify that STMT is pretty-printed as EXPECTED.
   3404  1.1  mrg    Helper function for selftests.  */
   3405  1.1  mrg 
   3406  1.1  mrg static void
   3407  1.1  mrg verify_gimple_pp (const char *expected, gimple *stmt)
   3408  1.1  mrg {
   3409  1.1  mrg   pretty_printer pp;
   3410  1.1  mrg   pp_gimple_stmt_1 (&pp, stmt, 0 /* spc */, TDF_NONE /* flags */);
   3411  1.1  mrg   ASSERT_STREQ (expected, pp_formatted_text (&pp));
   3412  1.1  mrg }
   3413  1.1  mrg 
   3414  1.1  mrg /* Build a GIMPLE_ASSIGN equivalent to
   3415  1.1  mrg      tmp = 5;
   3416  1.1  mrg    and verify various properties of it.  */
   3417  1.1  mrg 
   3418  1.1  mrg static void
   3419  1.1  mrg test_assign_single ()
   3420  1.1  mrg {
   3421  1.1  mrg   tree type = integer_type_node;
   3422  1.1  mrg   tree lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   3423  1.1  mrg 			 get_identifier ("tmp"),
   3424  1.1  mrg 			 type);
   3425  1.1  mrg   tree rhs = build_int_cst (type, 5);
   3426  1.1  mrg   gassign *stmt = gimple_build_assign (lhs, rhs);
   3427  1.1  mrg   verify_gimple_pp ("tmp = 5;", stmt);
   3428  1.1  mrg 
   3429  1.1  mrg   ASSERT_TRUE (is_gimple_assign (stmt));
   3430  1.1  mrg   ASSERT_EQ (lhs, gimple_assign_lhs (stmt));
   3431  1.1  mrg   ASSERT_EQ (lhs, gimple_get_lhs (stmt));
   3432  1.1  mrg   ASSERT_EQ (rhs, gimple_assign_rhs1 (stmt));
   3433  1.1  mrg   ASSERT_EQ (NULL, gimple_assign_rhs2 (stmt));
   3434  1.1  mrg   ASSERT_EQ (NULL, gimple_assign_rhs3 (stmt));
   3435  1.1  mrg   ASSERT_TRUE (gimple_assign_single_p (stmt));
   3436  1.1  mrg   ASSERT_EQ (INTEGER_CST, gimple_assign_rhs_code (stmt));
   3437  1.1  mrg }
   3438  1.1  mrg 
   3439  1.1  mrg /* Build a GIMPLE_ASSIGN equivalent to
   3440  1.1  mrg      tmp = a * b;
   3441  1.1  mrg    and verify various properties of it.  */
   3442  1.1  mrg 
   3443  1.1  mrg static void
   3444  1.1  mrg test_assign_binop ()
   3445  1.1  mrg {
   3446  1.1  mrg   tree type = integer_type_node;
   3447  1.1  mrg   tree lhs = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   3448  1.1  mrg 			 get_identifier ("tmp"),
   3449  1.1  mrg 			 type);
   3450  1.1  mrg   tree a = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   3451  1.1  mrg 		       get_identifier ("a"),
   3452  1.1  mrg 		       type);
   3453  1.1  mrg   tree b = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   3454  1.1  mrg 		       get_identifier ("b"),
   3455  1.1  mrg 		       type);
   3456  1.1  mrg   gassign *stmt = gimple_build_assign (lhs, MULT_EXPR, a, b);
   3457  1.1  mrg   verify_gimple_pp ("tmp = a * b;", stmt);
   3458  1.1  mrg 
   3459  1.1  mrg   ASSERT_TRUE (is_gimple_assign (stmt));
   3460  1.1  mrg   ASSERT_EQ (lhs, gimple_assign_lhs (stmt));
   3461  1.1  mrg   ASSERT_EQ (lhs, gimple_get_lhs (stmt));
   3462  1.1  mrg   ASSERT_EQ (a, gimple_assign_rhs1 (stmt));
   3463  1.1  mrg   ASSERT_EQ (b, gimple_assign_rhs2 (stmt));
   3464  1.1  mrg   ASSERT_EQ (NULL, gimple_assign_rhs3 (stmt));
   3465  1.1  mrg   ASSERT_FALSE (gimple_assign_single_p (stmt));
   3466  1.1  mrg   ASSERT_EQ (MULT_EXPR, gimple_assign_rhs_code (stmt));
   3467  1.1  mrg }
   3468  1.1  mrg 
   3469  1.1  mrg /* Build a GIMPLE_NOP and verify various properties of it.  */
   3470  1.1  mrg 
   3471  1.1  mrg static void
   3472  1.1  mrg test_nop_stmt ()
   3473  1.1  mrg {
   3474  1.1  mrg   gimple *stmt = gimple_build_nop ();
   3475  1.1  mrg   verify_gimple_pp ("GIMPLE_NOP", stmt);
   3476  1.1  mrg   ASSERT_EQ (GIMPLE_NOP, gimple_code (stmt));
   3477  1.1  mrg   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
   3478  1.1  mrg   ASSERT_FALSE (gimple_assign_single_p (stmt));
   3479  1.1  mrg }
   3480  1.1  mrg 
   3481  1.1  mrg /* Build a GIMPLE_RETURN equivalent to
   3482  1.1  mrg      return 7;
   3483  1.1  mrg    and verify various properties of it.  */
   3484  1.1  mrg 
   3485  1.1  mrg static void
   3486  1.1  mrg test_return_stmt ()
   3487  1.1  mrg {
   3488  1.1  mrg   tree type = integer_type_node;
   3489  1.1  mrg   tree val = build_int_cst (type, 7);
   3490  1.1  mrg   greturn *stmt = gimple_build_return (val);
   3491  1.1  mrg   verify_gimple_pp ("return 7;", stmt);
   3492  1.1  mrg 
   3493  1.1  mrg   ASSERT_EQ (GIMPLE_RETURN, gimple_code (stmt));
   3494  1.1  mrg   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
   3495  1.1  mrg   ASSERT_EQ (val, gimple_return_retval (stmt));
   3496  1.1  mrg   ASSERT_FALSE (gimple_assign_single_p (stmt));
   3497  1.1  mrg }
   3498  1.1  mrg 
   3499  1.1  mrg /* Build a GIMPLE_RETURN equivalent to
   3500  1.1  mrg      return;
   3501  1.1  mrg    and verify various properties of it.  */
   3502  1.1  mrg 
   3503  1.1  mrg static void
   3504  1.1  mrg test_return_without_value ()
   3505  1.1  mrg {
   3506  1.1  mrg   greturn *stmt = gimple_build_return (NULL);
   3507  1.1  mrg   verify_gimple_pp ("return;", stmt);
   3508  1.1  mrg 
   3509  1.1  mrg   ASSERT_EQ (GIMPLE_RETURN, gimple_code (stmt));
   3510  1.1  mrg   ASSERT_EQ (NULL, gimple_get_lhs (stmt));
   3511  1.1  mrg   ASSERT_EQ (NULL, gimple_return_retval (stmt));
   3512  1.1  mrg   ASSERT_FALSE (gimple_assign_single_p (stmt));
   3513  1.1  mrg }
   3514  1.1  mrg 
   3515  1.1  mrg /* Run all of the selftests within this file.  */
   3516  1.1  mrg 
   3517  1.1  mrg void
   3518  1.1  mrg gimple_cc_tests ()
   3519  1.1  mrg {
   3520  1.1  mrg   test_assign_single ();
   3521  1.1  mrg   test_assign_binop ();
   3522  1.1  mrg   test_nop_stmt ();
   3523  1.1  mrg   test_return_stmt ();
   3524  1.1  mrg   test_return_without_value ();
   3525  1.1  mrg }
   3526  1.1  mrg 
   3527  1.1  mrg } // namespace selftest
   3528  1.1  mrg 
   3529  1.1  mrg 
   3530           #endif /* CHECKING_P */
   3531