Mercurial > hg > CbC > CbC_gcc
comparison gcc/gimple.c @ 146:351920fa3827
merge
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 01 Mar 2020 16:13:28 +0900 |
parents | 4e440907fcbf 1830386684a0 |
children |
comparison
equal
deleted
inserted
replaced
144:8f4e72ab4e11 | 146:351920fa3827 |
---|---|
1 /* Gimple IR support functions. | 1 /* Gimple IR support functions. |
2 | 2 |
3 Copyright (C) 2007-2018 Free Software Foundation, Inc. | 3 Copyright (C) 2007-2020 Free Software Foundation, Inc. |
4 Contributed by Aldy Hernandez <aldyh@redhat.com> | 4 Contributed by Aldy Hernandez <aldyh@redhat.com> |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
45 #include "attribs.h" | 45 #include "attribs.h" |
46 #include "asan.h" | 46 #include "asan.h" |
47 #ifndef noCbC | 47 #ifndef noCbC |
48 #include "c/cbc-tree.h" | 48 #include "c/cbc-tree.h" |
49 #endif | 49 #endif |
50 #include "langhooks.h" | |
51 | |
50 | 52 |
51 /* All the tuples have their operand vector (if present) at the very bottom | 53 /* All the tuples have their operand vector (if present) at the very bottom |
52 of the structure. Therefore, the offset required to find the | 54 of the structure. Therefore, the offset required to find the |
53 operands vector the size of the structure minus the size of the 1 | 55 operands vector the size of the structure minus the size of the 1 |
54 element tree array at the end (see gimple_ops). */ | 56 element tree array at the end (see gimple_ops). */ |
109 } | 111 } |
110 | 112 |
111 /* Return the number of bytes needed to hold a GIMPLE statement with | 113 /* Return the number of bytes needed to hold a GIMPLE statement with |
112 code CODE. */ | 114 code CODE. */ |
113 | 115 |
114 static inline size_t | 116 size_t |
115 gimple_size (enum gimple_code code) | 117 gimple_size (enum gimple_code code, unsigned num_ops) |
116 { | 118 { |
117 return gsstruct_code_size[gss_for_code (code)]; | 119 size_t size = gsstruct_code_size[gss_for_code (code)]; |
120 if (num_ops > 0) | |
121 size += (sizeof (tree) * (num_ops - 1)); | |
122 return size; | |
123 } | |
124 | |
125 /* Initialize GIMPLE statement G with CODE and NUM_OPS. */ | |
126 | |
127 void | |
128 gimple_init (gimple *g, enum gimple_code code, unsigned num_ops) | |
129 { | |
130 gimple_set_code (g, code); | |
131 gimple_set_num_ops (g, num_ops); | |
132 | |
133 /* Do not call gimple_set_modified here as it has other side | |
134 effects and this tuple is still not completely built. */ | |
135 g->modified = 1; | |
136 gimple_init_singleton (g); | |
118 } | 137 } |
119 | 138 |
120 /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS | 139 /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS |
121 operands. */ | 140 operands. */ |
122 | 141 |
124 gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL) | 143 gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL) |
125 { | 144 { |
126 size_t size; | 145 size_t size; |
127 gimple *stmt; | 146 gimple *stmt; |
128 | 147 |
129 size = gimple_size (code); | 148 size = gimple_size (code, num_ops); |
130 if (num_ops > 0) | |
131 size += sizeof (tree) * (num_ops - 1); | |
132 | |
133 if (GATHER_STATISTICS) | 149 if (GATHER_STATISTICS) |
134 { | 150 { |
135 enum gimple_alloc_kind kind = gimple_alloc_kind (code); | 151 enum gimple_alloc_kind kind = gimple_alloc_kind (code); |
136 gimple_alloc_counts[(int) kind]++; | 152 gimple_alloc_counts[(int) kind]++; |
137 gimple_alloc_sizes[(int) kind] += size; | 153 gimple_alloc_sizes[(int) kind] += size; |
138 } | 154 } |
139 | 155 |
140 stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT); | 156 stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT); |
141 gimple_set_code (stmt, code); | 157 gimple_init (stmt, code, num_ops); |
142 gimple_set_num_ops (stmt, num_ops); | |
143 | |
144 /* Do not call gimple_set_modified here as it has other side | |
145 effects and this tuple is still not completely built. */ | |
146 stmt->modified = 1; | |
147 gimple_init_singleton (stmt); | |
148 | |
149 return stmt; | 158 return stmt; |
150 } | 159 } |
151 | 160 |
152 /* Set SUBCODE to be the code of the expression computed by statement G. */ | 161 /* Set SUBCODE to be the code of the expression computed by statement G. */ |
153 | 162 |
927 | 936 |
928 /* Build a GIMPLE_OMP_FOR statement. | 937 /* Build a GIMPLE_OMP_FOR statement. |
929 | 938 |
930 BODY is sequence of statements inside the for loop. | 939 BODY is sequence of statements inside the for loop. |
931 KIND is the `for' variant. | 940 KIND is the `for' variant. |
932 CLAUSES, are any of the construct's clauses. | 941 CLAUSES are any of the construct's clauses. |
933 COLLAPSE is the collapse count. | 942 COLLAPSE is the collapse count. |
934 PRE_BODY is the sequence of statements that are loop invariant. */ | 943 PRE_BODY is the sequence of statements that are loop invariant. */ |
935 | 944 |
936 gomp_for * | 945 gomp_for * |
937 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse, | 946 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse, |
953 | 962 |
954 | 963 |
955 /* Build a GIMPLE_OMP_PARALLEL statement. | 964 /* Build a GIMPLE_OMP_PARALLEL statement. |
956 | 965 |
957 BODY is sequence of statements which are executed in parallel. | 966 BODY is sequence of statements which are executed in parallel. |
958 CLAUSES, are the OMP parallel construct's clauses. | 967 CLAUSES are the OMP parallel construct's clauses. |
959 CHILD_FN is the function created for the parallel threads to execute. | 968 CHILD_FN is the function created for the parallel threads to execute. |
960 DATA_ARG are the shared data argument(s). */ | 969 DATA_ARG are the shared data argument(s). */ |
961 | 970 |
962 gomp_parallel * | 971 gomp_parallel * |
963 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, | 972 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, |
976 | 985 |
977 | 986 |
978 /* Build a GIMPLE_OMP_TASK statement. | 987 /* Build a GIMPLE_OMP_TASK statement. |
979 | 988 |
980 BODY is sequence of statements which are executed by the explicit task. | 989 BODY is sequence of statements which are executed by the explicit task. |
981 CLAUSES, are the OMP parallel construct's clauses. | 990 CLAUSES are the OMP task construct's clauses. |
982 CHILD_FN is the function created for the parallel threads to execute. | 991 CHILD_FN is the function created for the parallel threads to execute. |
983 DATA_ARG are the shared data argument(s). | 992 DATA_ARG are the shared data argument(s). |
984 COPY_FN is the optional function for firstprivate initialization. | 993 COPY_FN is the optional function for firstprivate initialization. |
985 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */ | 994 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */ |
986 | 995 |
1047 } | 1056 } |
1048 | 1057 |
1049 /* Build a GIMPLE_OMP_TASKGROUP statement. | 1058 /* Build a GIMPLE_OMP_TASKGROUP statement. |
1050 | 1059 |
1051 BODY is the sequence of statements to be executed by the taskgroup | 1060 BODY is the sequence of statements to be executed by the taskgroup |
1052 construct. */ | 1061 construct. |
1062 CLAUSES are any of the construct's clauses. */ | |
1053 | 1063 |
1054 gimple * | 1064 gimple * |
1055 gimple_build_omp_taskgroup (gimple_seq body) | 1065 gimple_build_omp_taskgroup (gimple_seq body, tree clauses) |
1056 { | 1066 { |
1057 gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0); | 1067 gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0); |
1068 gimple_omp_taskgroup_set_clauses (p, clauses); | |
1058 if (body) | 1069 if (body) |
1059 gimple_omp_set_body (p, body); | 1070 gimple_omp_set_body (p, body); |
1060 | 1071 |
1061 return p; | 1072 return p; |
1062 } | 1073 } |
1103 gimple_build_omp_return (bool wait_p) | 1114 gimple_build_omp_return (bool wait_p) |
1104 { | 1115 { |
1105 gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0); | 1116 gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0); |
1106 if (wait_p) | 1117 if (wait_p) |
1107 gimple_omp_return_set_nowait (p); | 1118 gimple_omp_return_set_nowait (p); |
1119 | |
1120 return p; | |
1121 } | |
1122 | |
1123 | |
1124 /* Build a GIMPLE_OMP_SCAN statement. | |
1125 | |
1126 BODY is the sequence of statements to be executed by the scan | |
1127 construct. | |
1128 CLAUSES are any of the construct's clauses. */ | |
1129 | |
1130 gomp_scan * | |
1131 gimple_build_omp_scan (gimple_seq body, tree clauses) | |
1132 { | |
1133 gomp_scan *p | |
1134 = as_a <gomp_scan *> (gimple_alloc (GIMPLE_OMP_SCAN, 0)); | |
1135 gimple_omp_scan_set_clauses (p, clauses); | |
1136 if (body) | |
1137 gimple_omp_set_body (p, body); | |
1108 | 1138 |
1109 return p; | 1139 return p; |
1110 } | 1140 } |
1111 | 1141 |
1112 | 1142 |
1195 | 1225 |
1196 | 1226 |
1197 /* Build a GIMPLE_OMP_ATOMIC_LOAD statement. */ | 1227 /* Build a GIMPLE_OMP_ATOMIC_LOAD statement. */ |
1198 | 1228 |
1199 gomp_atomic_load * | 1229 gomp_atomic_load * |
1200 gimple_build_omp_atomic_load (tree lhs, tree rhs) | 1230 gimple_build_omp_atomic_load (tree lhs, tree rhs, enum omp_memory_order mo) |
1201 { | 1231 { |
1202 gomp_atomic_load *p | 1232 gomp_atomic_load *p |
1203 = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0)); | 1233 = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0)); |
1204 gimple_omp_atomic_load_set_lhs (p, lhs); | 1234 gimple_omp_atomic_load_set_lhs (p, lhs); |
1205 gimple_omp_atomic_load_set_rhs (p, rhs); | 1235 gimple_omp_atomic_load_set_rhs (p, rhs); |
1236 gimple_omp_atomic_set_memory_order (p, mo); | |
1206 return p; | 1237 return p; |
1207 } | 1238 } |
1208 | 1239 |
1209 /* Build a GIMPLE_OMP_ATOMIC_STORE statement. | 1240 /* Build a GIMPLE_OMP_ATOMIC_STORE statement. |
1210 | 1241 |
1211 VAL is the value we are storing. */ | 1242 VAL is the value we are storing. */ |
1212 | 1243 |
1213 gomp_atomic_store * | 1244 gomp_atomic_store * |
1214 gimple_build_omp_atomic_store (tree val) | 1245 gimple_build_omp_atomic_store (tree val, enum omp_memory_order mo) |
1215 { | 1246 { |
1216 gomp_atomic_store *p | 1247 gomp_atomic_store *p |
1217 = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0)); | 1248 = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0)); |
1218 gimple_omp_atomic_store_set_val (p, val); | 1249 gimple_omp_atomic_store_set_val (p, val); |
1250 gimple_omp_atomic_set_memory_order (p, mo); | |
1219 return p; | 1251 return p; |
1220 } | 1252 } |
1221 | 1253 |
1222 /* Build a GIMPLE_TRANSACTION statement. */ | 1254 /* Build a GIMPLE_TRANSACTION statement. */ |
1223 | 1255 |
1445 call_expr_flags, but for gimple tuples. */ | 1477 call_expr_flags, but for gimple tuples. */ |
1446 | 1478 |
1447 int | 1479 int |
1448 gimple_call_flags (const gimple *stmt) | 1480 gimple_call_flags (const gimple *stmt) |
1449 { | 1481 { |
1450 int flags; | 1482 int flags = 0; |
1451 tree decl = gimple_call_fndecl (stmt); | 1483 |
1452 | 1484 if (gimple_call_internal_p (stmt)) |
1453 if (decl) | |
1454 flags = flags_from_decl_or_type (decl); | |
1455 else if (gimple_call_internal_p (stmt)) | |
1456 flags = internal_fn_flags (gimple_call_internal_fn (stmt)); | 1485 flags = internal_fn_flags (gimple_call_internal_fn (stmt)); |
1457 else | 1486 else |
1458 flags = flags_from_decl_or_type (gimple_call_fntype (stmt)); | 1487 { |
1488 tree decl = gimple_call_fndecl (stmt); | |
1489 if (decl) | |
1490 flags = flags_from_decl_or_type (decl); | |
1491 flags |= flags_from_decl_or_type (gimple_call_fntype (stmt)); | |
1492 } | |
1459 | 1493 |
1460 if (stmt->subcode & GF_CALL_NOTHROW) | 1494 if (stmt->subcode & GF_CALL_NOTHROW) |
1461 flags |= ECF_NOTHROW; | 1495 flags |= ECF_NOTHROW; |
1462 | 1496 |
1463 if (stmt->subcode & GF_CALL_BY_DESCRIPTOR) | 1497 if (stmt->subcode & GF_CALL_BY_DESCRIPTOR) |
1560 { | 1594 { |
1561 tree fndecl = gimple_call_fndecl (call); | 1595 tree fndecl = gimple_call_fndecl (call); |
1562 if (!fndecl) | 1596 if (!fndecl) |
1563 return false; | 1597 return false; |
1564 if (flag_delete_null_pointer_checks && !flag_check_new | 1598 if (flag_delete_null_pointer_checks && !flag_check_new |
1565 && DECL_IS_OPERATOR_NEW (fndecl) | 1599 && DECL_IS_OPERATOR_NEW_P (fndecl) |
1566 && !TREE_NOTHROW (fndecl)) | 1600 && !TREE_NOTHROW (fndecl)) |
1567 return true; | 1601 return true; |
1568 | 1602 |
1569 /* References are always non-NULL. */ | 1603 /* References are always non-NULL. */ |
1570 if (flag_delete_null_pointer_checks | 1604 if (flag_delete_null_pointer_checks |
1726 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code, | 1760 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code, |
1727 tree op1, tree op2, tree op3) | 1761 tree op1, tree op2, tree op3) |
1728 { | 1762 { |
1729 unsigned new_rhs_ops = get_gimple_rhs_num_ops (code); | 1763 unsigned new_rhs_ops = get_gimple_rhs_num_ops (code); |
1730 gimple *stmt = gsi_stmt (*gsi); | 1764 gimple *stmt = gsi_stmt (*gsi); |
1765 gimple *old_stmt = stmt; | |
1731 | 1766 |
1732 /* If the new CODE needs more operands, allocate a new statement. */ | 1767 /* If the new CODE needs more operands, allocate a new statement. */ |
1733 if (gimple_num_ops (stmt) < new_rhs_ops + 1) | 1768 if (gimple_num_ops (stmt) < new_rhs_ops + 1) |
1734 { | 1769 { |
1735 tree lhs = gimple_assign_lhs (stmt); | 1770 tree lhs = gimple_assign_lhs (old_stmt); |
1736 gimple *new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1); | 1771 stmt = gimple_alloc (gimple_code (old_stmt), new_rhs_ops + 1); |
1737 memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); | 1772 memcpy (stmt, old_stmt, gimple_size (gimple_code (old_stmt))); |
1738 gimple_init_singleton (new_stmt); | 1773 gimple_init_singleton (stmt); |
1739 gsi_replace (gsi, new_stmt, false); | |
1740 stmt = new_stmt; | |
1741 | 1774 |
1742 /* The LHS needs to be reset as this also changes the SSA name | 1775 /* The LHS needs to be reset as this also changes the SSA name |
1743 on the LHS. */ | 1776 on the LHS. */ |
1744 gimple_assign_set_lhs (stmt, lhs); | 1777 gimple_assign_set_lhs (stmt, lhs); |
1745 } | 1778 } |
1749 gimple_assign_set_rhs1 (stmt, op1); | 1782 gimple_assign_set_rhs1 (stmt, op1); |
1750 if (new_rhs_ops > 1) | 1783 if (new_rhs_ops > 1) |
1751 gimple_assign_set_rhs2 (stmt, op2); | 1784 gimple_assign_set_rhs2 (stmt, op2); |
1752 if (new_rhs_ops > 2) | 1785 if (new_rhs_ops > 2) |
1753 gimple_assign_set_rhs3 (stmt, op3); | 1786 gimple_assign_set_rhs3 (stmt, op3); |
1787 if (stmt != old_stmt) | |
1788 gsi_replace (gsi, stmt, false); | |
1754 } | 1789 } |
1755 | 1790 |
1756 | 1791 |
1757 /* Return the LHS of a statement that performs an assignment, | 1792 /* Return the LHS of a statement that performs an assignment, |
1758 either a GIMPLE_ASSIGN or a GIMPLE_CALL. Returns NULL_TREE | 1793 either a GIMPLE_ASSIGN or a GIMPLE_CALL. Returns NULL_TREE |
1766 | 1801 |
1767 if (code == GIMPLE_ASSIGN) | 1802 if (code == GIMPLE_ASSIGN) |
1768 return gimple_assign_lhs (stmt); | 1803 return gimple_assign_lhs (stmt); |
1769 else if (code == GIMPLE_CALL) | 1804 else if (code == GIMPLE_CALL) |
1770 return gimple_call_lhs (stmt); | 1805 return gimple_call_lhs (stmt); |
1806 else if (code == GIMPLE_PHI) | |
1807 return gimple_phi_result (stmt); | |
1771 else | 1808 else |
1772 return NULL_TREE; | 1809 return NULL_TREE; |
1773 } | 1810 } |
1774 | 1811 |
1775 | 1812 |
1938 t = unshare_expr (gimple_omp_ordered_clauses | 1975 t = unshare_expr (gimple_omp_ordered_clauses |
1939 (as_a <gomp_ordered *> (stmt))); | 1976 (as_a <gomp_ordered *> (stmt))); |
1940 gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t); | 1977 gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t); |
1941 goto copy_omp_body; | 1978 goto copy_omp_body; |
1942 | 1979 |
1980 case GIMPLE_OMP_SCAN: | |
1981 t = gimple_omp_scan_clauses (as_a <gomp_scan *> (stmt)); | |
1982 t = unshare_expr (t); | |
1983 gimple_omp_scan_set_clauses (as_a <gomp_scan *> (copy), t); | |
1984 goto copy_omp_body; | |
1985 | |
1986 case GIMPLE_OMP_TASKGROUP: | |
1987 t = unshare_expr (gimple_omp_taskgroup_clauses (stmt)); | |
1988 gimple_omp_taskgroup_set_clauses (copy, t); | |
1989 goto copy_omp_body; | |
1990 | |
1943 case GIMPLE_OMP_SECTIONS: | 1991 case GIMPLE_OMP_SECTIONS: |
1944 t = unshare_expr (gimple_omp_sections_clauses (stmt)); | 1992 t = unshare_expr (gimple_omp_sections_clauses (stmt)); |
1945 gimple_omp_sections_set_clauses (copy, t); | 1993 gimple_omp_sections_set_clauses (copy, t); |
1946 t = unshare_expr (gimple_omp_sections_control (stmt)); | 1994 t = unshare_expr (gimple_omp_sections_control (stmt)); |
1947 gimple_omp_sections_set_control (copy, t); | 1995 gimple_omp_sections_set_control (copy, t); |
1974 } | 2022 } |
1975 /* FALLTHRU */ | 2023 /* FALLTHRU */ |
1976 | 2024 |
1977 case GIMPLE_OMP_SECTION: | 2025 case GIMPLE_OMP_SECTION: |
1978 case GIMPLE_OMP_MASTER: | 2026 case GIMPLE_OMP_MASTER: |
1979 case GIMPLE_OMP_TASKGROUP: | |
1980 case GIMPLE_OMP_GRID_BODY: | 2027 case GIMPLE_OMP_GRID_BODY: |
1981 copy_omp_body: | 2028 copy_omp_body: |
1982 new_seq = gimple_seq_copy (gimple_omp_body (stmt)); | 2029 new_seq = gimple_seq_copy (gimple_omp_body (stmt)); |
1983 gimple_omp_set_body (copy, new_seq); | 2030 gimple_omp_set_body (copy, new_seq); |
1984 break; | 2031 break; |
2023 cfun->debug_marker_count++; | 2070 cfun->debug_marker_count++; |
2024 | 2071 |
2025 return copy; | 2072 return copy; |
2026 } | 2073 } |
2027 | 2074 |
2075 /* Move OLD_STMT's vuse and vdef operands to NEW_STMT, on the assumption | |
2076 that OLD_STMT is about to be removed. */ | |
2077 | |
2078 void | |
2079 gimple_move_vops (gimple *new_stmt, gimple *old_stmt) | |
2080 { | |
2081 tree vdef = gimple_vdef (old_stmt); | |
2082 gimple_set_vuse (new_stmt, gimple_vuse (old_stmt)); | |
2083 gimple_set_vdef (new_stmt, vdef); | |
2084 if (vdef && TREE_CODE (vdef) == SSA_NAME) | |
2085 SSA_NAME_DEF_STMT (vdef) = new_stmt; | |
2086 } | |
2028 | 2087 |
2029 /* Return true if statement S has side-effects. We consider a | 2088 /* Return true if statement S has side-effects. We consider a |
2030 statement to have side effects if: | 2089 statement to have side effects if: |
2031 | 2090 |
2032 - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST. | 2091 - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST. |
2094 if (!t || !DECL_P (t) || DECL_WEAK (t)) | 2153 if (!t || !DECL_P (t) || DECL_WEAK (t)) |
2095 return true; | 2154 return true; |
2096 return false; | 2155 return false; |
2097 | 2156 |
2098 case GIMPLE_ASSIGN: | 2157 case GIMPLE_ASSIGN: |
2099 t = gimple_expr_type (s); | |
2100 op = gimple_assign_rhs_code (s); | 2158 op = gimple_assign_rhs_code (s); |
2159 | |
2160 /* For COND_EXPR and VEC_COND_EXPR only the condition may trap. */ | |
2161 if (op == COND_EXPR || op == VEC_COND_EXPR) | |
2162 return tree_could_trap_p (gimple_assign_rhs1 (s)); | |
2163 | |
2164 /* For comparisons we need to check rhs operand types instead of rhs type | |
2165 (which is BOOLEAN_TYPE). */ | |
2166 if (TREE_CODE_CLASS (op) == tcc_comparison) | |
2167 t = TREE_TYPE (gimple_assign_rhs1 (s)); | |
2168 else | |
2169 t = gimple_expr_type (s); | |
2170 | |
2101 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) | 2171 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) |
2102 div = gimple_assign_rhs2 (s); | 2172 div = gimple_assign_rhs2 (s); |
2173 | |
2103 return (operation_could_trap_p (op, FLOAT_TYPE_P (t), | 2174 return (operation_could_trap_p (op, FLOAT_TYPE_P (t), |
2104 (INTEGRAL_TYPE_P (t) | 2175 (INTEGRAL_TYPE_P (t) |
2105 && TYPE_OVERFLOW_TRAPS (t)), | 2176 && TYPE_OVERFLOW_TRAPS (t)), |
2106 div)); | 2177 div)); |
2107 | 2178 |
2152 fprintf (stderr, "\nGIMPLE statements\n"); | 2223 fprintf (stderr, "\nGIMPLE statements\n"); |
2153 fprintf (stderr, "Kind Stmts Bytes\n"); | 2224 fprintf (stderr, "Kind Stmts Bytes\n"); |
2154 fprintf (stderr, "---------------------------------------\n"); | 2225 fprintf (stderr, "---------------------------------------\n"); |
2155 for (i = 0; i < (int) gimple_alloc_kind_all; ++i) | 2226 for (i = 0; i < (int) gimple_alloc_kind_all; ++i) |
2156 { | 2227 { |
2157 fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", | 2228 fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", |
2158 gimple_alloc_kind_names[i], gimple_alloc_counts[i], | 2229 gimple_alloc_kind_names[i], |
2159 gimple_alloc_sizes[i]); | 2230 SIZE_AMOUNT (gimple_alloc_counts[i]), |
2231 SIZE_AMOUNT (gimple_alloc_sizes[i])); | |
2160 total_tuples += gimple_alloc_counts[i]; | 2232 total_tuples += gimple_alloc_counts[i]; |
2161 total_bytes += gimple_alloc_sizes[i]; | 2233 total_bytes += gimple_alloc_sizes[i]; |
2162 } | 2234 } |
2163 fprintf (stderr, "---------------------------------------\n"); | 2235 fprintf (stderr, "---------------------------------------\n"); |
2164 fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total", | 2236 fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", "Total", |
2165 total_tuples, total_bytes); | 2237 SIZE_AMOUNT (total_tuples), SIZE_AMOUNT (total_bytes)); |
2166 fprintf (stderr, "---------------------------------------\n"); | 2238 fprintf (stderr, "---------------------------------------\n"); |
2167 } | 2239 } |
2168 | 2240 |
2169 | 2241 |
2170 /* Return the number of operands needed on the RHS of a GIMPLE | 2242 /* Return the number of operands needed on the RHS of a GIMPLE |
2171 assignment for an expression with tree code CODE. */ | 2243 assignment for an expression with tree code CODE. */ |
2172 | 2244 |
2173 unsigned | 2245 unsigned |
2174 get_gimple_rhs_num_ops (enum tree_code code) | 2246 get_gimple_rhs_num_ops (enum tree_code code) |
2175 { | 2247 { |
2176 enum gimple_rhs_class rhs_class = get_gimple_rhs_class (code); | 2248 switch (get_gimple_rhs_class (code)) |
2177 | 2249 { |
2178 if (rhs_class == GIMPLE_UNARY_RHS || rhs_class == GIMPLE_SINGLE_RHS) | 2250 case GIMPLE_UNARY_RHS: |
2179 return 1; | 2251 case GIMPLE_SINGLE_RHS: |
2180 else if (rhs_class == GIMPLE_BINARY_RHS) | 2252 return 1; |
2181 return 2; | 2253 case GIMPLE_BINARY_RHS: |
2182 else if (rhs_class == GIMPLE_TERNARY_RHS) | 2254 return 2; |
2183 return 3; | 2255 case GIMPLE_TERNARY_RHS: |
2184 else | 2256 return 3; |
2185 gcc_unreachable (); | 2257 default: |
2258 gcc_unreachable (); | |
2259 } | |
2186 } | 2260 } |
2187 | 2261 |
2188 #define DEFTREECODE(SYM, STRING, TYPE, NARGS) \ | 2262 #define DEFTREECODE(SYM, STRING, TYPE, NARGS) \ |
2189 (unsigned char) \ | 2263 (unsigned char) \ |
2190 ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS \ | 2264 ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS \ |
2582 /* t1 == t can happen for boolean nodes which are always unsigned. */ | 2656 /* t1 == t can happen for boolean nodes which are always unsigned. */ |
2583 if (t1 != t) | 2657 if (t1 != t) |
2584 return get_alias_set (t1); | 2658 return get_alias_set (t1); |
2585 } | 2659 } |
2586 | 2660 |
2661 /* Allow aliasing between enumeral types and the underlying | |
2662 integer type. This is required for C since those are | |
2663 compatible types. */ | |
2664 else if (TREE_CODE (t) == ENUMERAL_TYPE) | |
2665 { | |
2666 tree t1 = lang_hooks.types.type_for_size (tree_to_uhwi (TYPE_SIZE (t)), | |
2667 false /* short-cut above */); | |
2668 return get_alias_set (t1); | |
2669 } | |
2670 | |
2587 return -1; | 2671 return -1; |
2588 } | 2672 } |
2589 | 2673 |
2590 | 2674 |
2591 /* Helper for gimple_ior_addresses_taken_1. */ | 2675 /* Helper for gimple_ior_addresses_taken_1. */ |
2652 targs = TREE_CHAIN (targs); | 2736 targs = TREE_CHAIN (targs); |
2653 } | 2737 } |
2654 if (targs && !VOID_TYPE_P (TREE_VALUE (targs))) | 2738 if (targs && !VOID_TYPE_P (TREE_VALUE (targs))) |
2655 return false; | 2739 return false; |
2656 return true; | 2740 return true; |
2741 } | |
2742 | |
2743 /* Return true when STMT is operator delete call. */ | |
2744 | |
2745 bool | |
2746 gimple_call_operator_delete_p (const gcall *stmt) | |
2747 { | |
2748 tree fndecl; | |
2749 | |
2750 if ((fndecl = gimple_call_fndecl (stmt)) != NULL_TREE) | |
2751 return DECL_IS_OPERATOR_DELETE_P (fndecl); | |
2752 return false; | |
2657 } | 2753 } |
2658 | 2754 |
2659 /* Return true when STMT is builtins call. */ | 2755 /* Return true when STMT is builtins call. */ |
2660 | 2756 |
2661 bool | 2757 bool |