* gcc-dg/pthread-init-common.h: Define _GNU_SOURCE. Add tests for
[official-gcc.git] / gcc / tree-flow-inline.h
blob892be56a61ccc223cccd9412abb1664f99720237
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>
5 This file is part of GCC.
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.
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.
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. */
22 #ifndef _TREE_FLOW_INLINE_H
23 #define _TREE_FLOW_INLINE_H 1
25 /* Inline functions for manipulating various data structures defined in
26 tree-flow.h. See tree-flow.h for documentation. */
28 /* Initialize the hashtable iterator HTI to point to hashtable TABLE */
30 static inline void *
31 first_htab_element (htab_iterator *hti, htab_t table)
33 hti->htab = table;
34 hti->slot = table->entries;
35 hti->limit = hti->slot + htab_size (table);
38 PTR x = *(hti->slot);
39 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
40 break;
41 } while (++(hti->slot) < hti->limit);
43 if (hti->slot < hti->limit)
44 return *(hti->slot);
45 return NULL;
48 /* Return current non-empty/deleted slot of the hashtable pointed to by HTI,
49 or NULL if we have reached the end. */
51 static inline bool
52 end_htab_p (htab_iterator *hti)
54 if (hti->slot >= hti->limit)
55 return true;
56 return false;
59 /* Advance the hashtable iterator pointed to by HTI to the next element of the
60 hashtable. */
62 static inline void *
63 next_htab_element (htab_iterator *hti)
65 while (++(hti->slot) < hti->limit)
67 PTR x = *(hti->slot);
68 if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
69 return x;
71 return NULL;
74 /* Initialize ITER to point to the first referenced variable in the
75 referenced_vars hashtable, and return that variable. */
77 static inline tree
78 first_referenced_var (referenced_var_iterator *iter)
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;
88 /* Return true if we have hit the end of the referenced variables ITER is
89 iterating through. */
91 static inline bool
92 end_referenced_vars_p (referenced_var_iterator *iter)
94 return end_htab_p (&iter->hti);
97 /* Make ITER point to the next referenced_var in the referenced_var hashtable,
98 and return that variable. */
100 static inline tree
101 next_referenced_var (referenced_var_iterator *iter)
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;
110 /* Fill up VEC with the variables in the referenced vars hashtable. */
112 static inline void
113 fill_referenced_var_vec (VEC (tree, heap) **vec)
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);
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)
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);
132 return (var_ann_t) t->common.ann;
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)
140 var_ann_t ann = var_ann (var);
141 return (ann) ? ann : create_var_ann (var);
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)
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);
153 return (function_ann_t) t->common.ann;
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)
161 function_ann_t ann = function_ann (var);
162 gcc_assert (!var->common.ann || var->common.ann->common.type == FUNCTION_ANN);
163 return (ann) ? ann : create_function_ann (var);
166 /* Return the statement annotation for T, which must be a statement
167 node. Return NULL if the statement annotation doesn't exist. */
168 static inline stmt_ann_t
169 stmt_ann (tree t)
171 #ifdef ENABLE_CHECKING
172 gcc_assert (is_gimple_stmt (t));
173 #endif
174 gcc_assert (!t->common.ann || t->common.ann->common.type == STMT_ANN);
175 return (stmt_ann_t) t->common.ann;
178 /* Return the statement annotation for T, which must be a statement
179 node. Create the statement annotation if it doesn't exist. */
180 static inline stmt_ann_t
181 get_stmt_ann (tree stmt)
183 stmt_ann_t ann = stmt_ann (stmt);
184 return (ann) ? ann : create_stmt_ann (stmt);
187 /* Return the annotation type for annotation ANN. */
188 static inline enum tree_ann_type
189 ann_type (tree_ann_t ann)
191 return ann->common.type;
194 /* Return the basic block for statement T. */
195 static inline basic_block
196 bb_for_stmt (tree t)
198 stmt_ann_t ann;
200 if (TREE_CODE (t) == PHI_NODE)
201 return PHI_BB (t);
203 ann = stmt_ann (t);
204 return ann ? ann->bb : NULL;
207 /* Return the may_aliases varray for variable VAR, or NULL if it has
208 no may aliases. */
209 static inline VEC(tree, gc) *
210 may_aliases (tree var)
212 var_ann_t ann = var_ann (var);
213 return ann ? ann->may_aliases : NULL;
216 /* Return the line number for EXPR, or return -1 if we have no line
217 number information for it. */
218 static inline int
219 get_lineno (tree expr)
221 if (expr == NULL_TREE)
222 return -1;
224 if (TREE_CODE (expr) == COMPOUND_EXPR)
225 expr = TREE_OPERAND (expr, 0);
227 if (! EXPR_HAS_LOCATION (expr))
228 return -1;
230 return EXPR_LINENO (expr);
233 /* Return the file name for EXPR, or return "???" if we have no
234 filename information. */
235 static inline const char *
236 get_filename (tree expr)
238 const char *filename;
239 if (expr == NULL_TREE)
240 return "???";
242 if (TREE_CODE (expr) == COMPOUND_EXPR)
243 expr = TREE_OPERAND (expr, 0);
245 if (EXPR_HAS_LOCATION (expr) && (filename = EXPR_FILENAME (expr)))
246 return filename;
247 else
248 return "???";
251 /* Return true if T is a noreturn call. */
252 static inline bool
253 noreturn_call_p (tree t)
255 tree call = get_call_expr_in (t);
256 return call != 0 && (call_expr_flags (call) & ECF_NORETURN) != 0;
259 /* Mark statement T as modified. */
260 static inline void
261 mark_stmt_modified (tree t)
263 stmt_ann_t ann;
264 if (TREE_CODE (t) == PHI_NODE)
265 return;
267 ann = stmt_ann (t);
268 if (ann == NULL)
269 ann = create_stmt_ann (t);
270 else if (noreturn_call_p (t))
271 VEC_safe_push (tree, gc, modified_noreturn_calls, t);
272 ann->modified = 1;
275 /* Mark statement T as modified, and update it. */
276 static inline void
277 update_stmt (tree t)
279 if (TREE_CODE (t) == PHI_NODE)
280 return;
281 mark_stmt_modified (t);
282 update_stmt_operands (t);
285 static inline void
286 update_stmt_if_modified (tree t)
288 if (stmt_modified_p (t))
289 update_stmt_operands (t);
292 /* Return true if T is marked as modified, false otherwise. */
293 static inline bool
294 stmt_modified_p (tree t)
296 stmt_ann_t ann = stmt_ann (t);
298 /* Note that if the statement doesn't yet have an annotation, we consider it
299 modified. This will force the next call to update_stmt_operands to scan
300 the statement. */
301 return ann ? ann->modified : true;
304 /* Delink an immediate_uses node from its chain. */
305 static inline void
306 delink_imm_use (ssa_use_operand_t *linknode)
308 /* Return if this node is not in a list. */
309 if (linknode->prev == NULL)
310 return;
312 linknode->prev->next = linknode->next;
313 linknode->next->prev = linknode->prev;
314 linknode->prev = NULL;
315 linknode->next = NULL;
318 /* Link ssa_imm_use node LINKNODE into the chain for LIST. */
319 static inline void
320 link_imm_use_to_list (ssa_use_operand_t *linknode, ssa_use_operand_t *list)
322 /* Link the new node at the head of the list. If we are in the process of
323 traversing the list, we won't visit any new nodes added to it. */
324 linknode->prev = list;
325 linknode->next = list->next;
326 list->next->prev = linknode;
327 list->next = linknode;
330 /* Link ssa_imm_use node LINKNODE into the chain for DEF. */
331 static inline void
332 link_imm_use (ssa_use_operand_t *linknode, tree def)
334 ssa_use_operand_t *root;
336 if (!def || TREE_CODE (def) != SSA_NAME)
337 linknode->prev = NULL;
338 else
340 root = &(SSA_NAME_IMM_USE_NODE (def));
341 #ifdef ENABLE_CHECKING
342 if (linknode->use)
343 gcc_assert (*(linknode->use) == def);
344 #endif
345 link_imm_use_to_list (linknode, root);
349 /* Set the value of a use pointed to by USE to VAL. */
350 static inline void
351 set_ssa_use_from_ptr (use_operand_p use, tree val)
353 delink_imm_use (use);
354 *(use->use) = val;
355 link_imm_use (use, val);
358 /* Link ssa_imm_use node LINKNODE into the chain for DEF, with use occurring
359 in STMT. */
360 static inline void
361 link_imm_use_stmt (ssa_use_operand_t *linknode, tree def, tree stmt)
363 if (stmt)
364 link_imm_use (linknode, def);
365 else
366 link_imm_use (linknode, NULL);
367 linknode->stmt = stmt;
370 /* Relink a new node in place of an old node in the list. */
371 static inline void
372 relink_imm_use (ssa_use_operand_t *node, ssa_use_operand_t *old)
374 /* The node one had better be in the same list. */
375 gcc_assert (*(old->use) == *(node->use));
376 node->prev = old->prev;
377 node->next = old->next;
378 if (old->prev)
380 old->prev->next = node;
381 old->next->prev = node;
382 /* Remove the old node from the list. */
383 old->prev = NULL;
387 /* Relink ssa_imm_use node LINKNODE into the chain for OLD, with use occurring
388 in STMT. */
389 static inline void
390 relink_imm_use_stmt (ssa_use_operand_t *linknode, ssa_use_operand_t *old, tree stmt)
392 if (stmt)
393 relink_imm_use (linknode, old);
394 else
395 link_imm_use (linknode, NULL);
396 linknode->stmt = stmt;
400 /* Return true is IMM has reached the end of the immediate use list. */
401 static inline bool
402 end_readonly_imm_use_p (imm_use_iterator *imm)
404 return (imm->imm_use == imm->end_p);
407 /* Initialize iterator IMM to process the list for VAR. */
408 static inline use_operand_p
409 first_readonly_imm_use (imm_use_iterator *imm, tree var)
411 gcc_assert (TREE_CODE (var) == SSA_NAME);
413 imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
414 imm->imm_use = imm->end_p->next;
415 #ifdef ENABLE_CHECKING
416 imm->iter_node.next = imm->imm_use->next;
417 #endif
418 if (end_readonly_imm_use_p (imm))
419 return NULL_USE_OPERAND_P;
420 return imm->imm_use;
423 /* Bump IMM to the next use in the list. */
424 static inline use_operand_p
425 next_readonly_imm_use (imm_use_iterator *imm)
427 use_operand_p old = imm->imm_use;
429 #ifdef ENABLE_CHECKING
430 /* If this assertion fails, it indicates the 'next' pointer has changed
431 since we the last bump. This indicates that the list is being modified
432 via stmt changes, or SET_USE, or somesuch thing, and you need to be
433 using the SAFE version of the iterator. */
434 gcc_assert (imm->iter_node.next == old->next);
435 imm->iter_node.next = old->next->next;
436 #endif
438 imm->imm_use = old->next;
439 if (end_readonly_imm_use_p (imm))
440 return old;
441 return imm->imm_use;
444 /* Return true if VAR has no uses. */
445 static inline bool
446 has_zero_uses (tree var)
448 ssa_use_operand_t *ptr;
449 ptr = &(SSA_NAME_IMM_USE_NODE (var));
450 /* A single use means there is no items in the list. */
451 return (ptr == ptr->next);
454 /* Return true if VAR has a single use. */
455 static inline bool
456 has_single_use (tree var)
458 ssa_use_operand_t *ptr;
459 ptr = &(SSA_NAME_IMM_USE_NODE (var));
460 /* A single use means there is one item in the list. */
461 return (ptr != ptr->next && ptr == ptr->next->next);
464 /* If VAR has only a single immediate use, return true, and set USE_P and STMT
465 to the use pointer and stmt of occurrence. */
466 static inline bool
467 single_imm_use (tree var, use_operand_p *use_p, tree *stmt)
469 ssa_use_operand_t *ptr;
471 ptr = &(SSA_NAME_IMM_USE_NODE (var));
472 if (ptr != ptr->next && ptr == ptr->next->next)
474 *use_p = ptr->next;
475 *stmt = ptr->next->stmt;
476 return true;
478 *use_p = NULL_USE_OPERAND_P;
479 *stmt = NULL_TREE;
480 return false;
483 /* Return the number of immediate uses of VAR. */
484 static inline unsigned int
485 num_imm_uses (tree var)
487 ssa_use_operand_t *ptr, *start;
488 unsigned int num;
490 start = &(SSA_NAME_IMM_USE_NODE (var));
491 num = 0;
492 for (ptr = start->next; ptr != start; ptr = ptr->next)
493 num++;
495 return num;
499 /* Return the tree pointer to by USE. */
500 static inline tree
501 get_use_from_ptr (use_operand_p use)
503 return *(use->use);
506 /* Return the tree pointer to by DEF. */
507 static inline tree
508 get_def_from_ptr (def_operand_p def)
510 return *def;
513 /* Return a def_operand_p pointer for the result of PHI. */
514 static inline def_operand_p
515 get_phi_result_ptr (tree phi)
517 return &(PHI_RESULT_TREE (phi));
520 /* Return a use_operand_p pointer for argument I of phinode PHI. */
521 static inline use_operand_p
522 get_phi_arg_def_ptr (tree phi, int i)
524 return &(PHI_ARG_IMM_USE_NODE (phi,i));
528 /* Return the bitmap of addresses taken by STMT, or NULL if it takes
529 no addresses. */
530 static inline bitmap
531 addresses_taken (tree stmt)
533 stmt_ann_t ann = stmt_ann (stmt);
534 return ann ? ann->addresses_taken : NULL;
537 /* Return the PHI nodes for basic block BB, or NULL if there are no
538 PHI nodes. */
539 static inline tree
540 phi_nodes (basic_block bb)
542 return bb->phi_nodes;
545 /* Set list of phi nodes of a basic block BB to L. */
547 static inline void
548 set_phi_nodes (basic_block bb, tree l)
550 tree phi;
552 bb->phi_nodes = l;
553 for (phi = l; phi; phi = PHI_CHAIN (phi))
554 set_bb_for_stmt (phi, bb);
557 /* Return the phi argument which contains the specified use. */
559 static inline int
560 phi_arg_index_from_use (use_operand_p use)
562 struct phi_arg_d *element, *root;
563 int index;
564 tree phi;
566 /* Since the use is the first thing in a PHI argument element, we can
567 calculate its index based on casting it to an argument, and performing
568 pointer arithmetic. */
570 phi = USE_STMT (use);
571 gcc_assert (TREE_CODE (phi) == PHI_NODE);
573 element = (struct phi_arg_d *)use;
574 root = &(PHI_ARG_ELT (phi, 0));
575 index = element - root;
577 #ifdef ENABLE_CHECKING
578 /* Make sure the calculation doesn't have any leftover bytes. If it does,
579 then imm_use is likely not the first element in phi_arg_d. */
580 gcc_assert (
581 (((char *)element - (char *)root) % sizeof (struct phi_arg_d)) == 0);
582 gcc_assert (index >= 0 && index < PHI_ARG_CAPACITY (phi));
583 #endif
585 return index;
588 /* Mark VAR as used, so that it'll be preserved during rtl expansion. */
590 static inline void
591 set_is_used (tree var)
593 var_ann_t ann = get_var_ann (var);
594 ann->used = 1;
598 /* ----------------------------------------------------------------------- */
600 /* Return true if T is an executable statement. */
601 static inline bool
602 is_exec_stmt (tree t)
604 return (t && !IS_EMPTY_STMT (t) && t != error_mark_node);
608 /* Return true if this stmt can be the target of a control transfer stmt such
609 as a goto. */
610 static inline bool
611 is_label_stmt (tree t)
613 if (t)
614 switch (TREE_CODE (t))
616 case LABEL_DECL:
617 case LABEL_EXPR:
618 case CASE_LABEL_EXPR:
619 return true;
620 default:
621 return false;
623 return false;
626 /* PHI nodes should contain only ssa_names and invariants. A test
627 for ssa_name is definitely simpler; don't let invalid contents
628 slip in in the meantime. */
630 static inline bool
631 phi_ssa_name_p (tree t)
633 if (TREE_CODE (t) == SSA_NAME)
634 return true;
635 #ifdef ENABLE_CHECKING
636 gcc_assert (is_gimple_min_invariant (t));
637 #endif
638 return false;
641 /* ----------------------------------------------------------------------- */
643 /* Return a block_stmt_iterator that points to beginning of basic
644 block BB. */
645 static inline block_stmt_iterator
646 bsi_start (basic_block bb)
648 block_stmt_iterator bsi;
649 if (bb->stmt_list)
650 bsi.tsi = tsi_start (bb->stmt_list);
651 else
653 gcc_assert (bb->index < NUM_FIXED_BLOCKS);
654 bsi.tsi.ptr = NULL;
655 bsi.tsi.container = NULL;
657 bsi.bb = bb;
658 return bsi;
661 /* Return a block statement iterator that points to the first non-label
662 statement in block BB. */
664 static inline block_stmt_iterator
665 bsi_after_labels (basic_block bb)
667 block_stmt_iterator bsi = bsi_start (bb);
669 while (!bsi_end_p (bsi) && TREE_CODE (bsi_stmt (bsi)) == LABEL_EXPR)
670 bsi_next (&bsi);
672 return bsi;
675 /* Return a block statement iterator that points to the end of basic
676 block BB. */
677 static inline block_stmt_iterator
678 bsi_last (basic_block bb)
680 block_stmt_iterator bsi;
681 if (bb->stmt_list)
682 bsi.tsi = tsi_last (bb->stmt_list);
683 else
685 gcc_assert (bb->index < NUM_FIXED_BLOCKS);
686 bsi.tsi.ptr = NULL;
687 bsi.tsi.container = NULL;
689 bsi.bb = bb;
690 return bsi;
693 /* Return true if block statement iterator I has reached the end of
694 the basic block. */
695 static inline bool
696 bsi_end_p (block_stmt_iterator i)
698 return tsi_end_p (i.tsi);
701 /* Modify block statement iterator I so that it is at the next
702 statement in the basic block. */
703 static inline void
704 bsi_next (block_stmt_iterator *i)
706 tsi_next (&i->tsi);
709 /* Modify block statement iterator I so that it is at the previous
710 statement in the basic block. */
711 static inline void
712 bsi_prev (block_stmt_iterator *i)
714 tsi_prev (&i->tsi);
717 /* Return the statement that block statement iterator I is currently
718 at. */
719 static inline tree
720 bsi_stmt (block_stmt_iterator i)
722 return tsi_stmt (i.tsi);
725 /* Return a pointer to the statement that block statement iterator I
726 is currently at. */
727 static inline tree *
728 bsi_stmt_ptr (block_stmt_iterator i)
730 return tsi_stmt_ptr (i.tsi);
733 /* Returns the loop of the statement STMT. */
735 static inline struct loop *
736 loop_containing_stmt (tree stmt)
738 basic_block bb = bb_for_stmt (stmt);
739 if (!bb)
740 return NULL;
742 return bb->loop_father;
745 /* Return true if VAR is a clobbered by function calls. */
746 static inline bool
747 is_call_clobbered (tree var)
749 if (!MTAG_P (var))
750 return DECL_CALL_CLOBBERED (var);
751 else
752 return bitmap_bit_p (call_clobbered_vars, DECL_UID (var));
755 /* Mark variable VAR as being clobbered by function calls. */
756 static inline void
757 mark_call_clobbered (tree var, unsigned int escape_type)
759 var_ann (var)->escape_mask |= escape_type;
760 if (!MTAG_P (var))
761 DECL_CALL_CLOBBERED (var) = true;
762 bitmap_set_bit (call_clobbered_vars, DECL_UID (var));
765 /* Clear the call-clobbered attribute from variable VAR. */
766 static inline void
767 clear_call_clobbered (tree var)
769 var_ann_t ann = var_ann (var);
770 ann->escape_mask = 0;
771 if (MTAG_P (var) && TREE_CODE (var) != STRUCT_FIELD_TAG)
772 MTAG_GLOBAL (var) = 0;
773 if (!MTAG_P (var))
774 DECL_CALL_CLOBBERED (var) = false;
775 bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
778 /* Mark variable VAR as being non-addressable. */
779 static inline void
780 mark_non_addressable (tree var)
782 if (!MTAG_P (var))
783 DECL_CALL_CLOBBERED (var) = false;
784 bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
785 TREE_ADDRESSABLE (var) = 0;
788 /* Return the common annotation for T. Return NULL if the annotation
789 doesn't already exist. */
790 static inline tree_ann_common_t
791 tree_common_ann (tree t)
793 return &t->common.ann->common;
796 /* Return a common annotation for T. Create the constant annotation if it
797 doesn't exist. */
798 static inline tree_ann_common_t
799 get_tree_common_ann (tree t)
801 tree_ann_common_t ann = tree_common_ann (t);
802 return (ann) ? ann : create_tree_common_ann (t);
805 /* ----------------------------------------------------------------------- */
807 /* The following set of routines are used to iterator over various type of
808 SSA operands. */
810 /* Return true if PTR is finished iterating. */
811 static inline bool
812 op_iter_done (ssa_op_iter *ptr)
814 return ptr->done;
817 /* Get the next iterator use value for PTR. */
818 static inline use_operand_p
819 op_iter_next_use (ssa_op_iter *ptr)
821 use_operand_p use_p;
822 #ifdef ENABLE_CHECKING
823 gcc_assert (ptr->iter_type == ssa_op_iter_use);
824 #endif
825 if (ptr->uses)
827 use_p = USE_OP_PTR (ptr->uses);
828 ptr->uses = ptr->uses->next;
829 return use_p;
831 if (ptr->vuses)
833 use_p = VUSE_OP_PTR (ptr->vuses);
834 ptr->vuses = ptr->vuses->next;
835 return use_p;
837 if (ptr->mayuses)
839 use_p = MAYDEF_OP_PTR (ptr->mayuses);
840 ptr->mayuses = ptr->mayuses->next;
841 return use_p;
843 if (ptr->mustkills)
845 use_p = MUSTDEF_KILL_PTR (ptr->mustkills);
846 ptr->mustkills = ptr->mustkills->next;
847 return use_p;
849 if (ptr->phi_i < ptr->num_phi)
851 return PHI_ARG_DEF_PTR (ptr->phi_stmt, (ptr->phi_i)++);
853 ptr->done = true;
854 return NULL_USE_OPERAND_P;
857 /* Get the next iterator def value for PTR. */
858 static inline def_operand_p
859 op_iter_next_def (ssa_op_iter *ptr)
861 def_operand_p def_p;
862 #ifdef ENABLE_CHECKING
863 gcc_assert (ptr->iter_type == ssa_op_iter_def);
864 #endif
865 if (ptr->defs)
867 def_p = DEF_OP_PTR (ptr->defs);
868 ptr->defs = ptr->defs->next;
869 return def_p;
871 if (ptr->mustdefs)
873 def_p = MUSTDEF_RESULT_PTR (ptr->mustdefs);
874 ptr->mustdefs = ptr->mustdefs->next;
875 return def_p;
877 if (ptr->maydefs)
879 def_p = MAYDEF_RESULT_PTR (ptr->maydefs);
880 ptr->maydefs = ptr->maydefs->next;
881 return def_p;
883 ptr->done = true;
884 return NULL_DEF_OPERAND_P;
887 /* Get the next iterator tree value for PTR. */
888 static inline tree
889 op_iter_next_tree (ssa_op_iter *ptr)
891 tree val;
892 #ifdef ENABLE_CHECKING
893 gcc_assert (ptr->iter_type == ssa_op_iter_tree);
894 #endif
895 if (ptr->uses)
897 val = USE_OP (ptr->uses);
898 ptr->uses = ptr->uses->next;
899 return val;
901 if (ptr->vuses)
903 val = VUSE_OP (ptr->vuses);
904 ptr->vuses = ptr->vuses->next;
905 return val;
907 if (ptr->mayuses)
909 val = MAYDEF_OP (ptr->mayuses);
910 ptr->mayuses = ptr->mayuses->next;
911 return val;
913 if (ptr->mustkills)
915 val = MUSTDEF_KILL (ptr->mustkills);
916 ptr->mustkills = ptr->mustkills->next;
917 return val;
919 if (ptr->defs)
921 val = DEF_OP (ptr->defs);
922 ptr->defs = ptr->defs->next;
923 return val;
925 if (ptr->mustdefs)
927 val = MUSTDEF_RESULT (ptr->mustdefs);
928 ptr->mustdefs = ptr->mustdefs->next;
929 return val;
931 if (ptr->maydefs)
933 val = MAYDEF_RESULT (ptr->maydefs);
934 ptr->maydefs = ptr->maydefs->next;
935 return val;
938 ptr->done = true;
939 return NULL_TREE;
944 /* This functions clears the iterator PTR, and marks it done. This is normally
945 used to prevent warnings in the compile about might be uninitialized
946 components. */
948 static inline void
949 clear_and_done_ssa_iter (ssa_op_iter *ptr)
951 ptr->defs = NULL;
952 ptr->uses = NULL;
953 ptr->vuses = NULL;
954 ptr->maydefs = NULL;
955 ptr->mayuses = NULL;
956 ptr->mustdefs = NULL;
957 ptr->mustkills = NULL;
958 ptr->iter_type = ssa_op_iter_none;
959 ptr->phi_i = 0;
960 ptr->num_phi = 0;
961 ptr->phi_stmt = NULL_TREE;
962 ptr->done = true;
965 /* Initialize the iterator PTR to the virtual defs in STMT. */
966 static inline void
967 op_iter_init (ssa_op_iter *ptr, tree stmt, int flags)
969 #ifdef ENABLE_CHECKING
970 gcc_assert (stmt_ann (stmt));
971 #endif
973 ptr->defs = (flags & SSA_OP_DEF) ? DEF_OPS (stmt) : NULL;
974 ptr->uses = (flags & SSA_OP_USE) ? USE_OPS (stmt) : NULL;
975 ptr->vuses = (flags & SSA_OP_VUSE) ? VUSE_OPS (stmt) : NULL;
976 ptr->maydefs = (flags & SSA_OP_VMAYDEF) ? MAYDEF_OPS (stmt) : NULL;
977 ptr->mayuses = (flags & SSA_OP_VMAYUSE) ? MAYDEF_OPS (stmt) : NULL;
978 ptr->mustdefs = (flags & SSA_OP_VMUSTDEF) ? MUSTDEF_OPS (stmt) : NULL;
979 ptr->mustkills = (flags & SSA_OP_VMUSTKILL) ? MUSTDEF_OPS (stmt) : NULL;
980 ptr->done = false;
982 ptr->phi_i = 0;
983 ptr->num_phi = 0;
984 ptr->phi_stmt = NULL_TREE;
987 /* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return
988 the first use. */
989 static inline use_operand_p
990 op_iter_init_use (ssa_op_iter *ptr, tree stmt, int flags)
992 gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0);
993 op_iter_init (ptr, stmt, flags);
994 ptr->iter_type = ssa_op_iter_use;
995 return op_iter_next_use (ptr);
998 /* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return
999 the first def. */
1000 static inline def_operand_p
1001 op_iter_init_def (ssa_op_iter *ptr, tree stmt, int flags)
1003 gcc_assert ((flags & (SSA_OP_ALL_USES | SSA_OP_VIRTUAL_KILLS)) == 0);
1004 op_iter_init (ptr, stmt, flags);
1005 ptr->iter_type = ssa_op_iter_def;
1006 return op_iter_next_def (ptr);
1009 /* Initialize iterator PTR to the operands in STMT based on FLAGS. Return
1010 the first operand as a tree. */
1011 static inline tree
1012 op_iter_init_tree (ssa_op_iter *ptr, tree stmt, int flags)
1014 op_iter_init (ptr, stmt, flags);
1015 ptr->iter_type = ssa_op_iter_tree;
1016 return op_iter_next_tree (ptr);
1019 /* Get the next iterator mustdef value for PTR, returning the mustdef values in
1020 KILL and DEF. */
1021 static inline void
1022 op_iter_next_maymustdef (use_operand_p *use, def_operand_p *def,
1023 ssa_op_iter *ptr)
1025 #ifdef ENABLE_CHECKING
1026 gcc_assert (ptr->iter_type == ssa_op_iter_maymustdef);
1027 #endif
1028 if (ptr->mayuses)
1030 *def = MAYDEF_RESULT_PTR (ptr->mayuses);
1031 *use = MAYDEF_OP_PTR (ptr->mayuses);
1032 ptr->mayuses = ptr->mayuses->next;
1033 return;
1036 if (ptr->mustkills)
1038 *def = MUSTDEF_RESULT_PTR (ptr->mustkills);
1039 *use = MUSTDEF_KILL_PTR (ptr->mustkills);
1040 ptr->mustkills = ptr->mustkills->next;
1041 return;
1044 *def = NULL_DEF_OPERAND_P;
1045 *use = NULL_USE_OPERAND_P;
1046 ptr->done = true;
1047 return;
1051 /* Initialize iterator PTR to the operands in STMT. Return the first operands
1052 in USE and DEF. */
1053 static inline void
1054 op_iter_init_maydef (ssa_op_iter *ptr, tree stmt, use_operand_p *use,
1055 def_operand_p *def)
1057 gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1059 op_iter_init (ptr, stmt, SSA_OP_VMAYUSE);
1060 ptr->iter_type = ssa_op_iter_maymustdef;
1061 op_iter_next_maymustdef (use, def, ptr);
1065 /* Initialize iterator PTR to the operands in STMT. Return the first operands
1066 in KILL and DEF. */
1067 static inline void
1068 op_iter_init_mustdef (ssa_op_iter *ptr, tree stmt, use_operand_p *kill,
1069 def_operand_p *def)
1071 gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1073 op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL);
1074 ptr->iter_type = ssa_op_iter_maymustdef;
1075 op_iter_next_maymustdef (kill, def, ptr);
1078 /* Initialize iterator PTR to the operands in STMT. Return the first operands
1079 in KILL and DEF. */
1080 static inline void
1081 op_iter_init_must_and_may_def (ssa_op_iter *ptr, tree stmt,
1082 use_operand_p *kill, def_operand_p *def)
1084 gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1086 op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL|SSA_OP_VMAYUSE);
1087 ptr->iter_type = ssa_op_iter_maymustdef;
1088 op_iter_next_maymustdef (kill, def, ptr);
1092 /* If there is a single operand in STMT matching FLAGS, return it. Otherwise
1093 return NULL. */
1094 static inline tree
1095 single_ssa_tree_operand (tree stmt, int flags)
1097 tree var;
1098 ssa_op_iter iter;
1100 var = op_iter_init_tree (&iter, stmt, flags);
1101 if (op_iter_done (&iter))
1102 return NULL_TREE;
1103 op_iter_next_tree (&iter);
1104 if (op_iter_done (&iter))
1105 return var;
1106 return NULL_TREE;
1110 /* If there is a single operand in STMT matching FLAGS, return it. Otherwise
1111 return NULL. */
1112 static inline use_operand_p
1113 single_ssa_use_operand (tree stmt, int flags)
1115 use_operand_p var;
1116 ssa_op_iter iter;
1118 var = op_iter_init_use (&iter, stmt, flags);
1119 if (op_iter_done (&iter))
1120 return NULL_USE_OPERAND_P;
1121 op_iter_next_use (&iter);
1122 if (op_iter_done (&iter))
1123 return var;
1124 return NULL_USE_OPERAND_P;
1129 /* If there is a single operand in STMT matching FLAGS, return it. Otherwise
1130 return NULL. */
1131 static inline def_operand_p
1132 single_ssa_def_operand (tree stmt, int flags)
1134 def_operand_p var;
1135 ssa_op_iter iter;
1137 var = op_iter_init_def (&iter, stmt, flags);
1138 if (op_iter_done (&iter))
1139 return NULL_DEF_OPERAND_P;
1140 op_iter_next_def (&iter);
1141 if (op_iter_done (&iter))
1142 return var;
1143 return NULL_DEF_OPERAND_P;
1147 /* If there is a single operand in STMT matching FLAGS, return it. Otherwise
1148 return NULL. */
1149 static inline bool
1150 zero_ssa_operands (tree stmt, int flags)
1152 ssa_op_iter iter;
1154 op_iter_init_tree (&iter, stmt, flags);
1155 return op_iter_done (&iter);
1159 /* Return the number of operands matching FLAGS in STMT. */
1160 static inline int
1161 num_ssa_operands (tree stmt, int flags)
1163 ssa_op_iter iter;
1164 tree t;
1165 int num = 0;
1167 FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
1168 num++;
1169 return num;
1173 /* Delink all immediate_use information for STMT. */
1174 static inline void
1175 delink_stmt_imm_use (tree stmt)
1177 ssa_op_iter iter;
1178 use_operand_p use_p;
1180 if (ssa_operands_active ())
1181 FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
1182 (SSA_OP_ALL_USES | SSA_OP_ALL_KILLS))
1183 delink_imm_use (use_p);
1187 /* This routine will compare all the operands matching FLAGS in STMT1 to those
1188 in STMT2. TRUE is returned if they are the same. STMTs can be NULL. */
1189 static inline bool
1190 compare_ssa_operands_equal (tree stmt1, tree stmt2, int flags)
1192 ssa_op_iter iter1, iter2;
1193 tree op1 = NULL_TREE;
1194 tree op2 = NULL_TREE;
1195 bool look1, look2;
1197 if (stmt1 == stmt2)
1198 return true;
1200 look1 = stmt1 && stmt_ann (stmt1);
1201 look2 = stmt2 && stmt_ann (stmt2);
1203 if (look1)
1205 op1 = op_iter_init_tree (&iter1, stmt1, flags);
1206 if (!look2)
1207 return op_iter_done (&iter1);
1209 else
1210 clear_and_done_ssa_iter (&iter1);
1212 if (look2)
1214 op2 = op_iter_init_tree (&iter2, stmt2, flags);
1215 if (!look1)
1216 return op_iter_done (&iter2);
1218 else
1219 clear_and_done_ssa_iter (&iter2);
1221 while (!op_iter_done (&iter1) && !op_iter_done (&iter2))
1223 if (op1 != op2)
1224 return false;
1225 op1 = op_iter_next_tree (&iter1);
1226 op2 = op_iter_next_tree (&iter2);
1229 return (op_iter_done (&iter1) && op_iter_done (&iter2));
1233 /* If there is a single DEF in the PHI node which matches FLAG, return it.
1234 Otherwise return NULL_DEF_OPERAND_P. */
1235 static inline tree
1236 single_phi_def (tree stmt, int flags)
1238 tree def = PHI_RESULT (stmt);
1239 if ((flags & SSA_OP_DEF) && is_gimple_reg (def))
1240 return def;
1241 if ((flags & SSA_OP_VIRTUAL_DEFS) && !is_gimple_reg (def))
1242 return def;
1243 return NULL_TREE;
1246 /* Initialize the iterator PTR for uses matching FLAGS in PHI. FLAGS should
1247 be either SSA_OP_USES or SSA_OP_VIRTUAL_USES. */
1248 static inline use_operand_p
1249 op_iter_init_phiuse (ssa_op_iter *ptr, tree phi, int flags)
1251 tree phi_def = PHI_RESULT (phi);
1252 int comp;
1254 clear_and_done_ssa_iter (ptr);
1255 ptr->done = false;
1257 gcc_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
1259 comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1261 /* If the PHI node doesn't the operand type we care about, we're done. */
1262 if ((flags & comp) == 0)
1264 ptr->done = true;
1265 return NULL_USE_OPERAND_P;
1268 ptr->phi_stmt = phi;
1269 ptr->num_phi = PHI_NUM_ARGS (phi);
1270 ptr->iter_type = ssa_op_iter_use;
1271 return op_iter_next_use (ptr);
1275 /* Start an iterator for a PHI definition. */
1277 static inline def_operand_p
1278 op_iter_init_phidef (ssa_op_iter *ptr, tree phi, int flags)
1280 tree phi_def = PHI_RESULT (phi);
1281 int comp;
1283 clear_and_done_ssa_iter (ptr);
1284 ptr->done = false;
1286 gcc_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
1288 comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS);
1290 /* If the PHI node doesn't the operand type we care about, we're done. */
1291 if ((flags & comp) == 0)
1293 ptr->done = true;
1294 return NULL_USE_OPERAND_P;
1297 ptr->iter_type = ssa_op_iter_def;
1298 /* The first call to op_iter_next_def will terminate the iterator since
1299 all the fields are NULL. Simply return the result here as the first and
1300 therefore only result. */
1301 return PHI_RESULT_PTR (phi);
1304 /* Return true is IMM has reached the end of the immediate use stmt list. */
1306 static inline bool
1307 end_imm_use_stmt_p (imm_use_iterator *imm)
1309 return (imm->imm_use == imm->end_p);
1312 /* Finished the traverse of an immediate use stmt list IMM by removing the
1313 placeholder node from the list. */
1315 static inline void
1316 end_imm_use_stmt_traverse (imm_use_iterator *imm)
1318 delink_imm_use (&(imm->iter_node));
1321 /* Immediate use traversal of uses within a stmt require that all the
1322 uses on a stmt be sequentially listed. This routine is used to build up
1323 this sequential list by adding USE_P to the end of the current list
1324 currently delimited by HEAD and LAST_P. The new LAST_P value is
1325 returned. */
1327 static inline use_operand_p
1328 move_use_after_head (use_operand_p use_p, use_operand_p head,
1329 use_operand_p last_p)
1331 gcc_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
1332 /* Skip head when we find it. */
1333 if (use_p != head)
1335 /* If use_p is already linked in after last_p, continue. */
1336 if (last_p->next == use_p)
1337 last_p = use_p;
1338 else
1340 /* Delink from current location, and link in at last_p. */
1341 delink_imm_use (use_p);
1342 link_imm_use_to_list (use_p, last_p);
1343 last_p = use_p;
1346 return last_p;
1350 /* This routine will relink all uses with the same stmt as HEAD into the list
1351 immediately following HEAD for iterator IMM. */
1353 static inline void
1354 link_use_stmts_after (use_operand_p head, imm_use_iterator *imm)
1356 use_operand_p use_p;
1357 use_operand_p last_p = head;
1358 tree head_stmt = USE_STMT (head);
1359 tree use = USE_FROM_PTR (head);
1360 ssa_op_iter op_iter;
1361 int flag;
1363 /* Only look at virtual or real uses, depending on the type of HEAD. */
1364 flag = (is_gimple_reg (use) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1366 if (TREE_CODE (head_stmt) == PHI_NODE)
1368 FOR_EACH_PHI_ARG (use_p, head_stmt, op_iter, flag)
1369 if (USE_FROM_PTR (use_p) == use)
1370 last_p = move_use_after_head (use_p, head, last_p);
1372 else
1374 FOR_EACH_SSA_USE_OPERAND (use_p, head_stmt, op_iter, flag)
1375 if (USE_FROM_PTR (use_p) == use)
1376 last_p = move_use_after_head (use_p, head, last_p);
1378 /* LInk iter node in after last_p. */
1379 if (imm->iter_node.prev != NULL)
1380 delink_imm_use (&imm->iter_node);
1381 link_imm_use_to_list (&(imm->iter_node), last_p);
1384 /* Initialize IMM to traverse over uses of VAR. Return the first statement. */
1385 static inline tree
1386 first_imm_use_stmt (imm_use_iterator *imm, tree var)
1388 gcc_assert (TREE_CODE (var) == SSA_NAME);
1390 imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
1391 imm->imm_use = imm->end_p->next;
1392 imm->next_imm_name = NULL_USE_OPERAND_P;
1394 /* iter_node is used as a marker within the immediate use list to indicate
1395 where the end of the current stmt's uses are. Initialize it to NULL
1396 stmt and use, which indicates a marker node. */
1397 imm->iter_node.prev = NULL_USE_OPERAND_P;
1398 imm->iter_node.next = NULL_USE_OPERAND_P;
1399 imm->iter_node.stmt = NULL_TREE;
1400 imm->iter_node.use = NULL_USE_OPERAND_P;
1402 if (end_imm_use_stmt_p (imm))
1403 return NULL_TREE;
1405 link_use_stmts_after (imm->imm_use, imm);
1407 return USE_STMT (imm->imm_use);
1410 /* Bump IMM to the next stmt which has a use of var. */
1412 static inline tree
1413 next_imm_use_stmt (imm_use_iterator *imm)
1415 imm->imm_use = imm->iter_node.next;
1416 if (end_imm_use_stmt_p (imm))
1418 if (imm->iter_node.prev != NULL)
1419 delink_imm_use (&imm->iter_node);
1420 return NULL_TREE;
1423 link_use_stmts_after (imm->imm_use, imm);
1424 return USE_STMT (imm->imm_use);
1428 /* This routine will return the first use on the stmt IMM currently refers
1429 to. */
1431 static inline use_operand_p
1432 first_imm_use_on_stmt (imm_use_iterator *imm)
1434 imm->next_imm_name = imm->imm_use->next;
1435 return imm->imm_use;
1438 /* Return TRUE if the last use on the stmt IMM refers to has been visited. */
1440 static inline bool
1441 end_imm_use_on_stmt_p (imm_use_iterator *imm)
1443 return (imm->imm_use == &(imm->iter_node));
1446 /* Bump to the next use on the stmt IMM refers to, return NULL if done. */
1448 static inline use_operand_p
1449 next_imm_use_on_stmt (imm_use_iterator *imm)
1451 imm->imm_use = imm->next_imm_name;
1452 if (end_imm_use_on_stmt_p (imm))
1453 return NULL_USE_OPERAND_P;
1454 else
1456 imm->next_imm_name = imm->imm_use->next;
1457 return imm->imm_use;
1461 /* Return true if VAR cannot be modified by the program. */
1463 static inline bool
1464 unmodifiable_var_p (tree var)
1466 if (TREE_CODE (var) == SSA_NAME)
1467 var = SSA_NAME_VAR (var);
1469 if (MTAG_P (var))
1470 return TREE_READONLY (var) && (TREE_STATIC (var) || MTAG_GLOBAL (var));
1472 return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
1475 /* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it. */
1477 static inline bool
1478 array_ref_contains_indirect_ref (tree ref)
1480 gcc_assert (TREE_CODE (ref) == ARRAY_REF);
1482 do {
1483 ref = TREE_OPERAND (ref, 0);
1484 } while (handled_component_p (ref));
1486 return TREE_CODE (ref) == INDIRECT_REF;
1489 /* Return true if REF, a handled component reference, has an ARRAY_REF
1490 somewhere in it. */
1492 static inline bool
1493 ref_contains_array_ref (tree ref)
1495 gcc_assert (handled_component_p (ref));
1497 do {
1498 if (TREE_CODE (ref) == ARRAY_REF)
1499 return true;
1500 ref = TREE_OPERAND (ref, 0);
1501 } while (handled_component_p (ref));
1503 return false;
1506 /* Given a variable VAR, lookup and return a pointer to the list of
1507 subvariables for it. */
1509 static inline subvar_t *
1510 lookup_subvars_for_var (tree var)
1512 var_ann_t ann = var_ann (var);
1513 gcc_assert (ann);
1514 return &ann->subvars;
1517 /* Given a variable VAR, return a linked list of subvariables for VAR, or
1518 NULL, if there are no subvariables. */
1520 static inline subvar_t
1521 get_subvars_for_var (tree var)
1523 subvar_t subvars;
1525 gcc_assert (SSA_VAR_P (var));
1527 if (TREE_CODE (var) == SSA_NAME)
1528 subvars = *(lookup_subvars_for_var (SSA_NAME_VAR (var)));
1529 else
1530 subvars = *(lookup_subvars_for_var (var));
1531 return subvars;
1534 /* Return the subvariable of VAR at offset OFFSET. */
1536 static inline tree
1537 get_subvar_at (tree var, unsigned HOST_WIDE_INT offset)
1539 subvar_t sv;
1541 for (sv = get_subvars_for_var (var); sv; sv = sv->next)
1542 if (SFT_OFFSET (sv->var) == offset)
1543 return sv->var;
1545 return NULL_TREE;
1548 /* Return true if V is a tree that we can have subvars for.
1549 Normally, this is any aggregate type. Also complex
1550 types which are not gimple registers can have subvars. */
1552 static inline bool
1553 var_can_have_subvars (tree v)
1555 /* Volatile variables should never have subvars. */
1556 if (TREE_THIS_VOLATILE (v))
1557 return false;
1559 /* Non decls or memory tags can never have subvars. */
1560 if (!DECL_P (v) || MTAG_P (v))
1561 return false;
1563 /* Aggregates can have subvars. */
1564 if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
1565 return true;
1567 /* Complex types variables which are not also a gimple register can
1568 have subvars. */
1569 if (TREE_CODE (TREE_TYPE (v)) == COMPLEX_TYPE
1570 && !DECL_COMPLEX_GIMPLE_REG_P (v))
1571 return true;
1573 return false;
1577 /* Return true if OFFSET and SIZE define a range that overlaps with some
1578 portion of the range of SV, a subvar. If there was an exact overlap,
1579 *EXACT will be set to true upon return. */
1581 static inline bool
1582 overlap_subvar (unsigned HOST_WIDE_INT offset, unsigned HOST_WIDE_INT size,
1583 tree sv, bool *exact)
1585 /* There are three possible cases of overlap.
1586 1. We can have an exact overlap, like so:
1587 |offset, offset + size |
1588 |sv->offset, sv->offset + sv->size |
1590 2. We can have offset starting after sv->offset, like so:
1592 |offset, offset + size |
1593 |sv->offset, sv->offset + sv->size |
1595 3. We can have offset starting before sv->offset, like so:
1597 |offset, offset + size |
1598 |sv->offset, sv->offset + sv->size|
1601 if (exact)
1602 *exact = false;
1603 if (offset == SFT_OFFSET (sv) && size == SFT_SIZE (sv))
1605 if (exact)
1606 *exact = true;
1607 return true;
1609 else if (offset >= SFT_OFFSET (sv)
1610 && offset < (SFT_OFFSET (sv) + SFT_SIZE (sv)))
1612 return true;
1614 else if (offset < SFT_OFFSET (sv)
1615 && (size > SFT_OFFSET (sv) - offset))
1617 return true;
1619 return false;
1623 #endif /* _TREE_FLOW_INLINE_H */