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"
30 #include "hard-reg-set.h"
32 #include "gimple-expr.h"
33 #include "tree-ssa-alias.h"
34 #include "basic-block.h"
35 #include "fold-const.h"
37 #include "gimple-iterator.h"
38 #include "gimple-walk.h"
41 /* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt
42 on each one. WI is as in walk_gimple_stmt.
44 If walk_gimple_stmt returns non-NULL, the walk is stopped, and the
45 value is stored in WI->CALLBACK_RESULT. Also, the statement that
46 produced the value is returned if this statement has not been
47 removed by a callback (wi->removed_stmt). If the statement has
48 been removed, NULL is returned.
50 Otherwise, all the statements are walked and NULL returned. */
53 walk_gimple_seq_mod (gimple_seq
*pseq
, walk_stmt_fn callback_stmt
,
54 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
56 gimple_stmt_iterator gsi
;
58 for (gsi
= gsi_start (*pseq
); !gsi_end_p (gsi
); )
60 tree ret
= walk_gimple_stmt (&gsi
, callback_stmt
, callback_op
, wi
);
63 /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist
66 wi
->callback_result
= ret
;
68 return wi
->removed_stmt
? NULL
: gsi_stmt (gsi
);
71 if (!wi
->removed_stmt
)
76 wi
->callback_result
= NULL_TREE
;
82 /* Like walk_gimple_seq_mod, but ensure that the head of SEQ isn't
83 changed by the callbacks. */
86 walk_gimple_seq (gimple_seq seq
, walk_stmt_fn callback_stmt
,
87 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
89 gimple_seq seq2
= seq
;
90 gimple ret
= walk_gimple_seq_mod (&seq2
, callback_stmt
, callback_op
, wi
);
91 gcc_assert (seq2
== seq
);
96 /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */
99 walk_gimple_asm (gasm
*stmt
, walk_tree_fn callback_op
,
100 struct walk_stmt_info
*wi
)
104 const char **oconstraints
;
106 const char *constraint
;
107 bool allows_mem
, allows_reg
, is_inout
;
109 noutputs
= gimple_asm_noutputs (stmt
);
110 oconstraints
= (const char **) alloca ((noutputs
) * sizeof (const char *));
115 for (i
= 0; i
< noutputs
; i
++)
117 op
= gimple_asm_output_op (stmt
, i
);
118 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
119 oconstraints
[i
] = constraint
;
122 if (parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
,
123 &allows_reg
, &is_inout
))
124 wi
->val_only
= (allows_reg
|| !allows_mem
);
126 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
131 n
= gimple_asm_ninputs (stmt
);
132 for (i
= 0; i
< n
; i
++)
134 op
= gimple_asm_input_op (stmt
, i
);
135 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op
)));
139 if (parse_input_constraint (&constraint
, 0, 0, noutputs
, 0,
140 oconstraints
, &allows_mem
, &allows_reg
))
142 wi
->val_only
= (allows_reg
|| !allows_mem
);
143 /* Although input "m" is not really a LHS, we need a lvalue. */
144 wi
->is_lhs
= !wi
->val_only
;
147 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
158 n
= gimple_asm_nlabels (stmt
);
159 for (i
= 0; i
< n
; i
++)
161 op
= gimple_asm_label_op (stmt
, i
);
162 ret
= walk_tree (&TREE_VALUE (op
), callback_op
, wi
, NULL
);
171 /* Helper function of WALK_GIMPLE_STMT. Walk every tree operand in
172 STMT. CALLBACK_OP and WI are as in WALK_GIMPLE_STMT.
174 CALLBACK_OP is called on each operand of STMT via walk_tree.
175 Additional parameters to walk_tree must be stored in WI. For each operand
176 OP, walk_tree is called as:
178 walk_tree (&OP, CALLBACK_OP, WI, WI->PSET)
180 If CALLBACK_OP returns non-NULL for an operand, the remaining
181 operands are not scanned.
183 The return value is that returned by the last call to walk_tree, or
184 NULL_TREE if no CALLBACK_OP is specified. */
187 walk_gimple_op (gimple stmt
, walk_tree_fn callback_op
,
188 struct walk_stmt_info
*wi
)
190 hash_set
<tree
> *pset
= (wi
) ? wi
->pset
: NULL
;
192 tree ret
= NULL_TREE
;
194 switch (gimple_code (stmt
))
197 /* Walk the RHS operands. If the LHS is of a non-renamable type or
198 is a register variable, we may use a COMPONENT_REF on the RHS. */
201 tree lhs
= gimple_assign_lhs (stmt
);
203 = (is_gimple_reg_type (TREE_TYPE (lhs
)) && !is_gimple_reg (lhs
))
204 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
207 for (i
= 1; i
< gimple_num_ops (stmt
); i
++)
209 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
,
215 /* Walk the LHS. If the RHS is appropriate for a memory, we
216 may use a COMPONENT_REF on the LHS. */
219 /* If the RHS is of a non-renamable type or is a register variable,
220 we may use a COMPONENT_REF on the LHS. */
221 tree rhs1
= gimple_assign_rhs1 (stmt
);
223 = (is_gimple_reg_type (TREE_TYPE (rhs1
)) && !is_gimple_reg (rhs1
))
224 || gimple_assign_rhs_class (stmt
) != GIMPLE_SINGLE_RHS
;
228 ret
= walk_tree (gimple_op_ptr (stmt
, 0), callback_op
, wi
, pset
);
246 ret
= walk_tree (gimple_call_chain_ptr (as_a
<gcall
*> (stmt
)),
247 callback_op
, wi
, pset
);
251 ret
= walk_tree (gimple_call_fn_ptr (stmt
), callback_op
, wi
, pset
);
255 for (i
= 0; i
< gimple_call_num_args (stmt
); i
++)
259 = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt
, i
)));
260 ret
= walk_tree (gimple_call_arg_ptr (stmt
, i
), callback_op
, wi
,
266 if (gimple_call_lhs (stmt
))
272 = is_gimple_reg_type (TREE_TYPE (gimple_call_lhs (stmt
)));
275 ret
= walk_tree (gimple_call_lhs_ptr (stmt
), callback_op
, wi
, pset
);
288 ret
= walk_tree (gimple_catch_types_ptr (as_a
<gcatch
*> (stmt
)),
289 callback_op
, wi
, pset
);
294 case GIMPLE_EH_FILTER
:
295 ret
= walk_tree (gimple_eh_filter_types_ptr (stmt
), callback_op
, wi
,
302 ret
= walk_gimple_asm (as_a
<gasm
*> (stmt
), callback_op
, wi
);
307 case GIMPLE_OMP_CONTINUE
:
309 gomp_continue
*cont_stmt
= as_a
<gomp_continue
*> (stmt
);
310 ret
= walk_tree (gimple_omp_continue_control_def_ptr (cont_stmt
),
311 callback_op
, wi
, pset
);
315 ret
= walk_tree (gimple_omp_continue_control_use_ptr (cont_stmt
),
316 callback_op
, wi
, pset
);
322 case GIMPLE_OMP_CRITICAL
:
324 gomp_critical
*omp_stmt
= as_a
<gomp_critical
*> (stmt
);
325 ret
= walk_tree (gimple_omp_critical_name_ptr (omp_stmt
),
326 callback_op
, wi
, pset
);
333 ret
= walk_tree (gimple_omp_for_clauses_ptr (stmt
), callback_op
, wi
,
337 for (i
= 0; i
< gimple_omp_for_collapse (stmt
); i
++)
339 ret
= walk_tree (gimple_omp_for_index_ptr (stmt
, i
), callback_op
,
343 ret
= walk_tree (gimple_omp_for_initial_ptr (stmt
, i
), callback_op
,
347 ret
= walk_tree (gimple_omp_for_final_ptr (stmt
, i
), callback_op
,
351 ret
= walk_tree (gimple_omp_for_incr_ptr (stmt
, i
), callback_op
,
358 case GIMPLE_OMP_PARALLEL
:
360 gomp_parallel
*omp_par_stmt
= as_a
<gomp_parallel
*> (stmt
);
361 ret
= walk_tree (gimple_omp_parallel_clauses_ptr (omp_par_stmt
),
362 callback_op
, wi
, pset
);
365 ret
= walk_tree (gimple_omp_parallel_child_fn_ptr (omp_par_stmt
),
366 callback_op
, wi
, pset
);
369 ret
= walk_tree (gimple_omp_parallel_data_arg_ptr (omp_par_stmt
),
370 callback_op
, wi
, pset
);
376 case GIMPLE_OMP_TASK
:
377 ret
= walk_tree (gimple_omp_task_clauses_ptr (stmt
), callback_op
,
381 ret
= walk_tree (gimple_omp_task_child_fn_ptr (stmt
), callback_op
,
385 ret
= walk_tree (gimple_omp_task_data_arg_ptr (stmt
), callback_op
,
389 ret
= walk_tree (gimple_omp_task_copy_fn_ptr (stmt
), callback_op
,
393 ret
= walk_tree (gimple_omp_task_arg_size_ptr (stmt
), callback_op
,
397 ret
= walk_tree (gimple_omp_task_arg_align_ptr (stmt
), callback_op
,
403 case GIMPLE_OMP_SECTIONS
:
404 ret
= walk_tree (gimple_omp_sections_clauses_ptr (stmt
), callback_op
,
408 ret
= walk_tree (gimple_omp_sections_control_ptr (stmt
), callback_op
,
415 case GIMPLE_OMP_SINGLE
:
416 ret
= walk_tree (gimple_omp_single_clauses_ptr (stmt
), callback_op
, wi
,
422 case GIMPLE_OMP_TARGET
:
424 gomp_target
*omp_stmt
= as_a
<gomp_target
*> (stmt
);
425 ret
= walk_tree (gimple_omp_target_clauses_ptr (omp_stmt
),
426 callback_op
, wi
, pset
);
429 ret
= walk_tree (gimple_omp_target_child_fn_ptr (omp_stmt
),
430 callback_op
, wi
, pset
);
433 ret
= walk_tree (gimple_omp_target_data_arg_ptr (omp_stmt
),
434 callback_op
, wi
, pset
);
440 case GIMPLE_OMP_TEAMS
:
441 ret
= walk_tree (gimple_omp_teams_clauses_ptr (stmt
), callback_op
, wi
,
447 case GIMPLE_OMP_ATOMIC_LOAD
:
449 gomp_atomic_load
*omp_stmt
= as_a
<gomp_atomic_load
*> (stmt
);
450 ret
= walk_tree (gimple_omp_atomic_load_lhs_ptr (omp_stmt
),
451 callback_op
, wi
, pset
);
454 ret
= walk_tree (gimple_omp_atomic_load_rhs_ptr (omp_stmt
),
455 callback_op
, wi
, pset
);
461 case GIMPLE_OMP_ATOMIC_STORE
:
463 gomp_atomic_store
*omp_stmt
= as_a
<gomp_atomic_store
*> (stmt
);
464 ret
= walk_tree (gimple_omp_atomic_store_val_ptr (omp_stmt
),
465 callback_op
, wi
, pset
);
471 case GIMPLE_TRANSACTION
:
472 ret
= walk_tree (gimple_transaction_label_ptr (
473 as_a
<gtransaction
*> (stmt
)),
474 callback_op
, wi
, pset
);
479 case GIMPLE_OMP_RETURN
:
480 ret
= walk_tree (gimple_omp_return_lhs_ptr (stmt
), callback_op
, wi
,
486 /* Tuples that do not have operands. */
494 enum gimple_statement_structure_enum gss
;
495 gss
= gimple_statement_structure (stmt
);
496 if (gss
== GSS_WITH_OPS
|| gss
== GSS_WITH_MEM_OPS
)
497 for (i
= 0; i
< gimple_num_ops (stmt
); i
++)
499 ret
= walk_tree (gimple_op_ptr (stmt
, i
), callback_op
, wi
, pset
);
511 /* Walk the current statement in GSI (optionally using traversal state
512 stored in WI). If WI is NULL, no state is kept during traversal.
513 The callback CALLBACK_STMT is called. If CALLBACK_STMT indicates
514 that it has handled all the operands of the statement, its return
515 value is returned. Otherwise, the return value from CALLBACK_STMT
516 is discarded and its operands are scanned.
518 If CALLBACK_STMT is NULL or it didn't handle the operands,
519 CALLBACK_OP is called on each operand of the statement via
520 walk_gimple_op. If walk_gimple_op returns non-NULL for any
521 operand, the remaining operands are not scanned. In this case, the
522 return value from CALLBACK_OP is returned.
524 In any other case, NULL_TREE is returned. */
527 walk_gimple_stmt (gimple_stmt_iterator
*gsi
, walk_stmt_fn callback_stmt
,
528 walk_tree_fn callback_op
, struct walk_stmt_info
*wi
)
532 gimple stmt
= gsi_stmt (*gsi
);
537 wi
->removed_stmt
= false;
539 if (wi
->want_locations
&& gimple_has_location (stmt
))
540 input_location
= gimple_location (stmt
);
545 /* Invoke the statement callback. Return if the callback handled
546 all of STMT operands by itself. */
549 bool handled_ops
= false;
550 tree_ret
= callback_stmt (gsi
, &handled_ops
, wi
);
554 /* If CALLBACK_STMT did not handle operands, it should not have
555 a value to return. */
556 gcc_assert (tree_ret
== NULL
);
558 if (wi
&& wi
->removed_stmt
)
561 /* Re-read stmt in case the callback changed it. */
562 stmt
= gsi_stmt (*gsi
);
565 /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */
568 tree_ret
= walk_gimple_op (stmt
, callback_op
, wi
);
573 /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */
574 switch (gimple_code (stmt
))
577 ret
= walk_gimple_seq_mod (gimple_bind_body_ptr (as_a
<gbind
*> (stmt
)),
578 callback_stmt
, callback_op
, wi
);
580 return wi
->callback_result
;
584 ret
= walk_gimple_seq_mod (gimple_catch_handler_ptr (
585 as_a
<gcatch
*> (stmt
)),
586 callback_stmt
, callback_op
, wi
);
588 return wi
->callback_result
;
591 case GIMPLE_EH_FILTER
:
592 ret
= walk_gimple_seq_mod (gimple_eh_filter_failure_ptr (stmt
), callback_stmt
,
595 return wi
->callback_result
;
600 geh_else
*eh_else_stmt
= as_a
<geh_else
*> (stmt
);
601 ret
= walk_gimple_seq_mod (gimple_eh_else_n_body_ptr (eh_else_stmt
),
602 callback_stmt
, callback_op
, wi
);
604 return wi
->callback_result
;
605 ret
= walk_gimple_seq_mod (gimple_eh_else_e_body_ptr (eh_else_stmt
),
606 callback_stmt
, callback_op
, wi
);
608 return wi
->callback_result
;
613 ret
= walk_gimple_seq_mod (gimple_try_eval_ptr (stmt
), callback_stmt
, callback_op
,
616 return wi
->callback_result
;
618 ret
= walk_gimple_seq_mod (gimple_try_cleanup_ptr (stmt
), callback_stmt
,
621 return wi
->callback_result
;
625 ret
= walk_gimple_seq_mod (gimple_omp_for_pre_body_ptr (stmt
), callback_stmt
,
628 return wi
->callback_result
;
631 case GIMPLE_OMP_CRITICAL
:
632 case GIMPLE_OMP_MASTER
:
633 case GIMPLE_OMP_TASKGROUP
:
634 case GIMPLE_OMP_ORDERED
:
635 case GIMPLE_OMP_SECTION
:
636 case GIMPLE_OMP_PARALLEL
:
637 case GIMPLE_OMP_TASK
:
638 case GIMPLE_OMP_SECTIONS
:
639 case GIMPLE_OMP_SINGLE
:
640 case GIMPLE_OMP_TARGET
:
641 case GIMPLE_OMP_TEAMS
:
642 ret
= walk_gimple_seq_mod (gimple_omp_body_ptr (stmt
), callback_stmt
,
645 return wi
->callback_result
;
648 case GIMPLE_WITH_CLEANUP_EXPR
:
649 ret
= walk_gimple_seq_mod (gimple_wce_cleanup_ptr (stmt
), callback_stmt
,
652 return wi
->callback_result
;
655 case GIMPLE_TRANSACTION
:
656 ret
= walk_gimple_seq_mod (gimple_transaction_body_ptr (
657 as_a
<gtransaction
*> (stmt
)),
658 callback_stmt
, callback_op
, wi
);
660 return wi
->callback_result
;
664 gcc_assert (!gimple_has_substatements (stmt
));
671 /* From a tree operand OP return the base of a load or store operation
672 or NULL_TREE if OP is not a load or a store. */
675 get_base_loadstore (tree op
)
677 while (handled_component_p (op
))
678 op
= TREE_OPERAND (op
, 0);
680 || INDIRECT_REF_P (op
)
681 || TREE_CODE (op
) == MEM_REF
682 || TREE_CODE (op
) == TARGET_MEM_REF
)
688 /* For the statement STMT call the callbacks VISIT_LOAD, VISIT_STORE and
689 VISIT_ADDR if non-NULL on loads, store and address-taken operands
690 passing the STMT, the base of the operand, the operand itself containing
691 the base and DATA to it. The base will be either a decl, an indirect
692 reference (including TARGET_MEM_REF) or the argument of an address
694 Returns the results of these callbacks or'ed. */
697 walk_stmt_load_store_addr_ops (gimple stmt
, void *data
,
698 walk_stmt_load_store_addr_fn visit_load
,
699 walk_stmt_load_store_addr_fn visit_store
,
700 walk_stmt_load_store_addr_fn visit_addr
)
704 if (gimple_assign_single_p (stmt
))
709 arg
= gimple_assign_lhs (stmt
);
710 lhs
= get_base_loadstore (arg
);
712 ret
|= visit_store (stmt
, lhs
, arg
, data
);
714 arg
= gimple_assign_rhs1 (stmt
);
716 while (handled_component_p (rhs
))
717 rhs
= TREE_OPERAND (rhs
, 0);
720 if (TREE_CODE (rhs
) == ADDR_EXPR
)
721 ret
|= visit_addr (stmt
, TREE_OPERAND (rhs
, 0), arg
, data
);
722 else if (TREE_CODE (rhs
) == TARGET_MEM_REF
723 && TREE_CODE (TMR_BASE (rhs
)) == ADDR_EXPR
)
724 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (rhs
), 0), arg
,
726 else if (TREE_CODE (rhs
) == OBJ_TYPE_REF
727 && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs
)) == ADDR_EXPR
)
728 ret
|= visit_addr (stmt
, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs
),
730 else if (TREE_CODE (rhs
) == CONSTRUCTOR
)
735 FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs
), ix
, val
)
736 if (TREE_CODE (val
) == ADDR_EXPR
)
737 ret
|= visit_addr (stmt
, TREE_OPERAND (val
, 0), arg
, data
);
738 else if (TREE_CODE (val
) == OBJ_TYPE_REF
739 && TREE_CODE (OBJ_TYPE_REF_OBJECT (val
)) == ADDR_EXPR
)
740 ret
|= visit_addr (stmt
,
741 TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val
),
744 lhs
= gimple_assign_lhs (stmt
);
745 if (TREE_CODE (lhs
) == TARGET_MEM_REF
746 && TREE_CODE (TMR_BASE (lhs
)) == ADDR_EXPR
)
747 ret
|= visit_addr (stmt
, TREE_OPERAND (TMR_BASE (lhs
), 0), lhs
, data
);
751 rhs
= get_base_loadstore (rhs
);
753 ret
|= visit_load (stmt
, rhs
, arg
, data
);
757 && (is_gimple_assign (stmt
)
758 || gimple_code (stmt
) == GIMPLE_COND
))
760 for (i
= 0; i
< gimple_num_ops (stmt
); ++i
)
762 tree op
= gimple_op (stmt
, i
);
765 else if (TREE_CODE (op
) == ADDR_EXPR
)
766 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
767 /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
768 tree with two operands. */
769 else if (i
== 1 && COMPARISON_CLASS_P (op
))
771 if (TREE_CODE (TREE_OPERAND (op
, 0)) == ADDR_EXPR
)
772 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 0),
774 if (TREE_CODE (TREE_OPERAND (op
, 1)) == ADDR_EXPR
)
775 ret
|= visit_addr (stmt
, TREE_OPERAND (TREE_OPERAND (op
, 1),
780 else if (gcall
*call_stmt
= dyn_cast
<gcall
*> (stmt
))
784 tree arg
= gimple_call_lhs (call_stmt
);
787 tree lhs
= get_base_loadstore (arg
);
789 ret
|= visit_store (stmt
, lhs
, arg
, data
);
792 if (visit_load
|| visit_addr
)
793 for (i
= 0; i
< gimple_call_num_args (call_stmt
); ++i
)
795 tree arg
= gimple_call_arg (call_stmt
, i
);
797 && TREE_CODE (arg
) == ADDR_EXPR
)
798 ret
|= visit_addr (stmt
, TREE_OPERAND (arg
, 0), arg
, data
);
801 tree rhs
= get_base_loadstore (arg
);
803 ret
|= visit_load (stmt
, rhs
, arg
, data
);
807 && gimple_call_chain (call_stmt
)
808 && TREE_CODE (gimple_call_chain (call_stmt
)) == ADDR_EXPR
)
809 ret
|= visit_addr (stmt
, TREE_OPERAND (gimple_call_chain (call_stmt
), 0),
810 gimple_call_chain (call_stmt
), data
);
812 && gimple_call_return_slot_opt_p (call_stmt
)
813 && gimple_call_lhs (call_stmt
) != NULL_TREE
814 && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call_stmt
))))
815 ret
|= visit_addr (stmt
, gimple_call_lhs (call_stmt
),
816 gimple_call_lhs (call_stmt
), data
);
818 else if (gasm
*asm_stmt
= dyn_cast
<gasm
*> (stmt
))
821 const char *constraint
;
822 const char **oconstraints
;
823 bool allows_mem
, allows_reg
, is_inout
;
824 noutputs
= gimple_asm_noutputs (asm_stmt
);
825 oconstraints
= XALLOCAVEC (const char *, noutputs
);
826 if (visit_store
|| visit_addr
)
827 for (i
= 0; i
< gimple_asm_noutputs (asm_stmt
); ++i
)
829 tree link
= gimple_asm_output_op (asm_stmt
, i
);
830 tree op
= get_base_loadstore (TREE_VALUE (link
));
831 if (op
&& visit_store
)
832 ret
|= visit_store (stmt
, op
, TREE_VALUE (link
), data
);
835 constraint
= TREE_STRING_POINTER
836 (TREE_VALUE (TREE_PURPOSE (link
)));
837 oconstraints
[i
] = constraint
;
838 parse_output_constraint (&constraint
, i
, 0, 0, &allows_mem
,
839 &allows_reg
, &is_inout
);
840 if (op
&& !allows_reg
&& allows_mem
)
841 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
), data
);
844 if (visit_load
|| visit_addr
)
845 for (i
= 0; i
< gimple_asm_ninputs (asm_stmt
); ++i
)
847 tree link
= gimple_asm_input_op (asm_stmt
, i
);
848 tree op
= TREE_VALUE (link
);
850 && TREE_CODE (op
) == ADDR_EXPR
)
851 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
852 else if (visit_load
|| visit_addr
)
854 op
= get_base_loadstore (op
);
858 ret
|= visit_load (stmt
, op
, TREE_VALUE (link
), data
);
861 constraint
= TREE_STRING_POINTER
862 (TREE_VALUE (TREE_PURPOSE (link
)));
863 parse_input_constraint (&constraint
, 0, 0, noutputs
,
865 &allows_mem
, &allows_reg
);
866 if (!allows_reg
&& allows_mem
)
867 ret
|= visit_addr (stmt
, op
, TREE_VALUE (link
),
874 else if (greturn
*return_stmt
= dyn_cast
<greturn
*> (stmt
))
876 tree op
= gimple_return_retval (return_stmt
);
880 && TREE_CODE (op
) == ADDR_EXPR
)
881 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
884 tree base
= get_base_loadstore (op
);
886 ret
|= visit_load (stmt
, base
, op
, data
);
891 && gimple_code (stmt
) == GIMPLE_PHI
)
893 for (i
= 0; i
< gimple_phi_num_args (stmt
); ++i
)
895 tree op
= gimple_phi_arg_def (stmt
, i
);
896 if (TREE_CODE (op
) == ADDR_EXPR
)
897 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
901 && gimple_code (stmt
) == GIMPLE_GOTO
)
903 tree op
= gimple_goto_dest (stmt
);
904 if (TREE_CODE (op
) == ADDR_EXPR
)
905 ret
|= visit_addr (stmt
, TREE_OPERAND (op
, 0), op
, data
);
911 /* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP
912 should make a faster clone for this case. */
915 walk_stmt_load_store_ops (gimple stmt
, void *data
,
916 walk_stmt_load_store_addr_fn visit_load
,
917 walk_stmt_load_store_addr_fn visit_store
)
919 return walk_stmt_load_store_addr_ops (stmt
, data
,
920 visit_load
, visit_store
, NULL
);