comparison gcc/tree-flow-inline.h @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
46 46
47 /* Artificial variable used for the virtual operand FUD chain. */ 47 /* Artificial variable used for the virtual operand FUD chain. */
48 static inline tree 48 static inline tree
49 gimple_vop (const struct function *fun) 49 gimple_vop (const struct function *fun)
50 { 50 {
51 gcc_assert (fun && fun->gimple_df); 51 gcc_checking_assert (fun && fun->gimple_df);
52 return fun->gimple_df->vop; 52 return fun->gimple_df->vop;
53 } 53 }
54 54
55 /* Initialize the hashtable iterator HTI to point to hashtable TABLE */ 55 /* Initialize the hashtable iterator HTI to point to hashtable TABLE */
56 56
96 return x; 96 return x;
97 }; 97 };
98 return NULL; 98 return NULL;
99 } 99 }
100 100
101 /* Get the variable with uid UID from the list of referenced vars. */
102
103 static inline tree
104 referenced_var (unsigned int uid)
105 {
106 tree var = referenced_var_lookup (cfun, uid);
107 gcc_assert (var || uid == 0);
108 return var;
109 }
110
101 /* Initialize ITER to point to the first referenced variable in the 111 /* Initialize ITER to point to the first referenced variable in the
102 referenced_vars hashtable, and return that variable. */ 112 referenced_vars hashtable, and return that variable. */
103 113
104 static inline tree 114 static inline tree
105 first_referenced_var (referenced_var_iterator *iter) 115 first_referenced_var (struct function *fn, referenced_var_iterator *iter)
106 { 116 {
107 return (tree) first_htab_element (&iter->hti, 117 return (tree) first_htab_element (&iter->hti,
108 gimple_referenced_vars (cfun)); 118 gimple_referenced_vars (fn));
109 } 119 }
110 120
111 /* Return true if we have hit the end of the referenced variables ITER is 121 /* Return true if we have hit the end of the referenced variables ITER is
112 iterating through. */ 122 iterating through. */
113 123
139 Create the variable annotation if it doesn't exist. */ 149 Create the variable annotation if it doesn't exist. */
140 static inline var_ann_t 150 static inline var_ann_t
141 get_var_ann (tree var) 151 get_var_ann (tree var)
142 { 152 {
143 var_ann_t *p = DECL_VAR_ANN_PTR (var); 153 var_ann_t *p = DECL_VAR_ANN_PTR (var);
144 gcc_assert (p); 154 gcc_checking_assert (p);
145 return *p ? *p : create_var_ann (var); 155 return *p ? *p : create_var_ann (var);
146 } 156 }
147 157
148 /* Get the number of the next statement uid to be allocated. */ 158 /* Get the number of the next statement uid to be allocated. */
149 static inline unsigned int 159 static inline unsigned int
218 if (!def || TREE_CODE (def) != SSA_NAME) 228 if (!def || TREE_CODE (def) != SSA_NAME)
219 linknode->prev = NULL; 229 linknode->prev = NULL;
220 else 230 else
221 { 231 {
222 root = &(SSA_NAME_IMM_USE_NODE (def)); 232 root = &(SSA_NAME_IMM_USE_NODE (def));
223 #ifdef ENABLE_CHECKING
224 if (linknode->use) 233 if (linknode->use)
225 gcc_assert (*(linknode->use) == def); 234 gcc_checking_assert (*(linknode->use) == def);
226 #endif
227 link_imm_use_to_list (linknode, root); 235 link_imm_use_to_list (linknode, root);
228 } 236 }
229 } 237 }
230 238
231 /* Set the value of a use pointed to by USE to VAL. */ 239 /* Set the value of a use pointed to by USE to VAL. */
252 /* Relink a new node in place of an old node in the list. */ 260 /* Relink a new node in place of an old node in the list. */
253 static inline void 261 static inline void
254 relink_imm_use (ssa_use_operand_t *node, ssa_use_operand_t *old) 262 relink_imm_use (ssa_use_operand_t *node, ssa_use_operand_t *old)
255 { 263 {
256 /* The node one had better be in the same list. */ 264 /* The node one had better be in the same list. */
257 gcc_assert (*(old->use) == *(node->use)); 265 gcc_checking_assert (*(old->use) == *(node->use));
258 node->prev = old->prev; 266 node->prev = old->prev;
259 node->next = old->next; 267 node->next = old->next;
260 if (old->prev) 268 if (old->prev)
261 { 269 {
262 old->prev->next = node; 270 old->prev->next = node;
505 /* Return the PHI nodes for basic block BB, or NULL if there are no 513 /* Return the PHI nodes for basic block BB, or NULL if there are no
506 PHI nodes. */ 514 PHI nodes. */
507 static inline gimple_seq 515 static inline gimple_seq
508 phi_nodes (const_basic_block bb) 516 phi_nodes (const_basic_block bb)
509 { 517 {
510 gcc_assert (!(bb->flags & BB_RTL)); 518 gcc_checking_assert (!(bb->flags & BB_RTL));
511 if (!bb->il.gimple) 519 if (!bb->il.gimple)
512 return NULL; 520 return NULL;
513 return bb->il.gimple->phi_nodes; 521 return bb->il.gimple->phi_nodes;
514 } 522 }
515 523
518 static inline void 526 static inline void
519 set_phi_nodes (basic_block bb, gimple_seq seq) 527 set_phi_nodes (basic_block bb, gimple_seq seq)
520 { 528 {
521 gimple_stmt_iterator i; 529 gimple_stmt_iterator i;
522 530
523 gcc_assert (!(bb->flags & BB_RTL)); 531 gcc_checking_assert (!(bb->flags & BB_RTL));
524 bb->il.gimple->phi_nodes = seq; 532 bb->il.gimple->phi_nodes = seq;
525 if (seq) 533 if (seq)
526 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) 534 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
527 gimple_set_bb (gsi_stmt (i), bb); 535 gimple_set_bb (gsi_stmt (i), bb);
528 } 536 }
539 /* Since the use is the first thing in a PHI argument element, we can 547 /* Since the use is the first thing in a PHI argument element, we can
540 calculate its index based on casting it to an argument, and performing 548 calculate its index based on casting it to an argument, and performing
541 pointer arithmetic. */ 549 pointer arithmetic. */
542 550
543 phi = USE_STMT (use); 551 phi = USE_STMT (use);
544 gcc_assert (gimple_code (phi) == GIMPLE_PHI);
545 552
546 element = (struct phi_arg_d *)use; 553 element = (struct phi_arg_d *)use;
547 root = gimple_phi_arg (phi, 0); 554 root = gimple_phi_arg (phi, 0);
548 index = element - root; 555 index = element - root;
549 556
550 #ifdef ENABLE_CHECKING
551 /* Make sure the calculation doesn't have any leftover bytes. If it does, 557 /* Make sure the calculation doesn't have any leftover bytes. If it does,
552 then imm_use is likely not the first element in phi_arg_d. */ 558 then imm_use is likely not the first element in phi_arg_d. */
553 gcc_assert ((((char *)element - (char *)root) 559 gcc_checking_assert ((((char *)element - (char *)root)
554 % sizeof (struct phi_arg_d)) == 0 560 % sizeof (struct phi_arg_d)) == 0
555 && index < gimple_phi_capacity (phi)); 561 && index < gimple_phi_capacity (phi));
556 #endif
557 562
558 return index; 563 return index;
559 } 564 }
560 565
561 /* Mark VAR as used, so that it'll be preserved during rtl expansion. */ 566 /* Mark VAR as used, so that it'll be preserved during rtl expansion. */
562 567
563 static inline void 568 static inline void
564 set_is_used (tree var) 569 set_is_used (tree var)
565 { 570 {
566 var_ann_t ann = get_var_ann (var); 571 var_ann_t ann = get_var_ann (var);
567 ann->used = 1; 572 ann->used = true;
568 } 573 }
569 574
575 /* Clear VAR's used flag. */
576
577 static inline void
578 clear_is_used (tree var)
579 {
580 var_ann_t ann = var_ann (var);
581 ann->used = false;
582 }
583
584 /* Return true if VAR is marked as used. */
585
586 static inline bool
587 is_used_p (tree var)
588 {
589 var_ann_t ann = var_ann (var);
590 return ann->used;
591 }
570 592
571 /* Return true if T (assumed to be a DECL) is a global variable. 593 /* Return true if T (assumed to be a DECL) is a global variable.
572 A variable is considered global if its storage is not automatic. */ 594 A variable is considered global if its storage is not automatic. */
573 595
574 static inline bool 596 static inline bool
602 static inline bool 624 static inline bool
603 phi_ssa_name_p (const_tree t) 625 phi_ssa_name_p (const_tree t)
604 { 626 {
605 if (TREE_CODE (t) == SSA_NAME) 627 if (TREE_CODE (t) == SSA_NAME)
606 return true; 628 return true;
607 #ifdef ENABLE_CHECKING 629 gcc_checking_assert (is_gimple_min_invariant (t));
608 gcc_assert (is_gimple_min_invariant (t));
609 #endif
610 return false; 630 return false;
611 } 631 }
612 632
613 633
614 /* Returns the loop of the statement STMT. */ 634 /* Returns the loop of the statement STMT. */
639 /* Get the next iterator use value for PTR. */ 659 /* Get the next iterator use value for PTR. */
640 static inline use_operand_p 660 static inline use_operand_p
641 op_iter_next_use (ssa_op_iter *ptr) 661 op_iter_next_use (ssa_op_iter *ptr)
642 { 662 {
643 use_operand_p use_p; 663 use_operand_p use_p;
644 #ifdef ENABLE_CHECKING 664 gcc_checking_assert (ptr->iter_type == ssa_op_iter_use);
645 gcc_assert (ptr->iter_type == ssa_op_iter_use);
646 #endif
647 if (ptr->uses) 665 if (ptr->uses)
648 { 666 {
649 use_p = USE_OP_PTR (ptr->uses); 667 use_p = USE_OP_PTR (ptr->uses);
650 ptr->uses = ptr->uses->next; 668 ptr->uses = ptr->uses->next;
651 return use_p; 669 return use_p;
661 /* Get the next iterator def value for PTR. */ 679 /* Get the next iterator def value for PTR. */
662 static inline def_operand_p 680 static inline def_operand_p
663 op_iter_next_def (ssa_op_iter *ptr) 681 op_iter_next_def (ssa_op_iter *ptr)
664 { 682 {
665 def_operand_p def_p; 683 def_operand_p def_p;
666 #ifdef ENABLE_CHECKING 684 gcc_checking_assert (ptr->iter_type == ssa_op_iter_def);
667 gcc_assert (ptr->iter_type == ssa_op_iter_def);
668 #endif
669 if (ptr->defs) 685 if (ptr->defs)
670 { 686 {
671 def_p = DEF_OP_PTR (ptr->defs); 687 def_p = DEF_OP_PTR (ptr->defs);
672 ptr->defs = ptr->defs->next; 688 ptr->defs = ptr->defs->next;
673 return def_p; 689 return def_p;
679 /* Get the next iterator tree value for PTR. */ 695 /* Get the next iterator tree value for PTR. */
680 static inline tree 696 static inline tree
681 op_iter_next_tree (ssa_op_iter *ptr) 697 op_iter_next_tree (ssa_op_iter *ptr)
682 { 698 {
683 tree val; 699 tree val;
684 #ifdef ENABLE_CHECKING 700 gcc_checking_assert (ptr->iter_type == ssa_op_iter_tree);
685 gcc_assert (ptr->iter_type == ssa_op_iter_tree);
686 #endif
687 if (ptr->uses) 701 if (ptr->uses)
688 { 702 {
689 val = USE_OP (ptr->uses); 703 val = USE_OP (ptr->uses);
690 ptr->uses = ptr->uses->next; 704 ptr->uses = ptr->uses->next;
691 return val; 705 return val;
723 static inline void 737 static inline void
724 op_iter_init (ssa_op_iter *ptr, gimple stmt, int flags) 738 op_iter_init (ssa_op_iter *ptr, gimple stmt, int flags)
725 { 739 {
726 /* We do not support iterating over virtual defs or uses without 740 /* We do not support iterating over virtual defs or uses without
727 iterating over defs or uses at the same time. */ 741 iterating over defs or uses at the same time. */
728 gcc_assert ((!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF)) 742 gcc_checking_assert ((!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF))
729 && (!(flags & SSA_OP_VUSE) || (flags & SSA_OP_USE))); 743 && (!(flags & SSA_OP_VUSE) || (flags & SSA_OP_USE)));
730 ptr->defs = (flags & (SSA_OP_DEF|SSA_OP_VDEF)) ? gimple_def_ops (stmt) : NULL; 744 ptr->defs = (flags & (SSA_OP_DEF|SSA_OP_VDEF)) ? gimple_def_ops (stmt) : NULL;
731 if (!(flags & SSA_OP_VDEF) 745 if (!(flags & SSA_OP_VDEF)
732 && ptr->defs 746 && ptr->defs
733 && gimple_vdef (stmt) != NULL_TREE) 747 && gimple_vdef (stmt) != NULL_TREE)
734 ptr->defs = ptr->defs->next; 748 ptr->defs = ptr->defs->next;
747 /* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return 761 /* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return
748 the first use. */ 762 the first use. */
749 static inline use_operand_p 763 static inline use_operand_p
750 op_iter_init_use (ssa_op_iter *ptr, gimple stmt, int flags) 764 op_iter_init_use (ssa_op_iter *ptr, gimple stmt, int flags)
751 { 765 {
752 gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0 766 gcc_checking_assert ((flags & SSA_OP_ALL_DEFS) == 0
753 && (flags & SSA_OP_USE)); 767 && (flags & SSA_OP_USE));
754 op_iter_init (ptr, stmt, flags); 768 op_iter_init (ptr, stmt, flags);
755 ptr->iter_type = ssa_op_iter_use; 769 ptr->iter_type = ssa_op_iter_use;
756 return op_iter_next_use (ptr); 770 return op_iter_next_use (ptr);
757 } 771 }
758 772
759 /* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return 773 /* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return
760 the first def. */ 774 the first def. */
761 static inline def_operand_p 775 static inline def_operand_p
762 op_iter_init_def (ssa_op_iter *ptr, gimple stmt, int flags) 776 op_iter_init_def (ssa_op_iter *ptr, gimple stmt, int flags)
763 { 777 {
764 gcc_assert ((flags & SSA_OP_ALL_USES) == 0 778 gcc_checking_assert ((flags & SSA_OP_ALL_USES) == 0
765 && (flags & SSA_OP_DEF)); 779 && (flags & SSA_OP_DEF));
766 op_iter_init (ptr, stmt, flags); 780 op_iter_init (ptr, stmt, flags);
767 ptr->iter_type = ssa_op_iter_def; 781 ptr->iter_type = ssa_op_iter_def;
768 return op_iter_next_def (ptr); 782 return op_iter_next_def (ptr);
769 } 783 }
770 784
895 int comp; 909 int comp;
896 910
897 clear_and_done_ssa_iter (ptr); 911 clear_and_done_ssa_iter (ptr);
898 ptr->done = false; 912 ptr->done = false;
899 913
900 gcc_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0); 914 gcc_checking_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
901 915
902 comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES); 916 comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
903 917
904 /* If the PHI node doesn't the operand type we care about, we're done. */ 918 /* If the PHI node doesn't the operand type we care about, we're done. */
905 if ((flags & comp) == 0) 919 if ((flags & comp) == 0)
924 int comp; 938 int comp;
925 939
926 clear_and_done_ssa_iter (ptr); 940 clear_and_done_ssa_iter (ptr);
927 ptr->done = false; 941 ptr->done = false;
928 942
929 gcc_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0); 943 gcc_checking_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
930 944
931 comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS); 945 comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS);
932 946
933 /* If the PHI node doesn't have the operand type we care about, 947 /* If the PHI node doesn't have the operand type we care about,
934 we're done. */ 948 we're done. */
970 984
971 static inline use_operand_p 985 static inline use_operand_p
972 move_use_after_head (use_operand_p use_p, use_operand_p head, 986 move_use_after_head (use_operand_p use_p, use_operand_p head,
973 use_operand_p last_p) 987 use_operand_p last_p)
974 { 988 {
975 #ifdef ENABLE_CHECKING 989 gcc_checking_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
976 gcc_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
977 #endif
978 /* Skip head when we find it. */ 990 /* Skip head when we find it. */
979 if (use_p != head) 991 if (use_p != head)
980 { 992 {
981 /* If use_p is already linked in after last_p, continue. */ 993 /* If use_p is already linked in after last_p, continue. */
982 if (last_p->next == use_p) 994 if (last_p->next == use_p)
1118 var = SSA_NAME_VAR (var); 1130 var = SSA_NAME_VAR (var);
1119 1131
1120 return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var)); 1132 return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
1121 } 1133 }
1122 1134
1123 /* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it. */
1124
1125 static inline bool
1126 array_ref_contains_indirect_ref (const_tree ref)
1127 {
1128 gcc_assert (TREE_CODE (ref) == ARRAY_REF);
1129
1130 do {
1131 ref = TREE_OPERAND (ref, 0);
1132 } while (handled_component_p (ref));
1133
1134 return TREE_CODE (ref) == INDIRECT_REF;
1135 }
1136
1137 /* Return true if REF, a handled component reference, has an ARRAY_REF 1135 /* Return true if REF, a handled component reference, has an ARRAY_REF
1138 somewhere in it. */ 1136 somewhere in it. */
1139 1137
1140 static inline bool 1138 static inline bool
1141 ref_contains_array_ref (const_tree ref) 1139 ref_contains_array_ref (const_tree ref)
1142 { 1140 {
1143 gcc_assert (handled_component_p (ref)); 1141 gcc_checking_assert (handled_component_p (ref));
1144 1142
1145 do { 1143 do {
1146 if (TREE_CODE (ref) == ARRAY_REF) 1144 if (TREE_CODE (ref) == ARRAY_REF)
1147 return true; 1145 return true;
1148 ref = TREE_OPERAND (ref, 0); 1146 ref = TREE_OPERAND (ref, 0);