1 /* Gimple walk support.
3 Copyright (C) 2007-2015 Free Software Foundation, Inc.
4 Contributed by Aldy Hernandez <aldyh@redhat.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
29 #include "double-int.h"
36 #include "fold-const.h"
39 #include "hard-reg-set.h"
42 #include "basic-block.h"
43 #include "tree-ssa-alias.h"
44 #include "internal-fn.h"
45 #include "gimple-expr.h"
48 #include "gimple-iterator.h"
49 #include "gimple-walk.h"
50 #include "gimple-walk.h"
53 /* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt
54 on each one. WI is as in walk_gimple_stmt.
56 If walk_gimple_stmt returns non-NULL, the walk is stopped, and the
57 value is stored in WI->CALLBACK_RESULT. Also, the statement that
58 produced the value is returned if this statement has not been
59 removed by a callback (wi->removed_stmt). If the statement has
60 been removed, NULL is returned.
62 Otherwise, all the statements are walked and NULL returned. */
65 walk_gimple_seq_mod (gimple_seq
*pseq
, walk_stmt_fn callback_stmt
,
66 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
68 gimple_stmt_iterator gsi
;
70 for (gsi
= gsi_start (*pseq
); !gsi_end_p (gsi
); )
72 tree ret
= walk_gimple_stmt (&gsi
, callback_stmt
, callback_op
, wi
);
75 /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist
78 wi
->callback_result
= ret
;
80 return wi
->removed_stmt
? NULL
: gsi_stmt (gsi
);
83 if (!wi
->removed_stmt
)
88 wi
->callback_result
= NULL_TREE
;
94 /* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't
95 changed by the callbacks. */
98 walk_gimple_seq (gimple_seq seq
, walk_stmt_fn callback_stmt
,
99 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
101 gimple_seq seq2
= seq
;
102 gimple ret
= walk_gimple_seq_mod (&seq2
, callback_stmt
, callback_op
, wi
);
103 gcc_assert (seq2
== seq
);
108 /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */
111 walk_gimple_asm (gasm
*stmt
, walk_tree_fn callback_op
,
112 struct walk_stmt_info
*wi
)
116 const char **oconstraints
;
118 const char *constraint
;
119 bool allows_mem
, allows_reg
, is_inout
;
121 noutputs
= gimple_asm_noutputs (stmt
);
122 oconstraints
= (const char **) alloca ((noutputs
) * sizeof (const char *));
127 for (i
= 0; i
< noutputs
; i
++)
129 op
= gimple_asm_output_op (stmt
, i
);
130 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
131 oconstraints
[i
] = constraint
;
132 parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
, &allows_reg
,
135 wi
->val_only
= (allows_reg
|| !allows_mem
);
136 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
141 n
= gimple_asm_ninputs (stmt
);
142 for (i
= 0; i
< n
; i
++)
144 op
= gimple_asm_input_op (stmt
, i
);
145 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
146 parse_input_constraint (&constraint
, 0, 0, noutputs
, 0,
147 oconstraints
, &allows_mem
, &allows_reg
);
150 wi
->val_only
= (allows_reg
|| !allows_mem
);
151 /* Although input "m" is not really a LHS, we need a lvalue. */
152 wi
->is_lhs
= !wi
->val_only
;
154 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
165 n
= gimple_asm_nlabels (stmt
);
166 for (i
= 0; i
< n
; i
++)
168 op
= gimple_asm_label_op (stmt
, i
);
169 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
178 /* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
179 STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
181 CALLBACK_OP is called on each operand of STMT via walk_tree.
182 Additional parameters to walk_tree must be stored in WI. For each operand
183 OP, walk_tree is called as:
185 walk_tree (&OP, CALLBACK_OP, WI, WI->PSET)
187 If CALLBACK_OP returns non-NULL for an operand, the remaining
188 operands are not scanned.
190 The return value is that returned by the last call to walk_tree, or
191 NULL_TREE if no CALLBACK_OP is specified. */
194 walk_gimple_op (gimple stmt
, walk_tree_fn callback_op
,
195 struct walk_stmt_info
*wi
)
197 hash_set
<tree
> *pset
= (wi
) ? wi
->pset
: NULL
;
199 tree ret
= NULL_TREE
;
201 switch (gimple_code (stmt
))
204 /* Walk the RHS operands. If the LHS is of a non-renamable type or
205 is a register variable, we may use a COMPONENT_REF on the RHS. */
208 tree lhs
= gimple_assign_lhs (stmt
);
210 = (is_gimple_reg_type (TREE_TYPE (lhs
)) && !is_gimple_reg (lhs
))
211 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
214 for (i
= 1; i
< gimple_num_ops (stmt
); i
++)
216 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
,
222 /* Walk the LHS. If the RHS is appropriate for a memory, we
223 may use a COMPONENT_REF on the LHS. */
226 /* If the RHS is of a non-renamable type or is a register variable,
227 we may use a COMPONENT_REF on the LHS. */
228 tree rhs1
= gimple_assign_rhs1 (stmt
);
230 = (is_gimple_reg_type (TREE_TYPE (rhs1
)) && !is_gimple_reg (rhs1
))
231 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
235 ret
= walk_tree (gimple_op_ptr (stmt
, 0), callback_op
, wi
, pset
);
253 ret
= walk_tree (gimple_call_chain_ptr (as_a
<gcall
*> (stmt
)),
254 callback_op
, wi
, pset
);
258 ret
= walk_tree (gimple_call_fn_ptr (stmt
), callback_op
, wi
, pset
);
262 for (i
= 0; i
< gimple_call_num_args (stmt
); i
++)
266 = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt
, i
)));
267 ret
= walk_tree (gimple_call_arg_ptr (stmt
, i
), callback_op
, wi
,
273 if (gimple_call_lhs (stmt
))
279 = is_gimple_reg_type (TREE_TYPE (gimple_call_lhs (stmt
)));
282 ret
= walk_tree (gimple_call_lhs_ptr (stmt
), callback_op
, wi
, pset
);
295 ret
= walk_tree (gimple_catch_types_ptr (as_a
<gcatch
*> (stmt
)),
296 callback_op
, wi
, pset
);
301 case GIMPLE_EH_FILTER
:
302 ret
= walk_tree (gimple_eh_filter_types_ptr (stmt
), callback_op
, wi
,
309 ret
= walk_gimple_asm (as_a
<gasm
*> (stmt
), callback_op
, wi
);
314 case GIMPLE_OMP_CONTINUE
:
316 gomp_continue
*cont_stmt
= as_a
<gomp_continue
*> (stmt
);
317 ret
= walk_tree (gimple_omp_continue_control_def_ptr (cont_stmt
),
318 callback_op
, wi
, pset
);
322 ret
= walk_tree (gimple_omp_continue_control_use_ptr (cont_stmt
),
323 callback_op
, wi
, pset
);
329 case GIMPLE_OMP_CRITICAL
:
331 gomp_critical
*omp_stmt
= as_a
<gomp_critical
*> (stmt
);
332 ret
= walk_tree (gimple_omp_critical_name_ptr (omp_stmt
),
333 callback_op
, wi
, pset
);
340 ret
= walk_tree (gimple_omp_for_clauses_ptr (stmt
), callback_op
, wi
,
344 for (i
= 0; i
< gimple_omp_for_collapse (stmt
); i
++)
346 ret
= walk_tree (gimple_omp_for_index_ptr (stmt
, i
), callback_op
,
350 ret
= walk_tree (gimple_omp_for_initial_ptr (stmt
, i
), callback_op
,
354 ret
= walk_tree (gimple_omp_for_final_ptr (stmt
, i
), callback_op
,
358 ret
= walk_tree (gimple_omp_for_incr_ptr (stmt
, i
), callback_op
,
365 case GIMPLE_OMP_PARALLEL
:
367 gomp_parallel
*omp_par_stmt
= as_a
<gomp_parallel
*> (stmt
);
368 ret
= walk_tree (gimple_omp_parallel_clauses_ptr (omp_par_stmt
),
369 callback_op
, wi
, pset
);
372 ret
= walk_tree (gimple_omp_parallel_child_fn_ptr (omp_par_stmt
),
373 callback_op
, wi
, pset
);
376 ret
= walk_tree (gimple_omp_parallel_data_arg_ptr (omp_par_stmt
),
377 callback_op
, wi
, pset
);
383 case GIMPLE_OMP_TASK
:
384 ret
= walk_tree (gimple_omp_task_clauses_ptr (stmt
), callback_op
,
388 ret
= walk_tree (gimple_omp_task_child_fn_ptr (stmt
), callback_op
,
392 ret
= walk_tree (gimple_omp_task_data_arg_ptr (stmt
), callback_op
,
396 ret
= walk_tree (gimple_omp_task_copy_fn_ptr (stmt
), callback_op
,
400 ret
= walk_tree (gimple_omp_task_arg_size_ptr (stmt
), callback_op
,
404 ret
= walk_tree (gimple_omp_task_arg_align_ptr (stmt
), callback_op
,
410 case GIMPLE_OMP_SECTIONS
:
411 ret
= walk_tree (gimple_omp_sections_clauses_ptr (stmt
), callback_op
,
415 ret
= walk_tree (gimple_omp_sections_control_ptr (stmt
), callback_op
,
422 case GIMPLE_OMP_SINGLE
:
423 ret
= walk_tree (gimple_omp_single_clauses_ptr (stmt
), callback_op
, wi
,
429 case GIMPLE_OMP_TARGET
:
431 gomp_target
*omp_stmt
= as_a
<gomp_target
*> (stmt
);
432 ret
= walk_tree (gimple_omp_target_clauses_ptr (omp_stmt
),
433 callback_op
, wi
, pset
);
436 ret
= walk_tree (gimple_omp_target_child_fn_ptr (omp_stmt
),
437 callback_op
, wi
, pset
);
440 ret
= walk_tree (gimple_omp_target_data_arg_ptr (omp_stmt
),
441 callback_op
, wi
, pset
);
447 case GIMPLE_OMP_TEAMS
:
448 ret
= walk_tree (gimple_omp_teams_clauses_ptr (stmt
), callback_op
, wi
,
454 case GIMPLE_OMP_ATOMIC_LOAD
:
456 gomp_atomic_load
*omp_stmt
= as_a
<gomp_atomic_load
*> (stmt
);
457 ret
= walk_tree (gimple_omp_atomic_load_lhs_ptr (omp_stmt
),
458 callback_op
, wi
, pset
);
461 ret
= walk_tree (gimple_omp_atomic_load_rhs_ptr (omp_stmt
),
462 callback_op
, wi
, pset
);
468 case GIMPLE_OMP_ATOMIC_STORE
:
470 gomp_atomic_store
*omp_stmt
= as_a
<gomp_atomic_store
*> (stmt
);
471 ret
= walk_tree (gimple_omp_atomic_store_val_ptr (omp_stmt
),
472 callback_op
, wi
, pset
);
478 case GIMPLE_TRANSACTION
:
479 ret
= walk_tree (gimple_transaction_label_ptr (
480 as_a
<gtransaction
*> (stmt
)),
481 callback_op
, wi
, pset
);
486 case GIMPLE_OMP_RETURN
:
487 ret
= walk_tree (gimple_omp_return_lhs_ptr (stmt
), callback_op
, wi
,
493 /* Tuples that do not have operands. */
501 enum gimple_statement_structure_enum gss
;
502 gss
= gimple_statement_structure (stmt
);
503 if (gss
== GSS_WITH_OPS
|| gss
== GSS_WITH_MEM_OPS
)
504 for (i
= 0; i
< gimple_num_ops (stmt
); i
++)
506 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
, pset
);
518 /* Walk the current statement in GSI (optionally using traversal state
519 stored in WI). If WI is NULL, no state is kept during traversal.
520 The callback CALLBACK_STMT is called. If CALLBACK_STMT indicates
521 that it has handled all the operands of the statement, its return
522 value is returned. Otherwise, the return value from CALLBACK_STMT
523 is discarded and its operands are scanned.
525 If CALLBACK_STMT is NULL or it didn't handle the operands,
526 CALLBACK_OP is called on each operand of the statement via
527 walk_gimple_op. If walk_gimple_op returns non-NULL for any
528 operand, the remaining operands are not scanned. In this case, the
529 return value from CALLBACK_OP is returned.
531 In any other case, NULL_TREE is returned. */
534 walk_gimple_stmt (gimple_stmt_iterator
*gsi
, walk_stmt_fn callback_stmt
,
535 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
539 gimple stmt
= gsi_stmt (*gsi
);
544 wi
->removed_stmt
= false;
546 if (wi
->want_locations
&& gimple_has_location (stmt
))
547 input_location
= gimple_location (stmt
);
552 /* Invoke the statement callback. Return if the callback handled
553 all of STMT operands by itself. */
556 bool handled_ops
= false;
557 tree_ret
= callback_stmt (gsi
, &handled_ops
, wi
);
561 /* If CALLBACK_STMT did not handle operands, it should not have
562 a value to return. */
563 gcc_assert (tree_ret
== NULL
);
565 if (wi
&& wi
->removed_stmt
)
568 /* Re-read stmt in case the callback changed it. */
569 stmt
= gsi_stmt (*gsi
);
572 /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */
575 tree_ret
= walk_gimple_op (stmt
, callback_op
, wi
);
580 /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */
581 switch (gimple_code (stmt
))
584 ret
= walk_gimple_seq_mod (gimple_bind_body_ptr (as_a
<gbind
*> (stmt
)),
585 callback_stmt
, callback_op
, wi
);
587 return wi
->callback_result
;
591 ret
= walk_gimple_seq_mod (gimple_catch_handler_ptr (
592 as_a
<gcatch
*> (stmt
)),
593 callback_stmt
, callback_op
, wi
);
595 return wi
->callback_result
;
598 case GIMPLE_EH_FILTER
:
599 ret
= walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt
), callback_stmt
,
602 return wi
->callback_result
;
607 geh_else
*eh_else_stmt
= as_a
<geh_else
*> (stmt
);
608 ret
= walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (eh_else_stmt
),
609 callback_stmt
, callback_op
, wi
);
611 return wi
->callback_result
;
612 ret
= walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (eh_else_stmt
),
613 callback_stmt
, callback_op
, wi
);
615 return wi
->callback_result
;
620 ret
= walk_gimple_seq_mod (gimple_try_eval_ptr (stmt
), callback_stmt
, callback_op
,
623 return wi
->callback_result
;
625 ret
= walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt
), callback_stmt
,
628 return wi
->callback_result
;
632 ret
= walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt
), callback_stmt
,
635 return wi
->callback_result
;
638 case GIMPLE_OMP_CRITICAL
:
639 case GIMPLE_OMP_MASTER
:
640 case GIMPLE_OMP_TASKGROUP
:
641 case GIMPLE_OMP_ORDERED
:
642 case GIMPLE_OMP_SECTION
:
643 case GIMPLE_OMP_PARALLEL
:
644 case GIMPLE_OMP_TASK
:
645 case GIMPLE_OMP_SECTIONS
:
646 case GIMPLE_OMP_SINGLE
:
647 case GIMPLE_OMP_TARGET
:
648 case GIMPLE_OMP_TEAMS
:
649 ret
= walk_gimple_seq_mod (gimple_omp_body_ptr (stmt
), callback_stmt
,
652 return wi
->callback_result
;
655 case GIMPLE_WITH_CLEANUP_EXPR
:
656 ret
= walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt
), callback_stmt
,
659 return wi
->callback_result
;
662 case GIMPLE_TRANSACTION
:
663 ret
= walk_gimple_seq_mod (gimple_transaction_body_ptr (
664 as_a
<gtransaction
*> (stmt
)),
665 callback_stmt
, callback_op
, wi
);
667 return wi
->callback_result
;
671 gcc_assert (!gimple_has_substatements (stmt
));
678 /* From a tree operand OP return the base of a load or store operation
679 or NULL_TREE if OP is not a load or a store. */
682 get_base_loadstore (tree op
)
684 while (handled_component_p (op
))
685 op
= TREE_OPERAND (op
, 0);
687 || INDIRECT_REF_P (op
)
688 || TREE_CODE (op
) == MEM_REF
689 || TREE_CODE (op
) == TARGET_MEM_REF
)
695 /* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
696 VISIT_ADDR if non-NULL on loads, store and address-taken operands
697 passing the STMT, the base of the operand, the operand itself containing
698 the base and DATA to it. The base will be either a decl, an indirect
699 reference (including TARGET_MEM_REF) or the argument of an address
701 Returns the results of these callbacks or'ed. */
704 walk_stmt_load_store_addr_ops (gimple stmt
, void *data
,
705 walk_stmt_load_store_addr_fn visit_load
,
706 walk_stmt_load_store_addr_fn visit_store
,
707 walk_stmt_load_store_addr_fn visit_addr
)
711 if (gimple_assign_single_p (stmt
))
716 arg
= gimple_assign_lhs (stmt
);
717 lhs
= get_base_loadstore (arg
);
719 ret
|= visit_store (stmt
, lhs
, arg
, data
);
721 arg
= gimple_assign_rhs1 (stmt
);
723 while (handled_component_p (rhs
))
724 rhs
= TREE_OPERAND (rhs
, 0);
727 if (TREE_CODE (rhs
) == ADDR_EXPR
)
728 ret
|= visit_addr (stmt
, TREE_OPERAND (rhs
, 0), arg
, data
);
729 else if (TREE_CODE (rhs
) == TARGET_MEM_REF
730 && TREE_CODE (TMR_BASE (rhs
)) == ADDR_EXPR
)
731 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (rhs
), 0), arg
,
733 else if (TREE_CODE (rhs
) == OBJ_TYPE_REF
734 && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs
)) == ADDR_EXPR
)
735 ret
|= visit_addr (stmt
, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs
),
737 else if (TREE_CODE (rhs
) == CONSTRUCTOR
)
742 FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs
), ix
, val
)
743 if (TREE_CODE (val
) == ADDR_EXPR
)
744 ret
|= visit_addr (stmt
, TREE_OPERAND (val
, 0), arg
, data
);
745 else if (TREE_CODE (val
) == OBJ_TYPE_REF
746 && TREE_CODE (OBJ_TYPE_REF_OBJECT (val
)) == ADDR_EXPR
)
747 ret
|= visit_addr (stmt
,
748 TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val
),
751 lhs
= gimple_assign_lhs (stmt
);
752 if (TREE_CODE (lhs
) == TARGET_MEM_REF
753 && TREE_CODE (TMR_BASE (lhs
)) == ADDR_EXPR
)
754 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (lhs
), 0), lhs
, data
);
758 rhs
= get_base_loadstore (rhs
);
760 ret
|= visit_load (stmt
, rhs
, arg
, data
);
764 && (is_gimple_assign (stmt
)
765 || gimple_code (stmt
) == GIMPLE_COND
))
767 for (i
= 0; i
< gimple_num_ops (stmt
); ++i
)
769 tree op
= gimple_op (stmt
, i
);
772 else if (TREE_CODE (op
) == ADDR_EXPR
)
773 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
774 /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
775 tree with two operands. */
776 else if (i
== 1 && COMPARISON_CLASS_P (op
))
778 if (TREE_CODE (TREE_OPERAND (op
, 0)) == ADDR_EXPR
)
779 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 0),
781 if (TREE_CODE (TREE_OPERAND (op
, 1)) == ADDR_EXPR
)
782 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 1),
787 else if (gcall
*call_stmt
= dyn_cast
<gcall
*> (stmt
))
791 tree arg
= gimple_call_lhs (call_stmt
);
794 tree lhs
= get_base_loadstore (arg
);
796 ret
|= visit_store (stmt
, lhs
, arg
, data
);
799 if (visit_load
|| visit_addr
)
800 for (i
= 0; i
< gimple_call_num_args (call_stmt
); ++i
)
802 tree arg
= gimple_call_arg (call_stmt
, i
);
804 && TREE_CODE (arg
) == ADDR_EXPR
)
805 ret
|= visit_addr (stmt
, TREE_OPERAND (arg
, 0), arg
, data
);
808 tree rhs
= get_base_loadstore (arg
);
810 ret
|= visit_load (stmt
, rhs
, arg
, data
);
814 && gimple_call_chain (call_stmt
)
815 && TREE_CODE (gimple_call_chain (call_stmt
)) == ADDR_EXPR
)
816 ret
|= visit_addr (stmt
, TREE_OPERAND (gimple_call_chain (call_stmt
), 0),
817 gimple_call_chain (call_stmt
), data
);
819 && gimple_call_return_slot_opt_p (call_stmt
)
820 && gimple_call_lhs (call_stmt
) != NULL_TREE
821 && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call_stmt
))))
822 ret
|= visit_addr (stmt
, gimple_call_lhs (call_stmt
),
823 gimple_call_lhs (call_stmt
), data
);
825 else if (gasm
*asm_stmt
= dyn_cast
<gasm
*> (stmt
))
828 const char *constraint
;
829 const char **oconstraints
;
830 bool allows_mem
, allows_reg
, is_inout
;
831 noutputs
= gimple_asm_noutputs (asm_stmt
);
832 oconstraints
= XALLOCAVEC (const char *, noutputs
);
833 if (visit_store
|| visit_addr
)
834 for (i
= 0; i
< gimple_asm_noutputs (asm_stmt
); ++i
)
836 tree link
= gimple_asm_output_op (asm_stmt
, i
);
837 tree op
= get_base_loadstore (TREE_VALUE (link
));
838 if (op
&& visit_store
)
839 ret
|= visit_store (stmt
, op
, TREE_VALUE (link
), data
);
842 constraint
= TREE_STRING_POINTER
843 (TREE_VALUE (TREE_PURPOSE (link
)));
844 oconstraints
[i
] = constraint
;
845 parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
,
846 &allows_reg
, &is_inout
);
847 if (op
&& !allows_reg
&& allows_mem
)
848 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
), data
);
851 if (visit_load
|| visit_addr
)
852 for (i
= 0; i
< gimple_asm_ninputs (asm_stmt
); ++i
)
854 tree link
= gimple_asm_input_op (asm_stmt
, i
);
855 tree op
= TREE_VALUE (link
);
857 && TREE_CODE (op
) == ADDR_EXPR
)
858 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
859 else if (visit_load
|| visit_addr
)
861 op
= get_base_loadstore (op
);
865 ret
|= visit_load (stmt
, op
, TREE_VALUE (link
), data
);
868 constraint
= TREE_STRING_POINTER
869 (TREE_VALUE (TREE_PURPOSE (link
)));
870 parse_input_constraint (&constraint
, 0, 0, noutputs
,
872 &allows_mem
, &allows_reg
);
873 if (!allows_reg
&& allows_mem
)
874 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
),
881 else if (greturn
*return_stmt
= dyn_cast
<greturn
*> (stmt
))
883 tree op
= gimple_return_retval (return_stmt
);
887 && TREE_CODE (op
) == ADDR_EXPR
)
888 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
891 tree base
= get_base_loadstore (op
);
893 ret
|= visit_load (stmt
, base
, op
, data
);
898 && gimple_code (stmt
) == GIMPLE_PHI
)
900 for (i
= 0; i
< gimple_phi_num_args (stmt
); ++i
)
902 tree op
= gimple_phi_arg_def (stmt
, i
);
903 if (TREE_CODE (op
) == ADDR_EXPR
)
904 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
908 && gimple_code (stmt
) == GIMPLE_GOTO
)
910 tree op
= gimple_goto_dest (stmt
);
911 if (TREE_CODE (op
) == ADDR_EXPR
)
912 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
918 /* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP
919 should make a faster clone for this case. */
922 walk_stmt_load_store_ops (gimple stmt
, void *data
,
923 walk_stmt_load_store_addr_fn visit_load
,
924 walk_stmt_load_store_addr_fn visit_store
)
926 return walk_stmt_load_store_addr_ops (stmt
, data
,
927 visit_load
, visit_store
, NULL
);