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 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 /* Finished the traverse of an immediate use list IMM by removing it from 
398    the list.  */
399 static inline void
400 end_safe_imm_use_traverse (imm_use_iterator *imm)
401 {
402  delink_imm_use (&(imm->iter_node));
403 }
404
405 /* Return true if IMM is at the end of the list.  */
406 static inline bool
407 end_safe_imm_use_p (imm_use_iterator *imm)
408 {
409   return (imm->imm_use == imm->end_p);
410 }
411
412 /* Initialize iterator IMM to process the list for VAR.  */
413 static inline use_operand_p
414 first_safe_imm_use (imm_use_iterator *imm, tree var)
415 {
416   /* Set up and link the iterator node into the linked list for VAR.  */
417   imm->iter_node.use = NULL;
418   imm->iter_node.stmt = NULL_TREE;
419   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
420   /* Check if there are 0 elements.  */
421   if (imm->end_p->next == imm->end_p)
422     {
423       imm->imm_use = imm->end_p;
424       return NULL_USE_OPERAND_P;
425     }
426
427   link_imm_use (&(imm->iter_node), var);
428   imm->imm_use = imm->iter_node.next;
429   return imm->imm_use;
430 }
431
432 /* Bump IMM to the next use in the list.  */
433 static inline use_operand_p
434 next_safe_imm_use (imm_use_iterator *imm)
435 {
436   ssa_use_operand_t *ptr;
437   use_operand_p old;
438
439   old = imm->imm_use;
440   /* If the next node following the iter_node is still the one referred to by
441      imm_use, then the list hasn't changed, go to the next node.  */
442   if (imm->iter_node.next == imm->imm_use)
443     {
444       ptr = &(imm->iter_node);
445       /* Remove iternode from the list.  */
446       delink_imm_use (ptr);
447       imm->imm_use = imm->imm_use->next;
448       if (! end_safe_imm_use_p (imm))
449         {
450           /* This isn't the end, link iternode before the next use.  */
451           ptr->prev = imm->imm_use->prev;
452           ptr->next = imm->imm_use;
453           imm->imm_use->prev->next = ptr;
454           imm->imm_use->prev = ptr;
455         }
456       else
457         return old;
458     }
459   else
460     {
461       /* If the 'next' value after the iterator isn't the same as it was, then
462          a node has been deleted, so we simply proceed to the node following 
463          where the iterator is in the list.  */
464       imm->imm_use = imm->iter_node.next;
465       if (end_safe_imm_use_p (imm))
466         {
467           end_safe_imm_use_traverse (imm);
468           return old;
469         }
470     }
471
472   return imm->imm_use;
473 }
474
475 /* Return true is IMM has reached the end of the immediate use list.  */
476 static inline bool
477 end_readonly_imm_use_p (imm_use_iterator *imm)
478 {
479   return (imm->imm_use == imm->end_p);
480 }
481
482 /* Initialize iterator IMM to process the list for VAR.  */
483 static inline use_operand_p
484 first_readonly_imm_use (imm_use_iterator *imm, tree var)
485 {
486   gcc_assert (TREE_CODE (var) == SSA_NAME);
487
488   imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
489   imm->imm_use = imm->end_p->next;
490 #ifdef ENABLE_CHECKING
491   imm->iter_node.next = imm->imm_use->next;
492 #endif
493   if (end_readonly_imm_use_p (imm))
494     return NULL_USE_OPERAND_P;
495   return imm->imm_use;
496 }
497
498 /* Bump IMM to the next use in the list.  */
499 static inline use_operand_p
500 next_readonly_imm_use (imm_use_iterator *imm)
501 {
502   use_operand_p old = imm->imm_use;
503
504 #ifdef ENABLE_CHECKING
505   /* If this assertion fails, it indicates the 'next' pointer has changed 
506      since we the last bump.  This indicates that the list is being modified
507      via stmt changes, or SET_USE, or somesuch thing, and you need to be
508      using the SAFE version of the iterator.  */
509   gcc_assert (imm->iter_node.next == old->next);
510   imm->iter_node.next = old->next->next;
511 #endif
512
513   imm->imm_use = old->next;
514   if (end_readonly_imm_use_p (imm))
515     return old;
516   return imm->imm_use;
517 }
518
519 /* Return true if VAR has no uses.  */
520 static inline bool
521 has_zero_uses (tree var)
522 {
523   ssa_use_operand_t *ptr;
524   ptr = &(SSA_NAME_IMM_USE_NODE (var));
525   /* A single use means there is no items in the list.  */
526   return (ptr == ptr->next);
527 }
528
529 /* Return true if VAR has a single use.  */
530 static inline bool
531 has_single_use (tree var)
532 {
533   ssa_use_operand_t *ptr;
534   ptr = &(SSA_NAME_IMM_USE_NODE (var));
535   /* A single use means there is one item in the list.  */
536   return (ptr != ptr->next && ptr == ptr->next->next);
537 }
538
539 /* If VAR has only a single immediate use, return true, and set USE_P and STMT
540    to the use pointer and stmt of occurrence.  */
541 static inline bool
542 single_imm_use (tree var, use_operand_p *use_p, tree *stmt)
543 {
544   ssa_use_operand_t *ptr;
545
546   ptr = &(SSA_NAME_IMM_USE_NODE (var));
547   if (ptr != ptr->next && ptr == ptr->next->next)
548     {
549       *use_p = ptr->next;
550       *stmt = ptr->next->stmt;
551       return true;
552     }
553   *use_p = NULL_USE_OPERAND_P;
554   *stmt = NULL_TREE;
555   return false;
556 }
557
558 /* Return the number of immediate uses of VAR.  */
559 static inline unsigned int
560 num_imm_uses (tree var)
561 {
562   ssa_use_operand_t *ptr, *start;
563   unsigned int num;
564
565   start = &(SSA_NAME_IMM_USE_NODE (var));
566   num = 0;
567   for (ptr = start->next; ptr != start; ptr = ptr->next)
568      num++;
569
570   return num;
571 }
572
573
574 /* Return the tree pointer to by USE.  */ 
575 static inline tree
576 get_use_from_ptr (use_operand_p use)
577
578   return *(use->use);
579
580
581 /* Return the tree pointer to by DEF.  */
582 static inline tree
583 get_def_from_ptr (def_operand_p def)
584 {
585   return *def;
586 }
587
588 /* Return a def_operand_p pointer for the result of PHI.  */
589 static inline def_operand_p
590 get_phi_result_ptr (tree phi)
591 {
592   return &(PHI_RESULT_TREE (phi));
593 }
594
595 /* Return a use_operand_p pointer for argument I of phinode PHI.  */
596 static inline use_operand_p
597 get_phi_arg_def_ptr (tree phi, int i)
598 {
599   return &(PHI_ARG_IMM_USE_NODE (phi,i));
600 }
601
602
603 /* Return the bitmap of addresses taken by STMT, or NULL if it takes
604    no addresses.  */
605 static inline bitmap
606 addresses_taken (tree stmt)
607 {
608   stmt_ann_t ann = stmt_ann (stmt);
609   return ann ? ann->addresses_taken : NULL;
610 }
611
612 /* Return the PHI nodes for basic block BB, or NULL if there are no
613    PHI nodes.  */
614 static inline tree
615 phi_nodes (basic_block bb)
616 {
617   return bb->phi_nodes;
618 }
619
620 /* Set list of phi nodes of a basic block BB to L.  */
621
622 static inline void
623 set_phi_nodes (basic_block bb, tree l)
624 {
625   tree phi;
626
627   bb->phi_nodes = l;
628   for (phi = l; phi; phi = PHI_CHAIN (phi))
629     set_bb_for_stmt (phi, bb);
630 }
631
632 /* Return the phi argument which contains the specified use.  */
633
634 static inline int
635 phi_arg_index_from_use (use_operand_p use)
636 {
637   struct phi_arg_d *element, *root;
638   int index;
639   tree phi;
640
641   /* Since the use is the first thing in a PHI argument element, we can
642      calculate its index based on casting it to an argument, and performing
643      pointer arithmetic.  */
644
645   phi = USE_STMT (use);
646   gcc_assert (TREE_CODE (phi) == PHI_NODE);
647
648   element = (struct phi_arg_d *)use;
649   root = &(PHI_ARG_ELT (phi, 0));
650   index = element - root;
651
652 #ifdef ENABLE_CHECKING
653   /* Make sure the calculation doesn't have any leftover bytes.  If it does, 
654      then imm_use is likely not the first element in phi_arg_d.  */
655   gcc_assert (
656           (((char *)element - (char *)root) % sizeof (struct phi_arg_d)) == 0);
657   gcc_assert (index >= 0 && index < PHI_ARG_CAPACITY (phi));
658 #endif
659  
660  return index;
661 }
662
663 /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
664
665 static inline void
666 set_is_used (tree var)
667 {
668   var_ann_t ann = get_var_ann (var);
669   ann->used = 1;
670 }
671
672
673 /*  -----------------------------------------------------------------------  */
674
675 /* Return true if T is an executable statement.  */
676 static inline bool
677 is_exec_stmt (tree t)
678 {
679   return (t && !IS_EMPTY_STMT (t) && t != error_mark_node);
680 }
681
682
683 /* Return true if this stmt can be the target of a control transfer stmt such
684    as a goto.  */
685 static inline bool
686 is_label_stmt (tree t)
687 {
688   if (t)
689     switch (TREE_CODE (t))
690       {
691         case LABEL_DECL:
692         case LABEL_EXPR:
693         case CASE_LABEL_EXPR:
694           return true;
695         default:
696           return false;
697       }
698   return false;
699 }
700
701 /* PHI nodes should contain only ssa_names and invariants.  A test
702    for ssa_name is definitely simpler; don't let invalid contents
703    slip in in the meantime.  */
704
705 static inline bool
706 phi_ssa_name_p (tree t)
707 {
708   if (TREE_CODE (t) == SSA_NAME)
709     return true;
710 #ifdef ENABLE_CHECKING
711   gcc_assert (is_gimple_min_invariant (t));
712 #endif
713   return false;
714 }
715
716 /*  -----------------------------------------------------------------------  */
717
718 /* Return a block_stmt_iterator that points to beginning of basic
719    block BB.  */
720 static inline block_stmt_iterator
721 bsi_start (basic_block bb)
722 {
723   block_stmt_iterator bsi;
724   if (bb->stmt_list)
725     bsi.tsi = tsi_start (bb->stmt_list);
726   else
727     {
728       gcc_assert (bb->index < NUM_FIXED_BLOCKS);
729       bsi.tsi.ptr = NULL;
730       bsi.tsi.container = NULL;
731     }
732   bsi.bb = bb;
733   return bsi;
734 }
735
736 /* Return a block statement iterator that points to the first non-label
737    statement in block BB.  */
738
739 static inline block_stmt_iterator
740 bsi_after_labels (basic_block bb)
741 {
742   block_stmt_iterator bsi = bsi_start (bb);
743
744   while (!bsi_end_p (bsi) && TREE_CODE (bsi_stmt (bsi)) == LABEL_EXPR)
745     bsi_next (&bsi);
746
747   return bsi;
748 }
749
750 /* Return a block statement iterator that points to the end of basic
751    block BB.  */
752 static inline block_stmt_iterator
753 bsi_last (basic_block bb)
754 {
755   block_stmt_iterator bsi;
756   if (bb->stmt_list)
757     bsi.tsi = tsi_last (bb->stmt_list);
758   else
759     {
760       gcc_assert (bb->index < NUM_FIXED_BLOCKS);
761       bsi.tsi.ptr = NULL;
762       bsi.tsi.container = NULL;
763     }
764   bsi.bb = bb;
765   return bsi;
766 }
767
768 /* Return true if block statement iterator I has reached the end of
769    the basic block.  */
770 static inline bool
771 bsi_end_p (block_stmt_iterator i)
772 {
773   return tsi_end_p (i.tsi);
774 }
775
776 /* Modify block statement iterator I so that it is at the next
777    statement in the basic block.  */
778 static inline void
779 bsi_next (block_stmt_iterator *i)
780 {
781   tsi_next (&i->tsi);
782 }
783
784 /* Modify block statement iterator I so that it is at the previous
785    statement in the basic block.  */
786 static inline void
787 bsi_prev (block_stmt_iterator *i)
788 {
789   tsi_prev (&i->tsi);
790 }
791
792 /* Return the statement that block statement iterator I is currently
793    at.  */
794 static inline tree
795 bsi_stmt (block_stmt_iterator i)
796 {
797   return tsi_stmt (i.tsi);
798 }
799
800 /* Return a pointer to the statement that block statement iterator I
801    is currently at.  */
802 static inline tree *
803 bsi_stmt_ptr (block_stmt_iterator i)
804 {
805   return tsi_stmt_ptr (i.tsi);
806 }
807
808 /* Returns the loop of the statement STMT.  */
809
810 static inline struct loop *
811 loop_containing_stmt (tree stmt)
812 {
813   basic_block bb = bb_for_stmt (stmt);
814   if (!bb)
815     return NULL;
816
817   return bb->loop_father;
818 }
819
820 /* Return true if VAR is a clobbered by function calls.  */
821 static inline bool
822 is_call_clobbered (tree var)
823 {
824   return bitmap_bit_p (call_clobbered_vars, DECL_UID (var));
825 }
826
827 /* Mark variable VAR as being clobbered by function calls.  */
828 static inline void
829 mark_call_clobbered (tree var, unsigned int escape_type)
830 {
831   var_ann (var)->escape_mask |= escape_type;
832   bitmap_set_bit (call_clobbered_vars, DECL_UID (var));
833 }
834
835 /* Clear the call-clobbered attribute from variable VAR.  */
836 static inline void
837 clear_call_clobbered (tree var)
838 {
839   var_ann_t ann = var_ann (var);
840   ann->escape_mask = 0;
841   if (MTAG_P (var) && TREE_CODE (var) != STRUCT_FIELD_TAG)
842     MTAG_GLOBAL (var) = 0;
843   bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
844 }
845
846 /* Mark variable VAR as being non-addressable.  */
847 static inline void
848 mark_non_addressable (tree var)
849 {
850   bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
851   TREE_ADDRESSABLE (var) = 0;
852 }
853
854 /* Return the common annotation for T.  Return NULL if the annotation
855    doesn't already exist.  */
856 static inline tree_ann_t
857 tree_ann (tree t)
858 {
859   return t->common.ann;
860 }
861
862 /* Return a common annotation for T.  Create the constant annotation if it
863    doesn't exist.  */
864 static inline tree_ann_t
865 get_tree_ann (tree t)
866 {
867   tree_ann_t ann = tree_ann (t);
868   return (ann) ? ann : create_tree_ann (t);
869 }
870
871 /*  -----------------------------------------------------------------------  */
872
873 /* The following set of routines are used to iterator over various type of
874    SSA operands.  */
875
876 /* Return true if PTR is finished iterating.  */
877 static inline bool
878 op_iter_done (ssa_op_iter *ptr)
879 {
880   return ptr->done;
881 }
882
883 /* Get the next iterator use value for PTR.  */
884 static inline use_operand_p
885 op_iter_next_use (ssa_op_iter *ptr)
886 {
887   use_operand_p use_p;
888 #ifdef ENABLE_CHECKING
889   gcc_assert (ptr->iter_type == ssa_op_iter_use);
890 #endif
891   if (ptr->uses)
892     {
893       use_p = USE_OP_PTR (ptr->uses);
894       ptr->uses = ptr->uses->next;
895       return use_p;
896     }
897   if (ptr->vuses)
898     {
899       use_p = VUSE_OP_PTR (ptr->vuses);
900       ptr->vuses = ptr->vuses->next;
901       return use_p;
902     }
903   if (ptr->mayuses)
904     {
905       use_p = MAYDEF_OP_PTR (ptr->mayuses);
906       ptr->mayuses = ptr->mayuses->next;
907       return use_p;
908     }
909   if (ptr->mustkills)
910     {
911       use_p = MUSTDEF_KILL_PTR (ptr->mustkills);
912       ptr->mustkills = ptr->mustkills->next;
913       return use_p;
914     }
915   if (ptr->phi_i < ptr->num_phi)
916     {
917       return PHI_ARG_DEF_PTR (ptr->phi_stmt, (ptr->phi_i)++);
918     }
919   ptr->done = true;
920   return NULL_USE_OPERAND_P;
921 }
922
923 /* Get the next iterator def value for PTR.  */
924 static inline def_operand_p
925 op_iter_next_def (ssa_op_iter *ptr)
926 {
927   def_operand_p def_p;
928 #ifdef ENABLE_CHECKING
929   gcc_assert (ptr->iter_type == ssa_op_iter_def);
930 #endif
931   if (ptr->defs)
932     {
933       def_p = DEF_OP_PTR (ptr->defs);
934       ptr->defs = ptr->defs->next;
935       return def_p;
936     }
937   if (ptr->mustdefs)
938     {
939       def_p = MUSTDEF_RESULT_PTR (ptr->mustdefs);
940       ptr->mustdefs = ptr->mustdefs->next;
941       return def_p;
942     }
943   if (ptr->maydefs)
944     {
945       def_p = MAYDEF_RESULT_PTR (ptr->maydefs);
946       ptr->maydefs = ptr->maydefs->next;
947       return def_p;
948     }
949   ptr->done = true;
950   return NULL_DEF_OPERAND_P;
951 }
952
953 /* Get the next iterator tree value for PTR.  */
954 static inline tree
955 op_iter_next_tree (ssa_op_iter *ptr)
956 {
957   tree val;
958 #ifdef ENABLE_CHECKING
959   gcc_assert (ptr->iter_type == ssa_op_iter_tree);
960 #endif
961   if (ptr->uses)
962     {
963       val = USE_OP (ptr->uses);
964       ptr->uses = ptr->uses->next;
965       return val;
966     }
967   if (ptr->vuses)
968     {
969       val = VUSE_OP (ptr->vuses);
970       ptr->vuses = ptr->vuses->next;
971       return val;
972     }
973   if (ptr->mayuses)
974     {
975       val = MAYDEF_OP (ptr->mayuses);
976       ptr->mayuses = ptr->mayuses->next;
977       return val;
978     }
979   if (ptr->mustkills)
980     {
981       val = MUSTDEF_KILL (ptr->mustkills);
982       ptr->mustkills = ptr->mustkills->next;
983       return val;
984     }
985   if (ptr->defs)
986     {
987       val = DEF_OP (ptr->defs);
988       ptr->defs = ptr->defs->next;
989       return val;
990     }
991   if (ptr->mustdefs)
992     {
993       val = MUSTDEF_RESULT (ptr->mustdefs);
994       ptr->mustdefs = ptr->mustdefs->next;
995       return val;
996     }
997   if (ptr->maydefs)
998     {
999       val = MAYDEF_RESULT (ptr->maydefs);
1000       ptr->maydefs = ptr->maydefs->next;
1001       return val;
1002     }
1003
1004   ptr->done = true;
1005   return NULL_TREE;
1006
1007 }
1008
1009
1010 /* This functions clears the iterator PTR, and marks it done.  This is normally
1011    used to prevent warnings in the compile about might be uninitialized
1012    components.  */
1013
1014 static inline void
1015 clear_and_done_ssa_iter (ssa_op_iter *ptr)
1016 {
1017   ptr->defs = NULL;
1018   ptr->uses = NULL;
1019   ptr->vuses = NULL;
1020   ptr->maydefs = NULL;
1021   ptr->mayuses = NULL;
1022   ptr->mustdefs = NULL;
1023   ptr->mustkills = NULL;
1024   ptr->iter_type = ssa_op_iter_none;
1025   ptr->phi_i = 0;
1026   ptr->num_phi = 0;
1027   ptr->phi_stmt = NULL_TREE;
1028   ptr->done = true;
1029 }
1030
1031 /* Initialize the iterator PTR to the virtual defs in STMT.  */
1032 static inline void
1033 op_iter_init (ssa_op_iter *ptr, tree stmt, int flags)
1034 {
1035 #ifdef ENABLE_CHECKING
1036   gcc_assert (stmt_ann (stmt));
1037 #endif
1038
1039   ptr->defs = (flags & SSA_OP_DEF) ? DEF_OPS (stmt) : NULL;
1040   ptr->uses = (flags & SSA_OP_USE) ? USE_OPS (stmt) : NULL;
1041   ptr->vuses = (flags & SSA_OP_VUSE) ? VUSE_OPS (stmt) : NULL;
1042   ptr->maydefs = (flags & SSA_OP_VMAYDEF) ? MAYDEF_OPS (stmt) : NULL;
1043   ptr->mayuses = (flags & SSA_OP_VMAYUSE) ? MAYDEF_OPS (stmt) : NULL;
1044   ptr->mustdefs = (flags & SSA_OP_VMUSTDEF) ? MUSTDEF_OPS (stmt) : NULL;
1045   ptr->mustkills = (flags & SSA_OP_VMUSTKILL) ? MUSTDEF_OPS (stmt) : NULL;
1046   ptr->done = false;
1047
1048   ptr->phi_i = 0;
1049   ptr->num_phi = 0;
1050   ptr->phi_stmt = NULL_TREE;
1051 }
1052
1053 /* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return
1054    the first use.  */
1055 static inline use_operand_p
1056 op_iter_init_use (ssa_op_iter *ptr, tree stmt, int flags)
1057 {
1058   gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0);
1059   op_iter_init (ptr, stmt, flags);
1060   ptr->iter_type = ssa_op_iter_use;
1061   return op_iter_next_use (ptr);
1062 }
1063
1064 /* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return
1065    the first def.  */
1066 static inline def_operand_p
1067 op_iter_init_def (ssa_op_iter *ptr, tree stmt, int flags)
1068 {
1069   gcc_assert ((flags & (SSA_OP_ALL_USES | SSA_OP_VIRTUAL_KILLS)) == 0);
1070   op_iter_init (ptr, stmt, flags);
1071   ptr->iter_type = ssa_op_iter_def;
1072   return op_iter_next_def (ptr);
1073 }
1074
1075 /* Initialize iterator PTR to the operands in STMT based on FLAGS. Return
1076    the first operand as a tree.  */
1077 static inline tree
1078 op_iter_init_tree (ssa_op_iter *ptr, tree stmt, int flags)
1079 {
1080   op_iter_init (ptr, stmt, flags);
1081   ptr->iter_type = ssa_op_iter_tree;
1082   return op_iter_next_tree (ptr);
1083 }
1084
1085 /* Get the next iterator mustdef value for PTR, returning the mustdef values in
1086    KILL and DEF.  */
1087 static inline void
1088 op_iter_next_maymustdef (use_operand_p *use, def_operand_p *def, 
1089                          ssa_op_iter *ptr)
1090 {
1091 #ifdef ENABLE_CHECKING
1092   gcc_assert (ptr->iter_type == ssa_op_iter_maymustdef);
1093 #endif
1094   if (ptr->mayuses)
1095     {
1096       *def = MAYDEF_RESULT_PTR (ptr->mayuses);
1097       *use = MAYDEF_OP_PTR (ptr->mayuses);
1098       ptr->mayuses = ptr->mayuses->next;
1099       return;
1100     }
1101
1102   if (ptr->mustkills)
1103     {
1104       *def = MUSTDEF_RESULT_PTR (ptr->mustkills);
1105       *use = MUSTDEF_KILL_PTR (ptr->mustkills);
1106       ptr->mustkills = ptr->mustkills->next;
1107       return;
1108     }
1109
1110   *def = NULL_DEF_OPERAND_P;
1111   *use = NULL_USE_OPERAND_P;
1112   ptr->done = true;
1113   return;
1114 }
1115
1116
1117 /* Initialize iterator PTR to the operands in STMT.  Return the first operands
1118    in USE and DEF.  */
1119 static inline void
1120 op_iter_init_maydef (ssa_op_iter *ptr, tree stmt, use_operand_p *use, 
1121                      def_operand_p *def)
1122 {
1123   gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1124
1125   op_iter_init (ptr, stmt, SSA_OP_VMAYUSE);
1126   ptr->iter_type = ssa_op_iter_maymustdef;
1127   op_iter_next_maymustdef (use, def, ptr);
1128 }
1129
1130
1131 /* Initialize iterator PTR to the operands in STMT.  Return the first operands
1132    in KILL and DEF.  */
1133 static inline void
1134 op_iter_init_mustdef (ssa_op_iter *ptr, tree stmt, use_operand_p *kill, 
1135                      def_operand_p *def)
1136 {
1137   gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1138
1139   op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL);
1140   ptr->iter_type = ssa_op_iter_maymustdef;
1141   op_iter_next_maymustdef (kill, def, ptr);
1142 }
1143
1144 /* Initialize iterator PTR to the operands in STMT.  Return the first operands
1145    in KILL and DEF.  */
1146 static inline void
1147 op_iter_init_must_and_may_def (ssa_op_iter *ptr, tree stmt,
1148                                use_operand_p *kill, def_operand_p *def)
1149 {
1150   gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1151
1152   op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL|SSA_OP_VMAYUSE);
1153   ptr->iter_type = ssa_op_iter_maymustdef;
1154   op_iter_next_maymustdef (kill, def, ptr);
1155 }
1156
1157
1158 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1159    return NULL.  */
1160 static inline tree
1161 single_ssa_tree_operand (tree stmt, int flags)
1162 {
1163   tree var;
1164   ssa_op_iter iter;
1165
1166   var = op_iter_init_tree (&iter, stmt, flags);
1167   if (op_iter_done (&iter))
1168     return NULL_TREE;
1169   op_iter_next_tree (&iter);
1170   if (op_iter_done (&iter))
1171     return var;
1172   return NULL_TREE;
1173 }
1174
1175
1176 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1177    return NULL.  */
1178 static inline use_operand_p
1179 single_ssa_use_operand (tree stmt, int flags)
1180 {
1181   use_operand_p var;
1182   ssa_op_iter iter;
1183
1184   var = op_iter_init_use (&iter, stmt, flags);
1185   if (op_iter_done (&iter))
1186     return NULL_USE_OPERAND_P;
1187   op_iter_next_use (&iter);
1188   if (op_iter_done (&iter))
1189     return var;
1190   return NULL_USE_OPERAND_P;
1191 }
1192
1193
1194
1195 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1196    return NULL.  */
1197 static inline def_operand_p
1198 single_ssa_def_operand (tree stmt, int flags)
1199 {
1200   def_operand_p var;
1201   ssa_op_iter iter;
1202
1203   var = op_iter_init_def (&iter, stmt, flags);
1204   if (op_iter_done (&iter))
1205     return NULL_DEF_OPERAND_P;
1206   op_iter_next_def (&iter);
1207   if (op_iter_done (&iter))
1208     return var;
1209   return NULL_DEF_OPERAND_P;
1210 }
1211
1212
1213 /* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1214    return NULL.  */
1215 static inline bool
1216 zero_ssa_operands (tree stmt, int flags)
1217 {
1218   ssa_op_iter iter;
1219
1220   op_iter_init_tree (&iter, stmt, flags);
1221   return op_iter_done (&iter);
1222 }
1223
1224
1225 /* Return the number of operands matching FLAGS in STMT.  */
1226 static inline int
1227 num_ssa_operands (tree stmt, int flags)
1228 {
1229   ssa_op_iter iter;
1230   tree t;
1231   int num = 0;
1232
1233   FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
1234     num++;
1235   return num;
1236 }
1237
1238
1239 /* Delink all immediate_use information for STMT.  */
1240 static inline void
1241 delink_stmt_imm_use (tree stmt)
1242 {
1243    ssa_op_iter iter;
1244    use_operand_p use_p;
1245
1246    if (ssa_operands_active ())
1247      FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
1248                                (SSA_OP_ALL_USES | SSA_OP_ALL_KILLS))
1249        delink_imm_use (use_p);
1250 }
1251
1252
1253 /* This routine will compare all the operands matching FLAGS in STMT1 to those
1254    in STMT2.  TRUE is returned if they are the same.  STMTs can be NULL.  */
1255 static inline bool
1256 compare_ssa_operands_equal (tree stmt1, tree stmt2, int flags)
1257 {
1258   ssa_op_iter iter1, iter2;
1259   tree op1 = NULL_TREE;
1260   tree op2 = NULL_TREE;
1261   bool look1, look2;
1262
1263   if (stmt1 == stmt2)
1264     return true;
1265
1266   look1 = stmt1 && stmt_ann (stmt1);
1267   look2 = stmt2 && stmt_ann (stmt2);
1268
1269   if (look1)
1270     {
1271       op1 = op_iter_init_tree (&iter1, stmt1, flags);
1272       if (!look2)
1273         return op_iter_done (&iter1);
1274     }
1275   else
1276     clear_and_done_ssa_iter (&iter1);
1277
1278   if (look2)
1279     {
1280       op2 = op_iter_init_tree (&iter2, stmt2, flags);
1281       if (!look1)
1282         return op_iter_done (&iter2);
1283     }
1284   else
1285     clear_and_done_ssa_iter (&iter2);
1286
1287   while (!op_iter_done (&iter1) && !op_iter_done (&iter2))
1288     {
1289       if (op1 != op2)
1290         return false;
1291       op1 = op_iter_next_tree (&iter1);
1292       op2 = op_iter_next_tree (&iter2);
1293     }
1294
1295   return (op_iter_done (&iter1) && op_iter_done (&iter2));
1296 }
1297
1298
1299 /* If there is a single DEF in the PHI node which matches FLAG, return it.
1300    Otherwise return NULL_DEF_OPERAND_P.  */
1301 static inline tree
1302 single_phi_def (tree stmt, int flags)
1303 {
1304   tree def = PHI_RESULT (stmt);
1305   if ((flags & SSA_OP_DEF) && is_gimple_reg (def)) 
1306     return def;
1307   if ((flags & SSA_OP_VIRTUAL_DEFS) && !is_gimple_reg (def))
1308     return def;
1309   return NULL_TREE;
1310 }
1311
1312 /* Initialize the iterator PTR for uses matching FLAGS in PHI.  FLAGS should
1313    be either SSA_OP_USES or SAS_OP_VIRTUAL_USES.  */
1314 static inline use_operand_p
1315 op_iter_init_phiuse (ssa_op_iter *ptr, tree phi, int flags)
1316 {
1317   tree phi_def = PHI_RESULT (phi);
1318   int comp;
1319
1320   clear_and_done_ssa_iter (ptr);
1321   ptr->done = false;
1322
1323   gcc_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
1324
1325   comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1326     
1327   /* If the PHI node doesn't the operand type we care about, we're done.  */
1328   if ((flags & comp) == 0)
1329     {
1330       ptr->done = true;
1331       return NULL_USE_OPERAND_P;
1332     }
1333
1334   ptr->phi_stmt = phi;
1335   ptr->num_phi = PHI_NUM_ARGS (phi);
1336   ptr->iter_type = ssa_op_iter_use;
1337   return op_iter_next_use (ptr);
1338 }
1339
1340
1341 /* Start an iterator for a PHI definition.  */
1342
1343 static inline def_operand_p
1344 op_iter_init_phidef (ssa_op_iter *ptr, tree phi, int flags)
1345 {
1346   tree phi_def = PHI_RESULT (phi);
1347   int comp;
1348
1349   clear_and_done_ssa_iter (ptr);
1350   ptr->done = false;
1351
1352   gcc_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
1353
1354   comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS);
1355     
1356   /* If the PHI node doesn't the operand type we care about, we're done.  */
1357   if ((flags & comp) == 0)
1358     {
1359       ptr->done = true;
1360       return NULL_USE_OPERAND_P;
1361     }
1362
1363   ptr->iter_type = ssa_op_iter_def;
1364   /* The first call to op_iter_next_def will terminate the iterator since
1365      all the fields are NULL.  Simply return the result here as the first and
1366      therefore only result.  */
1367   return PHI_RESULT_PTR (phi);
1368 }
1369
1370
1371
1372 /* Return true if VAR cannot be modified by the program.  */
1373
1374 static inline bool
1375 unmodifiable_var_p (tree var)
1376 {
1377   if (TREE_CODE (var) == SSA_NAME)
1378     var = SSA_NAME_VAR (var);
1379
1380   if (MTAG_P (var))
1381     return TREE_READONLY (var) && (TREE_STATIC (var) || MTAG_GLOBAL (var));
1382
1383   return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
1384 }
1385
1386 /* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it.  */
1387
1388 static inline bool
1389 array_ref_contains_indirect_ref (tree ref)
1390 {
1391   gcc_assert (TREE_CODE (ref) == ARRAY_REF);
1392
1393   do {
1394     ref = TREE_OPERAND (ref, 0);
1395   } while (handled_component_p (ref));
1396
1397   return TREE_CODE (ref) == INDIRECT_REF;
1398 }
1399
1400 /* Return true if REF, a handled component reference, has an ARRAY_REF
1401    somewhere in it.  */
1402
1403 static inline bool
1404 ref_contains_array_ref (tree ref)
1405 {
1406   gcc_assert (handled_component_p (ref));
1407
1408   do {
1409     if (TREE_CODE (ref) == ARRAY_REF)
1410       return true;
1411     ref = TREE_OPERAND (ref, 0);
1412   } while (handled_component_p (ref));
1413
1414   return false;
1415 }
1416
1417 /* Given a variable VAR, lookup and return a pointer to the list of
1418    subvariables for it.  */
1419
1420 static inline subvar_t *
1421 lookup_subvars_for_var (tree var)
1422 {
1423   var_ann_t ann = var_ann (var);
1424   gcc_assert (ann);
1425   return &ann->subvars;
1426 }
1427
1428 /* Given a variable VAR, return a linked list of subvariables for VAR, or
1429    NULL, if there are no subvariables.  */
1430
1431 static inline subvar_t
1432 get_subvars_for_var (tree var)
1433 {
1434   subvar_t subvars;
1435
1436   gcc_assert (SSA_VAR_P (var));  
1437   
1438   if (TREE_CODE (var) == SSA_NAME)
1439     subvars = *(lookup_subvars_for_var (SSA_NAME_VAR (var)));
1440   else
1441     subvars = *(lookup_subvars_for_var (var));
1442   return subvars;
1443 }
1444
1445 /* Return the subvariable of VAR at offset OFFSET.  */
1446
1447 static inline tree
1448 get_subvar_at (tree var, unsigned HOST_WIDE_INT offset)
1449 {
1450   subvar_t sv;
1451
1452   for (sv = get_subvars_for_var (var); sv; sv = sv->next)
1453     if (SFT_OFFSET (sv->var) == offset)
1454       return sv->var;
1455
1456   return NULL_TREE;
1457 }
1458
1459 /* Return true if V is a tree that we can have subvars for.
1460    Normally, this is any aggregate type.  Also complex
1461    types which are not gimple registers can have subvars.  */
1462
1463 static inline bool
1464 var_can_have_subvars (tree v)
1465 {
1466   /* Volatile variables should never have subvars.  */
1467   if (TREE_THIS_VOLATILE (v))
1468     return false;
1469
1470   /* Non decls or memory tags can never have subvars.  */
1471   if (!DECL_P (v) || MTAG_P (v))
1472     return false;
1473
1474   /* Aggregates can have subvars.  */
1475   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
1476     return true;
1477
1478   /* Complex types variables which are not also a gimple register can
1479     have subvars. */
1480   if (TREE_CODE (TREE_TYPE (v)) == COMPLEX_TYPE
1481       && !DECL_COMPLEX_GIMPLE_REG_P (v))
1482     return true;
1483
1484   return false;
1485 }
1486
1487   
1488 /* Return true if OFFSET and SIZE define a range that overlaps with some
1489    portion of the range of SV, a subvar.  If there was an exact overlap,
1490    *EXACT will be set to true upon return. */
1491
1492 static inline bool
1493 overlap_subvar (unsigned HOST_WIDE_INT offset, unsigned HOST_WIDE_INT size,
1494                 tree sv,  bool *exact)
1495 {
1496   /* There are three possible cases of overlap.
1497      1. We can have an exact overlap, like so:   
1498      |offset, offset + size             |
1499      |sv->offset, sv->offset + sv->size |
1500      
1501      2. We can have offset starting after sv->offset, like so:
1502      
1503            |offset, offset + size              |
1504      |sv->offset, sv->offset + sv->size  |
1505
1506      3. We can have offset starting before sv->offset, like so:
1507      
1508      |offset, offset + size    |
1509        |sv->offset, sv->offset + sv->size|
1510   */
1511
1512   if (exact)
1513     *exact = false;
1514   if (offset == SFT_OFFSET (sv) && size == SFT_SIZE (sv))
1515     {
1516       if (exact)
1517         *exact = true;
1518       return true;
1519     }
1520   else if (offset >= SFT_OFFSET (sv) 
1521            && offset < (SFT_OFFSET (sv) + SFT_SIZE (sv)))
1522     {
1523       return true;
1524     }
1525   else if (offset < SFT_OFFSET (sv) 
1526            && (size > SFT_OFFSET (sv) - offset))
1527     {
1528       return true;
1529     }
1530   return false;
1531
1532 }
1533
1534 #endif /* _TREE_FLOW_INLINE_H  */