OSDN Git Service

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