OSDN Git Service

contrib/
[pf3gnuchains/gcc-fork.git] / gcc / tree-flow-inline.h
1 /* Inline functions for tree-flow.h
2    Copyright (C) 2001, 2003, 2005, 2006, 2007, 2008 Free Software
3    Foundation, Inc.
4    Contributed by Diego Novillo <dnovillo@redhat.com>
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef _TREE_FLOW_INLINE_H
23 #define _TREE_FLOW_INLINE_H 1
24
25 /* Inline functions for manipulating various data structures defined in
26    tree-flow.h.  See tree-flow.h for documentation.  */
27
28 /* Return true when gimple SSA form was built.
29    gimple_in_ssa_p is queried by gimplifier in various early stages before SSA
30    infrastructure is initialized.  Check for presence of the datastructures
31    at first place.  */
32 static inline bool
33 gimple_in_ssa_p (const struct function *fun)
34 {
35   return fun && fun->gimple_df && fun->gimple_df->in_ssa_p;
36 }
37
38 /* 'true' after aliases have been computed (see compute_may_aliases).  */
39 static inline bool
40 gimple_aliases_computed_p (const struct function *fun)
41 {
42   gcc_assert (fun && fun->gimple_df);
43   return fun->gimple_df->aliases_computed_p;
44 }
45
46 /* Addressable variables in the function.  If bit I is set, then
47    REFERENCED_VARS (I) has had its address taken.  Note that
48    CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related.  An
49    addressable variable is not necessarily call-clobbered (e.g., a
50    local addressable whose address does not escape) and not all
51    call-clobbered variables are addressable (e.g., a local static
52    variable).  */
53 static inline bitmap
54 gimple_addressable_vars (const struct function *fun)
55 {
56   gcc_assert (fun && fun->gimple_df);
57   return fun->gimple_df->addressable_vars;
58 }
59
60 /* Call clobbered variables in the function.  If bit I is set, then
61    REFERENCED_VARS (I) is call-clobbered.  */
62 static inline bitmap
63 gimple_call_clobbered_vars (const struct function *fun)
64 {
65   gcc_assert (fun && fun->gimple_df);
66   return fun->gimple_df->call_clobbered_vars;
67 }
68
69 /* Call-used variables in the function.  If bit I is set, then
70    REFERENCED_VARS (I) is call-used at pure function call-sites.  */
71 static inline bitmap
72 gimple_call_used_vars (const struct function *fun)
73 {
74   gcc_assert (fun && fun->gimple_df);
75   return fun->gimple_df->call_used_vars;
76 }
77
78 /* Array of all variables referenced in the function.  */
79 static inline htab_t
80 gimple_referenced_vars (const struct function *fun)
81 {
82   if (!fun->gimple_df)
83     return NULL;
84   return fun->gimple_df->referenced_vars;
85 }
86
87 /* Artificial variable used to model the effects of function calls.  */
88 static inline tree
89 gimple_global_var (const struct function *fun)
90 {
91   gcc_assert (fun && fun->gimple_df);
92   return fun->gimple_df->global_var;
93 }
94
95 /* Artificial variable used to model the effects of nonlocal
96    variables.  */
97 static inline tree
98 gimple_nonlocal_all (const struct function *fun)
99 {
100   gcc_assert (fun && fun->gimple_df);
101   return fun->gimple_df->nonlocal_all;
102 }
103
104 /* Initialize the hashtable iterator HTI to point to hashtable TABLE */
105
106 static inline void *
107 first_htab_element (htab_iterator *hti, htab_t table)
108 {
109   hti->htab = table;
110   hti->slot = table->entries;
111   hti->limit = hti->slot + htab_size (table);
112   do
113     {
114       PTR x = *(hti->slot);
115       if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
116         break;
117     } while (++(hti->slot) < hti->limit);
118   
119   if (hti->slot < hti->limit)
120     return *(hti->slot);
121   return NULL;
122 }
123
124 /* Return current non-empty/deleted slot of the hashtable pointed to by HTI,
125    or NULL if we have  reached the end.  */
126
127 static inline bool
128 end_htab_p (const htab_iterator *hti)
129 {
130   if (hti->slot >= hti->limit)
131     return true;
132   return false;
133 }
134
135 /* Advance the hashtable iterator pointed to by HTI to the next element of the
136    hashtable.  */
137
138 static inline void *
139 next_htab_element (htab_iterator *hti)
140 {
141   while (++(hti->slot) < hti->limit)
142     {
143       PTR x = *(hti->slot);
144       if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
145         return x;
146     };
147   return NULL;
148 }
149
150 /* Initialize ITER to point to the first referenced variable in the
151    referenced_vars hashtable, and return that variable.  */
152
153 static inline tree
154 first_referenced_var (referenced_var_iterator *iter)
155 {
156   return (tree) first_htab_element (&iter->hti,
157                                     gimple_referenced_vars (cfun));
158 }
159
160 /* Return true if we have hit the end of the referenced variables ITER is
161    iterating through.  */
162
163 static inline bool
164 end_referenced_vars_p (const referenced_var_iterator *iter)
165 {
166   return end_htab_p (&iter->hti);
167 }
168
169 /* Make ITER point to the next referenced_var in the referenced_var hashtable,
170    and return that variable.  */
171
172 static inline tree
173 next_referenced_var (referenced_var_iterator *iter)
174 {
175   return (tree) next_htab_element (&iter->hti);
176
177
178 /* Fill up VEC with the variables in the referenced vars hashtable.  */
179
180 static inline void
181 fill_referenced_var_vec (VEC (tree, heap) **vec)
182 {
183   referenced_var_iterator rvi;
184   tree var;
185   *vec = NULL;
186   FOR_EACH_REFERENCED_VAR (var, rvi)
187     VEC_safe_push (tree, heap, *vec, var);
188 }
189
190 /* Return the variable annotation for T, which must be a _DECL node.
191    Return NULL if the variable annotation doesn't already exist.  */
192 static inline var_ann_t
193 var_ann (const_tree t)
194 {
195   var_ann_t ann;
196
197   if (!t->base.ann)
198     return NULL;
199   ann = (var_ann_t) t->base.ann;
200
201   gcc_assert (ann->common.type == VAR_ANN);
202
203   return ann;
204 }
205
206 /* Return the variable annotation for T, which must be a _DECL node.
207    Create the variable annotation if it doesn't exist.  */
208 static inline var_ann_t
209 get_var_ann (tree var)
210 {
211   var_ann_t ann = var_ann (var);
212   return (ann) ? ann : create_var_ann (var);
213 }
214
215 /* Return the function annotation for T, which must be a FUNCTION_DECL node.
216    Return NULL if the function annotation doesn't already exist.  */
217 static inline function_ann_t
218 function_ann (const_tree t)
219 {
220   gcc_assert (t);
221   gcc_assert (TREE_CODE (t) == FUNCTION_DECL);
222   gcc_assert (!t->base.ann
223               || t->base.ann->common.type == FUNCTION_ANN);
224
225   return (function_ann_t) t->base.ann;
226 }
227
228 /* Return the function annotation for T, which must be a FUNCTION_DECL node.
229    Create the function annotation if it doesn't exist.  */
230 static inline function_ann_t
231 get_function_ann (tree var)
232 {
233   function_ann_t ann = function_ann (var);
234   gcc_assert (!var->base.ann || var->base.ann->common.type == FUNCTION_ANN);
235   return (ann) ? ann : create_function_ann (var);
236 }
237
238 /* Return true if T has a statement annotation attached to it.  */
239
240 static inline bool
241 has_stmt_ann (tree t)
242 {
243 #ifdef ENABLE_CHECKING
244   gcc_assert (is_gimple_stmt (t));
245 #endif
246   return t->base.ann && t->base.ann->common.type == STMT_ANN;
247 }
248
249 /* Return the statement annotation for T, which must be a statement
250    node.  Return NULL if the statement annotation doesn't exist.  */
251 static inline stmt_ann_t
252 stmt_ann (tree t)
253 {
254 #ifdef ENABLE_CHECKING
255   gcc_assert (is_gimple_stmt (t));
256 #endif
257   gcc_assert (!t->base.ann || t->base.ann->common.type == STMT_ANN);
258   return (stmt_ann_t) t->base.ann;
259 }
260
261 /* Return the statement annotation for T, which must be a statement
262    node.  Create the statement annotation if it doesn't exist.  */
263 static inline stmt_ann_t
264 get_stmt_ann (tree stmt)
265 {
266   stmt_ann_t ann = stmt_ann (stmt);
267   return (ann) ? ann : create_stmt_ann (stmt);
268 }
269
270 /* Set the uid of all non phi function statements.  */
271 static inline void
272 set_gimple_stmt_uid (tree stmt, unsigned int uid)
273 {
274   get_stmt_ann (stmt)->uid = uid;
275 }
276
277 /* Get the uid of all non phi function statements.  */
278 static inline unsigned int
279 gimple_stmt_uid (tree stmt)
280 {
281   return get_stmt_ann (stmt)->uid;
282 }
283
284 /* Get the number of the next statement uid to be allocated.  */
285 static inline unsigned int
286 gimple_stmt_max_uid (struct function *fn)
287 {
288   return fn->last_stmt_uid;
289 }
290
291 /* Set the number of the next statement uid to be allocated.  */
292 static inline void
293 set_gimple_stmt_max_uid (struct function *fn, unsigned int maxid)
294 {
295   fn->last_stmt_uid = maxid;
296 }
297
298 /* Set the number of the next statement uid to be allocated.  */
299 static inline unsigned int
300 inc_gimple_stmt_max_uid (struct function *fn)
301 {
302   return fn->last_stmt_uid++;
303 }
304
305 /* Return the annotation type for annotation ANN.  */
306 static inline enum tree_ann_type
307 ann_type (tree_ann_t ann)
308 {
309   return ann->common.type;
310 }
311
312 /* Return the basic block for statement T.  */
313 static inline basic_block
314 bb_for_stmt (tree t)
315 {
316   stmt_ann_t ann;
317
318   if (TREE_CODE (t) == PHI_NODE)
319     return PHI_BB (t);
320
321   ann = stmt_ann (t);
322   return ann ? ann->bb : NULL;
323 }
324
325 /* Return the may_aliases bitmap for variable VAR, or NULL if it has
326    no may aliases.  */
327 static inline bitmap
328 may_aliases (const_tree var)
329 {
330   return MTAG_ALIASES (var);
331 }
332
333 /* Return the line number for EXPR, or return -1 if we have no line
334    number information for it.  */
335 static inline int
336 get_lineno (const_tree expr)
337 {
338   if (expr == NULL_TREE)
339     return -1;
340
341   if (TREE_CODE (expr) == COMPOUND_EXPR)
342     expr = TREE_OPERAND (expr, 0);
343
344   if (! EXPR_HAS_LOCATION (expr))
345     return -1;
346
347   return EXPR_LINENO (expr);
348 }
349
350 /* Return true if T is a noreturn call.  */
351 static inline bool
352 noreturn_call_p (tree t)
353 {
354   tree call = get_call_expr_in (t);
355   return call != 0 && (call_expr_flags (call) & ECF_NORETURN) != 0;
356 }
357
358 /* Mark statement T as modified.  */
359 static inline void
360 mark_stmt_modified (tree t)
361 {
362   stmt_ann_t ann;
363   if (TREE_CODE (t) == PHI_NODE)
364     return;
365
366   ann = stmt_ann (t);
367   if (ann == NULL)
368     ann = create_stmt_ann (t);
369   else if (noreturn_call_p (t) && cfun->gimple_df)
370     VEC_safe_push (tree, gc, MODIFIED_NORETURN_CALLS (cfun), t);
371   ann->modified = 1;
372 }
373
374 /* Mark statement T as modified, and update it.  */
375 static inline void
376 update_stmt (tree t)
377 {
378   if (TREE_CODE (t) == PHI_NODE)
379     return;
380   mark_stmt_modified (t);
381   update_stmt_operands (t);
382 }
383
384 static inline void
385 update_stmt_if_modified (tree t)
386 {
387   if (stmt_modified_p (t))
388     update_stmt_operands (t);
389 }
390
391 /* Return true if T is marked as modified, false otherwise.  */
392 static inline bool
393 stmt_modified_p (tree t)
394 {
395   stmt_ann_t ann = stmt_ann (t);
396
397   /* Note that if the statement doesn't yet have an annotation, we consider it
398      modified.  This will force the next call to update_stmt_operands to scan 
399      the statement.  */
400   return ann ? ann->modified : true;
401 }
402
403 /* Delink an immediate_uses node from its chain.  */
404 static inline void
405 delink_imm_use (ssa_use_operand_t *linknode)
406 {
407   /* Return if this node is not in a list.  */
408   if (linknode->prev == NULL)
409     return;
410
411   linknode->prev->next = linknode->next;
412   linknode->next->prev = linknode->prev;
413   linknode->prev = NULL;
414   linknode->next = NULL;
415 }
416
417 /* Link ssa_imm_use node LINKNODE into the chain for LIST.  */
418 static inline void
419 link_imm_use_to_list (ssa_use_operand_t *linknode, ssa_use_operand_t *list)
420 {
421   /* Link the new node at the head of the list.  If we are in the process of 
422      traversing the list, we won't visit any new nodes added to it.  */
423   linknode->prev = list;
424   linknode->next = list->next;
425   list->next->prev = linknode;
426   list->next = linknode;
427 }
428
429 /* Link ssa_imm_use node LINKNODE into the chain for DEF.  */
430 static inline void
431 link_imm_use (ssa_use_operand_t *linknode, tree def)
432 {
433   ssa_use_operand_t *root;
434
435   if (!def || TREE_CODE (def) != SSA_NAME)
436     linknode->prev = NULL;
437   else
438     {
439       root = &(SSA_NAME_IMM_USE_NODE (def));
440 #ifdef ENABLE_CHECKING
441       if (linknode->use)
442         gcc_assert (*(linknode->use) == def);
443 #endif
444       link_imm_use_to_list (linknode, root);
445     }
446 }
447
448 /* Set the value of a use pointed to by USE to VAL.  */
449 static inline void
450 set_ssa_use_from_ptr (use_operand_p use, tree val)
451 {
452   delink_imm_use (use);
453   *(use->use) = val;
454   link_imm_use (use, val);
455 }
456
457 /* Link ssa_imm_use node LINKNODE into the chain for DEF, with use occurring 
458    in STMT.  */
459 static inline void
460 link_imm_use_stmt (ssa_use_operand_t *linknode, tree def, tree stmt)
461 {
462   if (stmt)
463     link_imm_use (linknode, def);
464   else
465     link_imm_use (linknode, NULL);
466   linknode->stmt = stmt;
467 }
468
469 /* Relink a new node in place of an old node in the list.  */
470 static inline void
471 relink_imm_use (ssa_use_operand_t *node, ssa_use_operand_t *old)
472 {
473   /* The node one had better be in the same list.  */
474   gcc_assert (*(old->use) == *(node->use));
475   node->prev = old->prev;
476   node->next = old->next;
477   if (old->prev)
478     {
479       old->prev->next = node;
480       old->next->prev = node;
481       /* Remove the old node from the list.  */
482       old->prev = NULL;
483     }
484 }
485
486 /* Relink ssa_imm_use node LINKNODE into the chain for OLD, with use occurring 
487    in STMT.  */
488 static inline void
489 relink_imm_use_stmt (ssa_use_operand_t *linknode, ssa_use_operand_t *old, tree stmt)
490 {
491   if (stmt)
492     relink_imm_use (linknode, old);
493   else
494     link_imm_use (linknode, NULL);
495   linknode->stmt = stmt;
496 }
497
498
499 /* Return true is IMM has reached the end of the immediate use list.  */
500 static inline bool
501 end_readonly_imm_use_p (const imm_use_iterator *imm)
502 {
503   return (imm->imm_use == imm->end_p);
504 }
505
506 /* Initialize iterator IMM to process the list for VAR.  */
507 static inline use_operand_p
508 first_readonly_imm_use (imm_use_iterator *imm, tree var)
509 {
510   gcc_assert (TREE_CODE (var) == SSA_NAME);
511
512   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
513   imm->imm_use = imm->end_p->next;
514 #ifdef ENABLE_CHECKING
515   imm->iter_node.next = imm->imm_use->next;
516 #endif
517   if (end_readonly_imm_use_p (imm))
518     return NULL_USE_OPERAND_P;
519   return imm->imm_use;
520 }
521
522 /* Bump IMM to the next use in the list.  */
523 static inline use_operand_p
524 next_readonly_imm_use (imm_use_iterator *imm)
525 {
526   use_operand_p old = imm->imm_use;
527
528 #ifdef ENABLE_CHECKING
529   /* If this assertion fails, it indicates the 'next' pointer has changed
530      since the last bump.  This indicates that the list is being modified
531      via stmt changes, or SET_USE, or somesuch thing, and you need to be
532      using the SAFE version of the iterator.  */
533   gcc_assert (imm->iter_node.next == old->next);
534   imm->iter_node.next = old->next->next;
535 #endif
536
537   imm->imm_use = old->next;
538   if (end_readonly_imm_use_p (imm))
539     return NULL_USE_OPERAND_P;
540   return imm->imm_use;
541 }
542
543 /* Return true if VAR has no uses.  */
544 static inline bool
545 has_zero_uses (const_tree var)
546 {
547   const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
548   /* A single use means there is no items in the list.  */
549   return (ptr == ptr->next);
550 }
551
552 /* Return true if VAR has a single use.  */
553 static inline bool
554 has_single_use (const_tree var)
555 {
556   const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
557   /* A single use means there is one item in the list.  */
558   return (ptr != ptr->next && ptr == ptr->next->next);
559 }
560
561
562 /* If VAR has only a single immediate use, return true, and set USE_P and STMT
563    to the use pointer and stmt of occurrence.  */
564 static inline bool
565 single_imm_use (const_tree var, use_operand_p *use_p, tree *stmt)
566 {
567   const ssa_use_operand_t *const ptr = &(SSA_NAME_IMM_USE_NODE (var));
568   if (ptr != ptr->next && ptr == ptr->next->next)
569     {
570       *use_p = ptr->next;
571       *stmt = ptr->next->stmt;
572       return true;
573     }
574   *use_p = NULL_USE_OPERAND_P;
575   *stmt = NULL_TREE;
576   return false;
577 }
578
579 /* Return the number of immediate uses of VAR.  */
580 static inline unsigned int
581 num_imm_uses (const_tree var)
582 {
583   const ssa_use_operand_t *const start = &(SSA_NAME_IMM_USE_NODE (var));
584   const ssa_use_operand_t *ptr;
585   unsigned int num = 0;
586
587   for (ptr = start->next; ptr != start; ptr = ptr->next)
588      num++;
589
590   return num;
591 }
592
593 /* Return the tree pointer to by USE.  */ 
594 static inline tree
595 get_use_from_ptr (use_operand_p use)
596
597   return *(use->use);
598
599
600 /* Return the tree pointer to by DEF.  */
601 static inline tree
602 get_def_from_ptr (def_operand_p def)
603 {
604   return *def;
605 }
606
607 /* Return a def_operand_p pointer for the result of PHI.  */
608 static inline def_operand_p
609 get_phi_result_ptr (tree phi)
610 {
611   return &(PHI_RESULT_TREE (phi));
612 }
613
614 /* Return a use_operand_p pointer for argument I of phinode PHI.  */
615 static inline use_operand_p
616 get_phi_arg_def_ptr (tree phi, int i)
617 {
618   return &(PHI_ARG_IMM_USE_NODE (phi,i));
619 }
620
621
622 /* Return the bitmap of addresses taken by STMT, or NULL if it takes
623    no addresses.  */
624 static inline bitmap
625 addresses_taken (tree stmt)
626 {
627   stmt_ann_t ann = stmt_ann (stmt);
628   return ann ? ann->addresses_taken : NULL;
629 }
630
631 /* Return the PHI nodes for basic block BB, or NULL if there are no
632    PHI nodes.  */
633 static inline tree
634 phi_nodes (const_basic_block bb)
635 {
636   gcc_assert (!(bb->flags & BB_RTL));
637   if (!bb->il.tree)
638     return NULL;
639   return bb->il.tree->phi_nodes;
640 }
641
642 /* Return pointer to the list of PHI nodes for basic block BB.  */
643
644 static inline tree *
645 phi_nodes_ptr (basic_block bb)
646 {
647   gcc_assert (!(bb->flags & BB_RTL));
648   return &bb->il.tree->phi_nodes;
649 }
650
651 /* Set list of phi nodes of a basic block BB to L.  */
652
653 static inline void
654 set_phi_nodes (basic_block bb, tree l)
655 {
656   tree phi;
657
658   gcc_assert (!(bb->flags & BB_RTL));
659   bb->il.tree->phi_nodes = l;
660   for (phi = l; phi; phi = PHI_CHAIN (phi))
661     set_bb_for_stmt (phi, bb);
662 }
663
664 /* Return the phi argument which contains the specified use.  */
665
666 static inline int
667 phi_arg_index_from_use (use_operand_p use)
668 {
669   struct phi_arg_d *element, *root;
670   int index;
671   tree phi;
672
673   /* Since the use is the first thing in a PHI argument element, we can
674      calculate its index based on casting it to an argument, and performing
675      pointer arithmetic.  */
676
677   phi = USE_STMT (use);
678   gcc_assert (TREE_CODE (phi) == PHI_NODE);
679
680   element = (struct phi_arg_d *)use;
681   root = &(PHI_ARG_ELT (phi, 0));
682   index = element - root;
683
684 #ifdef ENABLE_CHECKING
685   /* Make sure the calculation doesn't have any leftover bytes.  If it does, 
686      then imm_use is likely not the first element in phi_arg_d.  */
687   gcc_assert (
688           (((char *)element - (char *)root) % sizeof (struct phi_arg_d)) == 0);
689   gcc_assert (index >= 0 && index < PHI_ARG_CAPACITY (phi));
690 #endif
691  
692  return index;
693 }
694
695 /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
696
697 static inline void
698 set_is_used (tree var)
699 {
700   var_ann_t ann = get_var_ann (var);
701   ann->used = 1;
702 }
703
704
705 /* Return true if T (assumed to be a DECL) is a global variable.  */
706
707 static inline bool
708 is_global_var (const_tree t)
709 {
710   if (MTAG_P (t))
711     return MTAG_GLOBAL (t);
712   else
713     return (TREE_STATIC (t) || DECL_EXTERNAL (t));
714 }
715
716 /* PHI nodes should contain only ssa_names and invariants.  A test
717    for ssa_name is definitely simpler; don't let invalid contents
718    slip in in the meantime.  */
719
720 static inline bool
721 phi_ssa_name_p (const_tree t)
722 {
723   if (TREE_CODE (t) == SSA_NAME)
724     return true;
725 #ifdef ENABLE_CHECKING
726   gcc_assert (is_gimple_min_invariant (t));
727 #endif
728   return false;
729 }
730
731 /*  -----------------------------------------------------------------------  */
732
733 /* Returns the list of statements in BB.  */
734
735 static inline tree
736 bb_stmt_list (const_basic_block bb)
737 {
738   gcc_assert (!(bb->flags & BB_RTL));
739   return bb->il.tree->stmt_list;
740 }
741
742 /* Sets the list of statements in BB to LIST.  */
743
744 static inline void
745 set_bb_stmt_list (basic_block bb, tree list)
746 {
747   gcc_assert (!(bb->flags & BB_RTL));
748   bb->il.tree->stmt_list = list;
749 }
750
751 /* Return a block_stmt_iterator that points to beginning of basic
752    block BB.  */
753 static inline block_stmt_iterator
754 bsi_start (basic_block bb)
755 {
756   block_stmt_iterator bsi;
757   if (bb->index < NUM_FIXED_BLOCKS)
758     {
759       bsi.tsi.ptr = NULL;
760       bsi.tsi.container = NULL;
761     }
762   else
763     bsi.tsi = tsi_start (bb_stmt_list (bb));
764   bsi.bb = bb;
765   return bsi;
766 }
767
768 /* Return a block statement iterator that points to the first non-label
769    statement in block BB.  */
770
771 static inline block_stmt_iterator
772 bsi_after_labels (basic_block bb)
773 {
774   block_stmt_iterator bsi = bsi_start (bb);
775
776   while (!bsi_end_p (bsi) && TREE_CODE (bsi_stmt (bsi)) == LABEL_EXPR)
777     bsi_next (&bsi);
778
779   return bsi;
780 }
781
782 /* Return a block statement iterator that points to the end of basic
783    block BB.  */
784 static inline block_stmt_iterator
785 bsi_last (basic_block bb)
786 {
787   block_stmt_iterator bsi;
788
789   if (bb->index < NUM_FIXED_BLOCKS)
790     {
791       bsi.tsi.ptr = NULL;
792       bsi.tsi.container = NULL;
793     }
794   else
795     bsi.tsi = tsi_last (bb_stmt_list (bb));
796   bsi.bb = bb;
797   return bsi;
798 }
799
800 /* Return true if block statement iterator I has reached the end of
801    the basic block.  */
802 static inline bool
803 bsi_end_p (block_stmt_iterator i)
804 {
805   return tsi_end_p (i.tsi);
806 }
807
808 /* Modify block statement iterator I so that it is at the next
809    statement in the basic block.  */
810 static inline void
811 bsi_next (block_stmt_iterator *i)
812 {
813   tsi_next (&i->tsi);
814 }
815
816 /* Modify block statement iterator I so that it is at the previous
817    statement in the basic block.  */
818 static inline void
819 bsi_prev (block_stmt_iterator *i)
820 {
821   tsi_prev (&i->tsi);
822 }
823
824 /* Return the statement that block statement iterator I is currently
825    at.  */
826 static inline tree
827 bsi_stmt (block_stmt_iterator i)
828 {
829   return tsi_stmt (i.tsi);
830 }
831
832 /* Return a pointer to the statement that block statement iterator I
833    is currently at.  */
834 static inline tree *
835 bsi_stmt_ptr (block_stmt_iterator i)
836 {
837   return tsi_stmt_ptr (i.tsi);
838 }
839
840 /* Returns the loop of the statement STMT.  */
841
842 static inline struct loop *
843 loop_containing_stmt (tree stmt)
844 {
845   basic_block bb = bb_for_stmt (stmt);
846   if (!bb)
847     return NULL;
848
849   return bb->loop_father;
850 }
851
852
853 /* Return the memory partition tag associated with symbol SYM.  */
854
855 static inline tree
856 memory_partition (tree sym)
857 {
858   tree tag;
859
860   /* MPTs belong to their own partition.  */
861   if (TREE_CODE (sym) == MEMORY_PARTITION_TAG)
862     return sym;
863
864   gcc_assert (!is_gimple_reg (sym));
865   tag = get_var_ann (sym)->mpt;
866
867 #if defined ENABLE_CHECKING
868   if (tag)
869     gcc_assert (TREE_CODE (tag) == MEMORY_PARTITION_TAG);
870 #endif
871
872   return tag;
873 }
874
875 /* Return true if NAME is a memory factoring SSA name (i.e., an SSA
876    name for a memory partition.  */
877
878 static inline bool
879 factoring_name_p (const_tree name)
880 {
881   return TREE_CODE (SSA_NAME_VAR (name)) == MEMORY_PARTITION_TAG;
882 }
883
884 /* Return true if VAR is used by function calls.  */
885 static inline bool
886 is_call_used (const_tree var)
887 {
888   return (var_ann (var)->call_clobbered
889           || bitmap_bit_p (gimple_call_used_vars (cfun), DECL_UID (var)));
890 }
891
892 /* Return true if VAR is clobbered by function calls.  */
893 static inline bool
894 is_call_clobbered (const_tree var)
895 {
896   return var_ann (var)->call_clobbered;
897 }
898
899 /* Mark variable VAR as being clobbered by function calls.  */
900 static inline void
901 mark_call_clobbered (tree var, unsigned int escape_type)
902 {
903   var_ann (var)->escape_mask |= escape_type;
904   var_ann (var)->call_clobbered = true;
905   bitmap_set_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
906 }
907
908 /* Clear the call-clobbered attribute from variable VAR.  */
909 static inline void
910 clear_call_clobbered (tree var)
911 {
912   var_ann_t ann = var_ann (var);
913   ann->escape_mask = 0;
914   if (MTAG_P (var))
915     MTAG_GLOBAL (var) = 0;
916   var_ann (var)->call_clobbered = false;
917   bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
918 }
919
920 /* Return the common annotation for T.  Return NULL if the annotation
921    doesn't already exist.  */
922 static inline tree_ann_common_t
923 tree_common_ann (const_tree t)
924 {
925   /* Watch out static variables with unshared annotations.  */
926   if (DECL_P (t) && TREE_CODE (t) == VAR_DECL)
927     return &var_ann (t)->common;
928   return &t->base.ann->common;
929 }
930
931 /* Return a common annotation for T.  Create the constant annotation if it
932    doesn't exist.  */
933 static inline tree_ann_common_t
934 get_tree_common_ann (tree t)
935 {
936   tree_ann_common_t ann = tree_common_ann (t);
937   return (ann) ? ann : create_tree_common_ann (t);
938 }
939
940 /*  -----------------------------------------------------------------------  */
941
942 /* The following set of routines are used to iterator over various type of
943    SSA operands.  */
944
945 /* Return true if PTR is finished iterating.  */
946 static inline bool
947 op_iter_done (const ssa_op_iter *ptr)
948 {
949   return ptr->done;
950 }
951
952 /* Get the next iterator use value for PTR.  */
953 static inline use_operand_p
954 op_iter_next_use (ssa_op_iter *ptr)
955 {
956   use_operand_p use_p;
957 #ifdef ENABLE_CHECKING
958   gcc_assert (ptr->iter_type == ssa_op_iter_use);
959 #endif
960   if (ptr->uses)
961     {
962       use_p = USE_OP_PTR (ptr->uses);
963       ptr->uses = ptr->uses->next;
964       return use_p;
965     }
966   if (ptr->vuses)
967     {
968       use_p = VUSE_OP_PTR (ptr->vuses, ptr->vuse_index);
969       if (++(ptr->vuse_index) >= VUSE_NUM (ptr->vuses))
970         {
971           ptr->vuse_index = 0;
972           ptr->vuses = ptr->vuses->next;
973         }
974       return use_p;
975     }
976   if (ptr->mayuses)
977     {
978       use_p = VDEF_OP_PTR (ptr->mayuses, ptr->mayuse_index);
979       if (++(ptr->mayuse_index) >= VDEF_NUM (ptr->mayuses))
980         {
981           ptr->mayuse_index = 0;
982           ptr->mayuses = ptr->mayuses->next;
983         }
984       return use_p;
985     }
986   if (ptr->phi_i < ptr->num_phi)
987     {
988       return PHI_ARG_DEF_PTR (ptr->phi_stmt, (ptr->phi_i)++);
989     }
990   ptr->done = true;
991   return NULL_USE_OPERAND_P;
992 }
993
994 /* Get the next iterator def value for PTR.  */
995 static inline def_operand_p
996 op_iter_next_def (ssa_op_iter *ptr)
997 {
998   def_operand_p def_p;
999 #ifdef ENABLE_CHECKING
1000   gcc_assert (ptr->iter_type == ssa_op_iter_def);
1001 #endif
1002   if (ptr->defs)
1003     {
1004       def_p = DEF_OP_PTR (ptr->defs);
1005       ptr->defs = ptr->defs->next;
1006       return def_p;
1007     }
1008   if (ptr->vdefs)
1009     {
1010       def_p = VDEF_RESULT_PTR (ptr->vdefs);
1011       ptr->vdefs = ptr->vdefs->next;
1012       return def_p;
1013     }
1014   ptr->done = true;
1015   return NULL_DEF_OPERAND_P;
1016 }
1017
1018 /* Get the next iterator tree value for PTR.  */
1019 static inline tree
1020 op_iter_next_tree (ssa_op_iter *ptr)
1021 {
1022   tree val;
1023 #ifdef ENABLE_CHECKING
1024   gcc_assert (ptr->iter_type == ssa_op_iter_tree);
1025 #endif
1026   if (ptr->uses)
1027     {
1028       val = USE_OP (ptr->uses);
1029       ptr->uses = ptr->uses->next;
1030       return val;
1031     }
1032   if (ptr->vuses)
1033     {
1034       val = VUSE_OP (ptr->vuses, ptr->vuse_index);
1035       if (++(ptr->vuse_index) >= VUSE_NUM (ptr->vuses))
1036         {
1037           ptr->vuse_index = 0;
1038           ptr->vuses = ptr->vuses->next;
1039         }
1040       return val;
1041     }
1042   if (ptr->mayuses)
1043     {
1044       val = VDEF_OP (ptr->mayuses, ptr->mayuse_index);
1045       if (++(ptr->mayuse_index) >= VDEF_NUM (ptr->mayuses))
1046         {
1047           ptr->mayuse_index = 0;
1048           ptr->mayuses = ptr->mayuses->next;
1049         }
1050       return val;
1051     }
1052   if (ptr->defs)
1053     {
1054       val = DEF_OP (ptr->defs);
1055       ptr->defs = ptr->defs->next;
1056       return val;
1057     }
1058   if (ptr->vdefs)
1059     {
1060       val = VDEF_RESULT (ptr->vdefs);
1061       ptr->vdefs = ptr->vdefs->next;
1062       return val;
1063     }
1064
1065   ptr->done = true;
1066   return NULL_TREE;
1067
1068 }
1069
1070
1071 /* This functions clears the iterator PTR, and marks it done.  This is normally
1072    used to prevent warnings in the compile about might be uninitialized
1073    components.  */
1074
1075 static inline void
1076 clear_and_done_ssa_iter (ssa_op_iter *ptr)
1077 {
1078   ptr->defs = NULL;
1079   ptr->uses = NULL;
1080   ptr->vuses = NULL;
1081   ptr->vdefs = NULL;
1082   ptr->mayuses = NULL;
1083   ptr->iter_type = ssa_op_iter_none;
1084   ptr->phi_i = 0;
1085   ptr->num_phi = 0;
1086   ptr->phi_stmt = NULL_TREE;
1087   ptr->done = true;
1088   ptr->vuse_index = 0;
1089   ptr->mayuse_index = 0;
1090 }
1091
1092 /* Initialize the iterator PTR to the virtual defs in STMT.  */
1093 static inline void
1094 op_iter_init (ssa_op_iter *ptr, tree stmt, int flags)
1095 {
1096 #ifdef ENABLE_CHECKING
1097   gcc_assert (stmt_ann (stmt));
1098 #endif
1099
1100   ptr->defs = (flags & SSA_OP_DEF) ? DEF_OPS (stmt) : NULL;
1101   ptr->uses = (flags & SSA_OP_USE) ? USE_OPS (stmt) : NULL;
1102   ptr->vuses = (flags & SSA_OP_VUSE) ? VUSE_OPS (stmt) : NULL;
1103   ptr->vdefs = (flags & SSA_OP_VDEF) ? VDEF_OPS (stmt) : NULL;
1104   ptr->mayuses = (flags & SSA_OP_VMAYUSE) ? VDEF_OPS (stmt) : NULL;
1105   ptr->done = false;
1106
1107   ptr->phi_i = 0;
1108   ptr->num_phi = 0;
1109   ptr->phi_stmt = NULL_TREE;
1110   ptr->vuse_index = 0;
1111   ptr->mayuse_index = 0;
1112 }
1113
1114 /* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return
1115    the first use.  */
1116 static inline use_operand_p
1117 op_iter_init_use (ssa_op_iter *ptr, tree stmt, int flags)
1118 {
1119   gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0);
1120   op_iter_init (ptr, stmt, flags);
1121   ptr->iter_type = ssa_op_iter_use;
1122   return op_iter_next_use (ptr);
1123 }
1124
1125 /* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return
1126    the first def.  */
1127 static inline def_operand_p
1128 op_iter_init_def (ssa_op_iter *ptr, tree stmt, int flags)
1129 {
1130   gcc_assert ((flags & SSA_OP_ALL_USES) == 0);
1131   op_iter_init (ptr, stmt, flags);
1132   ptr->iter_type = ssa_op_iter_def;
1133   return op_iter_next_def (ptr);
1134 }
1135
1136 /* Initialize iterator PTR to the operands in STMT based on FLAGS. Return
1137    the first operand as a tree.  */
1138 static inline tree
1139 op_iter_init_tree (ssa_op_iter *ptr, tree stmt, int flags)
1140 {
1141   op_iter_init (ptr, stmt, flags);
1142   ptr->iter_type = ssa_op_iter_tree;
1143   return op_iter_next_tree (ptr);
1144 }
1145
1146 /* Get the next iterator mustdef value for PTR, returning the mustdef values in
1147    KILL and DEF.  */
1148 static inline void
1149 op_iter_next_vdef (vuse_vec_p *use, def_operand_p *def, 
1150                          ssa_op_iter *ptr)
1151 {
1152 #ifdef ENABLE_CHECKING
1153   gcc_assert (ptr->iter_type == ssa_op_iter_vdef);
1154 #endif
1155   if (ptr->mayuses)
1156     {
1157       *def = VDEF_RESULT_PTR (ptr->mayuses);
1158       *use = VDEF_VECT (ptr->mayuses);
1159       ptr->mayuses = ptr->mayuses->next;
1160       return;
1161     }
1162
1163   *def = NULL_DEF_OPERAND_P;
1164   *use = NULL;
1165   ptr->done = true;
1166   return;
1167 }
1168
1169
1170 static inline void
1171 op_iter_next_mustdef (use_operand_p *use, def_operand_p *def, 
1172                          ssa_op_iter *ptr)
1173 {
1174   vuse_vec_p vp;
1175   op_iter_next_vdef (&vp, def, ptr);
1176   if (vp != NULL)
1177     {
1178       gcc_assert (VUSE_VECT_NUM_ELEM (*vp) == 1);
1179       *use = VUSE_ELEMENT_PTR (*vp, 0);
1180     }
1181   else
1182     *use = NULL_USE_OPERAND_P;
1183 }
1184
1185 /* Initialize iterator PTR to the operands in STMT.  Return the first operands
1186    in USE and DEF.  */
1187 static inline void
1188 op_iter_init_vdef (ssa_op_iter *ptr, tree stmt, vuse_vec_p *use, 
1189                      def_operand_p *def)
1190 {
1191   gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1192
1193   op_iter_init (ptr, stmt, SSA_OP_VMAYUSE);
1194   ptr->iter_type = ssa_op_iter_vdef;
1195   op_iter_next_vdef (use, def, ptr);
1196 }
1197
1198
1199 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1200    return NULL.  */
1201 static inline tree
1202 single_ssa_tree_operand (tree stmt, int flags)
1203 {
1204   tree var;
1205   ssa_op_iter iter;
1206
1207   var = op_iter_init_tree (&iter, stmt, flags);
1208   if (op_iter_done (&iter))
1209     return NULL_TREE;
1210   op_iter_next_tree (&iter);
1211   if (op_iter_done (&iter))
1212     return var;
1213   return NULL_TREE;
1214 }
1215
1216
1217 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1218    return NULL.  */
1219 static inline use_operand_p
1220 single_ssa_use_operand (tree stmt, int flags)
1221 {
1222   use_operand_p var;
1223   ssa_op_iter iter;
1224
1225   var = op_iter_init_use (&iter, stmt, flags);
1226   if (op_iter_done (&iter))
1227     return NULL_USE_OPERAND_P;
1228   op_iter_next_use (&iter);
1229   if (op_iter_done (&iter))
1230     return var;
1231   return NULL_USE_OPERAND_P;
1232 }
1233
1234
1235
1236 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1237    return NULL.  */
1238 static inline def_operand_p
1239 single_ssa_def_operand (tree stmt, int flags)
1240 {
1241   def_operand_p var;
1242   ssa_op_iter iter;
1243
1244   var = op_iter_init_def (&iter, stmt, flags);
1245   if (op_iter_done (&iter))
1246     return NULL_DEF_OPERAND_P;
1247   op_iter_next_def (&iter);
1248   if (op_iter_done (&iter))
1249     return var;
1250   return NULL_DEF_OPERAND_P;
1251 }
1252
1253
1254 /* Return true if there are zero operands in STMT matching the type 
1255    given in FLAGS.  */
1256 static inline bool
1257 zero_ssa_operands (tree stmt, int flags)
1258 {
1259   ssa_op_iter iter;
1260
1261   op_iter_init_tree (&iter, stmt, flags);
1262   return op_iter_done (&iter);
1263 }
1264
1265
1266 /* Return the number of operands matching FLAGS in STMT.  */
1267 static inline int
1268 num_ssa_operands (tree stmt, int flags)
1269 {
1270   ssa_op_iter iter;
1271   tree t;
1272   int num = 0;
1273
1274   FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
1275     num++;
1276   return num;
1277 }
1278
1279
1280 /* Delink all immediate_use information for STMT.  */
1281 static inline void
1282 delink_stmt_imm_use (tree stmt)
1283 {
1284    ssa_op_iter iter;
1285    use_operand_p use_p;
1286
1287    if (ssa_operands_active ())
1288      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
1289        delink_imm_use (use_p);
1290 }
1291
1292
1293 /* This routine will compare all the operands matching FLAGS in STMT1 to those
1294    in STMT2.  TRUE is returned if they are the same.  STMTs can be NULL.  */
1295 static inline bool
1296 compare_ssa_operands_equal (tree stmt1, tree stmt2, int flags)
1297 {
1298   ssa_op_iter iter1, iter2;
1299   tree op1 = NULL_TREE;
1300   tree op2 = NULL_TREE;
1301   bool look1, look2;
1302
1303   if (stmt1 == stmt2)
1304     return true;
1305
1306   look1 = stmt1 && stmt_ann (stmt1);
1307   look2 = stmt2 && stmt_ann (stmt2);
1308
1309   if (look1)
1310     {
1311       op1 = op_iter_init_tree (&iter1, stmt1, flags);
1312       if (!look2)
1313         return op_iter_done (&iter1);
1314     }
1315   else
1316     clear_and_done_ssa_iter (&iter1);
1317
1318   if (look2)
1319     {
1320       op2 = op_iter_init_tree (&iter2, stmt2, flags);
1321       if (!look1)
1322         return op_iter_done (&iter2);
1323     }
1324   else
1325     clear_and_done_ssa_iter (&iter2);
1326
1327   while (!op_iter_done (&iter1) && !op_iter_done (&iter2))
1328     {
1329       if (op1 != op2)
1330         return false;
1331       op1 = op_iter_next_tree (&iter1);
1332       op2 = op_iter_next_tree (&iter2);
1333     }
1334
1335   return (op_iter_done (&iter1) && op_iter_done (&iter2));
1336 }
1337
1338
1339 /* If there is a single DEF in the PHI node which matches FLAG, return it.
1340    Otherwise return NULL_DEF_OPERAND_P.  */
1341 static inline tree
1342 single_phi_def (tree stmt, int flags)
1343 {
1344   tree def = PHI_RESULT (stmt);
1345   if ((flags & SSA_OP_DEF) && is_gimple_reg (def)) 
1346     return def;
1347   if ((flags & SSA_OP_VIRTUAL_DEFS) && !is_gimple_reg (def))
1348     return def;
1349   return NULL_TREE;
1350 }
1351
1352 /* Initialize the iterator PTR for uses matching FLAGS in PHI.  FLAGS should
1353    be either SSA_OP_USES or SSA_OP_VIRTUAL_USES.  */
1354 static inline use_operand_p
1355 op_iter_init_phiuse (ssa_op_iter *ptr, tree phi, int flags)
1356 {
1357   tree phi_def = PHI_RESULT (phi);
1358   int comp;
1359
1360   clear_and_done_ssa_iter (ptr);
1361   ptr->done = false;
1362
1363   gcc_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
1364
1365   comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1366     
1367   /* If the PHI node doesn't the operand type we care about, we're done.  */
1368   if ((flags & comp) == 0)
1369     {
1370       ptr->done = true;
1371       return NULL_USE_OPERAND_P;
1372     }
1373
1374   ptr->phi_stmt = phi;
1375   ptr->num_phi = PHI_NUM_ARGS (phi);
1376   ptr->iter_type = ssa_op_iter_use;
1377   return op_iter_next_use (ptr);
1378 }
1379
1380
1381 /* Start an iterator for a PHI definition.  */
1382
1383 static inline def_operand_p
1384 op_iter_init_phidef (ssa_op_iter *ptr, tree phi, int flags)
1385 {
1386   tree phi_def = PHI_RESULT (phi);
1387   int comp;
1388
1389   clear_and_done_ssa_iter (ptr);
1390   ptr->done = false;
1391
1392   gcc_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
1393
1394   comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS);
1395     
1396   /* If the PHI node doesn't the operand type we care about, we're done.  */
1397   if ((flags & comp) == 0)
1398     {
1399       ptr->done = true;
1400       return NULL_USE_OPERAND_P;
1401     }
1402
1403   ptr->iter_type = ssa_op_iter_def;
1404   /* The first call to op_iter_next_def will terminate the iterator since
1405      all the fields are NULL.  Simply return the result here as the first and
1406      therefore only result.  */
1407   return PHI_RESULT_PTR (phi);
1408 }
1409
1410 /* Return true is IMM has reached the end of the immediate use stmt list.  */
1411
1412 static inline bool
1413 end_imm_use_stmt_p (const imm_use_iterator *imm)
1414 {
1415   return (imm->imm_use == imm->end_p);
1416 }
1417
1418 /* Finished the traverse of an immediate use stmt list IMM by removing the
1419    placeholder node from the list.  */
1420
1421 static inline void
1422 end_imm_use_stmt_traverse (imm_use_iterator *imm)
1423 {
1424   delink_imm_use (&(imm->iter_node));
1425 }
1426
1427 /* Immediate use traversal of uses within a stmt require that all the
1428    uses on a stmt be sequentially listed.  This routine is used to build up
1429    this sequential list by adding USE_P to the end of the current list 
1430    currently delimited by HEAD and LAST_P.  The new LAST_P value is 
1431    returned.  */
1432
1433 static inline use_operand_p
1434 move_use_after_head (use_operand_p use_p, use_operand_p head, 
1435                       use_operand_p last_p)
1436 {
1437   gcc_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
1438   /* Skip head when we find it.  */
1439   if (use_p != head)
1440     {
1441       /* If use_p is already linked in after last_p, continue.  */
1442       if (last_p->next == use_p)
1443         last_p = use_p;
1444       else
1445         {
1446           /* Delink from current location, and link in at last_p.  */
1447           delink_imm_use (use_p);
1448           link_imm_use_to_list (use_p, last_p);
1449           last_p = use_p;
1450         }
1451     }
1452   return last_p;
1453 }
1454
1455
1456 /* This routine will relink all uses with the same stmt as HEAD into the list
1457    immediately following HEAD for iterator IMM.  */
1458
1459 static inline void
1460 link_use_stmts_after (use_operand_p head, imm_use_iterator *imm)
1461 {
1462   use_operand_p use_p;
1463   use_operand_p last_p = head;
1464   tree head_stmt = USE_STMT (head);
1465   tree use = USE_FROM_PTR (head);
1466   ssa_op_iter op_iter;
1467   int flag;
1468
1469   /* Only look at virtual or real uses, depending on the type of HEAD.  */
1470   flag = (is_gimple_reg (use) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1471
1472   if (TREE_CODE (head_stmt) == PHI_NODE)
1473     {
1474       FOR_EACH_PHI_ARG (use_p, head_stmt, op_iter, flag)
1475         if (USE_FROM_PTR (use_p) == use)
1476           last_p = move_use_after_head (use_p, head, last_p);
1477     }
1478   else
1479     {
1480       FOR_EACH_SSA_USE_OPERAND (use_p, head_stmt, op_iter, flag)
1481         if (USE_FROM_PTR (use_p) == use)
1482           last_p = move_use_after_head (use_p, head, last_p);
1483     }
1484   /* Link iter node in after last_p.  */
1485   if (imm->iter_node.prev != NULL)
1486     delink_imm_use (&imm->iter_node);
1487   link_imm_use_to_list (&(imm->iter_node), last_p);
1488 }
1489
1490 /* Initialize IMM to traverse over uses of VAR.  Return the first statement.  */
1491 static inline tree
1492 first_imm_use_stmt (imm_use_iterator *imm, tree var)
1493 {
1494   gcc_assert (TREE_CODE (var) == SSA_NAME);
1495   
1496   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
1497   imm->imm_use = imm->end_p->next;
1498   imm->next_imm_name = NULL_USE_OPERAND_P;
1499
1500   /* iter_node is used as a marker within the immediate use list to indicate
1501      where the end of the current stmt's uses are.  Initialize it to NULL
1502      stmt and use, which indicates a marker node.  */
1503   imm->iter_node.prev = NULL_USE_OPERAND_P;
1504   imm->iter_node.next = NULL_USE_OPERAND_P;
1505   imm->iter_node.stmt = NULL_TREE;
1506   imm->iter_node.use = NULL_USE_OPERAND_P;
1507
1508   if (end_imm_use_stmt_p (imm))
1509     return NULL_TREE;
1510
1511   link_use_stmts_after (imm->imm_use, imm);
1512
1513   return USE_STMT (imm->imm_use);
1514 }
1515
1516 /* Bump IMM to the next stmt which has a use of var.  */
1517
1518 static inline tree
1519 next_imm_use_stmt (imm_use_iterator *imm)
1520 {
1521   imm->imm_use = imm->iter_node.next;
1522   if (end_imm_use_stmt_p (imm))
1523     {
1524       if (imm->iter_node.prev != NULL)
1525         delink_imm_use (&imm->iter_node);
1526       return NULL_TREE;
1527     }
1528
1529   link_use_stmts_after (imm->imm_use, imm);
1530   return USE_STMT (imm->imm_use);
1531 }
1532
1533 /* This routine will return the first use on the stmt IMM currently refers
1534    to.  */
1535
1536 static inline use_operand_p
1537 first_imm_use_on_stmt (imm_use_iterator *imm)
1538 {
1539   imm->next_imm_name = imm->imm_use->next;
1540   return imm->imm_use;
1541 }
1542
1543 /*  Return TRUE if the last use on the stmt IMM refers to has been visited.  */
1544
1545 static inline bool
1546 end_imm_use_on_stmt_p (const imm_use_iterator *imm)
1547 {
1548   return (imm->imm_use == &(imm->iter_node));
1549 }
1550
1551 /* Bump to the next use on the stmt IMM refers to, return NULL if done.  */
1552
1553 static inline use_operand_p
1554 next_imm_use_on_stmt (imm_use_iterator *imm)
1555 {
1556   imm->imm_use = imm->next_imm_name;
1557   if (end_imm_use_on_stmt_p (imm))
1558     return NULL_USE_OPERAND_P;
1559   else
1560     {
1561       imm->next_imm_name = imm->imm_use->next;
1562       return imm->imm_use;
1563     }
1564 }
1565
1566 /* Return true if VAR cannot be modified by the program.  */
1567
1568 static inline bool
1569 unmodifiable_var_p (const_tree var)
1570 {
1571   if (TREE_CODE (var) == SSA_NAME)
1572     var = SSA_NAME_VAR (var);
1573
1574   if (MTAG_P (var))
1575     return false;
1576
1577   return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
1578 }
1579
1580 /* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it.  */
1581
1582 static inline bool
1583 array_ref_contains_indirect_ref (const_tree ref)
1584 {
1585   gcc_assert (TREE_CODE (ref) == ARRAY_REF);
1586
1587   do {
1588     ref = TREE_OPERAND (ref, 0);
1589   } while (handled_component_p (ref));
1590
1591   return TREE_CODE (ref) == INDIRECT_REF;
1592 }
1593
1594 /* Return true if REF, a handled component reference, has an ARRAY_REF
1595    somewhere in it.  */
1596
1597 static inline bool
1598 ref_contains_array_ref (const_tree ref)
1599 {
1600   gcc_assert (handled_component_p (ref));
1601
1602   do {
1603     if (TREE_CODE (ref) == ARRAY_REF)
1604       return true;
1605     ref = TREE_OPERAND (ref, 0);
1606   } while (handled_component_p (ref));
1607
1608   return false;
1609 }
1610
1611 /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
1612    overlap.  SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
1613    range is open-ended.  Otherwise return false.  */
1614
1615 static inline bool
1616 ranges_overlap_p (unsigned HOST_WIDE_INT pos1,
1617                   unsigned HOST_WIDE_INT size1,
1618                   unsigned HOST_WIDE_INT pos2,
1619                   unsigned HOST_WIDE_INT size2)
1620 {
1621   if (pos1 >= pos2
1622       && (size2 == (unsigned HOST_WIDE_INT)-1
1623           || pos1 < (pos2 + size2)))
1624     return true;
1625   if (pos2 >= pos1
1626       && (size1 == (unsigned HOST_WIDE_INT)-1
1627           || pos2 < (pos1 + size1)))
1628     return true;
1629
1630   return false;
1631 }
1632
1633 /* Return the memory tag associated with symbol SYM.  */
1634
1635 static inline tree
1636 symbol_mem_tag (tree sym)
1637 {
1638   tree tag = get_var_ann (sym)->symbol_mem_tag;
1639
1640 #if defined ENABLE_CHECKING
1641   if (tag)
1642     gcc_assert (TREE_CODE (tag) == SYMBOL_MEMORY_TAG);
1643 #endif
1644
1645   return tag;
1646 }
1647
1648
1649 /* Set the memory tag associated with symbol SYM.  */
1650
1651 static inline void
1652 set_symbol_mem_tag (tree sym, tree tag)
1653 {
1654 #if defined ENABLE_CHECKING
1655   if (tag)
1656     gcc_assert (TREE_CODE (tag) == SYMBOL_MEMORY_TAG);
1657 #endif
1658
1659   get_var_ann (sym)->symbol_mem_tag = tag;
1660 }
1661
1662 /* Accessor to tree-ssa-operands.c caches.  */
1663 static inline struct ssa_operands *
1664 gimple_ssa_operands (const struct function *fun)
1665 {
1666   return &fun->gimple_df->ssa_operands;
1667 }
1668
1669 /* Map describing reference statistics for function FN.  */
1670 static inline struct mem_ref_stats_d *
1671 gimple_mem_ref_stats (const struct function *fn)
1672 {
1673   return &fn->gimple_df->mem_ref_stats;
1674 }
1675
1676 /* Given an edge_var_map V, return the PHI arg definition.  */
1677
1678 static inline tree
1679 redirect_edge_var_map_def (edge_var_map *v)
1680 {
1681   return v->def;
1682 }
1683
1684 /* Given an edge_var_map V, return the PHI result.  */
1685
1686 static inline tree
1687 redirect_edge_var_map_result (edge_var_map *v)
1688 {
1689   return v->result;
1690 }
1691
1692
1693 /* Return an SSA_NAME node for variable VAR defined in statement STMT
1694    in function cfun.  */
1695
1696 static inline tree
1697 make_ssa_name (tree var, tree stmt)
1698 {
1699   return make_ssa_name_fn (cfun, var, stmt);
1700 }
1701
1702 #endif /* _TREE_FLOW_INLINE_H  */