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