comparison gcc/gimple.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children 351920fa3827
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
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
42 #include "selftest.h" 42 #include "selftest.h"
43 #include "gimple-pretty-print.h" 43 #include "gimple-pretty-print.h"
44 #include "stringpool.h" 44 #include "stringpool.h"
45 #include "attribs.h" 45 #include "attribs.h"
46 #include "asan.h" 46 #include "asan.h"
47 #include "langhooks.h"
47 48
48 49
49 /* All the tuples have their operand vector (if present) at the very bottom 50 /* All the tuples have their operand vector (if present) at the very bottom
50 of the structure. Therefore, the offset required to find the 51 of the structure. Therefore, the offset required to find the
51 operands vector the size of the structure minus the size of the 1 52 operands vector the size of the structure minus the size of the 1
107 } 108 }
108 109
109 /* Return the number of bytes needed to hold a GIMPLE statement with 110 /* Return the number of bytes needed to hold a GIMPLE statement with
110 code CODE. */ 111 code CODE. */
111 112
112 static inline size_t 113 size_t
113 gimple_size (enum gimple_code code) 114 gimple_size (enum gimple_code code, unsigned num_ops)
114 { 115 {
115 return gsstruct_code_size[gss_for_code (code)]; 116 size_t size = gsstruct_code_size[gss_for_code (code)];
117 if (num_ops > 0)
118 size += (sizeof (tree) * (num_ops - 1));
119 return size;
120 }
121
122 /* Initialize GIMPLE statement G with CODE and NUM_OPS. */
123
124 void
125 gimple_init (gimple *g, enum gimple_code code, unsigned num_ops)
126 {
127 gimple_set_code (g, code);
128 gimple_set_num_ops (g, num_ops);
129
130 /* Do not call gimple_set_modified here as it has other side
131 effects and this tuple is still not completely built. */
132 g->modified = 1;
133 gimple_init_singleton (g);
116 } 134 }
117 135
118 /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS 136 /* Allocate memory for a GIMPLE statement with code CODE and NUM_OPS
119 operands. */ 137 operands. */
120 138
122 gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL) 140 gimple_alloc (enum gimple_code code, unsigned num_ops MEM_STAT_DECL)
123 { 141 {
124 size_t size; 142 size_t size;
125 gimple *stmt; 143 gimple *stmt;
126 144
127 size = gimple_size (code); 145 size = gimple_size (code, num_ops);
128 if (num_ops > 0)
129 size += sizeof (tree) * (num_ops - 1);
130
131 if (GATHER_STATISTICS) 146 if (GATHER_STATISTICS)
132 { 147 {
133 enum gimple_alloc_kind kind = gimple_alloc_kind (code); 148 enum gimple_alloc_kind kind = gimple_alloc_kind (code);
134 gimple_alloc_counts[(int) kind]++; 149 gimple_alloc_counts[(int) kind]++;
135 gimple_alloc_sizes[(int) kind] += size; 150 gimple_alloc_sizes[(int) kind] += size;
136 } 151 }
137 152
138 stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT); 153 stmt = ggc_alloc_cleared_gimple_statement_stat (size PASS_MEM_STAT);
139 gimple_set_code (stmt, code); 154 gimple_init (stmt, code, num_ops);
140 gimple_set_num_ops (stmt, num_ops);
141
142 /* Do not call gimple_set_modified here as it has other side
143 effects and this tuple is still not completely built. */
144 stmt->modified = 1;
145 gimple_init_singleton (stmt);
146
147 return stmt; 155 return stmt;
148 } 156 }
149 157
150 /* Set SUBCODE to be the code of the expression computed by statement G. */ 158 /* Set SUBCODE to be the code of the expression computed by statement G. */
151 159
922 930
923 /* Build a GIMPLE_OMP_FOR statement. 931 /* Build a GIMPLE_OMP_FOR statement.
924 932
925 BODY is sequence of statements inside the for loop. 933 BODY is sequence of statements inside the for loop.
926 KIND is the `for' variant. 934 KIND is the `for' variant.
927 CLAUSES, are any of the construct's clauses. 935 CLAUSES are any of the construct's clauses.
928 COLLAPSE is the collapse count. 936 COLLAPSE is the collapse count.
929 PRE_BODY is the sequence of statements that are loop invariant. */ 937 PRE_BODY is the sequence of statements that are loop invariant. */
930 938
931 gomp_for * 939 gomp_for *
932 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse, 940 gimple_build_omp_for (gimple_seq body, int kind, tree clauses, size_t collapse,
948 956
949 957
950 /* Build a GIMPLE_OMP_PARALLEL statement. 958 /* Build a GIMPLE_OMP_PARALLEL statement.
951 959
952 BODY is sequence of statements which are executed in parallel. 960 BODY is sequence of statements which are executed in parallel.
953 CLAUSES, are the OMP parallel construct's clauses. 961 CLAUSES are the OMP parallel construct's clauses.
954 CHILD_FN is the function created for the parallel threads to execute. 962 CHILD_FN is the function created for the parallel threads to execute.
955 DATA_ARG are the shared data argument(s). */ 963 DATA_ARG are the shared data argument(s). */
956 964
957 gomp_parallel * 965 gomp_parallel *
958 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn, 966 gimple_build_omp_parallel (gimple_seq body, tree clauses, tree child_fn,
971 979
972 980
973 /* Build a GIMPLE_OMP_TASK statement. 981 /* Build a GIMPLE_OMP_TASK statement.
974 982
975 BODY is sequence of statements which are executed by the explicit task. 983 BODY is sequence of statements which are executed by the explicit task.
976 CLAUSES, are the OMP parallel construct's clauses. 984 CLAUSES are the OMP task construct's clauses.
977 CHILD_FN is the function created for the parallel threads to execute. 985 CHILD_FN is the function created for the parallel threads to execute.
978 DATA_ARG are the shared data argument(s). 986 DATA_ARG are the shared data argument(s).
979 COPY_FN is the optional function for firstprivate initialization. 987 COPY_FN is the optional function for firstprivate initialization.
980 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */ 988 ARG_SIZE and ARG_ALIGN are size and alignment of the data block. */
981 989
1042 } 1050 }
1043 1051
1044 /* Build a GIMPLE_OMP_TASKGROUP statement. 1052 /* Build a GIMPLE_OMP_TASKGROUP statement.
1045 1053
1046 BODY is the sequence of statements to be executed by the taskgroup 1054 BODY is the sequence of statements to be executed by the taskgroup
1047 construct. */ 1055 construct.
1056 CLAUSES are any of the construct's clauses. */
1048 1057
1049 gimple * 1058 gimple *
1050 gimple_build_omp_taskgroup (gimple_seq body) 1059 gimple_build_omp_taskgroup (gimple_seq body, tree clauses)
1051 { 1060 {
1052 gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0); 1061 gimple *p = gimple_alloc (GIMPLE_OMP_TASKGROUP, 0);
1062 gimple_omp_taskgroup_set_clauses (p, clauses);
1053 if (body) 1063 if (body)
1054 gimple_omp_set_body (p, body); 1064 gimple_omp_set_body (p, body);
1055 1065
1056 return p; 1066 return p;
1057 } 1067 }
1098 gimple_build_omp_return (bool wait_p) 1108 gimple_build_omp_return (bool wait_p)
1099 { 1109 {
1100 gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0); 1110 gimple *p = gimple_alloc (GIMPLE_OMP_RETURN, 0);
1101 if (wait_p) 1111 if (wait_p)
1102 gimple_omp_return_set_nowait (p); 1112 gimple_omp_return_set_nowait (p);
1113
1114 return p;
1115 }
1116
1117
1118 /* Build a GIMPLE_OMP_SCAN statement.
1119
1120 BODY is the sequence of statements to be executed by the scan
1121 construct.
1122 CLAUSES are any of the construct's clauses. */
1123
1124 gomp_scan *
1125 gimple_build_omp_scan (gimple_seq body, tree clauses)
1126 {
1127 gomp_scan *p
1128 = as_a <gomp_scan *> (gimple_alloc (GIMPLE_OMP_SCAN, 0));
1129 gimple_omp_scan_set_clauses (p, clauses);
1130 if (body)
1131 gimple_omp_set_body (p, body);
1103 1132
1104 return p; 1133 return p;
1105 } 1134 }
1106 1135
1107 1136
1190 1219
1191 1220
1192 /* Build a GIMPLE_OMP_ATOMIC_LOAD statement. */ 1221 /* Build a GIMPLE_OMP_ATOMIC_LOAD statement. */
1193 1222
1194 gomp_atomic_load * 1223 gomp_atomic_load *
1195 gimple_build_omp_atomic_load (tree lhs, tree rhs) 1224 gimple_build_omp_atomic_load (tree lhs, tree rhs, enum omp_memory_order mo)
1196 { 1225 {
1197 gomp_atomic_load *p 1226 gomp_atomic_load *p
1198 = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0)); 1227 = as_a <gomp_atomic_load *> (gimple_alloc (GIMPLE_OMP_ATOMIC_LOAD, 0));
1199 gimple_omp_atomic_load_set_lhs (p, lhs); 1228 gimple_omp_atomic_load_set_lhs (p, lhs);
1200 gimple_omp_atomic_load_set_rhs (p, rhs); 1229 gimple_omp_atomic_load_set_rhs (p, rhs);
1230 gimple_omp_atomic_set_memory_order (p, mo);
1201 return p; 1231 return p;
1202 } 1232 }
1203 1233
1204 /* Build a GIMPLE_OMP_ATOMIC_STORE statement. 1234 /* Build a GIMPLE_OMP_ATOMIC_STORE statement.
1205 1235
1206 VAL is the value we are storing. */ 1236 VAL is the value we are storing. */
1207 1237
1208 gomp_atomic_store * 1238 gomp_atomic_store *
1209 gimple_build_omp_atomic_store (tree val) 1239 gimple_build_omp_atomic_store (tree val, enum omp_memory_order mo)
1210 { 1240 {
1211 gomp_atomic_store *p 1241 gomp_atomic_store *p
1212 = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0)); 1242 = as_a <gomp_atomic_store *> (gimple_alloc (GIMPLE_OMP_ATOMIC_STORE, 0));
1213 gimple_omp_atomic_store_set_val (p, val); 1243 gimple_omp_atomic_store_set_val (p, val);
1244 gimple_omp_atomic_set_memory_order (p, mo);
1214 return p; 1245 return p;
1215 } 1246 }
1216 1247
1217 /* Build a GIMPLE_TRANSACTION statement. */ 1248 /* Build a GIMPLE_TRANSACTION statement. */
1218 1249
1440 call_expr_flags, but for gimple tuples. */ 1471 call_expr_flags, but for gimple tuples. */
1441 1472
1442 int 1473 int
1443 gimple_call_flags (const gimple *stmt) 1474 gimple_call_flags (const gimple *stmt)
1444 { 1475 {
1445 int flags; 1476 int flags = 0;
1446 tree decl = gimple_call_fndecl (stmt); 1477
1447 1478 if (gimple_call_internal_p (stmt))
1448 if (decl)
1449 flags = flags_from_decl_or_type (decl);
1450 else if (gimple_call_internal_p (stmt))
1451 flags = internal_fn_flags (gimple_call_internal_fn (stmt)); 1479 flags = internal_fn_flags (gimple_call_internal_fn (stmt));
1452 else 1480 else
1453 flags = flags_from_decl_or_type (gimple_call_fntype (stmt)); 1481 {
1482 tree decl = gimple_call_fndecl (stmt);
1483 if (decl)
1484 flags = flags_from_decl_or_type (decl);
1485 flags |= flags_from_decl_or_type (gimple_call_fntype (stmt));
1486 }
1454 1487
1455 if (stmt->subcode & GF_CALL_NOTHROW) 1488 if (stmt->subcode & GF_CALL_NOTHROW)
1456 flags |= ECF_NOTHROW; 1489 flags |= ECF_NOTHROW;
1457 1490
1458 if (stmt->subcode & GF_CALL_BY_DESCRIPTOR) 1491 if (stmt->subcode & GF_CALL_BY_DESCRIPTOR)
1555 { 1588 {
1556 tree fndecl = gimple_call_fndecl (call); 1589 tree fndecl = gimple_call_fndecl (call);
1557 if (!fndecl) 1590 if (!fndecl)
1558 return false; 1591 return false;
1559 if (flag_delete_null_pointer_checks && !flag_check_new 1592 if (flag_delete_null_pointer_checks && !flag_check_new
1560 && DECL_IS_OPERATOR_NEW (fndecl) 1593 && DECL_IS_OPERATOR_NEW_P (fndecl)
1561 && !TREE_NOTHROW (fndecl)) 1594 && !TREE_NOTHROW (fndecl))
1562 return true; 1595 return true;
1563 1596
1564 /* References are always non-NULL. */ 1597 /* References are always non-NULL. */
1565 if (flag_delete_null_pointer_checks 1598 if (flag_delete_null_pointer_checks
1721 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code, 1754 gimple_assign_set_rhs_with_ops (gimple_stmt_iterator *gsi, enum tree_code code,
1722 tree op1, tree op2, tree op3) 1755 tree op1, tree op2, tree op3)
1723 { 1756 {
1724 unsigned new_rhs_ops = get_gimple_rhs_num_ops (code); 1757 unsigned new_rhs_ops = get_gimple_rhs_num_ops (code);
1725 gimple *stmt = gsi_stmt (*gsi); 1758 gimple *stmt = gsi_stmt (*gsi);
1759 gimple *old_stmt = stmt;
1726 1760
1727 /* If the new CODE needs more operands, allocate a new statement. */ 1761 /* If the new CODE needs more operands, allocate a new statement. */
1728 if (gimple_num_ops (stmt) < new_rhs_ops + 1) 1762 if (gimple_num_ops (stmt) < new_rhs_ops + 1)
1729 { 1763 {
1730 tree lhs = gimple_assign_lhs (stmt); 1764 tree lhs = gimple_assign_lhs (old_stmt);
1731 gimple *new_stmt = gimple_alloc (gimple_code (stmt), new_rhs_ops + 1); 1765 stmt = gimple_alloc (gimple_code (old_stmt), new_rhs_ops + 1);
1732 memcpy (new_stmt, stmt, gimple_size (gimple_code (stmt))); 1766 memcpy (stmt, old_stmt, gimple_size (gimple_code (old_stmt)));
1733 gimple_init_singleton (new_stmt); 1767 gimple_init_singleton (stmt);
1734 gsi_replace (gsi, new_stmt, false);
1735 stmt = new_stmt;
1736 1768
1737 /* The LHS needs to be reset as this also changes the SSA name 1769 /* The LHS needs to be reset as this also changes the SSA name
1738 on the LHS. */ 1770 on the LHS. */
1739 gimple_assign_set_lhs (stmt, lhs); 1771 gimple_assign_set_lhs (stmt, lhs);
1740 } 1772 }
1744 gimple_assign_set_rhs1 (stmt, op1); 1776 gimple_assign_set_rhs1 (stmt, op1);
1745 if (new_rhs_ops > 1) 1777 if (new_rhs_ops > 1)
1746 gimple_assign_set_rhs2 (stmt, op2); 1778 gimple_assign_set_rhs2 (stmt, op2);
1747 if (new_rhs_ops > 2) 1779 if (new_rhs_ops > 2)
1748 gimple_assign_set_rhs3 (stmt, op3); 1780 gimple_assign_set_rhs3 (stmt, op3);
1781 if (stmt != old_stmt)
1782 gsi_replace (gsi, stmt, false);
1749 } 1783 }
1750 1784
1751 1785
1752 /* Return the LHS of a statement that performs an assignment, 1786 /* Return the LHS of a statement that performs an assignment,
1753 either a GIMPLE_ASSIGN or a GIMPLE_CALL. Returns NULL_TREE 1787 either a GIMPLE_ASSIGN or a GIMPLE_CALL. Returns NULL_TREE
1761 1795
1762 if (code == GIMPLE_ASSIGN) 1796 if (code == GIMPLE_ASSIGN)
1763 return gimple_assign_lhs (stmt); 1797 return gimple_assign_lhs (stmt);
1764 else if (code == GIMPLE_CALL) 1798 else if (code == GIMPLE_CALL)
1765 return gimple_call_lhs (stmt); 1799 return gimple_call_lhs (stmt);
1800 else if (code == GIMPLE_PHI)
1801 return gimple_phi_result (stmt);
1766 else 1802 else
1767 return NULL_TREE; 1803 return NULL_TREE;
1768 } 1804 }
1769 1805
1770 1806
1933 t = unshare_expr (gimple_omp_ordered_clauses 1969 t = unshare_expr (gimple_omp_ordered_clauses
1934 (as_a <gomp_ordered *> (stmt))); 1970 (as_a <gomp_ordered *> (stmt)));
1935 gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t); 1971 gimple_omp_ordered_set_clauses (as_a <gomp_ordered *> (copy), t);
1936 goto copy_omp_body; 1972 goto copy_omp_body;
1937 1973
1974 case GIMPLE_OMP_SCAN:
1975 t = gimple_omp_scan_clauses (as_a <gomp_scan *> (stmt));
1976 t = unshare_expr (t);
1977 gimple_omp_scan_set_clauses (as_a <gomp_scan *> (copy), t);
1978 goto copy_omp_body;
1979
1980 case GIMPLE_OMP_TASKGROUP:
1981 t = unshare_expr (gimple_omp_taskgroup_clauses (stmt));
1982 gimple_omp_taskgroup_set_clauses (copy, t);
1983 goto copy_omp_body;
1984
1938 case GIMPLE_OMP_SECTIONS: 1985 case GIMPLE_OMP_SECTIONS:
1939 t = unshare_expr (gimple_omp_sections_clauses (stmt)); 1986 t = unshare_expr (gimple_omp_sections_clauses (stmt));
1940 gimple_omp_sections_set_clauses (copy, t); 1987 gimple_omp_sections_set_clauses (copy, t);
1941 t = unshare_expr (gimple_omp_sections_control (stmt)); 1988 t = unshare_expr (gimple_omp_sections_control (stmt));
1942 gimple_omp_sections_set_control (copy, t); 1989 gimple_omp_sections_set_control (copy, t);
1969 } 2016 }
1970 /* FALLTHRU */ 2017 /* FALLTHRU */
1971 2018
1972 case GIMPLE_OMP_SECTION: 2019 case GIMPLE_OMP_SECTION:
1973 case GIMPLE_OMP_MASTER: 2020 case GIMPLE_OMP_MASTER:
1974 case GIMPLE_OMP_TASKGROUP:
1975 case GIMPLE_OMP_GRID_BODY: 2021 case GIMPLE_OMP_GRID_BODY:
1976 copy_omp_body: 2022 copy_omp_body:
1977 new_seq = gimple_seq_copy (gimple_omp_body (stmt)); 2023 new_seq = gimple_seq_copy (gimple_omp_body (stmt));
1978 gimple_omp_set_body (copy, new_seq); 2024 gimple_omp_set_body (copy, new_seq);
1979 break; 2025 break;
2018 cfun->debug_marker_count++; 2064 cfun->debug_marker_count++;
2019 2065
2020 return copy; 2066 return copy;
2021 } 2067 }
2022 2068
2069 /* Move OLD_STMT's vuse and vdef operands to NEW_STMT, on the assumption
2070 that OLD_STMT is about to be removed. */
2071
2072 void
2073 gimple_move_vops (gimple *new_stmt, gimple *old_stmt)
2074 {
2075 tree vdef = gimple_vdef (old_stmt);
2076 gimple_set_vuse (new_stmt, gimple_vuse (old_stmt));
2077 gimple_set_vdef (new_stmt, vdef);
2078 if (vdef && TREE_CODE (vdef) == SSA_NAME)
2079 SSA_NAME_DEF_STMT (vdef) = new_stmt;
2080 }
2023 2081
2024 /* Return true if statement S has side-effects. We consider a 2082 /* Return true if statement S has side-effects. We consider a
2025 statement to have side effects if: 2083 statement to have side effects if:
2026 2084
2027 - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST. 2085 - It is a GIMPLE_CALL not marked with ECF_PURE or ECF_CONST.
2089 if (!t || !DECL_P (t) || DECL_WEAK (t)) 2147 if (!t || !DECL_P (t) || DECL_WEAK (t))
2090 return true; 2148 return true;
2091 return false; 2149 return false;
2092 2150
2093 case GIMPLE_ASSIGN: 2151 case GIMPLE_ASSIGN:
2094 t = gimple_expr_type (s);
2095 op = gimple_assign_rhs_code (s); 2152 op = gimple_assign_rhs_code (s);
2153
2154 /* For COND_EXPR and VEC_COND_EXPR only the condition may trap. */
2155 if (op == COND_EXPR || op == VEC_COND_EXPR)
2156 return tree_could_trap_p (gimple_assign_rhs1 (s));
2157
2158 /* For comparisons we need to check rhs operand types instead of rhs type
2159 (which is BOOLEAN_TYPE). */
2160 if (TREE_CODE_CLASS (op) == tcc_comparison)
2161 t = TREE_TYPE (gimple_assign_rhs1 (s));
2162 else
2163 t = gimple_expr_type (s);
2164
2096 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS) 2165 if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS)
2097 div = gimple_assign_rhs2 (s); 2166 div = gimple_assign_rhs2 (s);
2167
2098 return (operation_could_trap_p (op, FLOAT_TYPE_P (t), 2168 return (operation_could_trap_p (op, FLOAT_TYPE_P (t),
2099 (INTEGRAL_TYPE_P (t) 2169 (INTEGRAL_TYPE_P (t)
2100 && TYPE_OVERFLOW_TRAPS (t)), 2170 && TYPE_OVERFLOW_TRAPS (t)),
2101 div)); 2171 div));
2102 2172
2147 fprintf (stderr, "\nGIMPLE statements\n"); 2217 fprintf (stderr, "\nGIMPLE statements\n");
2148 fprintf (stderr, "Kind Stmts Bytes\n"); 2218 fprintf (stderr, "Kind Stmts Bytes\n");
2149 fprintf (stderr, "---------------------------------------\n"); 2219 fprintf (stderr, "---------------------------------------\n");
2150 for (i = 0; i < (int) gimple_alloc_kind_all; ++i) 2220 for (i = 0; i < (int) gimple_alloc_kind_all; ++i)
2151 { 2221 {
2152 fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", 2222 fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n",
2153 gimple_alloc_kind_names[i], gimple_alloc_counts[i], 2223 gimple_alloc_kind_names[i],
2154 gimple_alloc_sizes[i]); 2224 SIZE_AMOUNT (gimple_alloc_counts[i]),
2225 SIZE_AMOUNT (gimple_alloc_sizes[i]));
2155 total_tuples += gimple_alloc_counts[i]; 2226 total_tuples += gimple_alloc_counts[i];
2156 total_bytes += gimple_alloc_sizes[i]; 2227 total_bytes += gimple_alloc_sizes[i];
2157 } 2228 }
2158 fprintf (stderr, "---------------------------------------\n"); 2229 fprintf (stderr, "---------------------------------------\n");
2159 fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total", 2230 fprintf (stderr, "%-20s %7" PRIu64 "%c %10" PRIu64 "%c\n", "Total",
2160 total_tuples, total_bytes); 2231 SIZE_AMOUNT (total_tuples), SIZE_AMOUNT (total_bytes));
2161 fprintf (stderr, "---------------------------------------\n"); 2232 fprintf (stderr, "---------------------------------------\n");
2162 } 2233 }
2163 2234
2164 2235
2165 /* Return the number of operands needed on the RHS of a GIMPLE 2236 /* Return the number of operands needed on the RHS of a GIMPLE
2166 assignment for an expression with tree code CODE. */ 2237 assignment for an expression with tree code CODE. */
2167 2238
2168 unsigned 2239 unsigned
2169 get_gimple_rhs_num_ops (enum tree_code code) 2240 get_gimple_rhs_num_ops (enum tree_code code)
2170 { 2241 {
2171 enum gimple_rhs_class rhs_class = get_gimple_rhs_class (code); 2242 switch (get_gimple_rhs_class (code))
2172 2243 {
2173 if (rhs_class == GIMPLE_UNARY_RHS || rhs_class == GIMPLE_SINGLE_RHS) 2244 case GIMPLE_UNARY_RHS:
2174 return 1; 2245 case GIMPLE_SINGLE_RHS:
2175 else if (rhs_class == GIMPLE_BINARY_RHS) 2246 return 1;
2176 return 2; 2247 case GIMPLE_BINARY_RHS:
2177 else if (rhs_class == GIMPLE_TERNARY_RHS) 2248 return 2;
2178 return 3; 2249 case GIMPLE_TERNARY_RHS:
2179 else 2250 return 3;
2180 gcc_unreachable (); 2251 default:
2252 gcc_unreachable ();
2253 }
2181 } 2254 }
2182 2255
2183 #define DEFTREECODE(SYM, STRING, TYPE, NARGS) \ 2256 #define DEFTREECODE(SYM, STRING, TYPE, NARGS) \
2184 (unsigned char) \ 2257 (unsigned char) \
2185 ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS \ 2258 ((TYPE) == tcc_unary ? GIMPLE_UNARY_RHS \
2573 /* t1 == t can happen for boolean nodes which are always unsigned. */ 2646 /* t1 == t can happen for boolean nodes which are always unsigned. */
2574 if (t1 != t) 2647 if (t1 != t)
2575 return get_alias_set (t1); 2648 return get_alias_set (t1);
2576 } 2649 }
2577 2650
2651 /* Allow aliasing between enumeral types and the underlying
2652 integer type. This is required for C since those are
2653 compatible types. */
2654 else if (TREE_CODE (t) == ENUMERAL_TYPE)
2655 {
2656 tree t1 = lang_hooks.types.type_for_size (tree_to_uhwi (TYPE_SIZE (t)),
2657 false /* short-cut above */);
2658 return get_alias_set (t1);
2659 }
2660
2578 return -1; 2661 return -1;
2579 } 2662 }
2580 2663
2581 2664
2582 /* Helper for gimple_ior_addresses_taken_1. */ 2665 /* Helper for gimple_ior_addresses_taken_1. */
2643 targs = TREE_CHAIN (targs); 2726 targs = TREE_CHAIN (targs);
2644 } 2727 }
2645 if (targs && !VOID_TYPE_P (TREE_VALUE (targs))) 2728 if (targs && !VOID_TYPE_P (TREE_VALUE (targs)))
2646 return false; 2729 return false;
2647 return true; 2730 return true;
2731 }
2732
2733 /* Return true when STMT is operator delete call. */
2734
2735 bool
2736 gimple_call_operator_delete_p (const gcall *stmt)
2737 {
2738 tree fndecl;
2739
2740 if ((fndecl = gimple_call_fndecl (stmt)) != NULL_TREE)
2741 return DECL_IS_OPERATOR_DELETE_P (fndecl);
2742 return false;
2648 } 2743 }
2649 2744
2650 /* Return true when STMT is builtins call. */ 2745 /* Return true when STMT is builtins call. */
2651 2746
2652 bool 2747 bool