Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple.c @ 70:b81903832de2
merge c-decl.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 09:24:16 +0900 |
parents | 1b10fe6932e1 |
children | ce75bd9117e4 |
comparison
equal
deleted
inserted
replaced
69:1b10fe6932e1 | 70:b81903832de2 |
---|---|
31 #include "gimple.h" | 31 #include "gimple.h" |
32 #include "diagnostic.h" | 32 #include "diagnostic.h" |
33 #include "tree-flow.h" | 33 #include "tree-flow.h" |
34 #include "value-prof.h" | 34 #include "value-prof.h" |
35 #include "flags.h" | 35 #include "flags.h" |
36 #ifndef noCbC | |
37 #include "cbc-tree.h" | |
38 #endif | |
39 #include "alias.h" | 36 #include "alias.h" |
40 #include "demangle.h" | 37 #include "demangle.h" |
41 #include "langhooks.h" | 38 #include "langhooks.h" |
42 | 39 |
43 /* Global type table. FIXME lto, it should be possible to re-use some | 40 /* Global type table. FIXME lto, it should be possible to re-use some |
61 /* All the tuples have their operand vector (if present) at the very bottom | 58 /* All the tuples have their operand vector (if present) at the very bottom |
62 of the structure. Therefore, the offset required to find the | 59 of the structure. Therefore, the offset required to find the |
63 operands vector the size of the structure minus the size of the 1 | 60 operands vector the size of the structure minus the size of the 1 |
64 element tree array at the end (see gimple_ops). */ | 61 element tree array at the end (see gimple_ops). */ |
65 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) \ | 62 #define DEFGSSTRUCT(SYM, STRUCT, HAS_TREE_OP) \ |
66 (HAS_TREE_OP ? sizeof (struct STRUCT) - sizeof (tree) : 0), | 63 (HAS_TREE_OP ? sizeof (struct STRUCT) - sizeof (tree) : 0), |
67 EXPORTED_CONST size_t gimple_ops_offset_[] = { | 64 EXPORTED_CONST size_t gimple_ops_offset_[] = { |
68 #include "gsstruct.def" | 65 #include "gsstruct.def" |
69 }; | 66 }; |
70 #undef DEFGSSTRUCT | 67 #undef DEFGSSTRUCT |
71 | 68 |
73 static const size_t gsstruct_code_size[] = { | 70 static const size_t gsstruct_code_size[] = { |
74 #include "gsstruct.def" | 71 #include "gsstruct.def" |
75 }; | 72 }; |
76 #undef DEFGSSTRUCT | 73 #undef DEFGSSTRUCT |
77 | 74 |
78 #define DEFGSCODE(SYM, NAME, GSSCODE) NAME, | 75 #define DEFGSCODE(SYM, NAME, GSSCODE) NAME, |
79 const char *const gimple_code_name[] = { | 76 const char *const gimple_code_name[] = { |
80 #include "gimple.def" | 77 #include "gimple.def" |
81 }; | 78 }; |
82 #undef DEFGSCODE | 79 #undef DEFGSCODE |
83 | 80 |
84 #define DEFGSCODE(SYM, NAME, GSSCODE) GSSCODE, | 81 #define DEFGSCODE(SYM, NAME, GSSCODE) GSSCODE, |
85 EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = { | 82 EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = { |
86 #include "gimple.def" | 83 #include "gimple.def" |
87 }; | 84 }; |
88 #undef DEFGSCODE | 85 #undef DEFGSCODE |
89 | 86 |
186 #define gimple_build_with_ops(c, s, n) \ | 183 #define gimple_build_with_ops(c, s, n) \ |
187 gimple_build_with_ops_stat (c, s, n MEM_STAT_INFO) | 184 gimple_build_with_ops_stat (c, s, n MEM_STAT_INFO) |
188 | 185 |
189 static gimple | 186 static gimple |
190 gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode, | 187 gimple_build_with_ops_stat (enum gimple_code code, unsigned subcode, |
191 unsigned num_ops MEM_STAT_DECL) | 188 unsigned num_ops MEM_STAT_DECL) |
192 { | 189 { |
193 gimple s = gimple_alloc_stat (code, num_ops PASS_MEM_STAT); | 190 gimple s = gimple_alloc_stat (code, num_ops PASS_MEM_STAT); |
194 gimple_set_subcode (s, subcode); | 191 gimple_set_subcode (s, subcode); |
195 | 192 |
196 return s; | 193 return s; |
305 gimple_call_set_tail (call, CALL_EXPR_TAILCALL (t)); | 302 gimple_call_set_tail (call, CALL_EXPR_TAILCALL (t)); |
306 gimple_call_set_cannot_inline (call, CALL_CANNOT_INLINE_P (t)); | 303 gimple_call_set_cannot_inline (call, CALL_CANNOT_INLINE_P (t)); |
307 gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t)); | 304 gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t)); |
308 gimple_call_set_from_thunk (call, CALL_FROM_THUNK_P (t)); | 305 gimple_call_set_from_thunk (call, CALL_FROM_THUNK_P (t)); |
309 gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t)); | 306 gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t)); |
310 #ifndef noCbC | |
311 gimple_call_set_cbc_goto (call, CALL_EXPR_CbC_GOTO (t)); | |
312 #endif | |
313 gimple_call_set_nothrow (call, TREE_NOTHROW (t)); | 307 gimple_call_set_nothrow (call, TREE_NOTHROW (t)); |
314 gimple_set_no_warning (call, TREE_NO_WARNING (t)); | 308 gimple_set_no_warning (call, TREE_NO_WARNING (t)); |
315 | 309 |
316 return call; | 310 return call; |
317 } | 311 } |
389 /* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the | 383 /* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the |
390 code). */ | 384 code). */ |
391 num_ops = get_gimple_rhs_num_ops (subcode) + 1; | 385 num_ops = get_gimple_rhs_num_ops (subcode) + 1; |
392 | 386 |
393 p = gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops | 387 p = gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops |
394 PASS_MEM_STAT); | 388 PASS_MEM_STAT); |
395 gimple_assign_set_lhs (p, lhs); | 389 gimple_assign_set_lhs (p, lhs); |
396 gimple_assign_set_rhs1 (p, op1); | 390 gimple_assign_set_rhs1 (p, op1); |
397 if (op2) | 391 if (op2) |
398 { | 392 { |
399 gcc_assert (num_ops > 2); | 393 gcc_assert (num_ops > 2); |
434 T_LABEL is the label to jump to if the condition is true. | 428 T_LABEL is the label to jump to if the condition is true. |
435 F_LABEL is the label to jump to otherwise. */ | 429 F_LABEL is the label to jump to otherwise. */ |
436 | 430 |
437 gimple | 431 gimple |
438 gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs, | 432 gimple_build_cond (enum tree_code pred_code, tree lhs, tree rhs, |
439 tree t_label, tree f_label) | 433 tree t_label, tree f_label) |
440 { | 434 { |
441 gimple p; | 435 gimple p; |
442 | 436 |
443 gcc_assert (TREE_CODE_CLASS (pred_code) == tcc_comparison); | 437 gcc_assert (TREE_CODE_CLASS (pred_code) == tcc_comparison); |
444 p = gimple_build_with_ops (GIMPLE_COND, pred_code, 4); | 438 p = gimple_build_with_ops (GIMPLE_COND, pred_code, 4); |
455 void | 449 void |
456 gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p, | 450 gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p, |
457 tree *lhs_p, tree *rhs_p) | 451 tree *lhs_p, tree *rhs_p) |
458 { | 452 { |
459 gcc_assert (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison | 453 gcc_assert (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison |
460 || TREE_CODE (cond) == TRUTH_NOT_EXPR | 454 || TREE_CODE (cond) == TRUTH_NOT_EXPR |
461 || is_gimple_min_invariant (cond) | 455 || is_gimple_min_invariant (cond) |
462 || SSA_VAR_P (cond)); | 456 || SSA_VAR_P (cond)); |
463 | 457 |
464 extract_ops_from_tree (cond, code_p, lhs_p, rhs_p); | 458 extract_ops_from_tree (cond, code_p, lhs_p, rhs_p); |
465 | 459 |
466 /* Canonicalize conditionals of the form 'if (!VAL)'. */ | 460 /* Canonicalize conditionals of the form 'if (!VAL)'. */ |
467 if (*code_p == TRUTH_NOT_EXPR) | 461 if (*code_p == TRUTH_NOT_EXPR) |
570 /* ASMs with labels cannot have outputs. This should have been | 564 /* ASMs with labels cannot have outputs. This should have been |
571 enforced by the front end. */ | 565 enforced by the front end. */ |
572 gcc_assert (nlabels == 0 || noutputs == 0); | 566 gcc_assert (nlabels == 0 || noutputs == 0); |
573 | 567 |
574 p = gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, | 568 p = gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, |
575 ninputs + noutputs + nclobbers + nlabels); | 569 ninputs + noutputs + nclobbers + nlabels); |
576 | 570 |
577 p->gimple_asm.ni = ninputs; | 571 p->gimple_asm.ni = ninputs; |
578 p->gimple_asm.no = noutputs; | 572 p->gimple_asm.no = noutputs; |
579 p->gimple_asm.nc = nclobbers; | 573 p->gimple_asm.nc = nclobbers; |
580 p->gimple_asm.nl = nlabels; | 574 p->gimple_asm.nl = nlabels; |
599 LABELS is a vector of destination labels. */ | 593 LABELS is a vector of destination labels. */ |
600 | 594 |
601 gimple | 595 gimple |
602 gimple_build_asm_vec (const char *string, VEC(tree,gc)* inputs, | 596 gimple_build_asm_vec (const char *string, VEC(tree,gc)* inputs, |
603 VEC(tree,gc)* outputs, VEC(tree,gc)* clobbers, | 597 VEC(tree,gc)* outputs, VEC(tree,gc)* clobbers, |
604 VEC(tree,gc)* labels) | 598 VEC(tree,gc)* labels) |
605 { | 599 { |
606 gimple p; | 600 gimple p; |
607 unsigned i; | 601 unsigned i; |
608 | 602 |
609 p = gimple_build_asm_1 (string, | 603 p = gimple_build_asm_1 (string, |
610 VEC_length (tree, inputs), | 604 VEC_length (tree, inputs), |
611 VEC_length (tree, outputs), | 605 VEC_length (tree, outputs), |
612 VEC_length (tree, clobbers), | 606 VEC_length (tree, clobbers), |
613 VEC_length (tree, labels)); | 607 VEC_length (tree, labels)); |
614 | 608 |
615 for (i = 0; i < VEC_length (tree, inputs); i++) | 609 for (i = 0; i < VEC_length (tree, inputs); i++) |
616 gimple_asm_set_input_op (p, i, VEC_index (tree, inputs, i)); | 610 gimple_asm_set_input_op (p, i, VEC_index (tree, inputs, i)); |
617 | 611 |
618 for (i = 0; i < VEC_length (tree, outputs); i++) | 612 for (i = 0; i < VEC_length (tree, outputs); i++) |
680 KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on | 674 KIND is either GIMPLE_TRY_CATCH or GIMPLE_TRY_FINALLY depending on |
681 whether this is a try/catch or a try/finally respectively. */ | 675 whether this is a try/catch or a try/finally respectively. */ |
682 | 676 |
683 gimple | 677 gimple |
684 gimple_build_try (gimple_seq eval, gimple_seq cleanup, | 678 gimple_build_try (gimple_seq eval, gimple_seq cleanup, |
685 enum gimple_try_flags kind) | 679 enum gimple_try_flags kind) |
686 { | 680 { |
687 gimple p; | 681 gimple p; |
688 | 682 |
689 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY); | 683 gcc_assert (kind == GIMPLE_TRY_CATCH || kind == GIMPLE_TRY_FINALLY); |
690 p = gimple_alloc (GIMPLE_TRY, 0); | 684 p = gimple_alloc (GIMPLE_TRY, 0); |
731 gimple | 725 gimple |
732 gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label) | 726 gimple_build_switch_nlabels (unsigned nlabels, tree index, tree default_label) |
733 { | 727 { |
734 /* nlabels + 1 default label + 1 index. */ | 728 /* nlabels + 1 default label + 1 index. */ |
735 gimple p = gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK, | 729 gimple p = gimple_build_with_ops (GIMPLE_SWITCH, ERROR_MARK, |
736 1 + (default_label != NULL) + nlabels); | 730 1 + (default_label != NULL) + nlabels); |
737 gimple_switch_set_index (p, index); | 731 gimple_switch_set_index (p, index); |
738 if (default_label) | 732 if (default_label) |
739 gimple_switch_set_default_label (p, default_label); | 733 gimple_switch_set_default_label (p, default_label); |
740 return p; | 734 return p; |
741 } | 735 } |
801 | 795 |
802 gimple | 796 gimple |
803 gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL) | 797 gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL) |
804 { | 798 { |
805 gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG, | 799 gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG, |
806 (unsigned)GIMPLE_DEBUG_BIND, 2 | 800 (unsigned)GIMPLE_DEBUG_BIND, 2 |
807 PASS_MEM_STAT); | 801 PASS_MEM_STAT); |
808 | 802 |
809 gimple_debug_bind_set_var (p, var); | 803 gimple_debug_bind_set_var (p, var); |
810 gimple_debug_bind_set_value (p, value); | 804 gimple_debug_bind_set_value (p, value); |
811 if (stmt) | 805 if (stmt) |
812 { | 806 { |
842 COLLAPSE is the collapse count. | 836 COLLAPSE is the collapse count. |
843 PRE_BODY is the sequence of statements that are loop invariant. */ | 837 PRE_BODY is the sequence of statements that are loop invariant. */ |
844 | 838 |
845 gimple | 839 gimple |
846 gimple_build_omp_for (gimple_seq body, tree clauses, size_t collapse, | 840 gimple_build_omp_for (gimple_seq body, tree clauses, size_t collapse, |
847 gimple_seq pre_body) | 841 gimple_seq pre_body) |
848 { | 842 { |
849 gimple p = gimple_alloc (GIMPLE_OMP_FOR, 0); | 843 gimple p = gimple_alloc (GIMPLE_OMP_FOR, 0); |
850 if (body) | 844 if (body) |
851 gimple_omp_set_body (p, body); | 845 gimple_omp_set_body (p, body); |
852 gimple_omp_for_set_clauses (p, clauses); | 846 gimple_omp_for_set_clauses (p, clauses); |
867 CHILD_FN is the function created for the parallel threads to execute. | 861 CHILD_FN is the function created for the parallel threads to execute. |
868 DATA_ARG are the shared data argument(s). */ | 862 DATA_ARG are the shared data argument(s). */ |
869 | 863 |
870 gimple | 864 gimple |
871 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, | 865 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, |
872 tree data_arg) | 866 tree data_arg) |
873 { | 867 { |
874 gimple p = gimple_alloc (GIMPLE_OMP_PARALLEL, 0); | 868 gimple p = gimple_alloc (GIMPLE_OMP_PARALLEL, 0); |
875 if (body) | 869 if (body) |
876 gimple_omp_set_body (p, body); | 870 gimple_omp_set_body (p, body); |
877 gimple_omp_parallel_set_clauses (p, clauses); | 871 gimple_omp_parallel_set_clauses (p, clauses); |
891 COPY_FN is the optional function for firstprivate initialization. | 885 COPY_FN is the optional function for firstprivate initialization. |
892 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */ | 886 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */ |
893 | 887 |
894 gimple | 888 gimple |
895 gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn, | 889 gimple_build_omp_task (gimple_seq body, tree clauses, tree child_fn, |
896 tree data_arg, tree copy_fn, tree arg_size, | 890 tree data_arg, tree copy_fn, tree arg_size, |
897 tree arg_align) | 891 tree arg_align) |
898 { | 892 { |
899 gimple p = gimple_alloc (GIMPLE_OMP_TASK, 0); | 893 gimple p = gimple_alloc (GIMPLE_OMP_TASK, 0); |
900 if (body) | 894 if (body) |
901 gimple_omp_set_body (p, body); | 895 gimple_omp_set_body (p, body); |
902 gimple_omp_task_set_clauses (p, clauses); | 896 gimple_omp_task_set_clauses (p, clauses); |
1069 #if defined ENABLE_GIMPLE_CHECKING | 1063 #if defined ENABLE_GIMPLE_CHECKING |
1070 /* Complain of a gimple type mismatch and die. */ | 1064 /* Complain of a gimple type mismatch and die. */ |
1071 | 1065 |
1072 void | 1066 void |
1073 gimple_check_failed (const_gimple gs, const char *file, int line, | 1067 gimple_check_failed (const_gimple gs, const char *file, int line, |
1074 const char *function, enum gimple_code code, | 1068 const char *function, enum gimple_code code, |
1075 enum tree_code subcode) | 1069 enum tree_code subcode) |
1076 { | 1070 { |
1077 internal_error ("gimple check: expected %s(%s), have %s(%s) in %s, at %s:%d", | 1071 internal_error ("gimple check: expected %s(%s), have %s(%s) in %s, at %s:%d", |
1078 gimple_code_name[code], | 1072 gimple_code_name[code], |
1079 tree_code_name[subcode], | 1073 tree_code_name[subcode], |
1080 gimple_code_name[gimple_code (gs)], | 1074 gimple_code_name[gimple_code (gs)], |
1081 gs->gsbase.subcode > 0 | 1075 gs->gsbase.subcode > 0 |
1082 ? tree_code_name[gs->gsbase.subcode] | 1076 ? tree_code_name[gs->gsbase.subcode] |
1083 : "", | 1077 : "", |
1084 function, trim_filename (file), line); | 1078 function, trim_filename (file), line); |
1085 } | 1079 } |
1086 #endif /* ENABLE_GIMPLE_CHECKING */ | 1080 #endif /* ENABLE_GIMPLE_CHECKING */ |
1087 | 1081 |
1088 | 1082 |
1089 /* Allocate a new GIMPLE sequence in GC memory and return it. If | 1083 /* Allocate a new GIMPLE sequence in GC memory and return it. If |
1194 | 1188 |
1195 if (gimple_seq_empty_p (body)) | 1189 if (gimple_seq_empty_p (body)) |
1196 return true; | 1190 return true; |
1197 for (i = gsi_start (body); !gsi_end_p (i); gsi_next (&i)) | 1191 for (i = gsi_start (body); !gsi_end_p (i); gsi_next (&i)) |
1198 if (!empty_stmt_p (gsi_stmt (i)) | 1192 if (!empty_stmt_p (gsi_stmt (i)) |
1199 && !is_gimple_debug (gsi_stmt (i))) | 1193 && !is_gimple_debug (gsi_stmt (i))) |
1200 return false; | 1194 return false; |
1201 | 1195 |
1202 return true; | 1196 return true; |
1203 } | 1197 } |
1204 | 1198 |
1231 | 1225 |
1232 Otherwise, all the statements are walked and NULL returned. */ | 1226 Otherwise, all the statements are walked and NULL returned. */ |
1233 | 1227 |
1234 gimple | 1228 gimple |
1235 walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, | 1229 walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, |
1236 walk_tree_fn callback_op, struct walk_stmt_info *wi) | 1230 walk_tree_fn callback_op, struct walk_stmt_info *wi) |
1237 { | 1231 { |
1238 gimple_stmt_iterator gsi; | 1232 gimple_stmt_iterator gsi; |
1239 | 1233 |
1240 for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi)) | 1234 for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi)) |
1241 { | 1235 { |
1242 tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi); | 1236 tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi); |
1243 if (ret) | 1237 if (ret) |
1244 { | 1238 { |
1245 /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist | 1239 /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist |
1246 to hold it. */ | 1240 to hold it. */ |
1247 gcc_assert (wi); | 1241 gcc_assert (wi); |
1248 wi->callback_result = ret; | 1242 wi->callback_result = ret; |
1249 return gsi_stmt (gsi); | 1243 return gsi_stmt (gsi); |
1250 } | 1244 } |
1251 } | 1245 } |
1252 | 1246 |
1253 if (wi) | 1247 if (wi) |
1254 wi->callback_result = NULL_TREE; | 1248 wi->callback_result = NULL_TREE; |
1255 | 1249 |
1259 | 1253 |
1260 /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */ | 1254 /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */ |
1261 | 1255 |
1262 static tree | 1256 static tree |
1263 walk_gimple_asm (gimple stmt, walk_tree_fn callback_op, | 1257 walk_gimple_asm (gimple stmt, walk_tree_fn callback_op, |
1264 struct walk_stmt_info *wi) | 1258 struct walk_stmt_info *wi) |
1265 { | 1259 { |
1266 tree ret, op; | 1260 tree ret, op; |
1267 unsigned noutputs; | 1261 unsigned noutputs; |
1268 const char **oconstraints; | 1262 const char **oconstraints; |
1269 unsigned i, n; | 1263 unsigned i, n; |
1280 { | 1274 { |
1281 op = gimple_asm_output_op (stmt, i); | 1275 op = gimple_asm_output_op (stmt, i); |
1282 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); | 1276 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); |
1283 oconstraints[i] = constraint; | 1277 oconstraints[i] = constraint; |
1284 parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg, | 1278 parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg, |
1285 &is_inout); | 1279 &is_inout); |
1286 if (wi) | 1280 if (wi) |
1287 wi->val_only = (allows_reg || !allows_mem); | 1281 wi->val_only = (allows_reg || !allows_mem); |
1288 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); | 1282 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); |
1289 if (ret) | 1283 if (ret) |
1290 return ret; | 1284 return ret; |
1291 } | 1285 } |
1292 | 1286 |
1293 n = gimple_asm_ninputs (stmt); | 1287 n = gimple_asm_ninputs (stmt); |
1294 for (i = 0; i < n; i++) | 1288 for (i = 0; i < n; i++) |
1295 { | 1289 { |
1296 op = gimple_asm_input_op (stmt, i); | 1290 op = gimple_asm_input_op (stmt, i); |
1297 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); | 1291 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); |
1298 parse_input_constraint (&constraint, 0, 0, noutputs, 0, | 1292 parse_input_constraint (&constraint, 0, 0, noutputs, 0, |
1299 oconstraints, &allows_mem, &allows_reg); | 1293 oconstraints, &allows_mem, &allows_reg); |
1300 if (wi) | 1294 if (wi) |
1301 { | 1295 { |
1302 wi->val_only = (allows_reg || !allows_mem); | 1296 wi->val_only = (allows_reg || !allows_mem); |
1303 /* Although input "m" is not really a LHS, we need a lvalue. */ | 1297 /* Although input "m" is not really a LHS, we need a lvalue. */ |
1304 wi->is_lhs = !wi->val_only; | 1298 wi->is_lhs = !wi->val_only; |
1305 } | 1299 } |
1306 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); | 1300 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); |
1307 if (ret) | 1301 if (ret) |
1308 return ret; | 1302 return ret; |
1309 } | 1303 } |
1310 | 1304 |
1311 if (wi) | 1305 if (wi) |
1312 { | 1306 { |
1313 wi->is_lhs = false; | 1307 wi->is_lhs = false; |
1318 for (i = 0; i < n; i++) | 1312 for (i = 0; i < n; i++) |
1319 { | 1313 { |
1320 op = gimple_asm_label_op (stmt, i); | 1314 op = gimple_asm_label_op (stmt, i); |
1321 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); | 1315 ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); |
1322 if (ret) | 1316 if (ret) |
1323 return ret; | 1317 return ret; |
1324 } | 1318 } |
1325 | 1319 |
1326 return NULL_TREE; | 1320 return NULL_TREE; |
1327 } | 1321 } |
1328 | 1322 |
1332 | 1326 |
1333 CALLBACK_OP is called on each operand of STMT via walk_tree. | 1327 CALLBACK_OP is called on each operand of STMT via walk_tree. |
1334 Additional parameters to walk_tree must be stored in WI. For each operand | 1328 Additional parameters to walk_tree must be stored in WI. For each operand |
1335 OP, walk_tree is called as: | 1329 OP, walk_tree is called as: |
1336 | 1330 |
1337 walk_tree (&OP, CALLBACK_OP, WI, WI->PSET) | 1331 walk_tree (&OP, CALLBACK_OP, WI, WI->PSET) |
1338 | 1332 |
1339 If CALLBACK_OP returns non-NULL for an operand, the remaining | 1333 If CALLBACK_OP returns non-NULL for an operand, the remaining |
1340 operands are not scanned. | 1334 operands are not scanned. |
1341 | 1335 |
1342 The return value is that returned by the last call to walk_tree, or | 1336 The return value is that returned by the last call to walk_tree, or |
1343 NULL_TREE if no CALLBACK_OP is specified. */ | 1337 NULL_TREE if no CALLBACK_OP is specified. */ |
1344 | 1338 |
1345 tree | 1339 tree |
1346 walk_gimple_op (gimple stmt, walk_tree_fn callback_op, | 1340 walk_gimple_op (gimple stmt, walk_tree_fn callback_op, |
1347 struct walk_stmt_info *wi) | 1341 struct walk_stmt_info *wi) |
1348 { | 1342 { |
1349 struct pointer_set_t *pset = (wi) ? wi->pset : NULL; | 1343 struct pointer_set_t *pset = (wi) ? wi->pset : NULL; |
1350 unsigned i; | 1344 unsigned i; |
1351 tree ret = NULL_TREE; | 1345 tree ret = NULL_TREE; |
1352 | 1346 |
1362 = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs)) | 1356 = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs)) |
1363 || !gimple_assign_single_p (stmt); | 1357 || !gimple_assign_single_p (stmt); |
1364 } | 1358 } |
1365 | 1359 |
1366 for (i = 1; i < gimple_num_ops (stmt); i++) | 1360 for (i = 1; i < gimple_num_ops (stmt); i++) |
1367 { | 1361 { |
1368 ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, | 1362 ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, |
1369 pset); | 1363 pset); |
1370 if (ret) | 1364 if (ret) |
1371 return ret; | 1365 return ret; |
1372 } | 1366 } |
1373 | 1367 |
1374 /* Walk the LHS. If the RHS is appropriate for a memory, we | 1368 /* Walk the LHS. If the RHS is appropriate for a memory, we |
1375 may use a COMPONENT_REF on the LHS. */ | 1369 may use a COMPONENT_REF on the LHS. */ |
1376 if (wi) | 1370 if (wi) |
1377 { | 1371 { |
1378 /* If the RHS has more than 1 operand, it is not appropriate | 1372 /* If the RHS has more than 1 operand, it is not appropriate |
1379 for the memory. */ | 1373 for the memory. */ |
1380 wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt)) | 1374 wi->val_only = !is_gimple_mem_rhs (gimple_assign_rhs1 (stmt)) |
1381 || !gimple_assign_single_p (stmt); | 1375 || !gimple_assign_single_p (stmt); |
1382 wi->is_lhs = true; | 1376 wi->is_lhs = true; |
1383 } | 1377 } |
1384 | 1378 |
1385 ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset); | 1379 ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset); |
1386 if (ret) | 1380 if (ret) |
1387 return ret; | 1381 return ret; |
1388 | 1382 |
1389 if (wi) | 1383 if (wi) |
1390 { | 1384 { |
1391 wi->val_only = true; | 1385 wi->val_only = true; |
1392 wi->is_lhs = false; | 1386 wi->is_lhs = false; |
1393 } | 1387 } |
1394 break; | 1388 break; |
1395 | 1389 |
1396 case GIMPLE_CALL: | 1390 case GIMPLE_CALL: |
1397 if (wi) | 1391 if (wi) |
1398 { | 1392 { |
1438 } | 1432 } |
1439 break; | 1433 break; |
1440 | 1434 |
1441 case GIMPLE_CATCH: | 1435 case GIMPLE_CATCH: |
1442 ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi, | 1436 ret = walk_tree (gimple_catch_types_ptr (stmt), callback_op, wi, |
1443 pset); | 1437 pset); |
1444 if (ret) | 1438 if (ret) |
1445 return ret; | 1439 return ret; |
1446 break; | 1440 break; |
1447 | 1441 |
1448 case GIMPLE_EH_FILTER: | 1442 case GIMPLE_EH_FILTER: |
1449 ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi, | 1443 ret = walk_tree (gimple_eh_filter_types_ptr (stmt), callback_op, wi, |
1450 pset); | 1444 pset); |
1451 if (ret) | 1445 if (ret) |
1452 return ret; | 1446 return ret; |
1453 break; | 1447 break; |
1454 | 1448 |
1455 case GIMPLE_ASM: | 1449 case GIMPLE_ASM: |
1456 ret = walk_gimple_asm (stmt, callback_op, wi); | 1450 ret = walk_gimple_asm (stmt, callback_op, wi); |
1457 if (ret) | 1451 if (ret) |
1458 return ret; | 1452 return ret; |
1459 break; | 1453 break; |
1460 | 1454 |
1461 case GIMPLE_OMP_CONTINUE: | 1455 case GIMPLE_OMP_CONTINUE: |
1462 ret = walk_tree (gimple_omp_continue_control_def_ptr (stmt), | 1456 ret = walk_tree (gimple_omp_continue_control_def_ptr (stmt), |
1463 callback_op, wi, pset); | 1457 callback_op, wi, pset); |
1464 if (ret) | 1458 if (ret) |
1465 return ret; | 1459 return ret; |
1466 | 1460 |
1467 ret = walk_tree (gimple_omp_continue_control_use_ptr (stmt), | 1461 ret = walk_tree (gimple_omp_continue_control_use_ptr (stmt), |
1468 callback_op, wi, pset); | 1462 callback_op, wi, pset); |
1469 if (ret) | 1463 if (ret) |
1470 return ret; | 1464 return ret; |
1471 break; | 1465 break; |
1472 | 1466 |
1473 case GIMPLE_OMP_CRITICAL: | 1467 case GIMPLE_OMP_CRITICAL: |
1474 ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi, | 1468 ret = walk_tree (gimple_omp_critical_name_ptr (stmt), callback_op, wi, |
1475 pset); | 1469 pset); |
1476 if (ret) | 1470 if (ret) |
1477 return ret; | 1471 return ret; |
1478 break; | 1472 break; |
1479 | 1473 |
1480 case GIMPLE_OMP_FOR: | 1474 case GIMPLE_OMP_FOR: |
1481 ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi, | 1475 ret = walk_tree (gimple_omp_for_clauses_ptr (stmt), callback_op, wi, |
1482 pset); | 1476 pset); |
1483 if (ret) | 1477 if (ret) |
1484 return ret; | 1478 return ret; |
1485 for (i = 0; i < gimple_omp_for_collapse (stmt); i++) | 1479 for (i = 0; i < gimple_omp_for_collapse (stmt); i++) |
1486 { | 1480 { |
1487 ret = walk_tree (gimple_omp_for_index_ptr (stmt, i), callback_op, | 1481 ret = walk_tree (gimple_omp_for_index_ptr (stmt, i), callback_op, |
1488 wi, pset); | 1482 wi, pset); |
1483 if (ret) | |
1484 return ret; | |
1485 ret = walk_tree (gimple_omp_for_initial_ptr (stmt, i), callback_op, | |
1486 wi, pset); | |
1487 if (ret) | |
1488 return ret; | |
1489 ret = walk_tree (gimple_omp_for_final_ptr (stmt, i), callback_op, | |
1490 wi, pset); | |
1491 if (ret) | |
1492 return ret; | |
1493 ret = walk_tree (gimple_omp_for_incr_ptr (stmt, i), callback_op, | |
1494 wi, pset); | |
1495 } | |
1489 if (ret) | 1496 if (ret) |
1490 return ret; | 1497 return ret; |
1491 ret = walk_tree (gimple_omp_for_initial_ptr (stmt, i), callback_op, | |
1492 wi, pset); | |
1493 if (ret) | |
1494 return ret; | |
1495 ret = walk_tree (gimple_omp_for_final_ptr (stmt, i), callback_op, | |
1496 wi, pset); | |
1497 if (ret) | |
1498 return ret; | |
1499 ret = walk_tree (gimple_omp_for_incr_ptr (stmt, i), callback_op, | |
1500 wi, pset); | |
1501 } | |
1502 if (ret) | |
1503 return ret; | |
1504 break; | 1498 break; |
1505 | 1499 |
1506 case GIMPLE_OMP_PARALLEL: | 1500 case GIMPLE_OMP_PARALLEL: |
1507 ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op, | 1501 ret = walk_tree (gimple_omp_parallel_clauses_ptr (stmt), callback_op, |
1508 wi, pset); | 1502 wi, pset); |
1509 if (ret) | 1503 if (ret) |
1510 return ret; | 1504 return ret; |
1511 ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op, | 1505 ret = walk_tree (gimple_omp_parallel_child_fn_ptr (stmt), callback_op, |
1512 wi, pset); | 1506 wi, pset); |
1513 if (ret) | 1507 if (ret) |
1514 return ret; | 1508 return ret; |
1515 ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op, | 1509 ret = walk_tree (gimple_omp_parallel_data_arg_ptr (stmt), callback_op, |
1516 wi, pset); | 1510 wi, pset); |
1517 if (ret) | 1511 if (ret) |
1518 return ret; | 1512 return ret; |
1519 break; | 1513 break; |
1520 | 1514 |
1521 case GIMPLE_OMP_TASK: | 1515 case GIMPLE_OMP_TASK: |
1522 ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op, | 1516 ret = walk_tree (gimple_omp_task_clauses_ptr (stmt), callback_op, |
1523 wi, pset); | 1517 wi, pset); |
1524 if (ret) | 1518 if (ret) |
1525 return ret; | 1519 return ret; |
1526 ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op, | 1520 ret = walk_tree (gimple_omp_task_child_fn_ptr (stmt), callback_op, |
1527 wi, pset); | 1521 wi, pset); |
1528 if (ret) | 1522 if (ret) |
1529 return ret; | 1523 return ret; |
1530 ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op, | 1524 ret = walk_tree (gimple_omp_task_data_arg_ptr (stmt), callback_op, |
1531 wi, pset); | 1525 wi, pset); |
1532 if (ret) | 1526 if (ret) |
1533 return ret; | 1527 return ret; |
1534 ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op, | 1528 ret = walk_tree (gimple_omp_task_copy_fn_ptr (stmt), callback_op, |
1535 wi, pset); | 1529 wi, pset); |
1536 if (ret) | 1530 if (ret) |
1537 return ret; | 1531 return ret; |
1538 ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op, | 1532 ret = walk_tree (gimple_omp_task_arg_size_ptr (stmt), callback_op, |
1539 wi, pset); | 1533 wi, pset); |
1540 if (ret) | 1534 if (ret) |
1541 return ret; | 1535 return ret; |
1542 ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op, | 1536 ret = walk_tree (gimple_omp_task_arg_align_ptr (stmt), callback_op, |
1543 wi, pset); | 1537 wi, pset); |
1544 if (ret) | 1538 if (ret) |
1545 return ret; | 1539 return ret; |
1546 break; | 1540 break; |
1547 | 1541 |
1548 case GIMPLE_OMP_SECTIONS: | 1542 case GIMPLE_OMP_SECTIONS: |
1549 ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op, | 1543 ret = walk_tree (gimple_omp_sections_clauses_ptr (stmt), callback_op, |
1550 wi, pset); | 1544 wi, pset); |
1551 if (ret) | 1545 if (ret) |
1552 return ret; | 1546 return ret; |
1553 | 1547 |
1554 ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op, | 1548 ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op, |
1555 wi, pset); | 1549 wi, pset); |
1556 if (ret) | 1550 if (ret) |
1557 return ret; | 1551 return ret; |
1558 | 1552 |
1559 break; | 1553 break; |
1560 | 1554 |
1561 case GIMPLE_OMP_SINGLE: | 1555 case GIMPLE_OMP_SINGLE: |
1562 ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi, | 1556 ret = walk_tree (gimple_omp_single_clauses_ptr (stmt), callback_op, wi, |
1563 pset); | 1557 pset); |
1564 if (ret) | 1558 if (ret) |
1565 return ret; | 1559 return ret; |
1566 break; | 1560 break; |
1567 | 1561 |
1568 case GIMPLE_OMP_ATOMIC_LOAD: | 1562 case GIMPLE_OMP_ATOMIC_LOAD: |
1569 ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (stmt), callback_op, wi, | 1563 ret = walk_tree (gimple_omp_atomic_load_lhs_ptr (stmt), callback_op, wi, |
1570 pset); | 1564 pset); |
1571 if (ret) | 1565 if (ret) |
1572 return ret; | 1566 return ret; |
1573 | 1567 |
1574 ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt), callback_op, wi, | 1568 ret = walk_tree (gimple_omp_atomic_load_rhs_ptr (stmt), callback_op, wi, |
1575 pset); | 1569 pset); |
1576 if (ret) | 1570 if (ret) |
1577 return ret; | 1571 return ret; |
1578 break; | 1572 break; |
1579 | 1573 |
1580 case GIMPLE_OMP_ATOMIC_STORE: | 1574 case GIMPLE_OMP_ATOMIC_STORE: |
1581 ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op, | 1575 ret = walk_tree (gimple_omp_atomic_store_val_ptr (stmt), callback_op, |
1582 wi, pset); | 1576 wi, pset); |
1583 if (ret) | 1577 if (ret) |
1584 return ret; | 1578 return ret; |
1585 break; | 1579 break; |
1586 | 1580 |
1587 /* Tuples that do not have operands. */ | 1581 /* Tuples that do not have operands. */ |
1588 case GIMPLE_NOP: | 1582 case GIMPLE_NOP: |
1589 case GIMPLE_RESX: | 1583 case GIMPLE_RESX: |
1591 case GIMPLE_PREDICT: | 1585 case GIMPLE_PREDICT: |
1592 break; | 1586 break; |
1593 | 1587 |
1594 default: | 1588 default: |
1595 { | 1589 { |
1596 enum gimple_statement_structure_enum gss; | 1590 enum gimple_statement_structure_enum gss; |
1597 gss = gimple_statement_structure (stmt); | 1591 gss = gimple_statement_structure (stmt); |
1598 if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS) | 1592 if (gss == GSS_WITH_OPS || gss == GSS_WITH_MEM_OPS) |
1599 for (i = 0; i < gimple_num_ops (stmt); i++) | 1593 for (i = 0; i < gimple_num_ops (stmt); i++) |
1600 { | 1594 { |
1601 ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, pset); | 1595 ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi, pset); |
1602 if (ret) | 1596 if (ret) |
1603 return ret; | 1597 return ret; |
1604 } | 1598 } |
1605 } | 1599 } |
1606 break; | 1600 break; |
1607 } | 1601 } |
1608 | 1602 |
1609 return NULL_TREE; | 1603 return NULL_TREE; |
1625 | 1619 |
1626 In any other case, NULL_TREE is returned. */ | 1620 In any other case, NULL_TREE is returned. */ |
1627 | 1621 |
1628 tree | 1622 tree |
1629 walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, | 1623 walk_gimple_stmt (gimple_stmt_iterator *gsi, walk_stmt_fn callback_stmt, |
1630 walk_tree_fn callback_op, struct walk_stmt_info *wi) | 1624 walk_tree_fn callback_op, struct walk_stmt_info *wi) |
1631 { | 1625 { |
1632 gimple ret; | 1626 gimple ret; |
1633 tree tree_ret; | 1627 tree tree_ret; |
1634 gimple stmt = gsi_stmt (*gsi); | 1628 gimple stmt = gsi_stmt (*gsi); |
1635 | 1629 |
1646 if (callback_stmt) | 1640 if (callback_stmt) |
1647 { | 1641 { |
1648 bool handled_ops = false; | 1642 bool handled_ops = false; |
1649 tree_ret = callback_stmt (gsi, &handled_ops, wi); | 1643 tree_ret = callback_stmt (gsi, &handled_ops, wi); |
1650 if (handled_ops) | 1644 if (handled_ops) |
1651 return tree_ret; | 1645 return tree_ret; |
1652 | 1646 |
1653 /* If CALLBACK_STMT did not handle operands, it should not have | 1647 /* If CALLBACK_STMT did not handle operands, it should not have |
1654 a value to return. */ | 1648 a value to return. */ |
1655 gcc_assert (tree_ret == NULL); | 1649 gcc_assert (tree_ret == NULL); |
1656 | 1650 |
1657 /* Re-read stmt in case the callback changed it. */ | 1651 /* Re-read stmt in case the callback changed it. */ |
1658 stmt = gsi_stmt (*gsi); | 1652 stmt = gsi_stmt (*gsi); |
1659 } | 1653 } |
1661 /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */ | 1655 /* If CALLBACK_OP is defined, invoke it on every operand of STMT. */ |
1662 if (callback_op) | 1656 if (callback_op) |
1663 { | 1657 { |
1664 tree_ret = walk_gimple_op (stmt, callback_op, wi); | 1658 tree_ret = walk_gimple_op (stmt, callback_op, wi); |
1665 if (tree_ret) | 1659 if (tree_ret) |
1666 return tree_ret; | 1660 return tree_ret; |
1667 } | 1661 } |
1668 | 1662 |
1669 /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */ | 1663 /* If STMT can have statements inside (e.g. GIMPLE_BIND), walk them. */ |
1670 switch (gimple_code (stmt)) | 1664 switch (gimple_code (stmt)) |
1671 { | 1665 { |
1672 case GIMPLE_BIND: | 1666 case GIMPLE_BIND: |
1673 ret = walk_gimple_seq (gimple_bind_body (stmt), callback_stmt, | 1667 ret = walk_gimple_seq (gimple_bind_body (stmt), callback_stmt, |
1674 callback_op, wi); | 1668 callback_op, wi); |
1675 if (ret) | 1669 if (ret) |
1676 return wi->callback_result; | 1670 return wi->callback_result; |
1677 break; | 1671 break; |
1678 | 1672 |
1679 case GIMPLE_CATCH: | 1673 case GIMPLE_CATCH: |
1680 ret = walk_gimple_seq (gimple_catch_handler (stmt), callback_stmt, | 1674 ret = walk_gimple_seq (gimple_catch_handler (stmt), callback_stmt, |
1681 callback_op, wi); | 1675 callback_op, wi); |
1682 if (ret) | 1676 if (ret) |
1683 return wi->callback_result; | 1677 return wi->callback_result; |
1684 break; | 1678 break; |
1685 | 1679 |
1686 case GIMPLE_EH_FILTER: | 1680 case GIMPLE_EH_FILTER: |
1687 ret = walk_gimple_seq (gimple_eh_filter_failure (stmt), callback_stmt, | 1681 ret = walk_gimple_seq (gimple_eh_filter_failure (stmt), callback_stmt, |
1688 callback_op, wi); | 1682 callback_op, wi); |
1689 if (ret) | 1683 if (ret) |
1690 return wi->callback_result; | 1684 return wi->callback_result; |
1691 break; | 1685 break; |
1692 | 1686 |
1693 case GIMPLE_TRY: | 1687 case GIMPLE_TRY: |
1694 ret = walk_gimple_seq (gimple_try_eval (stmt), callback_stmt, callback_op, | 1688 ret = walk_gimple_seq (gimple_try_eval (stmt), callback_stmt, callback_op, |
1695 wi); | 1689 wi); |
1696 if (ret) | 1690 if (ret) |
1697 return wi->callback_result; | 1691 return wi->callback_result; |
1698 | 1692 |
1699 ret = walk_gimple_seq (gimple_try_cleanup (stmt), callback_stmt, | 1693 ret = walk_gimple_seq (gimple_try_cleanup (stmt), callback_stmt, |
1700 callback_op, wi); | 1694 callback_op, wi); |
1701 if (ret) | 1695 if (ret) |
1702 return wi->callback_result; | 1696 return wi->callback_result; |
1703 break; | 1697 break; |
1704 | 1698 |
1705 case GIMPLE_OMP_FOR: | 1699 case GIMPLE_OMP_FOR: |
1706 ret = walk_gimple_seq (gimple_omp_for_pre_body (stmt), callback_stmt, | 1700 ret = walk_gimple_seq (gimple_omp_for_pre_body (stmt), callback_stmt, |
1707 callback_op, wi); | 1701 callback_op, wi); |
1708 if (ret) | 1702 if (ret) |
1709 return wi->callback_result; | 1703 return wi->callback_result; |
1710 | 1704 |
1711 /* FALL THROUGH. */ | 1705 /* FALL THROUGH. */ |
1712 case GIMPLE_OMP_CRITICAL: | 1706 case GIMPLE_OMP_CRITICAL: |
1713 case GIMPLE_OMP_MASTER: | 1707 case GIMPLE_OMP_MASTER: |
1714 case GIMPLE_OMP_ORDERED: | 1708 case GIMPLE_OMP_ORDERED: |
1716 case GIMPLE_OMP_PARALLEL: | 1710 case GIMPLE_OMP_PARALLEL: |
1717 case GIMPLE_OMP_TASK: | 1711 case GIMPLE_OMP_TASK: |
1718 case GIMPLE_OMP_SECTIONS: | 1712 case GIMPLE_OMP_SECTIONS: |
1719 case GIMPLE_OMP_SINGLE: | 1713 case GIMPLE_OMP_SINGLE: |
1720 ret = walk_gimple_seq (gimple_omp_body (stmt), callback_stmt, callback_op, | 1714 ret = walk_gimple_seq (gimple_omp_body (stmt), callback_stmt, callback_op, |
1721 wi); | 1715 wi); |
1722 if (ret) | 1716 if (ret) |
1723 return wi->callback_result; | 1717 return wi->callback_result; |
1724 break; | 1718 break; |
1725 | 1719 |
1726 case GIMPLE_WITH_CLEANUP_EXPR: | 1720 case GIMPLE_WITH_CLEANUP_EXPR: |
1727 ret = walk_gimple_seq (gimple_wce_cleanup (stmt), callback_stmt, | 1721 ret = walk_gimple_seq (gimple_wce_cleanup (stmt), callback_stmt, |
1728 callback_op, wi); | 1722 callback_op, wi); |
1729 if (ret) | 1723 if (ret) |
1730 return wi->callback_result; | 1724 return wi->callback_result; |
1731 break; | 1725 break; |
1732 | 1726 |
1733 default: | 1727 default: |
1734 gcc_assert (!gimple_has_substatements (stmt)); | 1728 gcc_assert (!gimple_has_substatements (stmt)); |
1735 break; | 1729 break; |
1746 { | 1740 { |
1747 struct function *fn = DECL_STRUCT_FUNCTION (fndecl); | 1741 struct function *fn = DECL_STRUCT_FUNCTION (fndecl); |
1748 if (fn == NULL) | 1742 if (fn == NULL) |
1749 { | 1743 { |
1750 /* If FNDECL still does not have a function structure associated | 1744 /* If FNDECL still does not have a function structure associated |
1751 with it, then it does not make sense for it to receive a | 1745 with it, then it does not make sense for it to receive a |
1752 GIMPLE body. */ | 1746 GIMPLE body. */ |
1753 gcc_assert (seq == NULL); | 1747 gcc_assert (seq == NULL); |
1754 } | 1748 } |
1755 else | 1749 else |
1756 fn->gimple_body = seq; | 1750 fn->gimple_body = seq; |
1757 } | 1751 } |
1792 flags = flags_from_decl_or_type (decl); | 1786 flags = flags_from_decl_or_type (decl); |
1793 else | 1787 else |
1794 { | 1788 { |
1795 t = TREE_TYPE (gimple_call_fn (stmt)); | 1789 t = TREE_TYPE (gimple_call_fn (stmt)); |
1796 if (t && TREE_CODE (t) == POINTER_TYPE) | 1790 if (t && TREE_CODE (t) == POINTER_TYPE) |
1797 flags = flags_from_decl_or_type (TREE_TYPE (t)); | 1791 flags = flags_from_decl_or_type (TREE_TYPE (t)); |
1798 else | 1792 else |
1799 flags = 0; | 1793 flags = 0; |
1800 } | 1794 } |
1801 | 1795 |
1802 if (stmt->gsbase.subcode & GF_CALL_NOTHROW) | 1796 if (stmt->gsbase.subcode & GF_CALL_NOTHROW) |
1803 flags |= ECF_NOTHROW; | 1797 flags |= ECF_NOTHROW; |
1804 | 1798 |
1942 int uid; | 1936 int uid; |
1943 | 1937 |
1944 t = gimple_label_label (stmt); | 1938 t = gimple_label_label (stmt); |
1945 uid = LABEL_DECL_UID (t); | 1939 uid = LABEL_DECL_UID (t); |
1946 if (uid == -1) | 1940 if (uid == -1) |
1947 { | 1941 { |
1948 unsigned old_len = VEC_length (basic_block, label_to_block_map); | 1942 unsigned old_len = VEC_length (basic_block, label_to_block_map); |
1949 LABEL_DECL_UID (t) = uid = cfun->cfg->last_label_uid++; | 1943 LABEL_DECL_UID (t) = uid = cfun->cfg->last_label_uid++; |
1950 if (old_len <= (unsigned) uid) | 1944 if (old_len <= (unsigned) uid) |
1951 { | 1945 { |
1952 unsigned new_len = 3 * uid / 2 + 1; | 1946 unsigned new_len = 3 * uid / 2 + 1; |
1953 | 1947 |
1954 VEC_safe_grow_cleared (basic_block, gc, label_to_block_map, | 1948 VEC_safe_grow_cleared (basic_block, gc, label_to_block_map, |
1955 new_len); | 1949 new_len); |
1956 } | 1950 } |
1957 } | 1951 } |
1958 | 1952 |
1959 VEC_replace (basic_block, label_to_block_map, uid, bb); | 1953 VEC_replace (basic_block, label_to_block_map, uid, bb); |
1960 } | 1954 } |
1961 } | 1955 } |
1962 | 1956 |
2010 memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); | 2004 memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); |
2011 gsi_replace (gsi, new_stmt, true); | 2005 gsi_replace (gsi, new_stmt, true); |
2012 stmt = new_stmt; | 2006 stmt = new_stmt; |
2013 | 2007 |
2014 /* The LHS needs to be reset as this also changes the SSA name | 2008 /* The LHS needs to be reset as this also changes the SSA name |
2015 on the LHS. */ | 2009 on the LHS. */ |
2016 gimple_assign_set_lhs (stmt, lhs); | 2010 gimple_assign_set_lhs (stmt, lhs); |
2017 } | 2011 } |
2018 | 2012 |
2019 gimple_set_num_ops (stmt, new_rhs_ops + 1); | 2013 gimple_set_num_ops (stmt, new_rhs_ops + 1); |
2020 gimple_set_subcode (stmt, code); | 2014 gimple_set_subcode (stmt, code); |
2226 | 2220 |
2227 /* Make copy of operands. */ | 2221 /* Make copy of operands. */ |
2228 if (num_ops > 0) | 2222 if (num_ops > 0) |
2229 { | 2223 { |
2230 for (i = 0; i < num_ops; i++) | 2224 for (i = 0; i < num_ops; i++) |
2231 gimple_set_op (copy, i, unshare_expr (gimple_op (stmt, i))); | 2225 gimple_set_op (copy, i, unshare_expr (gimple_op (stmt, i))); |
2232 | 2226 |
2233 /* Clear out SSA operand vectors on COPY. */ | 2227 /* Clear out SSA operand vectors on COPY. */ |
2234 if (gimple_has_ops (stmt)) | 2228 if (gimple_has_ops (stmt)) |
2235 { | 2229 { |
2236 gimple_set_def_ops (copy, NULL); | 2230 gimple_set_def_ops (copy, NULL); |
2237 gimple_set_use_ops (copy, NULL); | 2231 gimple_set_use_ops (copy, NULL); |
2238 } | 2232 } |
2239 | 2233 |
2240 if (gimple_has_mem_ops (stmt)) | 2234 if (gimple_has_mem_ops (stmt)) |
2241 { | 2235 { |
2242 gimple_set_vdef (copy, gimple_vdef (stmt)); | 2236 gimple_set_vdef (copy, gimple_vdef (stmt)); |
2243 gimple_set_vuse (copy, gimple_vuse (stmt)); | 2237 gimple_set_vuse (copy, gimple_vuse (stmt)); |
2244 } | 2238 } |
2245 | 2239 |
2246 /* SSA operands need to be updated. */ | 2240 /* SSA operands need to be updated. */ |
2247 gimple_set_modified (copy, true); | 2241 gimple_set_modified (copy, true); |
2248 } | 2242 } |
2249 | 2243 |
2260 if (gimple_has_ops (s)) | 2254 if (gimple_has_ops (s)) |
2261 { | 2255 { |
2262 s->gsbase.modified = (unsigned) modifiedp; | 2256 s->gsbase.modified = (unsigned) modifiedp; |
2263 | 2257 |
2264 if (modifiedp | 2258 if (modifiedp |
2265 && cfun->gimple_df | 2259 && cfun->gimple_df |
2266 && is_gimple_call (s) | 2260 && is_gimple_call (s) |
2267 && gimple_call_noreturn_p (s)) | 2261 && gimple_call_noreturn_p (s)) |
2268 VEC_safe_push (gimple, gc, MODIFIED_NORETURN_CALLS (cfun), s); | 2262 VEC_safe_push (gimple, gc, MODIFIED_NORETURN_CALLS (cfun), s); |
2269 } | 2263 } |
2270 } | 2264 } |
2271 | 2265 |
2272 | 2266 |
2273 /* Return true if statement S has side-effects. We consider a | 2267 /* Return true if statement S has side-effects. We consider a |
2295 unsigned nargs = gimple_call_num_args (s); | 2289 unsigned nargs = gimple_call_num_args (s); |
2296 | 2290 |
2297 if (!(gimple_call_flags (s) & (ECF_CONST | ECF_PURE))) | 2291 if (!(gimple_call_flags (s) & (ECF_CONST | ECF_PURE))) |
2298 return true; | 2292 return true; |
2299 else if (gimple_call_flags (s) & ECF_LOOPING_CONST_OR_PURE) | 2293 else if (gimple_call_flags (s) & ECF_LOOPING_CONST_OR_PURE) |
2300 /* An infinite loop is considered a side effect. */ | 2294 /* An infinite loop is considered a side effect. */ |
2301 return true; | 2295 return true; |
2302 | 2296 |
2303 if (gimple_call_lhs (s) | 2297 if (gimple_call_lhs (s) |
2304 && TREE_SIDE_EFFECTS (gimple_call_lhs (s))) | 2298 && TREE_SIDE_EFFECTS (gimple_call_lhs (s))) |
2305 { | 2299 { |
2306 gcc_assert (gimple_has_volatile_ops (s)); | 2300 gcc_assert (gimple_has_volatile_ops (s)); |
2307 return true; | 2301 return true; |
2308 } | 2302 } |
2309 | 2303 |
2310 if (TREE_SIDE_EFFECTS (gimple_call_fn (s))) | 2304 if (TREE_SIDE_EFFECTS (gimple_call_fn (s))) |
2311 return true; | 2305 return true; |
2312 | 2306 |
2313 for (i = 0; i < nargs; i++) | 2307 for (i = 0; i < nargs; i++) |
2314 if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i))) | 2308 if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i))) |
2315 { | 2309 { |
2316 gcc_assert (gimple_has_volatile_ops (s)); | 2310 gcc_assert (gimple_has_volatile_ops (s)); |
2317 return true; | 2311 return true; |
2318 } | 2312 } |
2319 | 2313 |
2320 return false; | 2314 return false; |
2321 } | 2315 } |
2322 else | 2316 else |
2323 { | 2317 { |
2324 for (i = 0; i < gimple_num_ops (s); i++) | 2318 for (i = 0; i < gimple_num_ops (s); i++) |
2325 if (TREE_SIDE_EFFECTS (gimple_op (s, i))) | 2319 if (TREE_SIDE_EFFECTS (gimple_op (s, i))) |
2326 { | 2320 { |
2327 gcc_assert (gimple_has_volatile_ops (s)); | 2321 gcc_assert (gimple_has_volatile_ops (s)); |
2328 return true; | 2322 return true; |
2329 } | 2323 } |
2330 } | 2324 } |
2331 | 2325 |
2332 return false; | 2326 return false; |
2333 } | 2327 } |
2334 | 2328 |
2352 | 2346 |
2353 /* We cannot use gimple_has_volatile_ops here, | 2347 /* We cannot use gimple_has_volatile_ops here, |
2354 because we must ignore a volatile LHS. */ | 2348 because we must ignore a volatile LHS. */ |
2355 if (TREE_SIDE_EFFECTS (gimple_call_fn (s)) | 2349 if (TREE_SIDE_EFFECTS (gimple_call_fn (s)) |
2356 || TREE_THIS_VOLATILE (gimple_call_fn (s))) | 2350 || TREE_THIS_VOLATILE (gimple_call_fn (s))) |
2357 { | 2351 { |
2358 gcc_assert (gimple_has_volatile_ops (s)); | 2352 gcc_assert (gimple_has_volatile_ops (s)); |
2359 return true; | 2353 return true; |
2360 } | 2354 } |
2361 | 2355 |
2362 for (i = 0; i < nargs; i++) | 2356 for (i = 0; i < nargs; i++) |
2363 if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i)) | 2357 if (TREE_SIDE_EFFECTS (gimple_call_arg (s, i)) |
2364 || TREE_THIS_VOLATILE (gimple_call_arg (s, i))) | 2358 || TREE_THIS_VOLATILE (gimple_call_arg (s, i))) |
2365 return true; | 2359 return true; |
2368 } | 2362 } |
2369 else if (is_gimple_assign (s)) | 2363 else if (is_gimple_assign (s)) |
2370 { | 2364 { |
2371 /* Skip the first operand, the LHS. */ | 2365 /* Skip the first operand, the LHS. */ |
2372 for (i = 1; i < gimple_num_ops (s); i++) | 2366 for (i = 1; i < gimple_num_ops (s); i++) |
2373 if (TREE_SIDE_EFFECTS (gimple_op (s, i)) | 2367 if (TREE_SIDE_EFFECTS (gimple_op (s, i)) |
2374 || TREE_THIS_VOLATILE (gimple_op (s, i))) | 2368 || TREE_THIS_VOLATILE (gimple_op (s, i))) |
2375 { | 2369 { |
2376 gcc_assert (gimple_has_volatile_ops (s)); | 2370 gcc_assert (gimple_has_volatile_ops (s)); |
2377 return true; | 2371 return true; |
2378 } | 2372 } |
2379 } | 2373 } |
2380 else if (is_gimple_debug (s)) | 2374 else if (is_gimple_debug (s)) |
2381 return false; | 2375 return false; |
2382 else | 2376 else |
2383 { | 2377 { |
2384 /* For statements without an LHS, examine all arguments. */ | 2378 /* For statements without an LHS, examine all arguments. */ |
2385 for (i = 0; i < gimple_num_ops (s); i++) | 2379 for (i = 0; i < gimple_num_ops (s); i++) |
2386 if (TREE_SIDE_EFFECTS (gimple_op (s, i)) | 2380 if (TREE_SIDE_EFFECTS (gimple_op (s, i)) |
2387 || TREE_THIS_VOLATILE (gimple_op (s, i))) | 2381 || TREE_THIS_VOLATILE (gimple_op (s, i))) |
2388 { | 2382 { |
2389 gcc_assert (gimple_has_volatile_ops (s)); | 2383 gcc_assert (gimple_has_volatile_ops (s)); |
2390 return true; | 2384 return true; |
2391 } | 2385 } |
2392 } | 2386 } |
2393 | 2387 |
2394 return false; | 2388 return false; |
2395 } | 2389 } |
2396 | 2390 |
2421 | 2415 |
2422 case GIMPLE_CALL: | 2416 case GIMPLE_CALL: |
2423 t = gimple_call_fndecl (s); | 2417 t = gimple_call_fndecl (s); |
2424 /* Assume that calls to weak functions may trap. */ | 2418 /* Assume that calls to weak functions may trap. */ |
2425 if (!t || !DECL_P (t) || DECL_WEAK (t)) | 2419 if (!t || !DECL_P (t) || DECL_WEAK (t)) |
2426 return true; | 2420 return true; |
2427 return false; | 2421 return false; |
2428 | 2422 |
2429 case GIMPLE_ASSIGN: | 2423 case GIMPLE_ASSIGN: |
2430 t = gimple_expr_type (s); | 2424 t = gimple_expr_type (s); |
2431 op = gimple_assign_rhs_code (s); | 2425 op = gimple_assign_rhs_code (s); |
2432 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) | 2426 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) |
2433 div = gimple_assign_rhs2 (s); | 2427 div = gimple_assign_rhs2 (s); |
2434 return (operation_could_trap_p (op, FLOAT_TYPE_P (t), | 2428 return (operation_could_trap_p (op, FLOAT_TYPE_P (t), |
2435 (INTEGRAL_TYPE_P (t) | 2429 (INTEGRAL_TYPE_P (t) |
2436 && TYPE_OVERFLOW_TRAPS (t)), | 2430 && TYPE_OVERFLOW_TRAPS (t)), |
2437 div)); | 2431 div)); |
2438 | 2432 |
2439 default: | 2433 default: |
2440 break; | 2434 break; |
2441 } | 2435 } |
2442 | 2436 |
2473 fprintf (stderr, "Kind Stmts Bytes\n"); | 2467 fprintf (stderr, "Kind Stmts Bytes\n"); |
2474 fprintf (stderr, "---------------------------------------\n"); | 2468 fprintf (stderr, "---------------------------------------\n"); |
2475 for (i = 0; i < (int) gimple_alloc_kind_all; ++i) | 2469 for (i = 0; i < (int) gimple_alloc_kind_all; ++i) |
2476 { | 2470 { |
2477 fprintf (stderr, "%-20s %7d %10d\n", gimple_alloc_kind_names[i], | 2471 fprintf (stderr, "%-20s %7d %10d\n", gimple_alloc_kind_names[i], |
2478 gimple_alloc_counts[i], gimple_alloc_sizes[i]); | 2472 gimple_alloc_counts[i], gimple_alloc_sizes[i]); |
2479 total_tuples += gimple_alloc_counts[i]; | 2473 total_tuples += gimple_alloc_counts[i]; |
2480 total_bytes += gimple_alloc_sizes[i]; | 2474 total_bytes += gimple_alloc_sizes[i]; |
2481 } | 2475 } |
2482 fprintf (stderr, "---------------------------------------\n"); | 2476 fprintf (stderr, "---------------------------------------\n"); |
2483 fprintf (stderr, "%-20s %7d %10d\n", "Total", total_tuples, total_bytes); | 2477 fprintf (stderr, "%-20s %7d %10d\n", "Total", total_tuples, total_bytes); |
2573 | 2567 |
2574 bool | 2568 bool |
2575 is_gimple_lvalue (tree t) | 2569 is_gimple_lvalue (tree t) |
2576 { | 2570 { |
2577 return (is_gimple_addressable (t) | 2571 return (is_gimple_addressable (t) |
2578 || TREE_CODE (t) == WITH_SIZE_EXPR | 2572 || TREE_CODE (t) == WITH_SIZE_EXPR |
2579 /* These are complex lvalues, but don't have addresses, so they | 2573 /* These are complex lvalues, but don't have addresses, so they |
2580 go here. */ | 2574 go here. */ |
2581 || TREE_CODE (t) == BIT_FIELD_REF); | 2575 || TREE_CODE (t) == BIT_FIELD_REF); |
2582 } | 2576 } |
2583 | 2577 |
2584 /* Return true if T is a GIMPLE condition. */ | 2578 /* Return true if T is a GIMPLE condition. */ |
2585 | 2579 |
2586 bool | 2580 bool |
2587 is_gimple_condexpr (tree t) | 2581 is_gimple_condexpr (tree t) |
2588 { | 2582 { |
2589 return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) | 2583 return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) |
2590 && !tree_could_trap_p (t) | 2584 && !tree_could_trap_p (t) |
2591 && is_gimple_val (TREE_OPERAND (t, 0)) | 2585 && is_gimple_val (TREE_OPERAND (t, 0)) |
2592 && is_gimple_val (TREE_OPERAND (t, 1)))); | 2586 && is_gimple_val (TREE_OPERAND (t, 1)))); |
2593 } | 2587 } |
2594 | 2588 |
2595 /* Return true if T is something whose address can be taken. */ | 2589 /* Return true if T is something whose address can be taken. */ |
2596 | 2590 |
2597 bool | 2591 bool |
2617 return true; | 2611 return true; |
2618 | 2612 |
2619 /* Vector constant constructors are gimple invariant. */ | 2613 /* Vector constant constructors are gimple invariant. */ |
2620 case CONSTRUCTOR: | 2614 case CONSTRUCTOR: |
2621 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE) | 2615 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE) |
2622 return TREE_CONSTANT (t); | 2616 return TREE_CONSTANT (t); |
2623 else | 2617 else |
2624 return false; | 2618 return false; |
2625 | 2619 |
2626 default: | 2620 default: |
2627 return false; | 2621 return false; |
2628 } | 2622 } |
2629 } | 2623 } |
2640 | 2634 |
2641 op = TREE_OPERAND (t, 0); | 2635 op = TREE_OPERAND (t, 0); |
2642 while (handled_component_p (op)) | 2636 while (handled_component_p (op)) |
2643 { | 2637 { |
2644 if ((TREE_CODE (op) == ARRAY_REF | 2638 if ((TREE_CODE (op) == ARRAY_REF |
2645 || TREE_CODE (op) == ARRAY_RANGE_REF) | 2639 || TREE_CODE (op) == ARRAY_RANGE_REF) |
2646 && !is_gimple_val (TREE_OPERAND (op, 1))) | 2640 && !is_gimple_val (TREE_OPERAND (op, 1))) |
2647 return false; | 2641 return false; |
2648 | 2642 |
2649 op = TREE_OPERAND (op, 0); | 2643 op = TREE_OPERAND (op, 0); |
2650 } | 2644 } |
2651 | 2645 |
2652 if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF) | 2646 if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF) |
2674 strip_invariant_refs (const_tree op) | 2668 strip_invariant_refs (const_tree op) |
2675 { | 2669 { |
2676 while (handled_component_p (op)) | 2670 while (handled_component_p (op)) |
2677 { | 2671 { |
2678 switch (TREE_CODE (op)) | 2672 switch (TREE_CODE (op)) |
2679 { | 2673 { |
2680 case ARRAY_REF: | 2674 case ARRAY_REF: |
2681 case ARRAY_RANGE_REF: | 2675 case ARRAY_RANGE_REF: |
2682 if (!is_gimple_constant (TREE_OPERAND (op, 1)) | 2676 if (!is_gimple_constant (TREE_OPERAND (op, 1)) |
2683 || TREE_OPERAND (op, 2) != NULL_TREE | 2677 || TREE_OPERAND (op, 2) != NULL_TREE |
2684 || TREE_OPERAND (op, 3) != NULL_TREE) | 2678 || TREE_OPERAND (op, 3) != NULL_TREE) |
2685 return NULL; | 2679 return NULL; |
2686 break; | 2680 break; |
2687 | 2681 |
2688 case COMPONENT_REF: | 2682 case COMPONENT_REF: |
2689 if (TREE_OPERAND (op, 2) != NULL_TREE) | 2683 if (TREE_OPERAND (op, 2) != NULL_TREE) |
2690 return NULL; | 2684 return NULL; |
2691 break; | 2685 break; |
2692 | 2686 |
2693 default:; | 2687 default:; |
2694 } | 2688 } |
2695 op = TREE_OPERAND (op, 0); | 2689 op = TREE_OPERAND (op, 0); |
2696 } | 2690 } |
2697 | 2691 |
2698 return op; | 2692 return op; |
2699 } | 2693 } |
2819 | 2813 |
2820 bool | 2814 bool |
2821 is_gimple_variable (tree t) | 2815 is_gimple_variable (tree t) |
2822 { | 2816 { |
2823 return (TREE_CODE (t) == VAR_DECL | 2817 return (TREE_CODE (t) == VAR_DECL |
2824 || TREE_CODE (t) == PARM_DECL | 2818 || TREE_CODE (t) == PARM_DECL |
2825 || TREE_CODE (t) == RESULT_DECL | 2819 || TREE_CODE (t) == RESULT_DECL |
2826 || TREE_CODE (t) == SSA_NAME); | 2820 || TREE_CODE (t) == SSA_NAME); |
2827 } | 2821 } |
2828 | 2822 |
2829 /* Return true if T is a GIMPLE identifier (something with an address). */ | 2823 /* Return true if T is a GIMPLE identifier (something with an address). */ |
2830 | 2824 |
2831 bool | 2825 bool |
2832 is_gimple_id (tree t) | 2826 is_gimple_id (tree t) |
2833 { | 2827 { |
2834 return (is_gimple_variable (t) | 2828 return (is_gimple_variable (t) |
2835 || TREE_CODE (t) == FUNCTION_DECL | 2829 || TREE_CODE (t) == FUNCTION_DECL |
2836 || TREE_CODE (t) == LABEL_DECL | 2830 || TREE_CODE (t) == LABEL_DECL |
2837 || TREE_CODE (t) == CONST_DECL | 2831 || TREE_CODE (t) == CONST_DECL |
2838 /* Allow string constants, since they are addressable. */ | 2832 /* Allow string constants, since they are addressable. */ |
2839 || TREE_CODE (t) == STRING_CST); | 2833 || TREE_CODE (t) == STRING_CST); |
2840 } | 2834 } |
2841 | 2835 |
2842 /* Return true if TYPE is a suitable type for a scalar register variable. */ | 2836 /* Return true if TYPE is a suitable type for a scalar register variable. */ |
2843 | 2837 |
2844 bool | 2838 bool |
3017 | 3011 |
3018 switch (TREE_CODE_CLASS (code)) | 3012 switch (TREE_CODE_CLASS (code)) |
3019 { | 3013 { |
3020 case tcc_expression: | 3014 case tcc_expression: |
3021 switch (code) | 3015 switch (code) |
3022 { | 3016 { |
3023 case INIT_EXPR: | 3017 case INIT_EXPR: |
3024 case MODIFY_EXPR: | 3018 case MODIFY_EXPR: |
3025 case VA_ARG_EXPR: | 3019 case VA_ARG_EXPR: |
3026 case PREDECREMENT_EXPR: | 3020 case PREDECREMENT_EXPR: |
3027 case PREINCREMENT_EXPR: | 3021 case PREINCREMENT_EXPR: |
3028 case POSTDECREMENT_EXPR: | 3022 case POSTDECREMENT_EXPR: |
3029 case POSTINCREMENT_EXPR: | 3023 case POSTINCREMENT_EXPR: |
3030 /* All of these have side-effects, no matter what their | 3024 /* All of these have side-effects, no matter what their |
3031 operands are. */ | 3025 operands are. */ |
3032 return; | 3026 return; |
3033 | 3027 |
3034 default: | 3028 default: |
3035 break; | 3029 break; |
3036 } | 3030 } |
3037 /* Fall through. */ | 3031 /* Fall through. */ |
3038 | 3032 |
3039 case tcc_comparison: /* a comparison expression */ | 3033 case tcc_comparison: /* a comparison expression */ |
3040 case tcc_unary: /* a unary arithmetic expression */ | 3034 case tcc_unary: /* a unary arithmetic expression */ |
3041 case tcc_binary: /* a binary arithmetic expression */ | 3035 case tcc_binary: /* a binary arithmetic expression */ |
3042 case tcc_reference: /* a reference */ | 3036 case tcc_reference: /* a reference */ |
3043 case tcc_vl_exp: /* a function call */ | 3037 case tcc_vl_exp: /* a function call */ |
3044 TREE_SIDE_EFFECTS (t) = TREE_THIS_VOLATILE (t); | 3038 TREE_SIDE_EFFECTS (t) = TREE_THIS_VOLATILE (t); |
3045 for (i = 0; i < len; ++i) | 3039 for (i = 0; i < len; ++i) |
3046 { | 3040 { |
3047 tree op = TREE_OPERAND (t, i); | 3041 tree op = TREE_OPERAND (t, i); |
3048 if (op && TREE_SIDE_EFFECTS (op)) | 3042 if (op && TREE_SIDE_EFFECTS (op)) |
3049 TREE_SIDE_EFFECTS (t) = 1; | 3043 TREE_SIDE_EFFECTS (t) = 1; |
3050 } | 3044 } |
3051 break; | 3045 break; |
3052 | 3046 |
3053 case tcc_constant: | 3047 case tcc_constant: |
3054 /* No side-effects. */ | 3048 /* No side-effects. */ |
3055 return; | 3049 return; |
3075 if (CONVERT_EXPR_P (t) | 3069 if (CONVERT_EXPR_P (t) |
3076 && TREE_CODE (TREE_TYPE (t)) == BOOLEAN_TYPE) | 3070 && TREE_CODE (TREE_TYPE (t)) == BOOLEAN_TYPE) |
3077 { | 3071 { |
3078 tree top0 = TREE_OPERAND (t, 0); | 3072 tree top0 = TREE_OPERAND (t, 0); |
3079 t = build2 (NE_EXPR, TREE_TYPE (t), | 3073 t = build2 (NE_EXPR, TREE_TYPE (t), |
3080 top0, build_int_cst (TREE_TYPE (top0), 0)); | 3074 top0, build_int_cst (TREE_TYPE (top0), 0)); |
3081 } | 3075 } |
3082 /* For !x use x == 0. */ | 3076 /* For !x use x == 0. */ |
3083 else if (TREE_CODE (t) == TRUTH_NOT_EXPR) | 3077 else if (TREE_CODE (t) == TRUTH_NOT_EXPR) |
3084 { | 3078 { |
3085 tree top0 = TREE_OPERAND (t, 0); | 3079 tree top0 = TREE_OPERAND (t, 0); |
3086 t = build2 (EQ_EXPR, TREE_TYPE (t), | 3080 t = build2 (EQ_EXPR, TREE_TYPE (t), |
3087 top0, build_int_cst (TREE_TYPE (top0), 0)); | 3081 top0, build_int_cst (TREE_TYPE (top0), 0)); |
3088 } | 3082 } |
3089 /* For cmp ? 1 : 0 use cmp. */ | 3083 /* For cmp ? 1 : 0 use cmp. */ |
3090 else if (TREE_CODE (t) == COND_EXPR | 3084 else if (TREE_CODE (t) == COND_EXPR |
3091 && COMPARISON_CLASS_P (TREE_OPERAND (t, 0)) | 3085 && COMPARISON_CLASS_P (TREE_OPERAND (t, 0)) |
3092 && integer_onep (TREE_OPERAND (t, 1)) | 3086 && integer_onep (TREE_OPERAND (t, 1)) |
3093 && integer_zerop (TREE_OPERAND (t, 2))) | 3087 && integer_zerop (TREE_OPERAND (t, 2))) |
3094 { | 3088 { |
3095 tree top0 = TREE_OPERAND (t, 0); | 3089 tree top0 = TREE_OPERAND (t, 0); |
3096 t = build2 (TREE_CODE (top0), TREE_TYPE (t), | 3090 t = build2 (TREE_CODE (top0), TREE_TYPE (t), |
3097 TREE_OPERAND (top0, 0), TREE_OPERAND (top0, 1)); | 3091 TREE_OPERAND (top0, 0), TREE_OPERAND (top0, 1)); |
3098 } | 3092 } |
3099 | 3093 |
3100 if (is_gimple_condexpr (t)) | 3094 if (is_gimple_condexpr (t)) |
3101 return t; | 3095 return t; |
3102 | 3096 |
3130 gimple_set_block (new_stmt, gimple_block (stmt)); | 3124 gimple_set_block (new_stmt, gimple_block (stmt)); |
3131 if (gimple_has_location (stmt)) | 3125 if (gimple_has_location (stmt)) |
3132 gimple_set_location (new_stmt, gimple_location (stmt)); | 3126 gimple_set_location (new_stmt, gimple_location (stmt)); |
3133 gimple_call_copy_flags (new_stmt, stmt); | 3127 gimple_call_copy_flags (new_stmt, stmt); |
3134 gimple_call_set_chain (new_stmt, gimple_call_chain (stmt)); | 3128 gimple_call_set_chain (new_stmt, gimple_call_chain (stmt)); |
3135 #ifndef noCbC | |
3136 gimple_call_set_cbc_goto (new_stmt, gimple_call_cbc_goto_p (stmt)); | |
3137 #endif | |
3138 | 3129 |
3139 gimple_set_modified (new_stmt, true); | 3130 gimple_set_modified (new_stmt, true); |
3131 | |
3140 return new_stmt; | 3132 return new_stmt; |
3141 } | 3133 } |
3142 | 3134 |
3143 | 3135 |
3144 static hashval_t gimple_type_hash_1 (const void *, enum gtc_mode); | 3136 static hashval_t gimple_type_hash_1 (const void *, enum gtc_mode); |
3172 { | 3164 { |
3173 const struct type_pair_d *pair = (const struct type_pair_d *) p; | 3165 const struct type_pair_d *pair = (const struct type_pair_d *) p; |
3174 hashval_t val1 = pair->uid1; | 3166 hashval_t val1 = pair->uid1; |
3175 hashval_t val2 = pair->uid2; | 3167 hashval_t val2 = pair->uid2; |
3176 return (iterative_hash_hashval_t (val2, val1) | 3168 return (iterative_hash_hashval_t (val2, val1) |
3177 ^ iterative_hash_hashval_t (val1, val2)); | 3169 ^ iterative_hash_hashval_t (val1, val2)); |
3178 } | 3170 } |
3179 | 3171 |
3180 /* Compare two type pairs pointed-to by P1 and P2. */ | 3172 /* Compare two type pairs pointed-to by P1 and P2. */ |
3181 | 3173 |
3182 static int | 3174 static int |
3183 type_pair_eq (const void *p1, const void *p2) | 3175 type_pair_eq (const void *p1, const void *p2) |
3184 { | 3176 { |
3185 const struct type_pair_d *pair1 = (const struct type_pair_d *) p1; | 3177 const struct type_pair_d *pair1 = (const struct type_pair_d *) p1; |
3186 const struct type_pair_d *pair2 = (const struct type_pair_d *) p2; | 3178 const struct type_pair_d *pair2 = (const struct type_pair_d *) p2; |
3187 return ((pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2) | 3179 return ((pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2) |
3188 || (pair1->uid1 == pair2->uid2 && pair1->uid2 == pair2->uid1)); | 3180 || (pair1->uid1 == pair2->uid2 && pair1->uid2 == pair2->uid1)); |
3189 } | 3181 } |
3190 | 3182 |
3191 /* Lookup the pair of types T1 and T2 in *VISITED_P. Insert a new | 3183 /* Lookup the pair of types T1 and T2 in *VISITED_P. Insert a new |
3192 entry if none existed. */ | 3184 entry if none existed. */ |
3193 | 3185 |
3289 | 3281 |
3290 if (name1 && TREE_CODE (name1) == TYPE_DECL) | 3282 if (name1 && TREE_CODE (name1) == TYPE_DECL) |
3291 { | 3283 { |
3292 name1 = DECL_NAME (name1); | 3284 name1 = DECL_NAME (name1); |
3293 if (for_completion_p | 3285 if (for_completion_p |
3294 && !name1) | 3286 && !name1) |
3295 return false; | 3287 return false; |
3296 } | 3288 } |
3297 gcc_assert (!name1 || TREE_CODE (name1) == IDENTIFIER_NODE); | 3289 gcc_assert (!name1 || TREE_CODE (name1) == IDENTIFIER_NODE); |
3298 | 3290 |
3299 if (name2 && TREE_CODE (name2) == TYPE_DECL) | 3291 if (name2 && TREE_CODE (name2) == TYPE_DECL) |
3300 { | 3292 { |
3301 name2 = DECL_NAME (name2); | 3293 name2 = DECL_NAME (name2); |
3302 if (for_completion_p | 3294 if (for_completion_p |
3303 && !name2) | 3295 && !name2) |
3304 return false; | 3296 return false; |
3305 } | 3297 } |
3306 gcc_assert (!name2 || TREE_CODE (name2) == IDENTIFIER_NODE); | 3298 gcc_assert (!name2 || TREE_CODE (name2) == IDENTIFIER_NODE); |
3307 | 3299 |
3308 /* Identifiers can be compared with pointer equality rather | 3300 /* Identifiers can be compared with pointer equality rather |
3309 than a string comparison. */ | 3301 than a string comparison. */ |
3351 { | 3343 { |
3352 unsigned HOST_WIDE_INT byte_offset1, byte_offset2; | 3344 unsigned HOST_WIDE_INT byte_offset1, byte_offset2; |
3353 unsigned HOST_WIDE_INT bit_offset1, bit_offset2; | 3345 unsigned HOST_WIDE_INT bit_offset1, bit_offset2; |
3354 bit_offset1 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f1)); | 3346 bit_offset1 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f1)); |
3355 byte_offset1 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f1)) | 3347 byte_offset1 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f1)) |
3356 + bit_offset1 / BITS_PER_UNIT); | 3348 + bit_offset1 / BITS_PER_UNIT); |
3357 bit_offset2 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f2)); | 3349 bit_offset2 = TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (f2)); |
3358 byte_offset2 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f2)) | 3350 byte_offset2 = (TREE_INT_CST_LOW (DECL_FIELD_OFFSET (f2)) |
3359 + bit_offset2 / BITS_PER_UNIT); | 3351 + bit_offset2 / BITS_PER_UNIT); |
3360 if (byte_offset1 != byte_offset2) | 3352 if (byte_offset1 != byte_offset2) |
3361 return false; | 3353 return false; |
3362 return bit_offset1 % BITS_PER_UNIT == bit_offset2 % BITS_PER_UNIT; | 3354 return bit_offset1 % BITS_PER_UNIT == bit_offset2 % BITS_PER_UNIT; |
3363 } | 3355 } |
3364 | 3356 |
3365 return false; | 3357 return false; |
3366 } | 3358 } |
3451 || TREE_CODE (t1) == VECTOR_TYPE | 3443 || TREE_CODE (t1) == VECTOR_TYPE |
3452 || TREE_CODE (t1) == COMPLEX_TYPE | 3444 || TREE_CODE (t1) == COMPLEX_TYPE |
3453 || TREE_CODE (t1) == OFFSET_TYPE) | 3445 || TREE_CODE (t1) == OFFSET_TYPE) |
3454 { | 3446 { |
3455 /* Can't be the same type if they have different alignment, | 3447 /* Can't be the same type if they have different alignment, |
3456 sign, precision or mode. */ | 3448 sign, precision or mode. */ |
3457 if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2) | 3449 if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2) |
3458 || TYPE_PRECISION (t1) != TYPE_PRECISION (t2) | 3450 || TYPE_PRECISION (t1) != TYPE_PRECISION (t2) |
3459 || TYPE_MODE (t1) != TYPE_MODE (t2) | 3451 || TYPE_MODE (t1) != TYPE_MODE (t2) |
3460 || TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2)) | 3452 || TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2)) |
3461 return false; | 3453 return false; |
3692 goto same_types; | 3684 goto same_types; |
3693 | 3685 |
3694 case INTEGER_TYPE: | 3686 case INTEGER_TYPE: |
3695 case BOOLEAN_TYPE: | 3687 case BOOLEAN_TYPE: |
3696 { | 3688 { |
3697 tree min1 = TYPE_MIN_VALUE (t1); | 3689 tree min1 = TYPE_MIN_VALUE (t1); |
3698 tree max1 = TYPE_MAX_VALUE (t1); | 3690 tree max1 = TYPE_MAX_VALUE (t1); |
3699 tree min2 = TYPE_MIN_VALUE (t2); | 3691 tree min2 = TYPE_MIN_VALUE (t2); |
3700 tree max2 = TYPE_MAX_VALUE (t2); | 3692 tree max2 = TYPE_MAX_VALUE (t2); |
3701 bool min_equal_p = false; | 3693 bool min_equal_p = false; |
3702 bool max_equal_p = false; | 3694 bool max_equal_p = false; |
3703 | 3695 |
3704 /* If either type has a minimum value, the other type must | 3696 /* If either type has a minimum value, the other type must |
3705 have the same. */ | 3697 have the same. */ |
3706 if (min1 == NULL_TREE && min2 == NULL_TREE) | 3698 if (min1 == NULL_TREE && min2 == NULL_TREE) |
3707 min_equal_p = true; | 3699 min_equal_p = true; |
3708 else if (min1 && min2 && operand_equal_p (min1, min2, 0)) | 3700 else if (min1 && min2 && operand_equal_p (min1, min2, 0)) |
3709 min_equal_p = true; | 3701 min_equal_p = true; |
3710 | 3702 |
3711 /* Likewise, if either type has a maximum value, the other | 3703 /* Likewise, if either type has a maximum value, the other |
3712 type must have the same. */ | 3704 type must have the same. */ |
3713 if (max1 == NULL_TREE && max2 == NULL_TREE) | 3705 if (max1 == NULL_TREE && max2 == NULL_TREE) |
3714 max_equal_p = true; | 3706 max_equal_p = true; |
3715 else if (max1 && max2 && operand_equal_p (max1, max2, 0)) | 3707 else if (max1 && max2 && operand_equal_p (max1, max2, 0)) |
3716 max_equal_p = true; | 3708 max_equal_p = true; |
3717 | 3709 |
3718 if (!min_equal_p || !max_equal_p) | 3710 if (!min_equal_p || !max_equal_p) |
3719 goto different_types; | 3711 goto different_types; |
3720 | 3712 |
3721 goto same_types; | 3713 goto same_types; |
3722 } | 3714 } |
3723 | 3715 |
3724 case ENUMERAL_TYPE: | 3716 case ENUMERAL_TYPE: |
3725 { | 3717 { |
3726 /* FIXME lto, we cannot check bounds on enumeral types because | 3718 /* FIXME lto, we cannot check bounds on enumeral types because |
3727 different front ends will produce different values. | 3719 different front ends will produce different values. |
3728 In C, enumeral types are integers, while in C++ each element | 3720 In C, enumeral types are integers, while in C++ each element |
3729 will have its own symbolic value. We should decide how enums | 3721 will have its own symbolic value. We should decide how enums |
3730 are to be represented in GIMPLE and have each front end lower | 3722 are to be represented in GIMPLE and have each front end lower |
3731 to that. */ | 3723 to that. */ |
3732 tree v1, v2; | 3724 tree v1, v2; |
3733 | 3725 |
3734 /* For enumeral types, all the values must be the same. */ | 3726 /* For enumeral types, all the values must be the same. */ |
3735 if (TYPE_VALUES (t1) == TYPE_VALUES (t2)) | 3727 if (TYPE_VALUES (t1) == TYPE_VALUES (t2)) |
3736 goto same_types; | 3728 goto same_types; |
3737 | 3729 |
3738 for (v1 = TYPE_VALUES (t1), v2 = TYPE_VALUES (t2); | 3730 for (v1 = TYPE_VALUES (t1), v2 = TYPE_VALUES (t2); |
3739 v1 && v2; | 3731 v1 && v2; |
3740 v1 = TREE_CHAIN (v1), v2 = TREE_CHAIN (v2)) | 3732 v1 = TREE_CHAIN (v1), v2 = TREE_CHAIN (v2)) |
3741 { | 3733 { |
3742 tree c1 = TREE_VALUE (v1); | 3734 tree c1 = TREE_VALUE (v1); |
3743 tree c2 = TREE_VALUE (v2); | 3735 tree c2 = TREE_VALUE (v2); |
3744 | 3736 |
3745 if (TREE_CODE (c1) == CONST_DECL) | 3737 if (TREE_CODE (c1) == CONST_DECL) |
3746 c1 = DECL_INITIAL (c1); | 3738 c1 = DECL_INITIAL (c1); |
3747 | 3739 |
3748 if (TREE_CODE (c2) == CONST_DECL) | 3740 if (TREE_CODE (c2) == CONST_DECL) |
3749 c2 = DECL_INITIAL (c2); | 3741 c2 = DECL_INITIAL (c2); |
3750 | 3742 |
3751 if (tree_int_cst_equal (c1, c2) != 1) | 3743 if (tree_int_cst_equal (c1, c2) != 1) |
3752 goto different_types; | 3744 goto different_types; |
3753 } | 3745 } |
3754 | 3746 |
3755 /* If one enumeration has more values than the other, they | 3747 /* If one enumeration has more values than the other, they |
3756 are not the same. */ | 3748 are not the same. */ |
3757 if (v1 || v2) | 3749 if (v1 || v2) |
3758 goto different_types; | 3750 goto different_types; |
3759 | 3751 |
3760 goto same_types; | 3752 goto same_types; |
3761 } | 3753 } |
3762 | 3754 |
3763 case RECORD_TYPE: | 3755 case RECORD_TYPE: |
3764 case UNION_TYPE: | 3756 case UNION_TYPE: |
3765 case QUAL_UNION_TYPE: | 3757 case QUAL_UNION_TYPE: |
3986 /* Not yet visited. DFS recurse. */ | 3978 /* Not yet visited. DFS recurse. */ |
3987 tem = iterative_hash_gimple_type (t, v, | 3979 tem = iterative_hash_gimple_type (t, v, |
3988 sccstack, sccstate, sccstate_obstack, | 3980 sccstack, sccstate, sccstate_obstack, |
3989 mode); | 3981 mode); |
3990 if (!cstate) | 3982 if (!cstate) |
3991 cstate = (struct sccs *)* pointer_map_contains (sccstate, t); | 3983 cstate = (struct sccs *)* pointer_map_contains (sccstate, t); |
3992 state->low = MIN (state->low, cstate->low); | 3984 state->low = MIN (state->low, cstate->low); |
3993 /* If the type is no longer on the SCC stack and thus is not part | 3985 /* If the type is no longer on the SCC stack and thus is not part |
3994 of the parents SCC mix in its hash value. Otherwise we will | 3986 of the parents SCC mix in its hash value. Otherwise we will |
3995 ignore the type for hashing purposes and return the unaltered | 3987 ignore the type for hashing purposes and return the unaltered |
3996 hash value. */ | 3988 hash value. */ |
3997 if (!cstate->on_sccstack) | 3989 if (!cstate->on_sccstack) |
3998 return tem; | 3990 return tem; |
3999 } | 3991 } |
4000 if (cstate->dfsnum < state->dfsnum | 3992 if (cstate->dfsnum < state->dfsnum |
4001 && cstate->on_sccstack) | 3993 && cstate->on_sccstack) |
4002 state->low = MIN (cstate->dfsnum, state->low); | 3994 state->low = MIN (cstate->dfsnum, state->low); |
4003 | 3995 |
4325 | 4317 |
4326 /* Do not merge types with different addressability. */ | 4318 /* Do not merge types with different addressability. */ |
4327 gcc_assert (TREE_ADDRESSABLE (t) == TREE_ADDRESSABLE (new_type)); | 4319 gcc_assert (TREE_ADDRESSABLE (t) == TREE_ADDRESSABLE (new_type)); |
4328 | 4320 |
4329 /* If t is not its main variant then make t unreachable from its | 4321 /* If t is not its main variant then make t unreachable from its |
4330 main variant list. Otherwise we'd queue up a lot of duplicates | 4322 main variant list. Otherwise we'd queue up a lot of duplicates |
4331 there. */ | 4323 there. */ |
4332 if (t != TYPE_MAIN_VARIANT (t)) | 4324 if (t != TYPE_MAIN_VARIANT (t)) |
4333 { | 4325 { |
4334 tree tem = TYPE_MAIN_VARIANT (t); | 4326 tree tem = TYPE_MAIN_VARIANT (t); |
4335 while (tem && TYPE_NEXT_VARIANT (tem) != t) | 4327 while (tem && TYPE_NEXT_VARIANT (tem) != t) |
4336 tem = TYPE_NEXT_VARIANT (tem); | 4328 tem = TYPE_NEXT_VARIANT (tem); |
4337 if (tem) | 4329 if (tem) |
4338 TYPE_NEXT_VARIANT (tem) = TYPE_NEXT_VARIANT (t); | 4330 TYPE_NEXT_VARIANT (tem) = TYPE_NEXT_VARIANT (t); |
4339 TYPE_NEXT_VARIANT (t) = NULL_TREE; | 4331 TYPE_NEXT_VARIANT (t) = NULL_TREE; |
4340 } | 4332 } |
4341 | 4333 |
4342 /* If we are a pointer then remove us from the pointer-to or | 4334 /* If we are a pointer then remove us from the pointer-to or |
4343 reference-to chain. Otherwise we'd queue up a lot of duplicates | 4335 reference-to chain. Otherwise we'd queue up a lot of duplicates |
4344 there. */ | 4336 there. */ |
4345 if (TREE_CODE (t) == POINTER_TYPE) | 4337 if (TREE_CODE (t) == POINTER_TYPE) |
4346 { | 4338 { |
4347 if (TYPE_POINTER_TO (TREE_TYPE (t)) == t) | 4339 if (TYPE_POINTER_TO (TREE_TYPE (t)) == t) |
4348 TYPE_POINTER_TO (TREE_TYPE (t)) = TYPE_NEXT_PTR_TO (t); | 4340 TYPE_POINTER_TO (TREE_TYPE (t)) = TYPE_NEXT_PTR_TO (t); |
4349 else | 4341 else |
4350 { | 4342 { |
4351 tree tem = TYPE_POINTER_TO (TREE_TYPE (t)); | 4343 tree tem = TYPE_POINTER_TO (TREE_TYPE (t)); |
4352 while (tem && TYPE_NEXT_PTR_TO (tem) != t) | 4344 while (tem && TYPE_NEXT_PTR_TO (tem) != t) |
4353 tem = TYPE_NEXT_PTR_TO (tem); | 4345 tem = TYPE_NEXT_PTR_TO (tem); |
4354 if (tem) | 4346 if (tem) |
4355 TYPE_NEXT_PTR_TO (tem) = TYPE_NEXT_PTR_TO (t); | 4347 TYPE_NEXT_PTR_TO (tem) = TYPE_NEXT_PTR_TO (t); |
4356 } | 4348 } |
4357 TYPE_NEXT_PTR_TO (t) = NULL_TREE; | 4349 TYPE_NEXT_PTR_TO (t) = NULL_TREE; |
4358 } | 4350 } |
4359 else if (TREE_CODE (t) == REFERENCE_TYPE) | 4351 else if (TREE_CODE (t) == REFERENCE_TYPE) |
4360 { | 4352 { |
4361 if (TYPE_REFERENCE_TO (TREE_TYPE (t)) == t) | 4353 if (TYPE_REFERENCE_TO (TREE_TYPE (t)) == t) |
4362 TYPE_REFERENCE_TO (TREE_TYPE (t)) = TYPE_NEXT_REF_TO (t); | 4354 TYPE_REFERENCE_TO (TREE_TYPE (t)) = TYPE_NEXT_REF_TO (t); |
4363 else | 4355 else |
4364 { | 4356 { |
4365 tree tem = TYPE_REFERENCE_TO (TREE_TYPE (t)); | 4357 tree tem = TYPE_REFERENCE_TO (TREE_TYPE (t)); |
4366 while (tem && TYPE_NEXT_REF_TO (tem) != t) | 4358 while (tem && TYPE_NEXT_REF_TO (tem) != t) |
4367 tem = TYPE_NEXT_REF_TO (tem); | 4359 tem = TYPE_NEXT_REF_TO (tem); |
4368 if (tem) | 4360 if (tem) |
4369 TYPE_NEXT_REF_TO (tem) = TYPE_NEXT_REF_TO (t); | 4361 TYPE_NEXT_REF_TO (tem) = TYPE_NEXT_REF_TO (t); |
4370 } | 4362 } |
4371 TYPE_NEXT_REF_TO (t) = NULL_TREE; | 4363 TYPE_NEXT_REF_TO (t) = NULL_TREE; |
4372 } | 4364 } |
4373 | 4365 |
4374 leader->type = t; | 4366 leader->type = t; |
4375 leader->leader = new_type; | 4367 leader->leader = new_type; |
4376 t = new_type; | 4368 t = new_type; |
4377 } | 4369 } |
4470 void | 4462 void |
4471 print_gimple_types_stats (void) | 4463 print_gimple_types_stats (void) |
4472 { | 4464 { |
4473 if (gimple_types) | 4465 if (gimple_types) |
4474 fprintf (stderr, "GIMPLE type table: size %ld, %ld elements, " | 4466 fprintf (stderr, "GIMPLE type table: size %ld, %ld elements, " |
4475 "%ld searches, %ld collisions (ratio: %f)\n", | 4467 "%ld searches, %ld collisions (ratio: %f)\n", |
4476 (long) htab_size (gimple_types), | 4468 (long) htab_size (gimple_types), |
4477 (long) htab_elements (gimple_types), | 4469 (long) htab_elements (gimple_types), |
4478 (long) gimple_types->searches, | 4470 (long) gimple_types->searches, |
4479 (long) gimple_types->collisions, | 4471 (long) gimple_types->collisions, |
4480 htab_collisions (gimple_types)); | 4472 htab_collisions (gimple_types)); |
4481 else | 4473 else |
4482 fprintf (stderr, "GIMPLE type table is empty\n"); | 4474 fprintf (stderr, "GIMPLE type table is empty\n"); |
4483 if (type_hash_cache) | 4475 if (type_hash_cache) |
4484 fprintf (stderr, "GIMPLE type hash table: size %ld, %ld elements, " | 4476 fprintf (stderr, "GIMPLE type hash table: size %ld, %ld elements, " |
4485 "%ld searches, %ld collisions (ratio: %f)\n", | 4477 "%ld searches, %ld collisions (ratio: %f)\n", |
4510 htab_collisions (canonical_type_hash_cache)); | 4502 htab_collisions (canonical_type_hash_cache)); |
4511 else | 4503 else |
4512 fprintf (stderr, "GIMPLE canonical type hash table is empty\n"); | 4504 fprintf (stderr, "GIMPLE canonical type hash table is empty\n"); |
4513 if (gtc_visited) | 4505 if (gtc_visited) |
4514 fprintf (stderr, "GIMPLE type comparison table: size %ld, %ld " | 4506 fprintf (stderr, "GIMPLE type comparison table: size %ld, %ld " |
4515 "elements, %ld searches, %ld collisions (ratio: %f)\n", | 4507 "elements, %ld searches, %ld collisions (ratio: %f)\n", |
4516 (long) htab_size (gtc_visited), | 4508 (long) htab_size (gtc_visited), |
4517 (long) htab_elements (gtc_visited), | 4509 (long) htab_elements (gtc_visited), |
4518 (long) gtc_visited->searches, | 4510 (long) gtc_visited->searches, |
4519 (long) gtc_visited->collisions, | 4511 (long) gtc_visited->collisions, |
4520 htab_collisions (gtc_visited)); | 4512 htab_collisions (gtc_visited)); |
4521 else | 4513 else |
4522 fprintf (stderr, "GIMPLE type comparison table is empty\n"); | 4514 fprintf (stderr, "GIMPLE type comparison table is empty\n"); |
4523 } | 4515 } |
4524 | 4516 |
4525 /* Free the gimple type hashtables used for LTO type merging. */ | 4517 /* Free the gimple type hashtables used for LTO type merging. */ |
4600 if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node) | 4592 if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node) |
4601 return unsignedp ? unsigned_intHI_type_node : intHI_type_node; | 4593 return unsignedp ? unsigned_intHI_type_node : intHI_type_node; |
4602 if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node) | 4594 if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node) |
4603 return unsignedp ? unsigned_intQI_type_node : intQI_type_node; | 4595 return unsignedp ? unsigned_intQI_type_node : intQI_type_node; |
4604 | 4596 |
4605 #define GIMPLE_FIXED_TYPES(NAME) \ | 4597 #define GIMPLE_FIXED_TYPES(NAME) \ |
4606 if (type1 == short_ ## NAME ## _type_node \ | 4598 if (type1 == short_ ## NAME ## _type_node \ |
4607 || type1 == unsigned_short_ ## NAME ## _type_node) \ | 4599 || type1 == unsigned_short_ ## NAME ## _type_node) \ |
4608 return unsignedp ? unsigned_short_ ## NAME ## _type_node \ | 4600 return unsignedp ? unsigned_short_ ## NAME ## _type_node \ |
4609 : short_ ## NAME ## _type_node; \ | 4601 : short_ ## NAME ## _type_node; \ |
4610 if (type1 == NAME ## _type_node \ | 4602 if (type1 == NAME ## _type_node \ |
4611 || type1 == unsigned_ ## NAME ## _type_node) \ | 4603 || type1 == unsigned_ ## NAME ## _type_node) \ |
4612 return unsignedp ? unsigned_ ## NAME ## _type_node \ | 4604 return unsignedp ? unsigned_ ## NAME ## _type_node \ |
4613 : NAME ## _type_node; \ | 4605 : NAME ## _type_node; \ |
4614 if (type1 == long_ ## NAME ## _type_node \ | 4606 if (type1 == long_ ## NAME ## _type_node \ |
4615 || type1 == unsigned_long_ ## NAME ## _type_node) \ | 4607 || type1 == unsigned_long_ ## NAME ## _type_node) \ |
4616 return unsignedp ? unsigned_long_ ## NAME ## _type_node \ | 4608 return unsignedp ? unsigned_long_ ## NAME ## _type_node \ |
4617 : long_ ## NAME ## _type_node; \ | 4609 : long_ ## NAME ## _type_node; \ |
4618 if (type1 == long_long_ ## NAME ## _type_node \ | 4610 if (type1 == long_long_ ## NAME ## _type_node \ |
4619 || type1 == unsigned_long_long_ ## NAME ## _type_node) \ | 4611 || type1 == unsigned_long_long_ ## NAME ## _type_node) \ |
4620 return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \ | 4612 return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \ |
4621 : long_long_ ## NAME ## _type_node; | 4613 : long_long_ ## NAME ## _type_node; |
4622 | 4614 |
4623 #define GIMPLE_FIXED_MODE_TYPES(NAME) \ | 4615 #define GIMPLE_FIXED_MODE_TYPES(NAME) \ |
4624 if (type1 == NAME ## _type_node \ | 4616 if (type1 == NAME ## _type_node \ |
4625 || type1 == u ## NAME ## _type_node) \ | 4617 || type1 == u ## NAME ## _type_node) \ |
4626 return unsignedp ? u ## NAME ## _type_node \ | 4618 return unsignedp ? u ## NAME ## _type_node \ |
4627 : NAME ## _type_node; | 4619 : NAME ## _type_node; |
4628 | 4620 |
4629 #define GIMPLE_FIXED_TYPES_SAT(NAME) \ | 4621 #define GIMPLE_FIXED_TYPES_SAT(NAME) \ |
4630 if (type1 == sat_ ## short_ ## NAME ## _type_node \ | 4622 if (type1 == sat_ ## short_ ## NAME ## _type_node \ |
4631 || type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \ | 4623 || type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \ |
4632 return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \ | 4624 return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \ |
4633 : sat_ ## short_ ## NAME ## _type_node; \ | 4625 : sat_ ## short_ ## NAME ## _type_node; \ |
4634 if (type1 == sat_ ## NAME ## _type_node \ | 4626 if (type1 == sat_ ## NAME ## _type_node \ |
4635 || type1 == sat_ ## unsigned_ ## NAME ## _type_node) \ | 4627 || type1 == sat_ ## unsigned_ ## NAME ## _type_node) \ |
4636 return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \ | 4628 return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \ |
4637 : sat_ ## NAME ## _type_node; \ | 4629 : sat_ ## NAME ## _type_node; \ |
4638 if (type1 == sat_ ## long_ ## NAME ## _type_node \ | 4630 if (type1 == sat_ ## long_ ## NAME ## _type_node \ |
4639 || type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \ | 4631 || type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \ |
4640 return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \ | 4632 return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \ |
4641 : sat_ ## long_ ## NAME ## _type_node; \ | 4633 : sat_ ## long_ ## NAME ## _type_node; \ |
4642 if (type1 == sat_ ## long_long_ ## NAME ## _type_node \ | 4634 if (type1 == sat_ ## long_long_ ## NAME ## _type_node \ |
4643 || type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \ | 4635 || type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \ |
4644 return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \ | 4636 return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \ |
4645 : sat_ ## long_long_ ## NAME ## _type_node; | 4637 : sat_ ## long_long_ ## NAME ## _type_node; |
4646 | 4638 |
4647 #define GIMPLE_FIXED_MODE_TYPES_SAT(NAME) \ | 4639 #define GIMPLE_FIXED_MODE_TYPES_SAT(NAME) \ |
4648 if (type1 == sat_ ## NAME ## _type_node \ | 4640 if (type1 == sat_ ## NAME ## _type_node \ |
4649 || type1 == sat_ ## u ## NAME ## _type_node) \ | 4641 || type1 == sat_ ## u ## NAME ## _type_node) \ |
4650 return unsignedp ? sat_ ## u ## NAME ## _type_node \ | 4642 return unsignedp ? sat_ ## u ## NAME ## _type_node \ |
4651 : sat_ ## NAME ## _type_node; | 4643 : sat_ ## NAME ## _type_node; |
4652 | 4644 |
4653 GIMPLE_FIXED_TYPES (fract); | 4645 GIMPLE_FIXED_TYPES (fract); |
4654 GIMPLE_FIXED_TYPES_SAT (fract); | 4646 GIMPLE_FIXED_TYPES_SAT (fract); |
4655 GIMPLE_FIXED_TYPES (accum); | 4647 GIMPLE_FIXED_TYPES (accum); |
4656 GIMPLE_FIXED_TYPES_SAT (accum); | 4648 GIMPLE_FIXED_TYPES_SAT (accum); |
4684 ENUMERAL_TYPE may cause other problems as well. */ | 4676 ENUMERAL_TYPE may cause other problems as well. */ |
4685 if (!INTEGRAL_TYPE_P (type) | 4677 if (!INTEGRAL_TYPE_P (type) |
4686 || TYPE_UNSIGNED (type) == unsignedp) | 4678 || TYPE_UNSIGNED (type) == unsignedp) |
4687 return type; | 4679 return type; |
4688 | 4680 |
4689 #define TYPE_OK(node) \ | 4681 #define TYPE_OK(node) \ |
4690 (TYPE_MODE (type) == TYPE_MODE (node) \ | 4682 (TYPE_MODE (type) == TYPE_MODE (node) \ |
4691 && TYPE_PRECISION (type) == TYPE_PRECISION (node)) | 4683 && TYPE_PRECISION (type) == TYPE_PRECISION (node)) |
4692 if (TYPE_OK (signed_char_type_node)) | 4684 if (TYPE_OK (signed_char_type_node)) |
4693 return unsignedp ? unsigned_char_type_node : signed_char_type_node; | 4685 return unsignedp ? unsigned_char_type_node : signed_char_type_node; |
4694 if (TYPE_OK (integer_type_node)) | 4686 if (TYPE_OK (integer_type_node)) |
4695 return unsignedp ? unsigned_type_node : integer_type_node; | 4687 return unsignedp ? unsigned_type_node : integer_type_node; |
4763 that such accesses have implementation-defined behavior. */ | 4755 that such accesses have implementation-defined behavior. */ |
4764 for (u = t; | 4756 for (u = t; |
4765 TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF; | 4757 TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF; |
4766 u = TREE_OPERAND (u, 0)) | 4758 u = TREE_OPERAND (u, 0)) |
4767 if (TREE_CODE (u) == COMPONENT_REF | 4759 if (TREE_CODE (u) == COMPONENT_REF |
4768 && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE) | 4760 && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE) |
4769 return 0; | 4761 return 0; |
4770 | 4762 |
4771 /* That's all the expressions we handle specially. */ | 4763 /* That's all the expressions we handle specially. */ |
4772 if (!TYPE_P (t)) | 4764 if (!TYPE_P (t)) |
4773 return -1; | 4765 return -1; |
4786 { | 4778 { |
4787 tree t1 = gimple_signed_type (t); | 4779 tree t1 = gimple_signed_type (t); |
4788 | 4780 |
4789 /* t1 == t can happen for boolean nodes which are always unsigned. */ | 4781 /* t1 == t can happen for boolean nodes which are always unsigned. */ |
4790 if (t1 != t) | 4782 if (t1 != t) |
4791 return get_alias_set (t1); | 4783 return get_alias_set (t1); |
4792 } | 4784 } |
4793 | 4785 |
4794 return -1; | 4786 return -1; |
4795 } | 4787 } |
4796 | 4788 |
4823 } | 4815 } |
4824 | 4816 |
4825 if (TREE_CODE (*tp) == MEM_REF && TREE_OPERAND (*tp, 0) == count_p->ptr) | 4817 if (TREE_CODE (*tp) == MEM_REF && TREE_OPERAND (*tp, 0) == count_p->ptr) |
4826 { | 4818 { |
4827 if (wi_p->is_lhs) | 4819 if (wi_p->is_lhs) |
4828 count_p->num_stores++; | 4820 count_p->num_stores++; |
4829 else | 4821 else |
4830 count_p->num_loads++; | 4822 count_p->num_loads++; |
4831 } | 4823 } |
4832 | 4824 |
4833 return NULL_TREE; | 4825 return NULL_TREE; |
4834 } | 4826 } |
4835 | 4827 |
4839 on whether they are store or load operations. The counts are | 4831 on whether they are store or load operations. The counts are |
4840 stored in *NUM_STORES_P and *NUM_LOADS_P. */ | 4832 stored in *NUM_STORES_P and *NUM_LOADS_P. */ |
4841 | 4833 |
4842 void | 4834 void |
4843 count_uses_and_derefs (tree ptr, gimple stmt, unsigned *num_uses_p, | 4835 count_uses_and_derefs (tree ptr, gimple stmt, unsigned *num_uses_p, |
4844 unsigned *num_loads_p, unsigned *num_stores_p) | 4836 unsigned *num_loads_p, unsigned *num_stores_p) |
4845 { | 4837 { |
4846 ssa_op_iter i; | 4838 ssa_op_iter i; |
4847 tree use; | 4839 tree use; |
4848 | 4840 |
4849 *num_uses_p = 0; | 4841 *num_uses_p = 0; |
4908 or the argument of an address expression. | 4900 or the argument of an address expression. |
4909 Returns the results of these callbacks or'ed. */ | 4901 Returns the results of these callbacks or'ed. */ |
4910 | 4902 |
4911 bool | 4903 bool |
4912 walk_stmt_load_store_addr_ops (gimple stmt, void *data, | 4904 walk_stmt_load_store_addr_ops (gimple stmt, void *data, |
4913 bool (*visit_load)(gimple, tree, void *), | 4905 bool (*visit_load)(gimple, tree, void *), |
4914 bool (*visit_store)(gimple, tree, void *), | 4906 bool (*visit_store)(gimple, tree, void *), |
4915 bool (*visit_addr)(gimple, tree, void *)) | 4907 bool (*visit_addr)(gimple, tree, void *)) |
4916 { | 4908 { |
4917 bool ret = false; | 4909 bool ret = false; |
4918 unsigned i; | 4910 unsigned i; |
4919 if (gimple_assign_single_p (stmt)) | 4911 if (gimple_assign_single_p (stmt)) |
4920 { | 4912 { |
4921 tree lhs, rhs; | 4913 tree lhs, rhs; |
4922 if (visit_store) | 4914 if (visit_store) |
4923 { | 4915 { |
4924 lhs = get_base_loadstore (gimple_assign_lhs (stmt)); | 4916 lhs = get_base_loadstore (gimple_assign_lhs (stmt)); |
4925 if (lhs) | 4917 if (lhs) |
4926 ret |= visit_store (stmt, lhs, data); | 4918 ret |= visit_store (stmt, lhs, data); |
4927 } | 4919 } |
4928 rhs = gimple_assign_rhs1 (stmt); | 4920 rhs = gimple_assign_rhs1 (stmt); |
4929 while (handled_component_p (rhs)) | 4921 while (handled_component_p (rhs)) |
4930 rhs = TREE_OPERAND (rhs, 0); | 4922 rhs = TREE_OPERAND (rhs, 0); |
4931 if (visit_addr) | 4923 if (visit_addr) |
4932 { | 4924 { |
4933 if (TREE_CODE (rhs) == ADDR_EXPR) | 4925 if (TREE_CODE (rhs) == ADDR_EXPR) |
4934 ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data); | 4926 ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data); |
4935 else if (TREE_CODE (rhs) == TARGET_MEM_REF | 4927 else if (TREE_CODE (rhs) == TARGET_MEM_REF |
4941 0), data); | 4933 0), data); |
4942 lhs = gimple_assign_lhs (stmt); | 4934 lhs = gimple_assign_lhs (stmt); |
4943 if (TREE_CODE (lhs) == TARGET_MEM_REF | 4935 if (TREE_CODE (lhs) == TARGET_MEM_REF |
4944 && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR) | 4936 && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR) |
4945 ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), data); | 4937 ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), data); |
4946 } | 4938 } |
4947 if (visit_load) | 4939 if (visit_load) |
4948 { | 4940 { |
4949 rhs = get_base_loadstore (rhs); | 4941 rhs = get_base_loadstore (rhs); |
4950 if (rhs) | 4942 if (rhs) |
4951 ret |= visit_load (stmt, rhs, data); | 4943 ret |= visit_load (stmt, rhs, data); |
4952 } | 4944 } |
4953 } | 4945 } |
4954 else if (visit_addr | 4946 else if (visit_addr |
4955 && (is_gimple_assign (stmt) | 4947 && (is_gimple_assign (stmt) |
4956 || gimple_code (stmt) == GIMPLE_COND)) | 4948 || gimple_code (stmt) == GIMPLE_COND)) |
4957 { | 4949 { |
4958 for (i = 0; i < gimple_num_ops (stmt); ++i) | 4950 for (i = 0; i < gimple_num_ops (stmt); ++i) |
4959 if (gimple_op (stmt, i) | 4951 if (gimple_op (stmt, i) |
4960 && TREE_CODE (gimple_op (stmt, i)) == ADDR_EXPR) | 4952 && TREE_CODE (gimple_op (stmt, i)) == ADDR_EXPR) |
4961 ret |= visit_addr (stmt, TREE_OPERAND (gimple_op (stmt, i), 0), data); | 4953 ret |= visit_addr (stmt, TREE_OPERAND (gimple_op (stmt, i), 0), data); |
4962 } | 4954 } |
4963 else if (is_gimple_call (stmt)) | 4955 else if (is_gimple_call (stmt)) |
4964 { | 4956 { |
4965 if (visit_store) | 4957 if (visit_store) |
4966 { | 4958 { |
4967 tree lhs = gimple_call_lhs (stmt); | 4959 tree lhs = gimple_call_lhs (stmt); |
4968 if (lhs) | 4960 if (lhs) |
4969 { | 4961 { |
4970 lhs = get_base_loadstore (lhs); | 4962 lhs = get_base_loadstore (lhs); |
4971 if (lhs) | 4963 if (lhs) |
4972 ret |= visit_store (stmt, lhs, data); | 4964 ret |= visit_store (stmt, lhs, data); |
4973 } | 4965 } |
4974 } | 4966 } |
4975 if (visit_load || visit_addr) | 4967 if (visit_load || visit_addr) |
4976 for (i = 0; i < gimple_call_num_args (stmt); ++i) | 4968 for (i = 0; i < gimple_call_num_args (stmt); ++i) |
4977 { | 4969 { |
4978 tree rhs = gimple_call_arg (stmt, i); | 4970 tree rhs = gimple_call_arg (stmt, i); |
4979 if (visit_addr | 4971 if (visit_addr |
4980 && TREE_CODE (rhs) == ADDR_EXPR) | 4972 && TREE_CODE (rhs) == ADDR_EXPR) |
4981 ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data); | 4973 ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data); |
4982 else if (visit_load) | 4974 else if (visit_load) |
4983 { | 4975 { |
4984 rhs = get_base_loadstore (rhs); | 4976 rhs = get_base_loadstore (rhs); |
4985 if (rhs) | 4977 if (rhs) |
4986 ret |= visit_load (stmt, rhs, data); | 4978 ret |= visit_load (stmt, rhs, data); |
4987 } | 4979 } |
4988 } | 4980 } |
4989 if (visit_addr | 4981 if (visit_addr |
4990 && gimple_call_chain (stmt) | 4982 && gimple_call_chain (stmt) |
4991 && TREE_CODE (gimple_call_chain (stmt)) == ADDR_EXPR) | 4983 && TREE_CODE (gimple_call_chain (stmt)) == ADDR_EXPR) |
4992 ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (stmt), 0), | 4984 ret |= visit_addr (stmt, TREE_OPERAND (gimple_call_chain (stmt), 0), |
4993 data); | 4985 data); |
4994 if (visit_addr | 4986 if (visit_addr |
4995 && gimple_call_return_slot_opt_p (stmt) | 4987 && gimple_call_return_slot_opt_p (stmt) |
4996 && gimple_call_lhs (stmt) != NULL_TREE | 4988 && gimple_call_lhs (stmt) != NULL_TREE |
4997 && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt)))) | 4989 && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt)))) |
4998 ret |= visit_addr (stmt, gimple_call_lhs (stmt), data); | 4990 ret |= visit_addr (stmt, gimple_call_lhs (stmt), data); |
4999 } | 4991 } |
5000 else if (gimple_code (stmt) == GIMPLE_ASM) | 4992 else if (gimple_code (stmt) == GIMPLE_ASM) |
5001 { | 4993 { |
5002 unsigned noutputs; | 4994 unsigned noutputs; |
5003 const char *constraint; | 4995 const char *constraint; |
5004 const char **oconstraints; | 4996 const char **oconstraints; |
5005 bool allows_mem, allows_reg, is_inout; | 4997 bool allows_mem, allows_reg, is_inout; |
5006 noutputs = gimple_asm_noutputs (stmt); | 4998 noutputs = gimple_asm_noutputs (stmt); |
5007 oconstraints = XALLOCAVEC (const char *, noutputs); | 4999 oconstraints = XALLOCAVEC (const char *, noutputs); |
5008 if (visit_store || visit_addr) | 5000 if (visit_store || visit_addr) |
5009 for (i = 0; i < gimple_asm_noutputs (stmt); ++i) | 5001 for (i = 0; i < gimple_asm_noutputs (stmt); ++i) |
5010 { | 5002 { |
5011 tree link = gimple_asm_output_op (stmt, i); | 5003 tree link = gimple_asm_output_op (stmt, i); |
5012 tree op = get_base_loadstore (TREE_VALUE (link)); | 5004 tree op = get_base_loadstore (TREE_VALUE (link)); |
5013 if (op && visit_store) | 5005 if (op && visit_store) |
5014 ret |= visit_store (stmt, op, data); | 5006 ret |= visit_store (stmt, op, data); |
5015 if (visit_addr) | 5007 if (visit_addr) |
5016 { | 5008 { |
5017 constraint = TREE_STRING_POINTER | 5009 constraint = TREE_STRING_POINTER |
5018 (TREE_VALUE (TREE_PURPOSE (link))); | 5010 (TREE_VALUE (TREE_PURPOSE (link))); |
5019 oconstraints[i] = constraint; | 5011 oconstraints[i] = constraint; |
5020 parse_output_constraint (&constraint, i, 0, 0, &allows_mem, | 5012 parse_output_constraint (&constraint, i, 0, 0, &allows_mem, |
5021 &allows_reg, &is_inout); | 5013 &allows_reg, &is_inout); |
5022 if (op && !allows_reg && allows_mem) | 5014 if (op && !allows_reg && allows_mem) |
5023 ret |= visit_addr (stmt, op, data); | 5015 ret |= visit_addr (stmt, op, data); |
5024 } | 5016 } |
5025 } | 5017 } |
5026 if (visit_load || visit_addr) | 5018 if (visit_load || visit_addr) |
5027 for (i = 0; i < gimple_asm_ninputs (stmt); ++i) | 5019 for (i = 0; i < gimple_asm_ninputs (stmt); ++i) |
5028 { | 5020 { |
5029 tree link = gimple_asm_input_op (stmt, i); | 5021 tree link = gimple_asm_input_op (stmt, i); |
5030 tree op = TREE_VALUE (link); | 5022 tree op = TREE_VALUE (link); |
5031 if (visit_addr | 5023 if (visit_addr |
5032 && TREE_CODE (op) == ADDR_EXPR) | 5024 && TREE_CODE (op) == ADDR_EXPR) |
5033 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); | 5025 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); |
5034 else if (visit_load || visit_addr) | 5026 else if (visit_load || visit_addr) |
5035 { | 5027 { |
5036 op = get_base_loadstore (op); | 5028 op = get_base_loadstore (op); |
5037 if (op) | 5029 if (op) |
5038 { | 5030 { |
5039 if (visit_load) | 5031 if (visit_load) |
5040 ret |= visit_load (stmt, op, data); | 5032 ret |= visit_load (stmt, op, data); |
5041 if (visit_addr) | 5033 if (visit_addr) |
5042 { | 5034 { |
5043 constraint = TREE_STRING_POINTER | 5035 constraint = TREE_STRING_POINTER |
5044 (TREE_VALUE (TREE_PURPOSE (link))); | 5036 (TREE_VALUE (TREE_PURPOSE (link))); |
5045 parse_input_constraint (&constraint, 0, 0, noutputs, | 5037 parse_input_constraint (&constraint, 0, 0, noutputs, |
5046 0, oconstraints, | 5038 0, oconstraints, |
5047 &allows_mem, &allows_reg); | 5039 &allows_mem, &allows_reg); |
5048 if (!allows_reg && allows_mem) | 5040 if (!allows_reg && allows_mem) |
5049 ret |= visit_addr (stmt, op, data); | 5041 ret |= visit_addr (stmt, op, data); |
5050 } | 5042 } |
5051 } | 5043 } |
5052 } | 5044 } |
5053 } | 5045 } |
5054 } | 5046 } |
5055 else if (gimple_code (stmt) == GIMPLE_RETURN) | 5047 else if (gimple_code (stmt) == GIMPLE_RETURN) |
5056 { | 5048 { |
5057 tree op = gimple_return_retval (stmt); | 5049 tree op = gimple_return_retval (stmt); |
5058 if (op) | 5050 if (op) |
5059 { | 5051 { |
5060 if (visit_addr | 5052 if (visit_addr |
5061 && TREE_CODE (op) == ADDR_EXPR) | 5053 && TREE_CODE (op) == ADDR_EXPR) |
5062 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); | 5054 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); |
5063 else if (visit_load) | 5055 else if (visit_load) |
5064 { | 5056 { |
5065 op = get_base_loadstore (op); | 5057 op = get_base_loadstore (op); |
5066 if (op) | 5058 if (op) |
5067 ret |= visit_load (stmt, op, data); | 5059 ret |= visit_load (stmt, op, data); |
5068 } | 5060 } |
5069 } | 5061 } |
5070 } | 5062 } |
5071 else if (visit_addr | 5063 else if (visit_addr |
5072 && gimple_code (stmt) == GIMPLE_PHI) | 5064 && gimple_code (stmt) == GIMPLE_PHI) |
5073 { | 5065 { |
5074 for (i = 0; i < gimple_phi_num_args (stmt); ++i) | 5066 for (i = 0; i < gimple_phi_num_args (stmt); ++i) |
5075 { | 5067 { |
5076 tree op = PHI_ARG_DEF (stmt, i); | 5068 tree op = PHI_ARG_DEF (stmt, i); |
5077 if (TREE_CODE (op) == ADDR_EXPR) | 5069 if (TREE_CODE (op) == ADDR_EXPR) |
5078 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); | 5070 ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); |
5079 } | 5071 } |
5080 } | 5072 } |
5081 | 5073 |
5082 return ret; | 5074 return ret; |
5083 } | 5075 } |
5084 | 5076 |
5085 /* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP | 5077 /* Like walk_stmt_load_store_addr_ops but with NULL visit_addr. IPA-CP |
5086 should make a faster clone for this case. */ | 5078 should make a faster clone for this case. */ |
5087 | 5079 |
5088 bool | 5080 bool |
5089 walk_stmt_load_store_ops (gimple stmt, void *data, | 5081 walk_stmt_load_store_ops (gimple stmt, void *data, |
5090 bool (*visit_load)(gimple, tree, void *), | 5082 bool (*visit_load)(gimple, tree, void *), |
5091 bool (*visit_store)(gimple, tree, void *)) | 5083 bool (*visit_store)(gimple, tree, void *)) |
5092 { | 5084 { |
5093 return walk_stmt_load_store_addr_ops (stmt, data, | 5085 return walk_stmt_load_store_addr_ops (stmt, data, |
5094 visit_load, visit_store, NULL); | 5086 visit_load, visit_store, NULL); |
5095 } | 5087 } |
5096 | 5088 |
5097 /* Helper for gimple_ior_addresses_taken_1. */ | 5089 /* Helper for gimple_ior_addresses_taken_1. */ |
5098 | 5090 |
5099 static bool | 5091 static bool |
5100 gimple_ior_addresses_taken_1 (gimple stmt ATTRIBUTE_UNUSED, | 5092 gimple_ior_addresses_taken_1 (gimple stmt ATTRIBUTE_UNUSED, |
5101 tree addr, void *data) | 5093 tree addr, void *data) |
5102 { | 5094 { |
5103 bitmap addresses_taken = (bitmap)data; | 5095 bitmap addresses_taken = (bitmap)data; |
5104 addr = get_base_address (addr); | 5096 addr = get_base_address (addr); |
5105 if (addr | 5097 if (addr |
5106 && DECL_P (addr)) | 5098 && DECL_P (addr)) |
5117 | 5109 |
5118 bool | 5110 bool |
5119 gimple_ior_addresses_taken (bitmap addresses_taken, gimple stmt) | 5111 gimple_ior_addresses_taken (bitmap addresses_taken, gimple stmt) |
5120 { | 5112 { |
5121 return walk_stmt_load_store_addr_ops (stmt, addresses_taken, NULL, NULL, | 5113 return walk_stmt_load_store_addr_ops (stmt, addresses_taken, NULL, NULL, |
5122 gimple_ior_addresses_taken_1); | 5114 gimple_ior_addresses_taken_1); |
5123 } | 5115 } |
5124 | 5116 |
5125 | 5117 |
5126 /* Return a printable name for symbol DECL. */ | 5118 /* Return a printable name for symbol DECL. */ |
5127 | 5119 |
5135 { | 5127 { |
5136 const char *str, *mangled_str; | 5128 const char *str, *mangled_str; |
5137 int dmgl_opts = DMGL_NO_OPTS; | 5129 int dmgl_opts = DMGL_NO_OPTS; |
5138 | 5130 |
5139 if (verbosity >= 2) | 5131 if (verbosity >= 2) |
5140 { | 5132 { |
5141 dmgl_opts = DMGL_VERBOSE | 5133 dmgl_opts = DMGL_VERBOSE |
5142 | DMGL_ANSI | 5134 | DMGL_ANSI |
5143 | DMGL_GNU_V3 | 5135 | DMGL_GNU_V3 |
5144 | DMGL_RET_POSTFIX; | 5136 | DMGL_RET_POSTFIX; |
5145 if (TREE_CODE (decl) == FUNCTION_DECL) | 5137 if (TREE_CODE (decl) == FUNCTION_DECL) |
5146 dmgl_opts |= DMGL_PARAMS; | 5138 dmgl_opts |= DMGL_PARAMS; |
5147 } | 5139 } |
5148 | 5140 |
5149 mangled_str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | 5141 mangled_str = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
5150 str = cplus_demangle_v3 (mangled_str, dmgl_opts); | 5142 str = cplus_demangle_v3 (mangled_str, dmgl_opts); |
5151 return (str) ? str : mangled_str; | 5143 return (str) ? str : mangled_str; |
5152 } | 5144 } |