20 #ifndef GCC_SSA_ITERATORS_H
21 #define GCC_SSA_ITERATORS_H
75 #define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR) \
76 for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR)); \
77 !end_readonly_imm_use_p (&(ITER)); \
78 (void) ((DEST) = next_readonly_imm_use (&(ITER))))
82 #define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR) \
83 for ((STMT) = first_imm_use_stmt (&(ITER), (SSAVAR)); \
84 !end_imm_use_stmt_p (&(ITER)); \
85 (void) ((STMT) = next_imm_use_stmt (&(ITER))))
90 #define BREAK_FROM_IMM_USE_STMT(ITER) \
92 end_imm_use_stmt_traverse (&(ITER)); \
110 #define FOR_EACH_IMM_USE_ON_STMT(DEST, ITER) \
111 for ((DEST) = first_imm_use_on_stmt (&(ITER)); \
112 !end_imm_use_on_stmt_p (&(ITER)); \
113 (void) ((DEST) = next_imm_use_on_stmt (&(ITER))))
147 #define SSA_OP_USE 0x01
148 #define SSA_OP_DEF 0x02
149 #define SSA_OP_VUSE 0x04
150 #define SSA_OP_VDEF 0x08
153 #define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE)
154 #define SSA_OP_VIRTUAL_DEFS (SSA_OP_VDEF)
155 #define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_DEFS)
156 #define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE)
157 #define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF)
158 #define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS)
163 #define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS) \
164 for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS); \
165 !op_iter_done (&(ITER)); \
166 (void) (TREEVAR = op_iter_next_tree (&(ITER))))
171 #define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS) \
172 for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS); \
173 !op_iter_done (&(ITER)); \
174 USEVAR = op_iter_next_use (&(ITER)))
179 #define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS) \
180 for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS); \
181 !op_iter_done (&(ITER)); \
182 DEFVAR = op_iter_next_def (&(ITER)))
187 #define FOR_EACH_PHI_ARG(USEVAR, STMT, ITER, FLAGS) \
188 for ((USEVAR) = op_iter_init_phiuse (&(ITER), STMT, FLAGS); \
189 !op_iter_done (&(ITER)); \
190 (USEVAR) = op_iter_next_use (&(ITER)))
195 #define FOR_EACH_PHI_OR_STMT_USE(USEVAR, STMT, ITER, FLAGS) \
196 for ((USEVAR) = (gimple_code (STMT) == GIMPLE_PHI \
197 ? op_iter_init_phiuse (&(ITER), STMT, FLAGS) \
198 : op_iter_init_use (&(ITER), STMT, FLAGS)); \
199 !op_iter_done (&(ITER)); \
200 (USEVAR) = op_iter_next_use (&(ITER)))
204 #define FOR_EACH_PHI_OR_STMT_DEF(DEFVAR, STMT, ITER, FLAGS) \
205 for ((DEFVAR) = (gimple_code (STMT) == GIMPLE_PHI \
206 ? op_iter_init_phidef (&(ITER), STMT, FLAGS) \
207 : op_iter_init_def (&(ITER), STMT, FLAGS)); \
208 !op_iter_done (&(ITER)); \
209 (DEFVAR) = op_iter_next_def (&(ITER)))
214 #define SINGLE_SSA_TREE_OPERAND(STMT, FLAGS) \
215 single_ssa_tree_operand (STMT, FLAGS)
220 #define SINGLE_SSA_USE_OPERAND(STMT, FLAGS) \
221 single_ssa_use_operand (STMT, FLAGS)
226 #define SINGLE_SSA_DEF_OPERAND(STMT, FLAGS) \
227 single_ssa_def_operand (STMT, FLAGS)
230 #define ZERO_SSA_OPERANDS(STMT, FLAGS) zero_ssa_operands (STMT, FLAGS)
233 #define NUM_SSA_OPERANDS(STMT, FLAGS) num_ssa_operands (STMT, FLAGS)
241 if (linknode->
prev == NULL)
246 linknode->
prev = NULL;
247 linknode->
next = NULL;
256 linknode->
prev = list;
259 list->
next = linknode;
268 if (!def || TREE_CODE (def) != SSA_NAME)
269 linknode->
prev = NULL;
272 root = &(SSA_NAME_IMM_USE_NODE (def));
274 gcc_checking_assert (*(linknode->
use) == def);
305 gcc_checking_assert (*(old->
use) == *(node->
use));
342 imm->
end_p = &(SSA_NAME_IMM_USE_NODE (var));
344 #ifdef ENABLE_CHECKING
348 return NULL_USE_OPERAND_P;
358 #ifdef ENABLE_CHECKING
369 return NULL_USE_OPERAND_P;
381 if (ptr == ptr->
next)
386 if (!MAY_HAVE_DEBUG_STMTS)
399 if (ptr == ptr->
next)
407 if (!MAY_HAVE_DEBUG_STMTS)
422 if (ptr == ptr->
next)
425 *use_p = NULL_USE_OPERAND_P;
444 if (!MAY_HAVE_DEBUG_STMTS)
451 static inline unsigned int
456 unsigned int num = 0;
458 if (!MAY_HAVE_DEBUG_STMTS)
459 for (ptr = start->
next; ptr != start; ptr = ptr->
next)
462 for (ptr = start->
next; ptr != start; ptr = ptr->
next)
489 use_p = USE_OP_PTR (ptr->
uses);
495 return PHI_ARG_DEF_PTR (ptr->
stmt, (ptr->
i)++);
498 return NULL_USE_OPERAND_P;
506 if (ptr->
flags & SSA_OP_VDEF)
509 ptr->
flags &= ~SSA_OP_VDEF;
514 if (ptr->
flags & SSA_OP_DEF)
522 if (TREE_CODE (*val) == TREE_LIST)
523 val = &TREE_VALUE (*val);
524 if (TREE_CODE (*val) == SSA_NAME
529 ptr->
flags &= ~SSA_OP_DEF;
533 return NULL_DEF_OPERAND_P;
544 val = USE_OP (ptr->
uses);
548 if (ptr->
flags & SSA_OP_VDEF)
550 ptr->
flags &= ~SSA_OP_VDEF;
554 if (ptr->
flags & SSA_OP_DEF)
562 if (TREE_CODE (val) == TREE_LIST)
563 val = TREE_VALUE (val);
564 if (TREE_CODE (val) == SSA_NAME
569 ptr->
flags &= ~SSA_OP_DEF;
600 gcc_checking_assert (
gimple_code (stmt) != GIMPLE_PHI
601 && (!(flags & SSA_OP_VDEF) || (flags & SSA_OP_DEF))
602 && (!(flags & SSA_OP_VUSE) || (flags & SSA_OP_USE)));
604 if (flags & (SSA_OP_DEF | SSA_OP_VDEF))
617 flags &= ~(SSA_OP_DEF | SSA_OP_VDEF);
622 if (!(flags & SSA_OP_VUSE)
638 gcc_checking_assert ((flags & SSA_OP_ALL_DEFS) == 0
639 && (flags & SSA_OP_USE));
650 gcc_checking_assert ((flags & SSA_OP_ALL_USES) == 0
651 && (flags & SSA_OP_DEF));
696 return NULL_USE_OPERAND_P;
700 return NULL_USE_OPERAND_P;
715 return NULL_DEF_OPERAND_P;
719 return NULL_DEF_OPERAND_P;
743 gcc_checking_assert (
gimple_code (stmt) != GIMPLE_PHI);
744 FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
773 gcc_checking_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
775 comp = (
is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
778 if ((flags & comp) == 0)
781 return NULL_USE_OPERAND_P;
797 tree phi_def = PHI_RESULT (phi);
803 gcc_checking_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
809 if ((flags & comp) == 0)
812 return NULL_DEF_OPERAND_P;
819 return PHI_RESULT_PTR (phi);
849 gcc_checking_assert (USE_FROM_PTR (use_p) == USE_FROM_PTR (head));
854 if (last_p->
next == use_p)
876 gimple head_stmt = USE_STMT (head);
877 tree use = USE_FROM_PTR (head);
882 flag = (
is_gimple_reg (use) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
886 FOR_EACH_PHI_ARG (use_p, head_stmt, op_iter, flag)
887 if (USE_FROM_PTR (use_p) == use)
892 if (flag == SSA_OP_USE)
894 FOR_EACH_SSA_USE_OPERAND (use_p, head_stmt, op_iter, flag)
895 if (USE_FROM_PTR (use_p) == use)
898 else if ((use_p =
gimple_vuse_op (head_stmt)) != NULL_USE_OPERAND_P)
900 if (USE_FROM_PTR (use_p) == use)
914 imm->
end_p = &(SSA_NAME_IMM_USE_NODE (var));
931 return USE_STMT (imm->
imm_use);
948 return USE_STMT (imm->
imm_use);
976 return NULL_USE_OPERAND_P;
992 FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, iter, SSA_OP_ALL_USES)