1 /* Gimple walk support.
3 Copyright (C) 2007-2014 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"
33 #include "hard-reg-set.h"
36 #include "basic-block.h"
37 #include "tree-ssa-alias.h"
38 #include "internal-fn.h"
39 #include "gimple-expr.h"
42 #include "gimple-iterator.h"
43 #include "gimple-walk.h"
44 #include "gimple-walk.h"
47 /* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt
48 on each one. WI is as in walk_gimple_stmt.
50 If walk_gimple_stmt returns non-NULL, the walk is stopped, and the
51 value is stored in WI->CALLBACK_RESULT. Also, the statement that
52 produced the value is returned if this statement has not been
53 removed by a callback (wi->removed_stmt). If the statement has
54 been removed, NULL is returned.
56 Otherwise, all the statements are walked and NULL returned. */
59 walk_gimple_seq_mod (gimple_seq
*pseq
, walk_stmt_fn callback_stmt
,
60 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
62 gimple_stmt_iterator gsi
;
64 for (gsi
= gsi_start (*pseq
); !gsi_end_p (gsi
); )
66 tree ret
= walk_gimple_stmt (&gsi
, callback_stmt
, callback_op
, wi
);
69 /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist
72 wi
->callback_result
= ret
;
74 return wi
->removed_stmt
? NULL
: gsi_stmt (gsi
);
77 if (!wi
->removed_stmt
)
82 wi
->callback_result
= NULL_TREE
;
88 /* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't
89 changed by the callbacks. */
92 walk_gimple_seq (gimple_seq seq
, walk_stmt_fn callback_stmt
,
93 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
95 gimple_seq seq2
= seq
;
96 gimple ret
= walk_gimple_seq_mod (&seq2
, callback_stmt
, callback_op
, wi
);
97 gcc_assert (seq2
== seq
);
102 /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */
105 walk_gimple_asm (gasm
*stmt
, walk_tree_fn callback_op
,
106 struct walk_stmt_info
*wi
)
110 const char **oconstraints
;
112 const char *constraint
;
113 bool allows_mem
, allows_reg
, is_inout
;
115 noutputs
= gimple_asm_noutputs (stmt
);
116 oconstraints
= (const char **) alloca ((noutputs
) * sizeof (const char *));
121 for (i
= 0; i
< noutputs
; i
++)
123 op
= gimple_asm_output_op (stmt
, i
);
124 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
125 oconstraints
[i
] = constraint
;
126 parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
, &allows_reg
,
129 wi
->val_only
= (allows_reg
|| !allows_mem
);
130 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
135 n
= gimple_asm_ninputs (stmt
);
136 for (i
= 0; i
< n
; i
++)
138 op
= gimple_asm_input_op (stmt
, i
);
139 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
140 parse_input_constraint (&constraint
, 0, 0, noutputs
, 0,
141 oconstraints
, &allows_mem
, &allows_reg
);
144 wi
->val_only
= (allows_reg
|| !allows_mem
);
145 /* Although input "m" is not really a LHS, we need a lvalue. */
146 wi
->is_lhs
= !wi
->val_only
;
148 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
159 n
= gimple_asm_nlabels (stmt
);
160 for (i
= 0; i
< n
; i
++)
162 op
= gimple_asm_label_op (stmt
, i
);
163 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
172 /* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
173 STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
175 CALLBACK_OP is called on each operand of STMT via walk_tree.
176 Additional parameters to walk_tree must be stored in WI. For each operand
177 OP, walk_tree is called as:
179 walk_tree (&OP, CALLBACK_OP, WI, WI->PSET)
181 If CALLBACK_OP returns non-NULL for an operand, the remaining
182 operands are not scanned.
184 The return value is that returned by the last call to walk_tree, or
185 NULL_TREE if no CALLBACK_OP is specified. */
188 walk_gimple_op (gimple stmt
, walk_tree_fn callback_op
,
189 struct walk_stmt_info
*wi
)
191 hash_set
<tree
> *pset
= (wi
) ? wi
->pset
: NULL
;
193 tree ret
= NULL_TREE
;
195 switch (gimple_code (stmt
))
198 /* Walk the RHS operands. If the LHS is of a non-renamable type or
199 is a register variable, we may use a COMPONENT_REF on the RHS. */
202 tree lhs
= gimple_assign_lhs (stmt
);
204 = (is_gimple_reg_type (TREE_TYPE (lhs
)) && !is_gimple_reg (lhs
))
205 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
208 for (i
= 1; i
< gimple_num_ops (stmt
); i
++)
210 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
,
216 /* Walk the LHS. If the RHS is appropriate for a memory, we
217 may use a COMPONENT_REF on the LHS. */
220 /* If the RHS is of a non-renamable type or is a register variable,
221 we may use a COMPONENT_REF on the LHS. */
222 tree rhs1
= gimple_assign_rhs1 (stmt
);
224 = (is_gimple_reg_type (TREE_TYPE (rhs1
)) && !is_gimple_reg (rhs1
))
225 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
229 ret
= walk_tree (gimple_op_ptr (stmt
, 0), callback_op
, wi
, pset
);
247 ret
= walk_tree (gimple_call_chain_ptr (as_a
<gcall
*> (stmt
)),
248 callback_op
, wi
, pset
);
252 ret
= walk_tree (gimple_call_fn_ptr (stmt
), callback_op
, wi
, pset
);
256 for (i
= 0; i
< gimple_call_num_args (stmt
); i
++)
260 = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt
, i
)));
261 ret
= walk_tree (gimple_call_arg_ptr (stmt
, i
), callback_op
, wi
,
267 if (gimple_call_lhs (stmt
))
273 = is_gimple_reg_type (TREE_TYPE (gimple_call_lhs (stmt
)));
276 ret
= walk_tree (gimple_call_lhs_ptr (stmt
), callback_op
, wi
, pset
);
289 ret
= walk_tree (gimple_catch_types_ptr (as_a
<gcatch
*> (stmt
)),
290 callback_op
, wi
, pset
);
295 case GIMPLE_EH_FILTER
:
296 ret
= walk_tree (gimple_eh_filter_types_ptr (stmt
), callback_op
, wi
,
303 ret
= walk_gimple_asm (as_a
<gasm
*> (stmt
), callback_op
, wi
);
308 case GIMPLE_OMP_CONTINUE
:
310 gomp_continue
*cont_stmt
= as_a
<gomp_continue
*> (stmt
);
311 ret
= walk_tree (gimple_omp_continue_control_def_ptr (cont_stmt
),
312 callback_op
, wi
, pset
);
316 ret
= walk_tree (gimple_omp_continue_control_use_ptr (cont_stmt
),
317 callback_op
, wi
, pset
);
323 case GIMPLE_OMP_CRITICAL
:
325 gomp_critical
*omp_stmt
= as_a
<gomp_critical
*> (stmt
);
326 ret
= walk_tree (gimple_omp_critical_name_ptr (omp_stmt
),
327 callback_op
, wi
, pset
);
334 ret
= walk_tree (gimple_omp_for_clauses_ptr (stmt
), callback_op
, wi
,
338 for (i
= 0; i
< gimple_omp_for_collapse (stmt
); i
++)
340 ret
= walk_tree (gimple_omp_for_index_ptr (stmt
, i
), callback_op
,
344 ret
= walk_tree (gimple_omp_for_initial_ptr (stmt
, i
), callback_op
,
348 ret
= walk_tree (gimple_omp_for_final_ptr (stmt
, i
), callback_op
,
352 ret
= walk_tree (gimple_omp_for_incr_ptr (stmt
, i
), callback_op
,
359 case GIMPLE_OMP_PARALLEL
:
361 gomp_parallel
*omp_par_stmt
= as_a
<gomp_parallel
*> (stmt
);
362 ret
= walk_tree (gimple_omp_parallel_clauses_ptr (omp_par_stmt
),
363 callback_op
, wi
, pset
);
366 ret
= walk_tree (gimple_omp_parallel_child_fn_ptr (omp_par_stmt
),
367 callback_op
, wi
, pset
);
370 ret
= walk_tree (gimple_omp_parallel_data_arg_ptr (omp_par_stmt
),
371 callback_op
, wi
, pset
);
377 case GIMPLE_OMP_TASK
:
378 ret
= walk_tree (gimple_omp_task_clauses_ptr (stmt
), callback_op
,
382 ret
= walk_tree (gimple_omp_task_child_fn_ptr (stmt
), callback_op
,
386 ret
= walk_tree (gimple_omp_task_data_arg_ptr (stmt
), callback_op
,
390 ret
= walk_tree (gimple_omp_task_copy_fn_ptr (stmt
), callback_op
,
394 ret
= walk_tree (gimple_omp_task_arg_size_ptr (stmt
), callback_op
,
398 ret
= walk_tree (gimple_omp_task_arg_align_ptr (stmt
), callback_op
,
404 case GIMPLE_OMP_SECTIONS
:
405 ret
= walk_tree (gimple_omp_sections_clauses_ptr (stmt
), callback_op
,
409 ret
= walk_tree (gimple_omp_sections_control_ptr (stmt
), callback_op
,
416 case GIMPLE_OMP_SINGLE
:
417 ret
= walk_tree (gimple_omp_single_clauses_ptr (stmt
), callback_op
, wi
,
423 case GIMPLE_OMP_TARGET
:
425 gomp_target
*omp_stmt
= as_a
<gomp_target
*> (stmt
);
426 ret
= walk_tree (gimple_omp_target_clauses_ptr (omp_stmt
),
427 callback_op
, wi
, pset
);
430 ret
= walk_tree (gimple_omp_target_child_fn_ptr (omp_stmt
),
431 callback_op
, wi
, pset
);
434 ret
= walk_tree (gimple_omp_target_data_arg_ptr (omp_stmt
),
435 callback_op
, wi
, pset
);
441 case GIMPLE_OMP_TEAMS
:
442 ret
= walk_tree (gimple_omp_teams_clauses_ptr (stmt
), callback_op
, wi
,
448 case GIMPLE_OMP_ATOMIC_LOAD
:
450 gomp_atomic_load
*omp_stmt
= as_a
<gomp_atomic_load
*> (stmt
);
451 ret
= walk_tree (gimple_omp_atomic_load_lhs_ptr (omp_stmt
),
452 callback_op
, wi
, pset
);
455 ret
= walk_tree (gimple_omp_atomic_load_rhs_ptr (omp_stmt
),
456 callback_op
, wi
, pset
);
462 case GIMPLE_OMP_ATOMIC_STORE
:
464 gomp_atomic_store
*omp_stmt
= as_a
<gomp_atomic_store
*> (stmt
);
465 ret
= walk_tree (gimple_omp_atomic_store_val_ptr (omp_stmt
),
466 callback_op
, wi
, pset
);
472 case GIMPLE_TRANSACTION
:
473 ret
= walk_tree (gimple_transaction_label_ptr (
474 as_a
<gtransaction
*> (stmt
)),
475 callback_op
, wi
, pset
);
480 case GIMPLE_OMP_RETURN
:
481 ret
= walk_tree (gimple_omp_return_lhs_ptr (stmt
), callback_op
, wi
,
487 /* Tuples that do not have operands. */
495 enum gimple_statement_structure_enum gss
;
496 gss
= gimple_statement_structure (stmt
);
497 if (gss
== GSS_WITH_OPS
|| gss
== GSS_WITH_MEM_OPS
)
498 for (i
= 0; i
< gimple_num_ops (stmt
); i
++)
500 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
, pset
);
512 /* Walk the current statement in GSI (optionally using traversal state
513 stored in WI). If WI is NULL, no state is kept during traversal.
514 The callback CALLBACK_STMT is called. If CALLBACK_STMT indicates
515 that it has handled all the operands of the statement, its return
516 value is returned. Otherwise, the return value from CALLBACK_STMT
517 is discarded and its operands are scanned.
519 If CALLBACK_STMT is NULL or it didn't handle the operands,
520 CALLBACK_OP is called on each operand of the statement via
521 walk_gimple_op. If walk_gimple_op returns non-NULL for any
522 operand, the remaining operands are not scanned. In this case, the
523 return value from CALLBACK_OP is returned.
525 In any other case, NULL_TREE is returned. */
528 walk_gimple_stmt (gimple_stmt_iterator
*gsi
, walk_stmt_fn callback_stmt
,
529 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
533 gimple stmt
= gsi_stmt (*gsi
);
538 wi
->removed_stmt
= false;
540 if (wi
->want_locations
&& gimple_has_location (stmt
))
541 input_location
= gimple_location (stmt
);
546 /* Invoke the statement callback. Return if the callback handled
547 all of STMT operands by itself. */
550 bool handled_ops
= false;
551 tree_ret
= callback_stmt (gsi
, &handled_ops
, wi
);
555 /* If CALLBACK_STMT did not handle operands, it should not have
556 a value to return. */
557 gcc_assert (tree_ret
== NULL
);
559 if (wi
&& wi
->removed_stmt
)
562 /* Re-read stmt in case the callback changed it. */
563 stmt
= gsi_stmt (*gsi
);
566 /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */
569 tree_ret
= walk_gimple_op (stmt
, callback_op
, wi
);
574 /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */
575 switch (gimple_code (stmt
))
578 ret
= walk_gimple_seq_mod (gimple_bind_body_ptr (as_a
<gbind
*> (stmt
)),
579 callback_stmt
, callback_op
, wi
);
581 return wi
->callback_result
;
585 ret
= walk_gimple_seq_mod (gimple_catch_handler_ptr (
586 as_a
<gcatch
*> (stmt
)),
587 callback_stmt
, callback_op
, wi
);
589 return wi
->callback_result
;
592 case GIMPLE_EH_FILTER
:
593 ret
= walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt
), callback_stmt
,
596 return wi
->callback_result
;
601 geh_else
*eh_else_stmt
= as_a
<geh_else
*> (stmt
);
602 ret
= walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (eh_else_stmt
),
603 callback_stmt
, callback_op
, wi
);
605 return wi
->callback_result
;
606 ret
= walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (eh_else_stmt
),
607 callback_stmt
, callback_op
, wi
);
609 return wi
->callback_result
;
614 ret
= walk_gimple_seq_mod (gimple_try_eval_ptr (stmt
), callback_stmt
, callback_op
,
617 return wi
->callback_result
;
619 ret
= walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt
), callback_stmt
,
622 return wi
->callback_result
;
626 ret
= walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt
), callback_stmt
,
629 return wi
->callback_result
;
632 case GIMPLE_OMP_CRITICAL
:
633 case GIMPLE_OMP_MASTER
:
634 case GIMPLE_OMP_TASKGROUP
:
635 case GIMPLE_OMP_ORDERED
:
636 case GIMPLE_OMP_SECTION
:
637 case GIMPLE_OMP_PARALLEL
:
638 case GIMPLE_OMP_TASK
:
639 case GIMPLE_OMP_SECTIONS
:
640 case GIMPLE_OMP_SINGLE
:
641 case GIMPLE_OMP_TARGET
:
642 case GIMPLE_OMP_TEAMS
:
643 ret
= walk_gimple_seq_mod (gimple_omp_body_ptr (stmt
), callback_stmt
,
646 return wi
->callback_result
;
649 case GIMPLE_WITH_CLEANUP_EXPR
:
650 ret
= walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt
), callback_stmt
,
653 return wi
->callback_result
;
656 case GIMPLE_TRANSACTION
:
657 ret
= walk_gimple_seq_mod (gimple_transaction_body_ptr (
658 as_a
<gtransaction
*> (stmt
)),
659 callback_stmt
, callback_op
, wi
);
661 return wi
->callback_result
;
665 gcc_assert (!gimple_has_substatements (stmt
));
672 /* From a tree operand OP return the base of a load or store operation
673 or NULL_TREE if OP is not a load or a store. */
676 get_base_loadstore (tree op
)
678 while (handled_component_p (op
))
679 op
= TREE_OPERAND (op
, 0);
681 || INDIRECT_REF_P (op
)
682 || TREE_CODE (op
) == MEM_REF
683 || TREE_CODE (op
) == TARGET_MEM_REF
)
689 /* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
690 VISIT_ADDR if non-NULL on loads, store and address-taken operands
691 passing the STMT, the base of the operand, the operand itself containing
692 the base and DATA to it. The base will be either a decl, an indirect
693 reference (including TARGET_MEM_REF) or the argument of an address
695 Returns the results of these callbacks or'ed. */
698 walk_stmt_load_store_addr_ops (gimple stmt
, void *data
,
699 walk_stmt_load_store_addr_fn visit_load
,
700 walk_stmt_load_store_addr_fn visit_store
,
701 walk_stmt_load_store_addr_fn visit_addr
)
705 if (gimple_assign_single_p (stmt
))
710 arg
= gimple_assign_lhs (stmt
);
711 lhs
= get_base_loadstore (arg
);
713 ret
|= visit_store (stmt
, lhs
, arg
, data
);
715 arg
= gimple_assign_rhs1 (stmt
);
717 while (handled_component_p (rhs
))
718 rhs
= TREE_OPERAND (rhs
, 0);
721 if (TREE_CODE (rhs
) == ADDR_EXPR
)
722 ret
|= visit_addr (stmt
, TREE_OPERAND (rhs
, 0), arg
, data
);
723 else if (TREE_CODE (rhs
) == TARGET_MEM_REF
724 && TREE_CODE (TMR_BASE (rhs
)) == ADDR_EXPR
)
725 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (rhs
), 0), arg
,
727 else if (TREE_CODE (rhs
) == OBJ_TYPE_REF
728 && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs
)) == ADDR_EXPR
)
729 ret
|= visit_addr (stmt
, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs
),
731 else if (TREE_CODE (rhs
) == CONSTRUCTOR
)
736 FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs
), ix
, val
)
737 if (TREE_CODE (val
) == ADDR_EXPR
)
738 ret
|= visit_addr (stmt
, TREE_OPERAND (val
, 0), arg
, data
);
739 else if (TREE_CODE (val
) == OBJ_TYPE_REF
740 && TREE_CODE (OBJ_TYPE_REF_OBJECT (val
)) == ADDR_EXPR
)
741 ret
|= visit_addr (stmt
,
742 TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val
),
745 lhs
= gimple_assign_lhs (stmt
);
746 if (TREE_CODE (lhs
) == TARGET_MEM_REF
747 && TREE_CODE (TMR_BASE (lhs
)) == ADDR_EXPR
)
748 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (lhs
), 0), lhs
, data
);
752 rhs
= get_base_loadstore (rhs
);
754 ret
|= visit_load (stmt
, rhs
, arg
, data
);
758 && (is_gimple_assign (stmt
)
759 || gimple_code (stmt
) == GIMPLE_COND
))
761 for (i
= 0; i
< gimple_num_ops (stmt
); ++i
)
763 tree op
= gimple_op (stmt
, i
);
766 else if (TREE_CODE (op
) == ADDR_EXPR
)
767 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
768 /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
769 tree with two operands. */
770 else if (i
== 1 && COMPARISON_CLASS_P (op
))
772 if (TREE_CODE (TREE_OPERAND (op
, 0)) == ADDR_EXPR
)
773 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 0),
775 if (TREE_CODE (TREE_OPERAND (op
, 1)) == ADDR_EXPR
)
776 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 1),
781 else if (gcall
*call_stmt
= dyn_cast
<gcall
*> (stmt
))
785 tree arg
= gimple_call_lhs (call_stmt
);
788 tree lhs
= get_base_loadstore (arg
);
790 ret
|= visit_store (stmt
, lhs
, arg
, data
);
793 if (visit_load
|| visit_addr
)
794 for (i
= 0; i
< gimple_call_num_args (call_stmt
); ++i
)
796 tree arg
= gimple_call_arg (call_stmt
, i
);
798 && TREE_CODE (arg
) == ADDR_EXPR
)
799 ret
|= visit_addr (stmt
, TREE_OPERAND (arg
, 0), arg
, data
);
802 tree rhs
= get_base_loadstore (arg
);
804 ret
|= visit_load (stmt
, rhs
, arg
, data
);
808 && gimple_call_chain (call_stmt
)
809 && TREE_CODE (gimple_call_chain (call_stmt
)) == ADDR_EXPR
)
810 ret
|= visit_addr (stmt
, TREE_OPERAND (gimple_call_chain (call_stmt
), 0),
811 gimple_call_chain (call_stmt
), data
);
813 && gimple_call_return_slot_opt_p (call_stmt
)
814 && gimple_call_lhs (call_stmt
) != NULL_TREE
815 && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call_stmt
))))
816 ret
|= visit_addr (stmt
, gimple_call_lhs (call_stmt
),
817 gimple_call_lhs (call_stmt
), data
);
819 else if (gasm
*asm_stmt
= dyn_cast
<gasm
*> (stmt
))
822 const char *constraint
;
823 const char **oconstraints
;
824 bool allows_mem
, allows_reg
, is_inout
;
825 noutputs
= gimple_asm_noutputs (asm_stmt
);
826 oconstraints
= XALLOCAVEC (const char *, noutputs
);
827 if (visit_store
|| visit_addr
)
828 for (i
= 0; i
< gimple_asm_noutputs (asm_stmt
); ++i
)
830 tree link
= gimple_asm_output_op (asm_stmt
, i
);
831 tree op
= get_base_loadstore (TREE_VALUE (link
));
832 if (op
&& visit_store
)
833 ret
|= visit_store (stmt
, op
, TREE_VALUE (link
), data
);
836 constraint
= TREE_STRING_POINTER
837 (TREE_VALUE (TREE_PURPOSE (link
)));
838 oconstraints
[i
] = constraint
;
839 parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
,
840 &allows_reg
, &is_inout
);
841 if (op
&& !allows_reg
&& allows_mem
)
842 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
), data
);
845 if (visit_load
|| visit_addr
)
846 for (i
= 0; i
< gimple_asm_ninputs (asm_stmt
); ++i
)
848 tree link
= gimple_asm_input_op (asm_stmt
, i
);
849 tree op
= TREE_VALUE (link
);
851 && TREE_CODE (op
) == ADDR_EXPR
)
852 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
853 else if (visit_load
|| visit_addr
)
855 op
= get_base_loadstore (op
);
859 ret
|= visit_load (stmt
, op
, TREE_VALUE (link
), data
);
862 constraint
= TREE_STRING_POINTER
863 (TREE_VALUE (TREE_PURPOSE (link
)));
864 parse_input_constraint (&constraint
, 0, 0, noutputs
,
866 &allows_mem
, &allows_reg
);
867 if (!allows_reg
&& allows_mem
)
868 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
),
875 else if (greturn
*return_stmt
= dyn_cast
<greturn
*> (stmt
))
877 tree op
= gimple_return_retval (return_stmt
);
881 && TREE_CODE (op
) == ADDR_EXPR
)
882 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
885 tree base
= get_base_loadstore (op
);
887 ret
|= visit_load (stmt
, base
, op
, data
);
892 && gimple_code (stmt
) == GIMPLE_PHI
)
894 for (i
= 0; i
< gimple_phi_num_args (stmt
); ++i
)
896 tree op
= gimple_phi_arg_def (stmt
, i
);
897 if (TREE_CODE (op
) == ADDR_EXPR
)
898 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
902 && gimple_code (stmt
) == GIMPLE_GOTO
)
904 tree op
= gimple_goto_dest (stmt
);
905 if (TREE_CODE (op
) == ADDR_EXPR
)
906 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
912 /* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP
913 should make a faster clone for this case. */
916 walk_stmt_load_store_ops (gimple stmt
, void *data
,
917 walk_stmt_load_store_addr_fn visit_load
,
918 walk_stmt_load_store_addr_fn visit_store
)
920 return walk_stmt_load_store_addr_ops (stmt
, data
,
921 visit_load
, visit_store
, NULL
);