Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 1b10fe6932e1 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Language-independent node constructors for parse phase of GNU compiler. | 1 /* Language-independent node constructors for parse phase of GNU compiler. |
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, |
4 Free Software Foundation, Inc. | 4 2011 Free Software Foundation, Inc. |
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 |
9 the terms of the GNU General Public License as published by the Free | 9 the terms of the GNU General Public License as published by the Free |
134 "stmts", | 134 "stmts", |
135 "refs", | 135 "refs", |
136 "exprs", | 136 "exprs", |
137 "constants", | 137 "constants", |
138 "identifiers", | 138 "identifiers", |
139 "perm_tree_lists", | |
140 "temp_tree_lists", | |
141 "vecs", | 139 "vecs", |
142 "binfos", | 140 "binfos", |
143 "ssa names", | 141 "ssa names", |
144 "constructors", | 142 "constructors", |
145 "random kinds", | 143 "random kinds", |
194 htab_t cl_option_hash_table; | 192 htab_t cl_option_hash_table; |
195 | 193 |
196 /* General tree->tree mapping structure for use in hash tables. */ | 194 /* General tree->tree mapping structure for use in hash tables. */ |
197 | 195 |
198 | 196 |
199 static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) | 197 static GTY ((if_marked ("tree_decl_map_marked_p"), param_is (struct tree_decl_map))) |
200 htab_t debug_expr_for_decl; | 198 htab_t debug_expr_for_decl; |
201 | 199 |
202 static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) | 200 static GTY ((if_marked ("tree_decl_map_marked_p"), param_is (struct tree_decl_map))) |
203 htab_t value_expr_for_decl; | 201 htab_t value_expr_for_decl; |
204 | 202 |
205 static GTY ((if_marked ("tree_priority_map_marked_p"), | 203 static GTY ((if_marked ("tree_priority_map_marked_p"), |
206 param_is (struct tree_priority_map))) | 204 param_is (struct tree_priority_map))) |
207 htab_t init_priority_for_decl; | 205 htab_t init_priority_for_decl; |
294 return TS_CONST_DECL; | 292 return TS_CONST_DECL; |
295 case TYPE_DECL: | 293 case TYPE_DECL: |
296 return TS_TYPE_DECL; | 294 return TS_TYPE_DECL; |
297 case FUNCTION_DECL: | 295 case FUNCTION_DECL: |
298 return TS_FUNCTION_DECL; | 296 return TS_FUNCTION_DECL; |
297 case TRANSLATION_UNIT_DECL: | |
298 return TS_TRANSLATION_UNIT_DECL; | |
299 default: | 299 default: |
300 return TS_DECL_NON_COMMON; | 300 return TS_DECL_NON_COMMON; |
301 } | 301 } |
302 } | 302 } |
303 case tcc_type: | 303 case tcc_type: |
464 case TS_TYPE_DECL: | 464 case TS_TYPE_DECL: |
465 case TS_FUNCTION_DECL: | 465 case TS_FUNCTION_DECL: |
466 MARK_TS_DECL_NON_COMMON (code); | 466 MARK_TS_DECL_NON_COMMON (code); |
467 break; | 467 break; |
468 | 468 |
469 case TS_TRANSLATION_UNIT_DECL: | |
470 MARK_TS_DECL_COMMON (code); | |
471 break; | |
472 | |
469 default: | 473 default: |
470 gcc_unreachable (); | 474 gcc_unreachable (); |
471 } | 475 } |
472 } | 476 } |
473 | 477 |
474 /* Basic consistency checks for attributes used in fold. */ | 478 /* Basic consistency checks for attributes used in fold. */ |
475 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]); | 479 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]); |
476 gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_NON_COMMON]); | |
477 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]); | 480 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]); |
478 gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]); | 481 gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]); |
479 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]); | 482 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]); |
480 gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]); | 483 gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]); |
481 gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]); | 484 gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]); |
500 gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]); | 503 gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]); |
501 gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]); | 504 gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]); |
502 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]); | 505 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]); |
503 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]); | 506 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]); |
504 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]); | 507 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]); |
505 gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_WITH_VIS]); | |
506 gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]); | 508 gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]); |
507 gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]); | 509 gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]); |
508 gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]); | 510 gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]); |
509 gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]); | 511 gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]); |
510 gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]); | 512 gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]); |
531 { | 533 { |
532 /* Initialize the hash table of types. */ | 534 /* Initialize the hash table of types. */ |
533 type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, | 535 type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, |
534 type_hash_eq, 0); | 536 type_hash_eq, 0); |
535 | 537 |
536 debug_expr_for_decl = htab_create_ggc (512, tree_map_hash, | 538 debug_expr_for_decl = htab_create_ggc (512, tree_decl_map_hash, |
537 tree_map_eq, 0); | 539 tree_decl_map_eq, 0); |
538 | 540 |
539 value_expr_for_decl = htab_create_ggc (512, tree_map_hash, | 541 value_expr_for_decl = htab_create_ggc (512, tree_decl_map_hash, |
540 tree_map_eq, 0); | 542 tree_decl_map_eq, 0); |
541 init_priority_for_decl = htab_create_ggc (512, tree_priority_map_hash, | 543 init_priority_for_decl = htab_create_ggc (512, tree_priority_map_hash, |
542 tree_priority_map_eq, 0); | 544 tree_priority_map_eq, 0); |
543 | 545 |
544 int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash, | 546 int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash, |
545 int_cst_hash_eq, NULL); | 547 int_cst_hash_eq, NULL); |
851 | 853 |
852 tree_node_counts[(int) kind]++; | 854 tree_node_counts[(int) kind]++; |
853 tree_node_sizes[(int) kind] += length; | 855 tree_node_sizes[(int) kind] += length; |
854 #endif | 856 #endif |
855 | 857 |
856 if (code == IDENTIFIER_NODE) | 858 t = ggc_alloc_zone_cleared_tree_node_stat ( |
857 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_id_zone); | 859 (code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone, |
858 else | 860 length PASS_MEM_STAT); |
859 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | |
860 | |
861 memset (t, 0, length); | |
862 | |
863 TREE_SET_CODE (t, code); | 861 TREE_SET_CODE (t, code); |
864 | 862 |
865 switch (type) | 863 switch (type) |
866 { | 864 { |
867 case tcc_statement: | 865 case tcc_statement: |
950 size_t length; | 948 size_t length; |
951 | 949 |
952 gcc_assert (code != STATEMENT_LIST); | 950 gcc_assert (code != STATEMENT_LIST); |
953 | 951 |
954 length = tree_size (node); | 952 length = tree_size (node); |
955 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 953 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
956 memcpy (t, node, length); | 954 memcpy (t, node, length); |
957 | 955 |
958 TREE_CHAIN (t) = 0; | 956 TREE_CHAIN (t) = 0; |
959 TREE_ASM_WRITTEN (t) = 0; | 957 TREE_ASM_WRITTEN (t) = 0; |
960 TREE_VISITED (t) = 0; | 958 TREE_VISITED (t) = 0; |
1051 precision of the integer constants. */ | 1049 precision of the integer constants. */ |
1052 | 1050 |
1053 tree | 1051 tree |
1054 build_int_cst_type (tree type, HOST_WIDE_INT low) | 1052 build_int_cst_type (tree type, HOST_WIDE_INT low) |
1055 { | 1053 { |
1056 unsigned HOST_WIDE_INT low1; | |
1057 HOST_WIDE_INT hi; | |
1058 | |
1059 gcc_assert (type); | 1054 gcc_assert (type); |
1060 | 1055 |
1061 fit_double_type (low, low < 0 ? -1 : 0, &low1, &hi, type); | 1056 return double_int_to_tree (type, shwi_to_double_int (low)); |
1062 | |
1063 return build_int_cst_wide (type, low1, hi); | |
1064 } | 1057 } |
1065 | 1058 |
1066 /* Constructs tree in type TYPE from with value given by CST. Signedness | 1059 /* Constructs tree in type TYPE from with value given by CST. Signedness |
1067 of CST is assumed to be the same as the signedness of TYPE. */ | 1060 of CST is assumed to be the same as the signedness of TYPE. */ |
1068 | 1061 |
1094 = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); | 1087 = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); |
1095 | 1088 |
1096 return double_int_equal_p (cst, ext); | 1089 return double_int_equal_p (cst, ext); |
1097 } | 1090 } |
1098 | 1091 |
1092 /* We force the double_int CST to the range of the type TYPE by sign or | |
1093 zero extending it. OVERFLOWABLE indicates if we are interested in | |
1094 overflow of the value, when >0 we are only interested in signed | |
1095 overflow, for <0 we are interested in any overflow. OVERFLOWED | |
1096 indicates whether overflow has already occurred. CONST_OVERFLOWED | |
1097 indicates whether constant overflow has already occurred. We force | |
1098 T's value to be within range of T's type (by setting to 0 or 1 all | |
1099 the bits outside the type's range). We set TREE_OVERFLOWED if, | |
1100 OVERFLOWED is nonzero, | |
1101 or OVERFLOWABLE is >0 and signed overflow occurs | |
1102 or OVERFLOWABLE is <0 and any overflow occurs | |
1103 We return a new tree node for the extended double_int. The node | |
1104 is shared if no overflow flags are set. */ | |
1105 | |
1106 | |
1107 tree | |
1108 force_fit_type_double (tree type, double_int cst, int overflowable, | |
1109 bool overflowed) | |
1110 { | |
1111 bool sign_extended_type; | |
1112 | |
1113 /* Size types *are* sign extended. */ | |
1114 sign_extended_type = (!TYPE_UNSIGNED (type) | |
1115 || (TREE_CODE (type) == INTEGER_TYPE | |
1116 && TYPE_IS_SIZETYPE (type))); | |
1117 | |
1118 /* If we need to set overflow flags, return a new unshared node. */ | |
1119 if (overflowed || !double_int_fits_to_tree_p(type, cst)) | |
1120 { | |
1121 if (overflowed | |
1122 || overflowable < 0 | |
1123 || (overflowable > 0 && sign_extended_type)) | |
1124 { | |
1125 tree t = make_node (INTEGER_CST); | |
1126 TREE_INT_CST (t) = double_int_ext (cst, TYPE_PRECISION (type), | |
1127 !sign_extended_type); | |
1128 TREE_TYPE (t) = type; | |
1129 TREE_OVERFLOW (t) = 1; | |
1130 return t; | |
1131 } | |
1132 } | |
1133 | |
1134 /* Else build a shared node. */ | |
1135 return double_int_to_tree (type, cst); | |
1136 } | |
1137 | |
1099 /* These are the hash table functions for the hash table of INTEGER_CST | 1138 /* These are the hash table functions for the hash table of INTEGER_CST |
1100 nodes of a sizetype. */ | 1139 nodes of a sizetype. */ |
1101 | 1140 |
1102 /* Return the hash code code X, an INTEGER_CST. */ | 1141 /* Return the hash code code X, an INTEGER_CST. */ |
1103 | 1142 |
1137 | 1176 |
1138 gcc_assert (type); | 1177 gcc_assert (type); |
1139 | 1178 |
1140 switch (TREE_CODE (type)) | 1179 switch (TREE_CODE (type)) |
1141 { | 1180 { |
1181 case NULLPTR_TYPE: | |
1182 gcc_assert (hi == 0 && low == 0); | |
1183 /* Fallthru. */ | |
1184 | |
1142 case POINTER_TYPE: | 1185 case POINTER_TYPE: |
1143 case REFERENCE_TYPE: | 1186 case REFERENCE_TYPE: |
1144 /* Cache NULL pointer. */ | 1187 /* Cache NULL pointer. */ |
1145 if (!hi && !low) | 1188 if (!hi && !low) |
1146 { | 1189 { |
1279 build_vector (tree type, tree vals) | 1322 build_vector (tree type, tree vals) |
1280 { | 1323 { |
1281 tree v = make_node (VECTOR_CST); | 1324 tree v = make_node (VECTOR_CST); |
1282 int over = 0; | 1325 int over = 0; |
1283 tree link; | 1326 tree link; |
1327 unsigned cnt = 0; | |
1284 | 1328 |
1285 TREE_VECTOR_CST_ELTS (v) = vals; | 1329 TREE_VECTOR_CST_ELTS (v) = vals; |
1286 TREE_TYPE (v) = type; | 1330 TREE_TYPE (v) = type; |
1287 | 1331 |
1288 /* Iterate through elements and check for overflow. */ | 1332 /* Iterate through elements and check for overflow. */ |
1289 for (link = vals; link; link = TREE_CHAIN (link)) | 1333 for (link = vals; link; link = TREE_CHAIN (link)) |
1290 { | 1334 { |
1291 tree value = TREE_VALUE (link); | 1335 tree value = TREE_VALUE (link); |
1336 cnt++; | |
1292 | 1337 |
1293 /* Don't crash if we get an address constant. */ | 1338 /* Don't crash if we get an address constant. */ |
1294 if (!CONSTANT_CLASS_P (value)) | 1339 if (!CONSTANT_CLASS_P (value)) |
1295 continue; | 1340 continue; |
1296 | 1341 |
1297 over |= TREE_OVERFLOW (value); | 1342 over |= TREE_OVERFLOW (value); |
1298 } | 1343 } |
1299 | 1344 |
1345 gcc_assert (cnt == TYPE_VECTOR_SUBPARTS (type)); | |
1346 | |
1300 TREE_OVERFLOW (v) = over; | 1347 TREE_OVERFLOW (v) = over; |
1301 return v; | 1348 return v; |
1302 } | 1349 } |
1303 | 1350 |
1304 /* Return a new VECTOR_CST node whose type is TYPE and whose values | 1351 /* Return a new VECTOR_CST node whose type is TYPE and whose values |
1311 unsigned HOST_WIDE_INT idx; | 1358 unsigned HOST_WIDE_INT idx; |
1312 tree value; | 1359 tree value; |
1313 | 1360 |
1314 FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) | 1361 FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) |
1315 list = tree_cons (NULL_TREE, value, list); | 1362 list = tree_cons (NULL_TREE, value, list); |
1363 for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx) | |
1364 list = tree_cons (NULL_TREE, | |
1365 build_zero_cst (TREE_TYPE (type)), list); | |
1316 return build_vector (type, nreverse (list)); | 1366 return build_vector (type, nreverse (list)); |
1367 } | |
1368 | |
1369 /* Build a vector of type VECTYPE where all the elements are SCs. */ | |
1370 tree | |
1371 build_vector_from_val (tree vectype, tree sc) | |
1372 { | |
1373 int i, nunits = TYPE_VECTOR_SUBPARTS (vectype); | |
1374 VEC(constructor_elt, gc) *v = NULL; | |
1375 | |
1376 if (sc == error_mark_node) | |
1377 return sc; | |
1378 | |
1379 /* Verify that the vector type is suitable for SC. Note that there | |
1380 is some inconsistency in the type-system with respect to restrict | |
1381 qualifications of pointers. Vector types always have a main-variant | |
1382 element type and the qualification is applied to the vector-type. | |
1383 So TREE_TYPE (vector-type) does not return a properly qualified | |
1384 vector element-type. */ | |
1385 gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)), | |
1386 TREE_TYPE (vectype))); | |
1387 | |
1388 v = VEC_alloc (constructor_elt, gc, nunits); | |
1389 for (i = 0; i < nunits; ++i) | |
1390 CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc); | |
1391 | |
1392 if (CONSTANT_CLASS_P (sc)) | |
1393 return build_vector_from_ctor (vectype, v); | |
1394 else | |
1395 return build_constructor (vectype, v); | |
1317 } | 1396 } |
1318 | 1397 |
1319 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values | 1398 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values |
1320 are in the VEC pointed to by VALS. */ | 1399 are in the VEC pointed to by VALS. */ |
1321 tree | 1400 tree |
1327 bool constant_p = true; | 1406 bool constant_p = true; |
1328 | 1407 |
1329 TREE_TYPE (c) = type; | 1408 TREE_TYPE (c) = type; |
1330 CONSTRUCTOR_ELTS (c) = vals; | 1409 CONSTRUCTOR_ELTS (c) = vals; |
1331 | 1410 |
1332 for (i = 0; VEC_iterate (constructor_elt, vals, i, elt); i++) | 1411 FOR_EACH_VEC_ELT (constructor_elt, vals, i, elt) |
1333 if (!TREE_CONSTANT (elt->value)) | 1412 if (!TREE_CONSTANT (elt->value)) |
1334 { | 1413 { |
1335 constant_p = false; | 1414 constant_p = false; |
1336 break; | 1415 break; |
1337 } | 1416 } |
1383 { | 1462 { |
1384 tree v; | 1463 tree v; |
1385 FIXED_VALUE_TYPE *fp; | 1464 FIXED_VALUE_TYPE *fp; |
1386 | 1465 |
1387 v = make_node (FIXED_CST); | 1466 v = make_node (FIXED_CST); |
1388 fp = GGC_NEW (FIXED_VALUE_TYPE); | 1467 fp = ggc_alloc_fixed_value (); |
1389 memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE)); | 1468 memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE)); |
1390 | 1469 |
1391 TREE_TYPE (v) = type; | 1470 TREE_TYPE (v) = type; |
1392 TREE_FIXED_CST_PTR (v) = fp; | 1471 TREE_FIXED_CST_PTR (v) = fp; |
1393 return v; | 1472 return v; |
1404 | 1483 |
1405 /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE. | 1484 /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE. |
1406 Consider doing it via real_convert now. */ | 1485 Consider doing it via real_convert now. */ |
1407 | 1486 |
1408 v = make_node (REAL_CST); | 1487 v = make_node (REAL_CST); |
1409 dp = GGC_NEW (REAL_VALUE_TYPE); | 1488 dp = ggc_alloc_real_value (); |
1410 memcpy (dp, &d, sizeof (REAL_VALUE_TYPE)); | 1489 memcpy (dp, &d, sizeof (REAL_VALUE_TYPE)); |
1411 | 1490 |
1412 TREE_TYPE (v) = type; | 1491 TREE_TYPE (v) = type; |
1413 TREE_REAL_CST_PTR (v) = dp; | 1492 TREE_REAL_CST_PTR (v) = dp; |
1414 TREE_OVERFLOW (v) = overflow; | 1493 TREE_OVERFLOW (v) = overflow; |
1464 #ifdef GATHER_STATISTICS | 1543 #ifdef GATHER_STATISTICS |
1465 tree_node_counts[(int) c_kind]++; | 1544 tree_node_counts[(int) c_kind]++; |
1466 tree_node_sizes[(int) c_kind] += length; | 1545 tree_node_sizes[(int) c_kind] += length; |
1467 #endif | 1546 #endif |
1468 | 1547 |
1469 s = ggc_alloc_tree (length); | 1548 s = ggc_alloc_tree_node (length); |
1470 | 1549 |
1471 memset (s, 0, sizeof (struct tree_common)); | 1550 memset (s, 0, sizeof (struct tree_common)); |
1472 TREE_SET_CODE (s, STRING_CST); | 1551 TREE_SET_CODE (s, STRING_CST); |
1473 TREE_CONSTANT (s) = 1; | 1552 TREE_CONSTANT (s) = 1; |
1474 TREE_STRING_LENGTH (s) = len; | 1553 TREE_STRING_LENGTH (s) = len; |
1516 gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); | 1595 gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); |
1517 return build_fixed (type, FCONST1(TYPE_MODE (type))); | 1596 return build_fixed (type, FCONST1(TYPE_MODE (type))); |
1518 | 1597 |
1519 case VECTOR_TYPE: | 1598 case VECTOR_TYPE: |
1520 { | 1599 { |
1521 tree scalar, cst; | 1600 tree scalar = build_one_cst (TREE_TYPE (type)); |
1522 int i; | 1601 |
1523 | 1602 return build_vector_from_val (type, scalar); |
1524 scalar = build_one_cst (TREE_TYPE (type)); | |
1525 | |
1526 /* Create 'vect_cst_ = {cst,cst,...,cst}' */ | |
1527 cst = NULL_TREE; | |
1528 for (i = TYPE_VECTOR_SUBPARTS (type); --i >= 0; ) | |
1529 cst = tree_cons (NULL_TREE, scalar, cst); | |
1530 | |
1531 return build_vector (type, cst); | |
1532 } | 1603 } |
1533 | 1604 |
1534 case COMPLEX_TYPE: | 1605 case COMPLEX_TYPE: |
1535 return build_complex (type, | 1606 return build_complex (type, |
1536 build_one_cst (TREE_TYPE (type)), | 1607 build_one_cst (TREE_TYPE (type)), |
1537 fold_convert (TREE_TYPE (type), integer_zero_node)); | 1608 build_zero_cst (TREE_TYPE (type))); |
1538 | 1609 |
1539 default: | 1610 default: |
1540 gcc_unreachable (); | 1611 gcc_unreachable (); |
1541 } | 1612 } |
1542 } | 1613 } |
1614 | |
1615 /* Build 0 constant of type TYPE. This is used by constructor folding | |
1616 and thus the constant should be represented in memory by | |
1617 zero(es). */ | |
1618 | |
1619 tree | |
1620 build_zero_cst (tree type) | |
1621 { | |
1622 switch (TREE_CODE (type)) | |
1623 { | |
1624 case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: | |
1625 case POINTER_TYPE: case REFERENCE_TYPE: | |
1626 case OFFSET_TYPE: | |
1627 return build_int_cst (type, 0); | |
1628 | |
1629 case REAL_TYPE: | |
1630 return build_real (type, dconst0); | |
1631 | |
1632 case FIXED_POINT_TYPE: | |
1633 return build_fixed (type, FCONST0 (TYPE_MODE (type))); | |
1634 | |
1635 case VECTOR_TYPE: | |
1636 { | |
1637 tree scalar = build_zero_cst (TREE_TYPE (type)); | |
1638 | |
1639 return build_vector_from_val (type, scalar); | |
1640 } | |
1641 | |
1642 case COMPLEX_TYPE: | |
1643 { | |
1644 tree zero = build_zero_cst (TREE_TYPE (type)); | |
1645 | |
1646 return build_complex (type, zero, zero); | |
1647 } | |
1648 | |
1649 default: | |
1650 if (!AGGREGATE_TYPE_P (type)) | |
1651 return fold_convert (type, integer_zero_node); | |
1652 return build_constructor (type, NULL); | |
1653 } | |
1654 } | |
1655 | |
1543 | 1656 |
1544 /* Build a BINFO with LEN language slots. */ | 1657 /* Build a BINFO with LEN language slots. */ |
1545 | 1658 |
1546 tree | 1659 tree |
1547 make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL) | 1660 make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL) |
1553 #ifdef GATHER_STATISTICS | 1666 #ifdef GATHER_STATISTICS |
1554 tree_node_counts[(int) binfo_kind]++; | 1667 tree_node_counts[(int) binfo_kind]++; |
1555 tree_node_sizes[(int) binfo_kind] += length; | 1668 tree_node_sizes[(int) binfo_kind] += length; |
1556 #endif | 1669 #endif |
1557 | 1670 |
1558 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 1671 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
1559 | 1672 |
1560 memset (t, 0, offsetof (struct tree_binfo, base_binfos)); | 1673 memset (t, 0, offsetof (struct tree_binfo, base_binfos)); |
1561 | 1674 |
1562 TREE_SET_CODE (t, TREE_BINFO); | 1675 TREE_SET_CODE (t, TREE_BINFO); |
1563 | 1676 |
1578 #ifdef GATHER_STATISTICS | 1691 #ifdef GATHER_STATISTICS |
1579 tree_node_counts[(int) vec_kind]++; | 1692 tree_node_counts[(int) vec_kind]++; |
1580 tree_node_sizes[(int) vec_kind] += length; | 1693 tree_node_sizes[(int) vec_kind] += length; |
1581 #endif | 1694 #endif |
1582 | 1695 |
1583 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 1696 t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
1584 | |
1585 memset (t, 0, length); | |
1586 | 1697 |
1587 TREE_SET_CODE (t, TREE_VEC); | 1698 TREE_SET_CODE (t, TREE_VEC); |
1588 TREE_VEC_LENGTH (t) = len; | 1699 TREE_VEC_LENGTH (t) = len; |
1589 | 1700 |
1590 return t; | 1701 return t; |
1921 list = TREE_CHAIN (list); | 2032 list = TREE_CHAIN (list); |
1922 } | 2033 } |
1923 return NULL_TREE; | 2034 return NULL_TREE; |
1924 } | 2035 } |
1925 | 2036 |
2037 /* Return true if ELEM is in V. */ | |
2038 | |
2039 bool | |
2040 vec_member (const_tree elem, VEC(tree,gc) *v) | |
2041 { | |
2042 unsigned ix; | |
2043 tree t; | |
2044 FOR_EACH_VEC_ELT (tree, v, ix, t) | |
2045 if (elem == t) | |
2046 return true; | |
2047 return false; | |
2048 } | |
2049 | |
1926 /* Returns element number IDX (zero-origin) of chain CHAIN, or | 2050 /* Returns element number IDX (zero-origin) of chain CHAIN, or |
1927 NULL_TREE. */ | 2051 NULL_TREE. */ |
1928 | 2052 |
1929 tree | 2053 tree |
1930 chain_index (int idx, tree chain) | 2054 chain_index (int idx, tree chain) |
1941 { | 2065 { |
1942 while (chain) | 2066 while (chain) |
1943 { | 2067 { |
1944 if (elem == chain) | 2068 if (elem == chain) |
1945 return 1; | 2069 return 1; |
1946 chain = TREE_CHAIN (chain); | 2070 chain = DECL_CHAIN (chain); |
1947 } | 2071 } |
1948 | 2072 |
1949 return 0; | 2073 return 0; |
1950 } | 2074 } |
1951 | 2075 |
1982 fields_length (const_tree type) | 2106 fields_length (const_tree type) |
1983 { | 2107 { |
1984 tree t = TYPE_FIELDS (type); | 2108 tree t = TYPE_FIELDS (type); |
1985 int count = 0; | 2109 int count = 0; |
1986 | 2110 |
1987 for (; t; t = TREE_CHAIN (t)) | 2111 for (; t; t = DECL_CHAIN (t)) |
1988 if (TREE_CODE (t) == FIELD_DECL) | 2112 if (TREE_CODE (t) == FIELD_DECL) |
1989 ++count; | 2113 ++count; |
1990 | 2114 |
1991 return count; | 2115 return count; |
1992 } | 2116 } |
2051 nreverse (tree t) | 2175 nreverse (tree t) |
2052 { | 2176 { |
2053 tree prev = 0, decl, next; | 2177 tree prev = 0, decl, next; |
2054 for (decl = t; decl; decl = next) | 2178 for (decl = t; decl; decl = next) |
2055 { | 2179 { |
2180 /* We shouldn't be using this function to reverse BLOCK chains; we | |
2181 have blocks_nreverse for that. */ | |
2182 gcc_checking_assert (TREE_CODE (decl) != BLOCK); | |
2056 next = TREE_CHAIN (decl); | 2183 next = TREE_CHAIN (decl); |
2057 TREE_CHAIN (decl) = prev; | 2184 TREE_CHAIN (decl) = prev; |
2058 prev = decl; | 2185 prev = decl; |
2059 } | 2186 } |
2060 return prev; | 2187 return prev; |
2079 { | 2206 { |
2080 tree ret = NULL_TREE; | 2207 tree ret = NULL_TREE; |
2081 tree *pp = &ret; | 2208 tree *pp = &ret; |
2082 unsigned int i; | 2209 unsigned int i; |
2083 tree t; | 2210 tree t; |
2084 for (i = 0; VEC_iterate (tree, vec, i, t); ++i) | 2211 FOR_EACH_VEC_ELT (tree, vec, i, t) |
2085 { | 2212 { |
2086 *pp = build_tree_list_stat (NULL, t PASS_MEM_STAT); | 2213 *pp = build_tree_list_stat (NULL, t PASS_MEM_STAT); |
2087 pp = &TREE_CHAIN (*pp); | 2214 pp = &TREE_CHAIN (*pp); |
2088 } | 2215 } |
2089 return ret; | 2216 return ret; |
2091 | 2218 |
2092 /* Return a newly created TREE_LIST node whose | 2219 /* Return a newly created TREE_LIST node whose |
2093 purpose and value fields are PURPOSE and VALUE | 2220 purpose and value fields are PURPOSE and VALUE |
2094 and whose TREE_CHAIN is CHAIN. */ | 2221 and whose TREE_CHAIN is CHAIN. */ |
2095 | 2222 |
2096 tree | 2223 tree |
2097 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) | 2224 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) |
2098 { | 2225 { |
2099 tree node; | 2226 tree node; |
2100 | 2227 |
2101 node = (tree) ggc_alloc_zone_pass_stat (sizeof (struct tree_list), &tree_zone); | 2228 node = ggc_alloc_zone_tree_node_stat (&tree_zone, sizeof (struct tree_list) |
2102 | 2229 PASS_MEM_STAT); |
2103 memset (node, 0, sizeof (struct tree_common)); | 2230 memset (node, 0, sizeof (struct tree_common)); |
2104 | 2231 |
2105 #ifdef GATHER_STATISTICS | 2232 #ifdef GATHER_STATISTICS |
2106 tree_node_counts[(int) x_kind]++; | 2233 tree_node_counts[(int) x_kind]++; |
2107 tree_node_sizes[(int) x_kind] += sizeof (struct tree_list); | 2234 tree_node_sizes[(int) x_kind] += sizeof (struct tree_list); |
2376 return staticp (TREE_OPERAND (arg, 0)); | 2503 return staticp (TREE_OPERAND (arg, 0)); |
2377 | 2504 |
2378 case BIT_FIELD_REF: | 2505 case BIT_FIELD_REF: |
2379 return NULL; | 2506 return NULL; |
2380 | 2507 |
2381 case MISALIGNED_INDIRECT_REF: | |
2382 case ALIGN_INDIRECT_REF: | |
2383 case INDIRECT_REF: | 2508 case INDIRECT_REF: |
2384 return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL; | 2509 return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL; |
2385 | 2510 |
2386 case ARRAY_REF: | 2511 case ARRAY_REF: |
2387 case ARRAY_RANGE_REF: | 2512 case ARRAY_RANGE_REF: |
2417 case LABEL_DECL: | 2542 case LABEL_DECL: |
2418 case FUNCTION_DECL: | 2543 case FUNCTION_DECL: |
2419 return true; | 2544 return true; |
2420 | 2545 |
2421 case VAR_DECL: | 2546 case VAR_DECL: |
2422 if (((TREE_STATIC (op) || DECL_EXTERNAL (op)) | 2547 if ((TREE_STATIC (op) || DECL_EXTERNAL (op)) |
2423 && !DECL_DLLIMPORT_P (op)) | |
2424 || DECL_THREAD_LOCAL_P (op) | 2548 || DECL_THREAD_LOCAL_P (op) |
2425 || DECL_CONTEXT (op) == current_function_decl | 2549 || DECL_CONTEXT (op) == current_function_decl |
2426 || decl_function_context (op) == current_function_decl) | 2550 || decl_function_context (op) == current_function_decl) |
2427 return true; | 2551 return true; |
2428 break; | 2552 break; |
2675 | 2799 |
2676 TREE_SIDE_EFFECTS (t) = side_effects; | 2800 TREE_SIDE_EFFECTS (t) = side_effects; |
2677 TREE_READONLY (t) = read_only; | 2801 TREE_READONLY (t) = read_only; |
2678 } | 2802 } |
2679 | 2803 |
2680 /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size | 2804 /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a |
2681 or offset that depends on a field within a record. */ | 2805 size or offset that depends on a field within a record. */ |
2682 | 2806 |
2683 bool | 2807 bool |
2684 contains_placeholder_p (const_tree exp) | 2808 contains_placeholder_p (const_tree exp) |
2685 { | 2809 { |
2686 enum tree_code code; | 2810 enum tree_code code; |
2762 return 0; | 2886 return 0; |
2763 } | 2887 } |
2764 return 0; | 2888 return 0; |
2765 } | 2889 } |
2766 | 2890 |
2767 /* Return true if any part of the computation of TYPE involves a | 2891 /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR |
2768 PLACEHOLDER_EXPR. This includes size, bounds, qualifiers | 2892 directly. This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and |
2769 (for QUAL_UNION_TYPE) and field positions. */ | 2893 field positions. */ |
2770 | 2894 |
2771 static bool | 2895 static bool |
2772 type_contains_placeholder_1 (const_tree type) | 2896 type_contains_placeholder_1 (const_tree type) |
2773 { | 2897 { |
2774 /* If the size contains a placeholder or the parent type (component type in | 2898 /* If the size contains a placeholder or the parent type (component type in |
2775 the case of arrays) type involves a placeholder, this type does. */ | 2899 the case of arrays) type involves a placeholder, this type does. */ |
2776 if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)) | 2900 if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)) |
2777 || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type)) | 2901 || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type)) |
2778 || (TREE_TYPE (type) != 0 | 2902 || (!POINTER_TYPE_P (type) |
2903 && TREE_TYPE (type) | |
2779 && type_contains_placeholder_p (TREE_TYPE (type)))) | 2904 && type_contains_placeholder_p (TREE_TYPE (type)))) |
2780 return true; | 2905 return true; |
2781 | 2906 |
2782 /* Now do type-specific checks. Note that the last part of the check above | 2907 /* Now do type-specific checks. Note that the last part of the check above |
2783 greatly limits what we have to do below. */ | 2908 greatly limits what we have to do below. */ |
2801 /* Here we just check the bounds. */ | 2926 /* Here we just check the bounds. */ |
2802 return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type)) | 2927 return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type)) |
2803 || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type))); | 2928 || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type))); |
2804 | 2929 |
2805 case ARRAY_TYPE: | 2930 case ARRAY_TYPE: |
2806 /* We're already checked the component type (TREE_TYPE), so just check | 2931 /* We have already checked the component type above, so just check the |
2807 the index type. */ | 2932 domain type. */ |
2808 return type_contains_placeholder_p (TYPE_DOMAIN (type)); | 2933 return type_contains_placeholder_p (TYPE_DOMAIN (type)); |
2809 | 2934 |
2810 case RECORD_TYPE: | 2935 case RECORD_TYPE: |
2811 case UNION_TYPE: | 2936 case UNION_TYPE: |
2812 case QUAL_UNION_TYPE: | 2937 case QUAL_UNION_TYPE: |
2813 { | 2938 { |
2814 tree field; | 2939 tree field; |
2815 | 2940 |
2816 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) | 2941 for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) |
2817 if (TREE_CODE (field) == FIELD_DECL | 2942 if (TREE_CODE (field) == FIELD_DECL |
2818 && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field)) | 2943 && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field)) |
2819 || (TREE_CODE (type) == QUAL_UNION_TYPE | 2944 || (TREE_CODE (type) == QUAL_UNION_TYPE |
2820 && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field))) | 2945 && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field))) |
2821 || type_contains_placeholder_p (TREE_TYPE (field)))) | 2946 || type_contains_placeholder_p (TREE_TYPE (field)))) |
2827 default: | 2952 default: |
2828 gcc_unreachable (); | 2953 gcc_unreachable (); |
2829 } | 2954 } |
2830 } | 2955 } |
2831 | 2956 |
2957 /* Wrapper around above function used to cache its result. */ | |
2958 | |
2832 bool | 2959 bool |
2833 type_contains_placeholder_p (tree type) | 2960 type_contains_placeholder_p (tree type) |
2834 { | 2961 { |
2835 bool result; | 2962 bool result; |
2836 | 2963 |
2858 push_without_duplicates (tree exp, VEC (tree, heap) **queue) | 2985 push_without_duplicates (tree exp, VEC (tree, heap) **queue) |
2859 { | 2986 { |
2860 unsigned int i; | 2987 unsigned int i; |
2861 tree iter; | 2988 tree iter; |
2862 | 2989 |
2863 for (i = 0; VEC_iterate (tree, *queue, i, iter); i++) | 2990 FOR_EACH_VEC_ELT (tree, *queue, i, iter) |
2864 if (simple_cst_equal (iter, exp) == 1) | 2991 if (simple_cst_equal (iter, exp) == 1) |
2865 break; | 2992 break; |
2866 | 2993 |
2867 if (!iter) | 2994 if (!iter) |
2868 VEC_safe_push (tree, heap, *queue, exp); | 2995 VEC_safe_push (tree, heap, *queue, exp); |
3115 default: | 3242 default: |
3116 gcc_unreachable (); | 3243 gcc_unreachable (); |
3117 } | 3244 } |
3118 | 3245 |
3119 TREE_READONLY (new_tree) |= TREE_READONLY (exp); | 3246 TREE_READONLY (new_tree) |= TREE_READONLY (exp); |
3247 | |
3248 if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) | |
3249 TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); | |
3250 | |
3120 return new_tree; | 3251 return new_tree; |
3121 } | 3252 } |
3122 | 3253 |
3123 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement | 3254 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement |
3124 for it within OBJ, a tree that is an object or a chain of references. */ | 3255 for it within OBJ, a tree that is an object or a chain of references. */ |
3282 default: | 3413 default: |
3283 gcc_unreachable (); | 3414 gcc_unreachable (); |
3284 } | 3415 } |
3285 | 3416 |
3286 TREE_READONLY (new_tree) |= TREE_READONLY (exp); | 3417 TREE_READONLY (new_tree) |= TREE_READONLY (exp); |
3418 | |
3419 if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) | |
3420 TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); | |
3421 | |
3287 return new_tree; | 3422 return new_tree; |
3288 } | 3423 } |
3289 | 3424 |
3290 /* Stabilize a reference so that we can use it any number of times | 3425 /* Stabilize a reference so that we can use it any number of times |
3291 without causing its operands to be evaluated more than once. | 3426 without causing its operands to be evaluated more than once. |
3509 /* Now see what's inside. If it's an INDIRECT_REF, copy our properties from | 3644 /* Now see what's inside. If it's an INDIRECT_REF, copy our properties from |
3510 the address, since &(*a)->b is a form of addition. If it's a constant, the | 3645 the address, since &(*a)->b is a form of addition. If it's a constant, the |
3511 address is constant too. If it's a decl, its address is constant if the | 3646 address is constant too. If it's a decl, its address is constant if the |
3512 decl is static. Everything else is not constant and, furthermore, | 3647 decl is static. Everything else is not constant and, furthermore, |
3513 taking the address of a volatile variable is not volatile. */ | 3648 taking the address of a volatile variable is not volatile. */ |
3514 if (TREE_CODE (node) == INDIRECT_REF) | 3649 if (TREE_CODE (node) == INDIRECT_REF |
3650 || TREE_CODE (node) == MEM_REF) | |
3515 UPDATE_FLAGS (TREE_OPERAND (node, 0)); | 3651 UPDATE_FLAGS (TREE_OPERAND (node, 0)); |
3516 else if (CONSTANT_CLASS_P (node)) | 3652 else if (CONSTANT_CLASS_P (node)) |
3517 ; | 3653 ; |
3518 else if (DECL_P (node)) | 3654 else if (DECL_P (node)) |
3519 tc &= (staticp (node) != NULL_TREE); | 3655 tc &= (staticp (node) != NULL_TREE); |
3576 tree_node_sizes[(int) kind] += length; | 3712 tree_node_sizes[(int) kind] += length; |
3577 #endif | 3713 #endif |
3578 | 3714 |
3579 gcc_assert (TREE_CODE_LENGTH (code) == 1); | 3715 gcc_assert (TREE_CODE_LENGTH (code) == 1); |
3580 | 3716 |
3581 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 3717 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
3582 | 3718 |
3583 memset (t, 0, sizeof (struct tree_common)); | 3719 memset (t, 0, sizeof (struct tree_common)); |
3584 | 3720 |
3585 TREE_SET_CODE (t, code); | 3721 TREE_SET_CODE (t, code); |
3586 | 3722 |
3603 operands are. */ | 3739 operands are. */ |
3604 TREE_SIDE_EFFECTS (t) = 1; | 3740 TREE_SIDE_EFFECTS (t) = 1; |
3605 TREE_READONLY (t) = 0; | 3741 TREE_READONLY (t) = 0; |
3606 break; | 3742 break; |
3607 | 3743 |
3608 case MISALIGNED_INDIRECT_REF: | |
3609 case ALIGN_INDIRECT_REF: | |
3610 case INDIRECT_REF: | 3744 case INDIRECT_REF: |
3611 /* Whether a dereference is readonly has nothing to do with whether | 3745 /* Whether a dereference is readonly has nothing to do with whether |
3612 its operand is readonly. */ | 3746 its operand is readonly. */ |
3613 TREE_READONLY (t) = 0; | 3747 TREE_READONLY (t) = 0; |
3614 break; | 3748 break; |
3823 && arg5 && TREE_THIS_VOLATILE (arg5)); | 3957 && arg5 && TREE_THIS_VOLATILE (arg5)); |
3824 | 3958 |
3825 return t; | 3959 return t; |
3826 } | 3960 } |
3827 | 3961 |
3962 /* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF | |
3963 on the pointer PTR. */ | |
3964 | |
3965 tree | |
3966 build_simple_mem_ref_loc (location_t loc, tree ptr) | |
3967 { | |
3968 HOST_WIDE_INT offset = 0; | |
3969 tree ptype = TREE_TYPE (ptr); | |
3970 tree tem; | |
3971 /* For convenience allow addresses that collapse to a simple base | |
3972 and offset. */ | |
3973 if (TREE_CODE (ptr) == ADDR_EXPR | |
3974 && (handled_component_p (TREE_OPERAND (ptr, 0)) | |
3975 || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF)) | |
3976 { | |
3977 ptr = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &offset); | |
3978 gcc_assert (ptr); | |
3979 ptr = build_fold_addr_expr (ptr); | |
3980 gcc_assert (is_gimple_reg (ptr) || is_gimple_min_invariant (ptr)); | |
3981 } | |
3982 tem = build2 (MEM_REF, TREE_TYPE (ptype), | |
3983 ptr, build_int_cst (ptype, offset)); | |
3984 SET_EXPR_LOCATION (tem, loc); | |
3985 return tem; | |
3986 } | |
3987 | |
3988 /* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T. */ | |
3989 | |
3990 double_int | |
3991 mem_ref_offset (const_tree t) | |
3992 { | |
3993 tree toff = TREE_OPERAND (t, 1); | |
3994 return double_int_sext (tree_to_double_int (toff), | |
3995 TYPE_PRECISION (TREE_TYPE (toff))); | |
3996 } | |
3997 | |
3998 /* Return the pointer-type relevant for TBAA purposes from the | |
3999 gimple memory reference tree T. This is the type to be used for | |
4000 the offset operand of MEM_REF or TARGET_MEM_REF replacements of T. */ | |
4001 | |
4002 tree | |
4003 reference_alias_ptr_type (const_tree t) | |
4004 { | |
4005 const_tree base = t; | |
4006 while (handled_component_p (base)) | |
4007 base = TREE_OPERAND (base, 0); | |
4008 if (TREE_CODE (base) == MEM_REF) | |
4009 return TREE_TYPE (TREE_OPERAND (base, 1)); | |
4010 else if (TREE_CODE (base) == TARGET_MEM_REF) | |
4011 return TREE_TYPE (TMR_OFFSET (base)); | |
4012 else | |
4013 return build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (base))); | |
4014 } | |
4015 | |
3828 /* Similar except don't specify the TREE_TYPE | 4016 /* Similar except don't specify the TREE_TYPE |
3829 and leave the TREE_SIDE_EFFECTS as 0. | 4017 and leave the TREE_SIDE_EFFECTS as 0. |
3830 It is permissible for arguments to be null, | 4018 It is permissible for arguments to be null, |
3831 or even garbage if their values do not matter. */ | 4019 or even garbage if their values do not matter. */ |
3832 | 4020 |
3850 | 4038 |
3851 va_end (p); | 4039 va_end (p); |
3852 return t; | 4040 return t; |
3853 } | 4041 } |
3854 | 4042 |
3855 /* Similar to build_nt, but for creating a CALL_EXPR object with | |
3856 ARGLIST passed as a list. */ | |
3857 | |
3858 tree | |
3859 build_nt_call_list (tree fn, tree arglist) | |
3860 { | |
3861 tree t; | |
3862 int i; | |
3863 | |
3864 t = build_vl_exp (CALL_EXPR, list_length (arglist) + 3); | |
3865 CALL_EXPR_FN (t) = fn; | |
3866 CALL_EXPR_STATIC_CHAIN (t) = NULL_TREE; | |
3867 for (i = 0; arglist; arglist = TREE_CHAIN (arglist), i++) | |
3868 CALL_EXPR_ARG (t, i) = TREE_VALUE (arglist); | |
3869 return t; | |
3870 } | |
3871 | |
3872 /* Similar to build_nt, but for creating a CALL_EXPR object with a | 4043 /* Similar to build_nt, but for creating a CALL_EXPR object with a |
3873 tree VEC. */ | 4044 tree VEC. */ |
3874 | 4045 |
3875 tree | 4046 tree |
3876 build_nt_call_vec (tree fn, VEC(tree,gc) *args) | 4047 build_nt_call_vec (tree fn, VEC(tree,gc) *args) |
3879 unsigned int ix; | 4050 unsigned int ix; |
3880 | 4051 |
3881 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); | 4052 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); |
3882 CALL_EXPR_FN (ret) = fn; | 4053 CALL_EXPR_FN (ret) = fn; |
3883 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; | 4054 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; |
3884 for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix) | 4055 FOR_EACH_VEC_ELT (tree, args, ix, t) |
3885 CALL_EXPR_ARG (ret, ix) = t; | 4056 CALL_EXPR_ARG (ret, ix) = t; |
3886 return ret; | 4057 return ret; |
3887 } | 4058 } |
3888 | 4059 |
3889 /* Create a DECL_... node of code CODE, name NAME and data type TYPE. | 4060 /* Create a DECL_... node of code CODE, name NAME and data type TYPE. |
3929 TREE_PUBLIC (decl) = 1; | 4100 TREE_PUBLIC (decl) = 1; |
3930 DECL_ARTIFICIAL (decl) = 1; | 4101 DECL_ARTIFICIAL (decl) = 1; |
3931 TREE_NOTHROW (decl) = 1; | 4102 TREE_NOTHROW (decl) = 1; |
3932 | 4103 |
3933 return decl; | 4104 return decl; |
4105 } | |
4106 | |
4107 VEC(tree,gc) *all_translation_units; | |
4108 | |
4109 /* Builds a new translation-unit decl with name NAME, queues it in the | |
4110 global list of translation-unit decls and returns it. */ | |
4111 | |
4112 tree | |
4113 build_translation_unit_decl (tree name) | |
4114 { | |
4115 tree tu = build_decl (UNKNOWN_LOCATION, TRANSLATION_UNIT_DECL, | |
4116 name, NULL_TREE); | |
4117 TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name; | |
4118 VEC_safe_push (tree, gc, all_translation_units, tu); | |
4119 return tu; | |
3934 } | 4120 } |
3935 | 4121 |
3936 | 4122 |
3937 /* BLOCK nodes are used to represent the structure of binding contours | 4123 /* BLOCK nodes are used to represent the structure of binding contours |
3938 and declarations, once those contours have been exited and their contents | 4124 and declarations, once those contours have been exited and their contents |
3946 BLOCK_VARS (block) = vars; | 4132 BLOCK_VARS (block) = vars; |
3947 BLOCK_SUBBLOCKS (block) = subblocks; | 4133 BLOCK_SUBBLOCKS (block) = subblocks; |
3948 BLOCK_SUPERCONTEXT (block) = supercontext; | 4134 BLOCK_SUPERCONTEXT (block) = supercontext; |
3949 BLOCK_CHAIN (block) = chain; | 4135 BLOCK_CHAIN (block) = chain; |
3950 return block; | 4136 return block; |
3951 } | |
3952 | |
3953 expanded_location | |
3954 expand_location (source_location loc) | |
3955 { | |
3956 expanded_location xloc; | |
3957 if (loc <= BUILTINS_LOCATION) | |
3958 { | |
3959 xloc.file = loc == UNKNOWN_LOCATION ? NULL : _("<built-in>"); | |
3960 xloc.line = 0; | |
3961 xloc.column = 0; | |
3962 xloc.sysp = 0; | |
3963 } | |
3964 else | |
3965 { | |
3966 const struct line_map *map = linemap_lookup (line_table, loc); | |
3967 xloc.file = map->to_file; | |
3968 xloc.line = SOURCE_LINE (map, loc); | |
3969 xloc.column = SOURCE_COLUMN (map, loc); | |
3970 xloc.sysp = map->sysp != 0; | |
3971 }; | |
3972 return xloc; | |
3973 } | 4137 } |
3974 | 4138 |
3975 | 4139 |
3976 /* Like SET_EXPR_LOCATION, but make sure the tree can have a location. | 4140 /* Like SET_EXPR_LOCATION, but make sure the tree can have a location. |
3977 | 4141 |
4180 BINFO_VTABLE (binfo) = NULL_TREE; | 4344 BINFO_VTABLE (binfo) = NULL_TREE; |
4181 BINFO_BASE_ACCESSES (binfo) = NULL; | 4345 BINFO_BASE_ACCESSES (binfo) = NULL; |
4182 BINFO_INHERITANCE_CHAIN (binfo) = NULL_TREE; | 4346 BINFO_INHERITANCE_CHAIN (binfo) = NULL_TREE; |
4183 BINFO_SUBVTT_INDEX (binfo) = NULL_TREE; | 4347 BINFO_SUBVTT_INDEX (binfo) = NULL_TREE; |
4184 | 4348 |
4185 for (i = 0; VEC_iterate (tree, BINFO_BASE_BINFOS (binfo), i, t); i++) | 4349 FOR_EACH_VEC_ELT (tree, BINFO_BASE_BINFOS (binfo), i, t) |
4186 free_lang_data_in_binfo (t); | 4350 free_lang_data_in_binfo (t); |
4187 } | 4351 } |
4188 | 4352 |
4189 | 4353 |
4190 /* Reset all language specific information still present in TYPE. */ | 4354 /* Reset all language specific information still present in TYPE. */ |
4343 | 4507 |
4344 return true; | 4508 return true; |
4345 } | 4509 } |
4346 | 4510 |
4347 | 4511 |
4348 /* Remove all the non-variable decls from BLOCK. LOCALS is the set of | |
4349 variables in DECL_STRUCT_FUNCTION (FN)->local_decls. Every decl | |
4350 in BLOCK that is not in LOCALS is removed. */ | |
4351 | |
4352 static void | |
4353 free_lang_data_in_block (tree fn, tree block, struct pointer_set_t *locals) | |
4354 { | |
4355 tree *tp, t; | |
4356 | |
4357 tp = &BLOCK_VARS (block); | |
4358 while (*tp) | |
4359 { | |
4360 if (!pointer_set_contains (locals, *tp)) | |
4361 *tp = TREE_CHAIN (*tp); | |
4362 else | |
4363 tp = &TREE_CHAIN (*tp); | |
4364 } | |
4365 | |
4366 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t)) | |
4367 free_lang_data_in_block (fn, t, locals); | |
4368 } | |
4369 | |
4370 | |
4371 /* Reset all language specific information still present in symbol | 4512 /* Reset all language specific information still present in symbol |
4372 DECL. */ | 4513 DECL. */ |
4373 | 4514 |
4374 static void | 4515 static void |
4375 free_lang_data_in_decl (tree decl) | 4516 free_lang_data_in_decl (tree decl) |
4389 | 4530 |
4390 /* Identifiers need not have a type. */ | 4531 /* Identifiers need not have a type. */ |
4391 if (DECL_NAME (decl)) | 4532 if (DECL_NAME (decl)) |
4392 TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; | 4533 TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; |
4393 | 4534 |
4394 /* Ignore any intervening types, because we are going to clear their | |
4395 TYPE_CONTEXT fields. */ | |
4396 if (TREE_CODE (decl) != FIELD_DECL | |
4397 && TREE_CODE (decl) != FUNCTION_DECL) | |
4398 DECL_CONTEXT (decl) = decl_function_context (decl); | |
4399 | |
4400 if (DECL_CONTEXT (decl) | |
4401 && TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL) | |
4402 DECL_CONTEXT (decl) = NULL_TREE; | |
4403 | |
4404 if (TREE_CODE (decl) == VAR_DECL) | |
4405 { | |
4406 tree context = DECL_CONTEXT (decl); | |
4407 | |
4408 if (context) | |
4409 { | |
4410 enum tree_code code = TREE_CODE (context); | |
4411 if (code == FUNCTION_DECL && DECL_ABSTRACT (context)) | |
4412 { | |
4413 /* Do not clear the decl context here, that will promote | |
4414 all vars to global ones. */ | |
4415 DECL_INITIAL (decl) = NULL_TREE; | |
4416 } | |
4417 | |
4418 if (TREE_STATIC (decl)) | |
4419 DECL_CONTEXT (decl) = NULL_TREE; | |
4420 } | |
4421 } | |
4422 | |
4423 free_lang_data_in_one_sizepos (&DECL_SIZE (decl)); | 4535 free_lang_data_in_one_sizepos (&DECL_SIZE (decl)); |
4424 free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl)); | 4536 free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl)); |
4425 if (TREE_CODE (decl) == FIELD_DECL) | 4537 if (TREE_CODE (decl) == FIELD_DECL) |
4426 free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl)); | 4538 free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl)); |
4427 | 4539 |
4433 if (TREE_CODE (decl) == FUNCTION_DECL) | 4545 if (TREE_CODE (decl) == FUNCTION_DECL) |
4434 { | 4546 { |
4435 if (gimple_has_body_p (decl)) | 4547 if (gimple_has_body_p (decl)) |
4436 { | 4548 { |
4437 tree t; | 4549 tree t; |
4438 struct pointer_set_t *locals; | |
4439 | 4550 |
4440 /* If DECL has a gimple body, then the context for its | 4551 /* If DECL has a gimple body, then the context for its |
4441 arguments must be DECL. Otherwise, it doesn't really | 4552 arguments must be DECL. Otherwise, it doesn't really |
4442 matter, as we will not be emitting any code for DECL. In | 4553 matter, as we will not be emitting any code for DECL. In |
4443 general, there may be other instances of DECL created by | 4554 general, there may be other instances of DECL created by |
4446 created. The only time where DECL_CONTEXT is important | 4557 created. The only time where DECL_CONTEXT is important |
4447 is for the FUNCTION_DECLs that have a gimple body (since | 4558 is for the FUNCTION_DECLs that have a gimple body (since |
4448 the PARM_DECL will be used in the function's body). */ | 4559 the PARM_DECL will be used in the function's body). */ |
4449 for (t = DECL_ARGUMENTS (decl); t; t = TREE_CHAIN (t)) | 4560 for (t = DECL_ARGUMENTS (decl); t; t = TREE_CHAIN (t)) |
4450 DECL_CONTEXT (t) = decl; | 4561 DECL_CONTEXT (t) = decl; |
4451 | |
4452 /* Collect all the symbols declared in DECL. */ | |
4453 locals = pointer_set_create (); | |
4454 t = DECL_STRUCT_FUNCTION (decl)->local_decls; | |
4455 for (; t; t = TREE_CHAIN (t)) | |
4456 { | |
4457 pointer_set_insert (locals, TREE_VALUE (t)); | |
4458 | |
4459 /* All the local symbols should have DECL as their | |
4460 context. */ | |
4461 DECL_CONTEXT (TREE_VALUE (t)) = decl; | |
4462 } | |
4463 | |
4464 /* Get rid of any decl not in local_decls. */ | |
4465 free_lang_data_in_block (decl, DECL_INITIAL (decl), locals); | |
4466 | |
4467 pointer_set_destroy (locals); | |
4468 } | 4562 } |
4469 | 4563 |
4470 /* DECL_SAVED_TREE holds the GENERIC representation for DECL. | 4564 /* DECL_SAVED_TREE holds the GENERIC representation for DECL. |
4471 At this point, it is not needed anymore. */ | 4565 At this point, it is not needed anymore. */ |
4472 DECL_SAVED_TREE (decl) = NULL_TREE; | 4566 DECL_SAVED_TREE (decl) = NULL_TREE; |
4567 | |
4568 /* Clear the abstract origin if it refers to a method. Otherwise | |
4569 dwarf2out.c will ICE as we clear TYPE_METHODS and thus the | |
4570 origin will not be output correctly. */ | |
4571 if (DECL_ABSTRACT_ORIGIN (decl) | |
4572 && DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl)) | |
4573 && RECORD_OR_UNION_TYPE_P | |
4574 (DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl)))) | |
4575 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
4473 } | 4576 } |
4474 else if (TREE_CODE (decl) == VAR_DECL) | 4577 else if (TREE_CODE (decl) == VAR_DECL) |
4475 { | 4578 { |
4476 tree expr = DECL_DEBUG_EXPR (decl); | 4579 if ((DECL_EXTERNAL (decl) |
4477 if (expr | 4580 && (!TREE_STATIC (decl) || !TREE_READONLY (decl))) |
4478 && TREE_CODE (expr) == VAR_DECL | 4581 || (decl_function_context (decl) && !TREE_STATIC (decl))) |
4479 && !TREE_STATIC (expr) && !DECL_EXTERNAL (expr)) | |
4480 SET_DECL_DEBUG_EXPR (decl, NULL_TREE); | |
4481 | |
4482 if (DECL_EXTERNAL (decl) | |
4483 && (!TREE_STATIC (decl) || !TREE_READONLY (decl))) | |
4484 DECL_INITIAL (decl) = NULL_TREE; | 4582 DECL_INITIAL (decl) = NULL_TREE; |
4485 } | 4583 } |
4486 else if (TREE_CODE (decl) == TYPE_DECL) | 4584 else if (TREE_CODE (decl) == TYPE_DECL) |
4487 { | 4585 DECL_INITIAL (decl) = NULL_TREE; |
4488 DECL_INITIAL (decl) = NULL_TREE; | 4586 else if (TREE_CODE (decl) == TRANSLATION_UNIT_DECL |
4489 | 4587 && DECL_INITIAL (decl) |
4490 /* DECL_CONTEXT is overloaded as DECL_FIELD_CONTEXT for | 4588 && TREE_CODE (DECL_INITIAL (decl)) == BLOCK) |
4491 FIELD_DECLs, which should be preserved. Otherwise, | 4589 { |
4492 we shouldn't be concerned with source-level lexical | 4590 /* Strip builtins from the translation-unit BLOCK. We still have |
4493 nesting beyond this point. */ | 4591 targets without builtin_decl support and also builtins are |
4494 DECL_CONTEXT (decl) = NULL_TREE; | 4592 shared nodes and thus we can't use TREE_CHAIN in multiple |
4593 lists. */ | |
4594 tree *nextp = &BLOCK_VARS (DECL_INITIAL (decl)); | |
4595 while (*nextp) | |
4596 { | |
4597 tree var = *nextp; | |
4598 if (TREE_CODE (var) == FUNCTION_DECL | |
4599 && DECL_BUILT_IN (var)) | |
4600 *nextp = TREE_CHAIN (var); | |
4601 else | |
4602 nextp = &TREE_CHAIN (var); | |
4603 } | |
4495 } | 4604 } |
4496 } | 4605 } |
4497 | 4606 |
4498 | 4607 |
4499 /* Data used when collecting DECLs and TYPEs for language data removal. */ | 4608 /* Data used when collecting DECLs and TYPEs for language data removal. */ |
4639 | 4748 |
4640 if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) | 4749 if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) |
4641 && DECL_HAS_VALUE_EXPR_P (t)) | 4750 && DECL_HAS_VALUE_EXPR_P (t)) |
4642 fld_worklist_push (DECL_VALUE_EXPR (t), fld); | 4751 fld_worklist_push (DECL_VALUE_EXPR (t), fld); |
4643 | 4752 |
4644 if (TREE_CODE (t) != FIELD_DECL) | 4753 if (TREE_CODE (t) != FIELD_DECL |
4754 && TREE_CODE (t) != TYPE_DECL) | |
4645 fld_worklist_push (TREE_CHAIN (t), fld); | 4755 fld_worklist_push (TREE_CHAIN (t), fld); |
4646 *ws = 0; | 4756 *ws = 0; |
4647 } | 4757 } |
4648 else if (TYPE_P (t)) | 4758 else if (TYPE_P (t)) |
4649 { | 4759 { |
4657 fld_worklist_push (TYPE_SIZE_UNIT (t), fld); | 4767 fld_worklist_push (TYPE_SIZE_UNIT (t), fld); |
4658 fld_worklist_push (TYPE_ATTRIBUTES (t), fld); | 4768 fld_worklist_push (TYPE_ATTRIBUTES (t), fld); |
4659 fld_worklist_push (TYPE_POINTER_TO (t), fld); | 4769 fld_worklist_push (TYPE_POINTER_TO (t), fld); |
4660 fld_worklist_push (TYPE_REFERENCE_TO (t), fld); | 4770 fld_worklist_push (TYPE_REFERENCE_TO (t), fld); |
4661 fld_worklist_push (TYPE_NAME (t), fld); | 4771 fld_worklist_push (TYPE_NAME (t), fld); |
4662 fld_worklist_push (TYPE_MINVAL (t), fld); | 4772 /* Do not walk TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO. We do not stream |
4773 them and thus do not and want not to reach unused pointer types | |
4774 this way. */ | |
4775 if (!POINTER_TYPE_P (t)) | |
4776 fld_worklist_push (TYPE_MINVAL (t), fld); | |
4663 if (!RECORD_OR_UNION_TYPE_P (t)) | 4777 if (!RECORD_OR_UNION_TYPE_P (t)) |
4664 fld_worklist_push (TYPE_MAXVAL (t), fld); | 4778 fld_worklist_push (TYPE_MAXVAL (t), fld); |
4665 fld_worklist_push (TYPE_MAIN_VARIANT (t), fld); | 4779 fld_worklist_push (TYPE_MAIN_VARIANT (t), fld); |
4666 fld_worklist_push (TYPE_NEXT_VARIANT (t), fld); | 4780 /* Do not walk TYPE_NEXT_VARIANT. We do not stream it and thus |
4781 do not and want not to reach unused variants this way. */ | |
4667 fld_worklist_push (TYPE_CONTEXT (t), fld); | 4782 fld_worklist_push (TYPE_CONTEXT (t), fld); |
4668 fld_worklist_push (TYPE_CANONICAL (t), fld); | 4783 /* Do not walk TYPE_CANONICAL. We do not stream it and thus do not |
4784 and want not to reach unused types this way. */ | |
4669 | 4785 |
4670 if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t)) | 4786 if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t)) |
4671 { | 4787 { |
4672 unsigned i; | 4788 unsigned i; |
4673 tree tem; | 4789 tree tem; |
4710 for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem)) | 4826 for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem)) |
4711 fld_worklist_push (tem, fld); | 4827 fld_worklist_push (tem, fld); |
4712 fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); | 4828 fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); |
4713 } | 4829 } |
4714 | 4830 |
4715 fld_worklist_push (TREE_TYPE (t), fld); | 4831 if (TREE_CODE (t) != IDENTIFIER_NODE) |
4832 fld_worklist_push (TREE_TYPE (t), fld); | |
4716 | 4833 |
4717 return NULL_TREE; | 4834 return NULL_TREE; |
4718 } | 4835 } |
4719 | 4836 |
4720 | 4837 |
4808 static void | 4925 static void |
4809 find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) | 4926 find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) |
4810 { | 4927 { |
4811 basic_block bb; | 4928 basic_block bb; |
4812 struct function *fn; | 4929 struct function *fn; |
4930 unsigned ix; | |
4813 tree t; | 4931 tree t; |
4814 | 4932 |
4815 find_decls_types (n->decl, fld); | 4933 find_decls_types (n->decl, fld); |
4816 | 4934 |
4817 if (!gimple_has_body_p (n->decl)) | 4935 if (!gimple_has_body_p (n->decl)) |
4820 gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); | 4938 gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); |
4821 | 4939 |
4822 fn = DECL_STRUCT_FUNCTION (n->decl); | 4940 fn = DECL_STRUCT_FUNCTION (n->decl); |
4823 | 4941 |
4824 /* Traverse locals. */ | 4942 /* Traverse locals. */ |
4825 for (t = fn->local_decls; t; t = TREE_CHAIN (t)) | 4943 FOR_EACH_LOCAL_DECL (fn, ix, t) |
4826 find_decls_types (TREE_VALUE (t), fld); | 4944 find_decls_types (t, fld); |
4827 | 4945 |
4828 /* Traverse EH regions in FN. */ | 4946 /* Traverse EH regions in FN. */ |
4829 { | 4947 { |
4830 eh_region r; | 4948 eh_region r; |
4831 FOR_ALL_EH_REGION_FN (r, fn) | 4949 FOR_ALL_EH_REGION_FN (r, fn) |
4938 | 5056 |
4939 /* Find decls and types in the body of every function in the callgraph. */ | 5057 /* Find decls and types in the body of every function in the callgraph. */ |
4940 for (n = cgraph_nodes; n; n = n->next) | 5058 for (n = cgraph_nodes; n; n = n->next) |
4941 find_decls_types_in_node (n, &fld); | 5059 find_decls_types_in_node (n, &fld); |
4942 | 5060 |
4943 for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++) | 5061 FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p) |
4944 find_decls_types (p->decl, &fld); | 5062 find_decls_types (p->decl, &fld); |
4945 | 5063 |
4946 /* Find decls and types in every varpool symbol. */ | 5064 /* Find decls and types in every varpool symbol. */ |
4947 for (v = varpool_nodes_queue; v; v = v->next_needed) | 5065 for (v = varpool_nodes; v; v = v->next) |
4948 find_decls_types_in_var (v, &fld); | 5066 find_decls_types_in_var (v, &fld); |
4949 | 5067 |
4950 /* Set the assembler name on every decl found. We need to do this | 5068 /* Set the assembler name on every decl found. We need to do this |
4951 now because free_lang_data_in_decl will invalidate data needed | 5069 now because free_lang_data_in_decl will invalidate data needed |
4952 for mangling. This breaks mangling on interdependent decls. */ | 5070 for mangling. This breaks mangling on interdependent decls. */ |
4953 for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) | 5071 FOR_EACH_VEC_ELT (tree, fld.decls, i, t) |
4954 assign_assembler_name_if_neeeded (t); | 5072 assign_assembler_name_if_neeeded (t); |
4955 | 5073 |
4956 /* Traverse every decl found freeing its language data. */ | 5074 /* Traverse every decl found freeing its language data. */ |
4957 for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) | 5075 FOR_EACH_VEC_ELT (tree, fld.decls, i, t) |
4958 free_lang_data_in_decl (t); | 5076 free_lang_data_in_decl (t); |
4959 | 5077 |
4960 /* Traverse every type found freeing its language data. */ | 5078 /* Traverse every type found freeing its language data. */ |
4961 for (i = 0; VEC_iterate (tree, fld.types, i, t); i++) | 5079 FOR_EACH_VEC_ELT (tree, fld.types, i, t) |
4962 free_lang_data_in_type (t); | 5080 free_lang_data_in_type (t); |
4963 | 5081 |
4964 pointer_set_destroy (fld.pset); | 5082 pointer_set_destroy (fld.pset); |
4965 VEC_free (tree, heap, fld.worklist); | 5083 VEC_free (tree, heap, fld.worklist); |
4966 VEC_free (tree, heap, fld.decls); | 5084 VEC_free (tree, heap, fld.decls); |
5415 | 5533 |
5416 if (*no_add_attrs == false) | 5534 if (*no_add_attrs == false) |
5417 DECL_DLLIMPORT_P (node) = 1; | 5535 DECL_DLLIMPORT_P (node) = 1; |
5418 } | 5536 } |
5419 else if (TREE_CODE (node) == FUNCTION_DECL | 5537 else if (TREE_CODE (node) == FUNCTION_DECL |
5420 && DECL_DECLARED_INLINE_P (node)) | 5538 && DECL_DECLARED_INLINE_P (node) |
5539 && flag_keep_inline_dllexport) | |
5421 /* An exported function, even if inline, must be emitted. */ | 5540 /* An exported function, even if inline, must be emitted. */ |
5422 DECL_EXTERNAL (node) = 0; | 5541 DECL_EXTERNAL (node) = 0; |
5423 | 5542 |
5424 /* Report error if symbol is not accessible at global scope. */ | 5543 /* Report error if symbol is not accessible at global scope. */ |
5425 if (!TREE_PUBLIC (node) | 5544 if (!TREE_PUBLIC (node) |
5471 { | 5590 { |
5472 return (TYPE_QUALS (cand) == type_quals | 5591 return (TYPE_QUALS (cand) == type_quals |
5473 && TYPE_NAME (cand) == TYPE_NAME (base) | 5592 && TYPE_NAME (cand) == TYPE_NAME (base) |
5474 /* Apparently this is needed for Objective-C. */ | 5593 /* Apparently this is needed for Objective-C. */ |
5475 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) | 5594 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) |
5595 /* Check alignment. */ | |
5596 && TYPE_ALIGN (cand) == TYPE_ALIGN (base) | |
5597 && attribute_list_equal (TYPE_ATTRIBUTES (cand), | |
5598 TYPE_ATTRIBUTES (base))); | |
5599 } | |
5600 | |
5601 /* Returns true iff CAND is equivalent to BASE with ALIGN. */ | |
5602 | |
5603 static bool | |
5604 check_aligned_type (const_tree cand, const_tree base, unsigned int align) | |
5605 { | |
5606 return (TYPE_QUALS (cand) == TYPE_QUALS (base) | |
5607 && TYPE_NAME (cand) == TYPE_NAME (base) | |
5608 /* Apparently this is needed for Objective-C. */ | |
5609 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) | |
5610 /* Check alignment. */ | |
5611 && TYPE_ALIGN (cand) == align | |
5476 && attribute_list_equal (TYPE_ATTRIBUTES (cand), | 5612 && attribute_list_equal (TYPE_ATTRIBUTES (cand), |
5477 TYPE_ATTRIBUTES (base))); | 5613 TYPE_ATTRIBUTES (base))); |
5478 } | 5614 } |
5479 | 5615 |
5480 /* Return a version of the TYPE, qualified as indicated by the | 5616 /* Return a version of the TYPE, qualified as indicated by the |
5531 } | 5667 } |
5532 | 5668 |
5533 return t; | 5669 return t; |
5534 } | 5670 } |
5535 | 5671 |
5672 /* Create a variant of type T with alignment ALIGN. */ | |
5673 | |
5674 tree | |
5675 build_aligned_type (tree type, unsigned int align) | |
5676 { | |
5677 tree t; | |
5678 | |
5679 if (TYPE_PACKED (type) | |
5680 || TYPE_ALIGN (type) == align) | |
5681 return type; | |
5682 | |
5683 for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) | |
5684 if (check_aligned_type (t, type, align)) | |
5685 return t; | |
5686 | |
5687 t = build_variant_type_copy (type); | |
5688 TYPE_ALIGN (t) = align; | |
5689 | |
5690 return t; | |
5691 } | |
5692 | |
5536 /* Create a new distinct copy of TYPE. The new type is made its own | 5693 /* Create a new distinct copy of TYPE. The new type is made its own |
5537 MAIN_VARIANT. If TYPE requires structural equality checks, the | 5694 MAIN_VARIANT. If TYPE requires structural equality checks, the |
5538 resulting type requires structural equality checks; otherwise, its | 5695 resulting type requires structural equality checks; otherwise, its |
5539 TYPE_CANONICAL points to itself. */ | 5696 TYPE_CANONICAL points to itself. */ |
5540 | 5697 |
5597 const struct tree_map_base *const a = (const struct tree_map_base *) va, | 5754 const struct tree_map_base *const a = (const struct tree_map_base *) va, |
5598 *const b = (const struct tree_map_base *) vb; | 5755 *const b = (const struct tree_map_base *) vb; |
5599 return (a->from == b->from); | 5756 return (a->from == b->from); |
5600 } | 5757 } |
5601 | 5758 |
5602 /* Hash a from tree in a tree_map. */ | 5759 /* Hash a from tree in a tree_base_map. */ |
5603 | 5760 |
5604 unsigned int | 5761 unsigned int |
5605 tree_map_base_hash (const void *item) | 5762 tree_map_base_hash (const void *item) |
5606 { | 5763 { |
5607 return htab_hash_pointer (((const struct tree_map_base *)item)->from); | 5764 return htab_hash_pointer (((const struct tree_map_base *)item)->from); |
5615 tree_map_base_marked_p (const void *p) | 5772 tree_map_base_marked_p (const void *p) |
5616 { | 5773 { |
5617 return ggc_marked_p (((const struct tree_map_base *) p)->from); | 5774 return ggc_marked_p (((const struct tree_map_base *) p)->from); |
5618 } | 5775 } |
5619 | 5776 |
5777 /* Hash a from tree in a tree_map. */ | |
5778 | |
5620 unsigned int | 5779 unsigned int |
5621 tree_map_hash (const void *item) | 5780 tree_map_hash (const void *item) |
5622 { | 5781 { |
5623 return (((const struct tree_map *) item)->hash); | 5782 return (((const struct tree_map *) item)->hash); |
5783 } | |
5784 | |
5785 /* Hash a from tree in a tree_decl_map. */ | |
5786 | |
5787 unsigned int | |
5788 tree_decl_map_hash (const void *item) | |
5789 { | |
5790 return DECL_UID (((const struct tree_decl_map *) item)->base.from); | |
5624 } | 5791 } |
5625 | 5792 |
5626 /* Return the initialization priority for DECL. */ | 5793 /* Return the initialization priority for DECL. */ |
5627 | 5794 |
5628 priority_type | 5795 priority_type |
5665 in.base.from = decl; | 5832 in.base.from = decl; |
5666 loc = htab_find_slot (init_priority_for_decl, &in, INSERT); | 5833 loc = htab_find_slot (init_priority_for_decl, &in, INSERT); |
5667 h = (struct tree_priority_map *) *loc; | 5834 h = (struct tree_priority_map *) *loc; |
5668 if (!h) | 5835 if (!h) |
5669 { | 5836 { |
5670 h = GGC_CNEW (struct tree_priority_map); | 5837 h = ggc_alloc_cleared_tree_priority_map (); |
5671 *loc = h; | 5838 *loc = h; |
5672 h->base.from = decl; | 5839 h->base.from = decl; |
5673 h->init = DEFAULT_INIT_PRIORITY; | 5840 h->init = DEFAULT_INIT_PRIORITY; |
5674 h->fini = DEFAULT_INIT_PRIORITY; | 5841 h->fini = DEFAULT_INIT_PRIORITY; |
5675 } | 5842 } |
5726 /* Lookup a debug expression for FROM, and return it if we find one. */ | 5893 /* Lookup a debug expression for FROM, and return it if we find one. */ |
5727 | 5894 |
5728 tree | 5895 tree |
5729 decl_debug_expr_lookup (tree from) | 5896 decl_debug_expr_lookup (tree from) |
5730 { | 5897 { |
5731 struct tree_map *h, in; | 5898 struct tree_decl_map *h, in; |
5732 in.base.from = from; | 5899 in.base.from = from; |
5733 | 5900 |
5734 h = (struct tree_map *) htab_find_with_hash (debug_expr_for_decl, &in, | 5901 h = (struct tree_decl_map *) |
5735 htab_hash_pointer (from)); | 5902 htab_find_with_hash (debug_expr_for_decl, &in, DECL_UID (from)); |
5736 if (h) | 5903 if (h) |
5737 return h->to; | 5904 return h->to; |
5738 return NULL_TREE; | 5905 return NULL_TREE; |
5739 } | 5906 } |
5740 | 5907 |
5741 /* Insert a mapping FROM->TO in the debug expression hashtable. */ | 5908 /* Insert a mapping FROM->TO in the debug expression hashtable. */ |
5742 | 5909 |
5743 void | 5910 void |
5744 decl_debug_expr_insert (tree from, tree to) | 5911 decl_debug_expr_insert (tree from, tree to) |
5745 { | 5912 { |
5746 struct tree_map *h; | 5913 struct tree_decl_map *h; |
5747 void **loc; | 5914 void **loc; |
5748 | 5915 |
5749 h = GGC_NEW (struct tree_map); | 5916 h = ggc_alloc_tree_decl_map (); |
5750 h->hash = htab_hash_pointer (from); | |
5751 h->base.from = from; | 5917 h->base.from = from; |
5752 h->to = to; | 5918 h->to = to; |
5753 loc = htab_find_slot_with_hash (debug_expr_for_decl, h, h->hash, INSERT); | 5919 loc = htab_find_slot_with_hash (debug_expr_for_decl, h, DECL_UID (from), |
5754 *(struct tree_map **) loc = h; | 5920 INSERT); |
5921 *(struct tree_decl_map **) loc = h; | |
5755 } | 5922 } |
5756 | 5923 |
5757 /* Lookup a value expression for FROM, and return it if we find one. */ | 5924 /* Lookup a value expression for FROM, and return it if we find one. */ |
5758 | 5925 |
5759 tree | 5926 tree |
5760 decl_value_expr_lookup (tree from) | 5927 decl_value_expr_lookup (tree from) |
5761 { | 5928 { |
5762 struct tree_map *h, in; | 5929 struct tree_decl_map *h, in; |
5763 in.base.from = from; | 5930 in.base.from = from; |
5764 | 5931 |
5765 h = (struct tree_map *) htab_find_with_hash (value_expr_for_decl, &in, | 5932 h = (struct tree_decl_map *) |
5766 htab_hash_pointer (from)); | 5933 htab_find_with_hash (value_expr_for_decl, &in, DECL_UID (from)); |
5767 if (h) | 5934 if (h) |
5768 return h->to; | 5935 return h->to; |
5769 return NULL_TREE; | 5936 return NULL_TREE; |
5770 } | 5937 } |
5771 | 5938 |
5772 /* Insert a mapping FROM->TO in the value expression hashtable. */ | 5939 /* Insert a mapping FROM->TO in the value expression hashtable. */ |
5773 | 5940 |
5774 void | 5941 void |
5775 decl_value_expr_insert (tree from, tree to) | 5942 decl_value_expr_insert (tree from, tree to) |
5776 { | 5943 { |
5777 struct tree_map *h; | 5944 struct tree_decl_map *h; |
5778 void **loc; | 5945 void **loc; |
5779 | 5946 |
5780 h = GGC_NEW (struct tree_map); | 5947 h = ggc_alloc_tree_decl_map (); |
5781 h->hash = htab_hash_pointer (from); | |
5782 h->base.from = from; | 5948 h->base.from = from; |
5783 h->to = to; | 5949 h->to = to; |
5784 loc = htab_find_slot_with_hash (value_expr_for_decl, h, h->hash, INSERT); | 5950 loc = htab_find_slot_with_hash (value_expr_for_decl, h, DECL_UID (from), |
5785 *(struct tree_map **) loc = h; | 5951 INSERT); |
5952 *(struct tree_decl_map **) loc = h; | |
5786 } | 5953 } |
5787 | 5954 |
5788 /* Hashing of types so that we don't make duplicates. | 5955 /* Hashing of types so that we don't make duplicates. |
5789 The entry point is `type_hash_canon'. */ | 5956 The entry point is `type_hash_canon'. */ |
5790 | 5957 |
5819 if (a->hash != b->hash | 5986 if (a->hash != b->hash |
5820 || TREE_CODE (a->type) != TREE_CODE (b->type) | 5987 || TREE_CODE (a->type) != TREE_CODE (b->type) |
5821 || TREE_TYPE (a->type) != TREE_TYPE (b->type) | 5988 || TREE_TYPE (a->type) != TREE_TYPE (b->type) |
5822 || !attribute_list_equal (TYPE_ATTRIBUTES (a->type), | 5989 || !attribute_list_equal (TYPE_ATTRIBUTES (a->type), |
5823 TYPE_ATTRIBUTES (b->type)) | 5990 TYPE_ATTRIBUTES (b->type)) |
5824 || TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) | |
5825 || TYPE_MODE (a->type) != TYPE_MODE (b->type) | |
5826 || (TREE_CODE (a->type) != COMPLEX_TYPE | 5991 || (TREE_CODE (a->type) != COMPLEX_TYPE |
5827 && TYPE_NAME (a->type) != TYPE_NAME (b->type))) | 5992 && TYPE_NAME (a->type) != TYPE_NAME (b->type))) |
5993 return 0; | |
5994 | |
5995 /* Be careful about comparing arrays before and after the element type | |
5996 has been completed; don't compare TYPE_ALIGN unless both types are | |
5997 complete. */ | |
5998 if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type) | |
5999 && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) | |
6000 || TYPE_MODE (a->type) != TYPE_MODE (b->type))) | |
5828 return 0; | 6001 return 0; |
5829 | 6002 |
5830 switch (TREE_CODE (a->type)) | 6003 switch (TREE_CODE (a->type)) |
5831 { | 6004 { |
5832 case VOID_TYPE: | 6005 case VOID_TYPE: |
5865 | 6038 |
5866 case OFFSET_TYPE: | 6039 case OFFSET_TYPE: |
5867 return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type); | 6040 return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type); |
5868 | 6041 |
5869 case METHOD_TYPE: | 6042 case METHOD_TYPE: |
5870 return (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type) | 6043 if (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type) |
5871 && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type) | 6044 && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type) |
5872 || (TYPE_ARG_TYPES (a->type) | 6045 || (TYPE_ARG_TYPES (a->type) |
5873 && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST | 6046 && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST |
5874 && TYPE_ARG_TYPES (b->type) | 6047 && TYPE_ARG_TYPES (b->type) |
5875 && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST | 6048 && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST |
5876 && type_list_equal (TYPE_ARG_TYPES (a->type), | 6049 && type_list_equal (TYPE_ARG_TYPES (a->type), |
5877 TYPE_ARG_TYPES (b->type))))); | 6050 TYPE_ARG_TYPES (b->type))))) |
5878 | 6051 break; |
6052 return 0; | |
5879 case ARRAY_TYPE: | 6053 case ARRAY_TYPE: |
5880 return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type); | 6054 return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type); |
5881 | 6055 |
5882 case RECORD_TYPE: | 6056 case RECORD_TYPE: |
5883 case UNION_TYPE: | 6057 case UNION_TYPE: |
5948 type_hash_add (hashval_t hashcode, tree type) | 6122 type_hash_add (hashval_t hashcode, tree type) |
5949 { | 6123 { |
5950 struct type_hash *h; | 6124 struct type_hash *h; |
5951 void **loc; | 6125 void **loc; |
5952 | 6126 |
5953 h = GGC_NEW (struct type_hash); | 6127 h = ggc_alloc_type_hash (); |
5954 h->hash = hashcode; | 6128 h->hash = hashcode; |
5955 h->type = type; | 6129 h->type = type; |
5956 loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT); | 6130 loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT); |
5957 *loc = (void *)h; | 6131 *loc = (void *)h; |
5958 } | 6132 } |
5972 tree t1; | 6146 tree t1; |
5973 | 6147 |
5974 /* The hash table only contains main variants, so ensure that's what we're | 6148 /* The hash table only contains main variants, so ensure that's what we're |
5975 being passed. */ | 6149 being passed. */ |
5976 gcc_assert (TYPE_MAIN_VARIANT (type) == type); | 6150 gcc_assert (TYPE_MAIN_VARIANT (type) == type); |
5977 | |
5978 if (!lang_hooks.types.hash_types) | |
5979 return type; | |
5980 | 6151 |
5981 /* See if the type is in the hash table already. If so, return it. | 6152 /* See if the type is in the hash table already. If so, return it. |
5982 Otherwise, add the type. */ | 6153 Otherwise, add the type. */ |
5983 t1 = type_hash_lookup (hashcode, type); | 6154 t1 = type_hash_lookup (hashcode, type); |
5984 if (t1 != 0) | 6155 if (t1 != 0) |
5996 } | 6167 } |
5997 } | 6168 } |
5998 | 6169 |
5999 /* See if the data pointed to by the type hash table is marked. We consider | 6170 /* See if the data pointed to by the type hash table is marked. We consider |
6000 it marked if the type is marked or if a debug type number or symbol | 6171 it marked if the type is marked or if a debug type number or symbol |
6001 table entry has been made for the type. This reduces the amount of | 6172 table entry has been made for the type. */ |
6002 debugging output and eliminates that dependency of the debug output on | |
6003 the number of garbage collections. */ | |
6004 | 6173 |
6005 static int | 6174 static int |
6006 type_hash_marked_p (const void *p) | 6175 type_hash_marked_p (const void *p) |
6007 { | 6176 { |
6008 const_tree const type = ((const struct type_hash *) p)->type; | 6177 const_tree const type = ((const struct type_hash *) p)->type; |
6009 | 6178 |
6010 return ggc_marked_p (type) || TYPE_SYMTAB_POINTER (type); | 6179 return ggc_marked_p (type); |
6011 } | 6180 } |
6012 | 6181 |
6013 static void | 6182 static void |
6014 print_type_hash_statistics (void) | 6183 print_type_hash_statistics (void) |
6015 { | 6184 { |
6552 case UNEQ_EXPR: | 6721 case UNEQ_EXPR: |
6553 case LTGT_EXPR: | 6722 case LTGT_EXPR: |
6554 case TRUTH_AND_EXPR: | 6723 case TRUTH_AND_EXPR: |
6555 case TRUTH_XOR_EXPR: | 6724 case TRUTH_XOR_EXPR: |
6556 case TRUTH_OR_EXPR: | 6725 case TRUTH_OR_EXPR: |
6726 return true; | |
6727 | |
6728 default: | |
6729 break; | |
6730 } | |
6731 return false; | |
6732 } | |
6733 | |
6734 /* Return true if CODE represents a ternary tree code for which the | |
6735 first two operands are commutative. Otherwise return false. */ | |
6736 bool | |
6737 commutative_ternary_tree_code (enum tree_code code) | |
6738 { | |
6739 switch (code) | |
6740 { | |
6741 case WIDEN_MULT_PLUS_EXPR: | |
6742 case WIDEN_MULT_MINUS_EXPR: | |
6557 return true; | 6743 return true; |
6558 | 6744 |
6559 default: | 6745 default: |
6560 break; | 6746 break; |
6561 } | 6747 } |
6628 val = iterative_hash_expr (field, val); | 6814 val = iterative_hash_expr (field, val); |
6629 val = iterative_hash_expr (value, val); | 6815 val = iterative_hash_expr (value, val); |
6630 } | 6816 } |
6631 return val; | 6817 return val; |
6632 } | 6818 } |
6819 case MEM_REF: | |
6820 { | |
6821 /* The type of the second operand is relevant, except for | |
6822 its top-level qualifiers. */ | |
6823 tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (t, 1))); | |
6824 | |
6825 val = iterative_hash_object (TYPE_HASH (type), val); | |
6826 | |
6827 /* We could use the standard hash computation from this point | |
6828 on. */ | |
6829 val = iterative_hash_object (code, val); | |
6830 val = iterative_hash_expr (TREE_OPERAND (t, 1), val); | |
6831 val = iterative_hash_expr (TREE_OPERAND (t, 0), val); | |
6832 return val; | |
6833 } | |
6633 case FUNCTION_DECL: | 6834 case FUNCTION_DECL: |
6634 /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. | 6835 /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. |
6635 Otherwise nodes that compare equal according to operand_equal_p might | 6836 Otherwise nodes that compare equal according to operand_equal_p might |
6636 get different hash codes. However, don't do this for machine specific | 6837 get different hash codes. However, don't do this for machine specific |
6637 or front end builtins, since the function code is overloaded in those | 6838 or front end builtins, since the function code is overloaded in those |
6879 default: | 7080 default: |
6880 return TYPE_MAIN_VARIANT (t); | 7081 return TYPE_MAIN_VARIANT (t); |
6881 } | 7082 } |
6882 } | 7083 } |
6883 | 7084 |
6884 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. | |
6885 MAXVAL should be the maximum value in the domain | |
6886 (one less than the length of the array). | |
6887 | |
6888 The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT. | |
6889 We don't enforce this limit, that is up to caller (e.g. language front end). | |
6890 The limit exists because the result is a signed type and we don't handle | |
6891 sizes that use more than one HOST_WIDE_INT. */ | |
6892 | |
6893 tree | |
6894 build_index_type (tree maxval) | |
6895 { | |
6896 tree itype = make_node (INTEGER_TYPE); | |
6897 | |
6898 TREE_TYPE (itype) = sizetype; | |
6899 TYPE_PRECISION (itype) = TYPE_PRECISION (sizetype); | |
6900 TYPE_MIN_VALUE (itype) = size_zero_node; | |
6901 TYPE_MAX_VALUE (itype) = fold_convert (sizetype, maxval); | |
6902 SET_TYPE_MODE (itype, TYPE_MODE (sizetype)); | |
6903 TYPE_SIZE (itype) = TYPE_SIZE (sizetype); | |
6904 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (sizetype); | |
6905 TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype); | |
6906 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (sizetype); | |
6907 | |
6908 if (host_integerp (maxval, 1)) | |
6909 return type_hash_canon (tree_low_cst (maxval, 1), itype); | |
6910 else | |
6911 { | |
6912 /* Since we cannot hash this type, we need to compare it using | |
6913 structural equality checks. */ | |
6914 SET_TYPE_STRUCTURAL_EQUALITY (itype); | |
6915 return itype; | |
6916 } | |
6917 } | |
6918 | |
6919 #define MAX_INT_CACHED_PREC \ | 7085 #define MAX_INT_CACHED_PREC \ |
6920 (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64) | 7086 (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64) |
6921 static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2]; | 7087 static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2]; |
6922 | 7088 |
6923 /* Builds a signed or unsigned integer type of precision PRECISION. | 7089 /* Builds a signed or unsigned integer type of precision PRECISION. |
6948 fixup_signed_type (itype); | 7114 fixup_signed_type (itype); |
6949 | 7115 |
6950 ret = itype; | 7116 ret = itype; |
6951 if (host_integerp (TYPE_MAX_VALUE (itype), 1)) | 7117 if (host_integerp (TYPE_MAX_VALUE (itype), 1)) |
6952 ret = type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype); | 7118 ret = type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype); |
6953 if (precision <= MAX_INT_CACHED_PREC && lang_hooks.types.hash_types) | 7119 if (precision <= MAX_INT_CACHED_PREC) |
6954 nonstandard_integer_type_cache[precision + unsignedp] = ret; | 7120 nonstandard_integer_type_cache[precision + unsignedp] = ret; |
6955 | 7121 |
6956 return ret; | 7122 return ret; |
6957 } | 7123 } |
6958 | 7124 |
6959 /* Create a range of some discrete type TYPE (an INTEGER_TYPE, | 7125 /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE |
6960 ENUMERAL_TYPE or BOOLEAN_TYPE), with low bound LOWVAL and | 7126 or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL. If SHARED |
6961 high bound HIGHVAL. If TYPE is NULL, sizetype is used. */ | 7127 is true, reuse such a type that has already been constructed. */ |
6962 | 7128 |
6963 tree | 7129 static tree |
6964 build_range_type (tree type, tree lowval, tree highval) | 7130 build_range_type_1 (tree type, tree lowval, tree highval, bool shared) |
6965 { | 7131 { |
6966 tree itype = make_node (INTEGER_TYPE); | 7132 tree itype = make_node (INTEGER_TYPE); |
7133 hashval_t hashcode = 0; | |
6967 | 7134 |
6968 TREE_TYPE (itype) = type; | 7135 TREE_TYPE (itype) = type; |
6969 if (type == NULL_TREE) | |
6970 type = sizetype; | |
6971 | 7136 |
6972 TYPE_MIN_VALUE (itype) = fold_convert (type, lowval); | 7137 TYPE_MIN_VALUE (itype) = fold_convert (type, lowval); |
6973 TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL; | 7138 TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL; |
6974 | 7139 |
6975 TYPE_PRECISION (itype) = TYPE_PRECISION (type); | 7140 TYPE_PRECISION (itype) = TYPE_PRECISION (type); |
6977 TYPE_SIZE (itype) = TYPE_SIZE (type); | 7142 TYPE_SIZE (itype) = TYPE_SIZE (type); |
6978 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type); | 7143 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type); |
6979 TYPE_ALIGN (itype) = TYPE_ALIGN (type); | 7144 TYPE_ALIGN (itype) = TYPE_ALIGN (type); |
6980 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type); | 7145 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type); |
6981 | 7146 |
6982 if (host_integerp (lowval, 0) && highval != 0 && host_integerp (highval, 0)) | 7147 if (!shared) |
6983 return type_hash_canon (tree_low_cst (highval, 0) | |
6984 - tree_low_cst (lowval, 0), | |
6985 itype); | |
6986 else | |
6987 return itype; | 7148 return itype; |
7149 | |
7150 if ((TYPE_MIN_VALUE (itype) | |
7151 && TREE_CODE (TYPE_MIN_VALUE (itype)) != INTEGER_CST) | |
7152 || (TYPE_MAX_VALUE (itype) | |
7153 && TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST)) | |
7154 { | |
7155 /* Since we cannot reliably merge this type, we need to compare it using | |
7156 structural equality checks. */ | |
7157 SET_TYPE_STRUCTURAL_EQUALITY (itype); | |
7158 return itype; | |
7159 } | |
7160 | |
7161 hashcode = iterative_hash_expr (TYPE_MIN_VALUE (itype), hashcode); | |
7162 hashcode = iterative_hash_expr (TYPE_MAX_VALUE (itype), hashcode); | |
7163 hashcode = iterative_hash_hashval_t (TYPE_HASH (type), hashcode); | |
7164 itype = type_hash_canon (hashcode, itype); | |
7165 | |
7166 return itype; | |
7167 } | |
7168 | |
7169 /* Wrapper around build_range_type_1 with SHARED set to true. */ | |
7170 | |
7171 tree | |
7172 build_range_type (tree type, tree lowval, tree highval) | |
7173 { | |
7174 return build_range_type_1 (type, lowval, highval, true); | |
7175 } | |
7176 | |
7177 /* Wrapper around build_range_type_1 with SHARED set to false. */ | |
7178 | |
7179 tree | |
7180 build_nonshared_range_type (tree type, tree lowval, tree highval) | |
7181 { | |
7182 return build_range_type_1 (type, lowval, highval, false); | |
7183 } | |
7184 | |
7185 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. | |
7186 MAXVAL should be the maximum value in the domain | |
7187 (one less than the length of the array). | |
7188 | |
7189 The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT. | |
7190 We don't enforce this limit, that is up to caller (e.g. language front end). | |
7191 The limit exists because the result is a signed type and we don't handle | |
7192 sizes that use more than one HOST_WIDE_INT. */ | |
7193 | |
7194 tree | |
7195 build_index_type (tree maxval) | |
7196 { | |
7197 return build_range_type (sizetype, size_zero_node, maxval); | |
6988 } | 7198 } |
6989 | 7199 |
6990 /* Return true if the debug information for TYPE, a subtype, should be emitted | 7200 /* Return true if the debug information for TYPE, a subtype, should be emitted |
6991 as a subrange type. If so, set LOWVAL to the low bound and HIGHVAL to the | 7201 as a subrange type. If so, set LOWVAL to the low bound and HIGHVAL to the |
6992 high bound, respectively. Sometimes doing so unnecessarily obfuscates the | 7202 high bound, respectively. Sometimes doing so unnecessarily obfuscates the |
7036 if (highval) | 7246 if (highval) |
7037 *highval = high; | 7247 *highval = high; |
7038 return true; | 7248 return true; |
7039 } | 7249 } |
7040 | 7250 |
7041 /* Just like build_index_type, but takes lowval and highval instead | |
7042 of just highval (maxval). */ | |
7043 | |
7044 tree | |
7045 build_index_2_type (tree lowval, tree highval) | |
7046 { | |
7047 return build_range_type (sizetype, lowval, highval); | |
7048 } | |
7049 | |
7050 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE | 7251 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE |
7051 and number of elements specified by the range of values of INDEX_TYPE. | 7252 and number of elements specified by the range of values of INDEX_TYPE. |
7052 If such a type has already been constructed, reuse it. */ | 7253 If SHARED is true, reuse such a type that has already been constructed. */ |
7053 | 7254 |
7054 tree | 7255 static tree |
7055 build_array_type (tree elt_type, tree index_type) | 7256 build_array_type_1 (tree elt_type, tree index_type, bool shared) |
7056 { | 7257 { |
7057 tree t; | 7258 tree t; |
7058 hashval_t hashcode = 0; | |
7059 | 7259 |
7060 if (TREE_CODE (elt_type) == FUNCTION_TYPE) | 7260 if (TREE_CODE (elt_type) == FUNCTION_TYPE) |
7061 { | 7261 { |
7062 error ("arrays of functions are not meaningful"); | 7262 error ("arrays of functions are not meaningful"); |
7063 elt_type = integer_type_node; | 7263 elt_type = integer_type_node; |
7073 structural equality. Do not record these types in the canonical | 7273 structural equality. Do not record these types in the canonical |
7074 type hashtable. */ | 7274 type hashtable. */ |
7075 if (TYPE_STRUCTURAL_EQUALITY_P (t)) | 7275 if (TYPE_STRUCTURAL_EQUALITY_P (t)) |
7076 return t; | 7276 return t; |
7077 | 7277 |
7078 hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode); | 7278 if (shared) |
7079 if (index_type) | 7279 { |
7080 hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); | 7280 hashval_t hashcode = iterative_hash_object (TYPE_HASH (elt_type), 0); |
7081 t = type_hash_canon (hashcode, t); | 7281 if (index_type) |
7282 hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); | |
7283 t = type_hash_canon (hashcode, t); | |
7284 } | |
7082 | 7285 |
7083 if (TYPE_CANONICAL (t) == t) | 7286 if (TYPE_CANONICAL (t) == t) |
7084 { | 7287 { |
7085 if (TYPE_STRUCTURAL_EQUALITY_P (elt_type) | 7288 if (TYPE_STRUCTURAL_EQUALITY_P (elt_type) |
7086 || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))) | 7289 || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))) |
7087 SET_TYPE_STRUCTURAL_EQUALITY (t); | 7290 SET_TYPE_STRUCTURAL_EQUALITY (t); |
7088 else if (TYPE_CANONICAL (elt_type) != elt_type | 7291 else if (TYPE_CANONICAL (elt_type) != elt_type |
7089 || (index_type && TYPE_CANONICAL (index_type) != index_type)) | 7292 || (index_type && TYPE_CANONICAL (index_type) != index_type)) |
7090 TYPE_CANONICAL (t) | 7293 TYPE_CANONICAL (t) |
7091 = build_array_type (TYPE_CANONICAL (elt_type), | 7294 = build_array_type_1 (TYPE_CANONICAL (elt_type), |
7092 index_type ? TYPE_CANONICAL (index_type) : NULL); | 7295 index_type |
7296 ? TYPE_CANONICAL (index_type) : NULL_TREE, | |
7297 shared); | |
7093 } | 7298 } |
7094 | 7299 |
7095 return t; | 7300 return t; |
7301 } | |
7302 | |
7303 /* Wrapper around build_array_type_1 with SHARED set to true. */ | |
7304 | |
7305 tree | |
7306 build_array_type (tree elt_type, tree index_type) | |
7307 { | |
7308 return build_array_type_1 (elt_type, index_type, true); | |
7309 } | |
7310 | |
7311 /* Wrapper around build_array_type_1 with SHARED set to false. */ | |
7312 | |
7313 tree | |
7314 build_nonshared_array_type (tree elt_type, tree index_type) | |
7315 { | |
7316 return build_array_type_1 (elt_type, index_type, false); | |
7096 } | 7317 } |
7097 | 7318 |
7098 /* Recursively examines the array elements of TYPE, until a non-array | 7319 /* Recursively examines the array elements of TYPE, until a non-array |
7099 element type is found. */ | 7320 element type is found. */ |
7100 | 7321 |
7257 When we are asked to remove it, we need to build new FUNCTION_TYPE | 7478 When we are asked to remove it, we need to build new FUNCTION_TYPE |
7258 instead. */ | 7479 instead. */ |
7259 if (TREE_CODE (orig_type) != METHOD_TYPE | 7480 if (TREE_CODE (orig_type) != METHOD_TYPE |
7260 || !bitmap_bit_p (args_to_skip, 0)) | 7481 || !bitmap_bit_p (args_to_skip, 0)) |
7261 { | 7482 { |
7262 new_type = copy_node (orig_type); | 7483 new_type = build_distinct_type_copy (orig_type); |
7263 TYPE_ARG_TYPES (new_type) = new_reversed; | 7484 TYPE_ARG_TYPES (new_type) = new_reversed; |
7264 } | 7485 } |
7265 else | 7486 else |
7266 { | 7487 { |
7267 new_type | 7488 new_type |
7306 | 7527 |
7307 /* For declarations setting DECL_VINDEX (i.e. methods) | 7528 /* For declarations setting DECL_VINDEX (i.e. methods) |
7308 we expect first argument to be THIS pointer. */ | 7529 we expect first argument to be THIS pointer. */ |
7309 if (bitmap_bit_p (args_to_skip, 0)) | 7530 if (bitmap_bit_p (args_to_skip, 0)) |
7310 DECL_VINDEX (new_decl) = NULL_TREE; | 7531 DECL_VINDEX (new_decl) = NULL_TREE; |
7532 | |
7533 /* When signature changes, we need to clear builtin info. */ | |
7534 if (DECL_BUILT_IN (new_decl) && !bitmap_empty_p (args_to_skip)) | |
7535 { | |
7536 DECL_BUILT_IN_CLASS (new_decl) = NOT_BUILT_IN; | |
7537 DECL_FUNCTION_CODE (new_decl) = (enum built_in_function) 0; | |
7538 } | |
7311 return new_decl; | 7539 return new_decl; |
7312 } | 7540 } |
7313 | 7541 |
7314 /* Build a function type. The RETURN_TYPE is the type returned by the | 7542 /* Build a function type. The RETURN_TYPE is the type returned by the |
7315 function. If VAARGS is set, no void_type_node is appended to the | 7543 function. If VAARGS is set, no void_type_node is appended to the |
7796 | 8024 |
7797 *unsignedp_ptr = uns; | 8025 *unsignedp_ptr = uns; |
7798 return win; | 8026 return win; |
7799 } | 8027 } |
7800 | 8028 |
7801 /* Nonzero if integer constant C has a value that is permissible | 8029 /* Returns true if integer constant C has a value that is permissible |
7802 for type TYPE (an INTEGER_TYPE). */ | 8030 for type TYPE (an INTEGER_TYPE). */ |
7803 | 8031 |
7804 int | 8032 bool |
7805 int_fits_type_p (const_tree c, const_tree type) | 8033 int_fits_type_p (const_tree c, const_tree type) |
7806 { | 8034 { |
7807 tree type_low_bound, type_high_bound; | 8035 tree type_low_bound, type_high_bound; |
7808 bool ok_for_low_bound, ok_for_high_bound, unsc; | 8036 bool ok_for_low_bound, ok_for_high_bound, unsc; |
7809 double_int dc, dd; | 8037 double_int dc, dd; |
7828 type_high_bound = TYPE_MAX_VALUE (type); | 8056 type_high_bound = TYPE_MAX_VALUE (type); |
7829 | 8057 |
7830 /* If at least one bound of the type is a constant integer, we can check | 8058 /* If at least one bound of the type is a constant integer, we can check |
7831 ourselves and maybe make a decision. If no such decision is possible, but | 8059 ourselves and maybe make a decision. If no such decision is possible, but |
7832 this type is a subtype, try checking against that. Otherwise, use | 8060 this type is a subtype, try checking against that. Otherwise, use |
7833 fit_double_type, which checks against the precision. | 8061 double_int_fits_to_tree_p, which checks against the precision. |
7834 | 8062 |
7835 Compute the status for each possibly constant bound, and return if we see | 8063 Compute the status for each possibly constant bound, and return if we see |
7836 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1 | 8064 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1 |
7837 for "unknown if constant fits", 0 for "constant known *not* to fit" and 1 | 8065 for "unknown if constant fits", 0 for "constant known *not* to fit" and 1 |
7838 for "constant known to fit". */ | 8066 for "constant known to fit". */ |
7849 { | 8077 { |
7850 int c_neg = (!unsc && double_int_negative_p (dc)); | 8078 int c_neg = (!unsc && double_int_negative_p (dc)); |
7851 int t_neg = (unsc && double_int_negative_p (dd)); | 8079 int t_neg = (unsc && double_int_negative_p (dd)); |
7852 | 8080 |
7853 if (c_neg && !t_neg) | 8081 if (c_neg && !t_neg) |
7854 return 0; | 8082 return false; |
7855 if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0) | 8083 if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0) |
7856 return 0; | 8084 return false; |
7857 } | 8085 } |
7858 else if (double_int_cmp (dc, dd, unsc) < 0) | 8086 else if (double_int_cmp (dc, dd, unsc) < 0) |
7859 return 0; | 8087 return false; |
7860 ok_for_low_bound = true; | 8088 ok_for_low_bound = true; |
7861 } | 8089 } |
7862 else | 8090 else |
7863 ok_for_low_bound = false; | 8091 ok_for_low_bound = false; |
7864 | 8092 |
7874 { | 8102 { |
7875 int c_neg = (!unsc && double_int_negative_p (dc)); | 8103 int c_neg = (!unsc && double_int_negative_p (dc)); |
7876 int t_neg = (unsc && double_int_negative_p (dd)); | 8104 int t_neg = (unsc && double_int_negative_p (dd)); |
7877 | 8105 |
7878 if (t_neg && !c_neg) | 8106 if (t_neg && !c_neg) |
7879 return 0; | 8107 return false; |
7880 if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0) | 8108 if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0) |
7881 return 0; | 8109 return false; |
7882 } | 8110 } |
7883 else if (double_int_cmp (dc, dd, unsc) > 0) | 8111 else if (double_int_cmp (dc, dd, unsc) > 0) |
7884 return 0; | 8112 return false; |
7885 ok_for_high_bound = true; | 8113 ok_for_high_bound = true; |
7886 } | 8114 } |
7887 else | 8115 else |
7888 ok_for_high_bound = false; | 8116 ok_for_high_bound = false; |
7889 | 8117 |
7890 /* If the constant fits both bounds, the result is known. */ | 8118 /* If the constant fits both bounds, the result is known. */ |
7891 if (ok_for_low_bound && ok_for_high_bound) | 8119 if (ok_for_low_bound && ok_for_high_bound) |
7892 return 1; | 8120 return true; |
7893 | 8121 |
7894 /* Perform some generic filtering which may allow making a decision | 8122 /* Perform some generic filtering which may allow making a decision |
7895 even if the bounds are not constant. First, negative integers | 8123 even if the bounds are not constant. First, negative integers |
7896 never fit in unsigned types, */ | 8124 never fit in unsigned types, */ |
7897 if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc)) | 8125 if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc)) |
7898 return 0; | 8126 return false; |
7899 | 8127 |
7900 /* Second, narrower types always fit in wider ones. */ | 8128 /* Second, narrower types always fit in wider ones. */ |
7901 if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c))) | 8129 if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c))) |
7902 return 1; | 8130 return true; |
7903 | 8131 |
7904 /* Third, unsigned integers with top bit set never fit signed types. */ | 8132 /* Third, unsigned integers with top bit set never fit signed types. */ |
7905 if (! TYPE_UNSIGNED (type) && unsc) | 8133 if (! TYPE_UNSIGNED (type) && unsc) |
7906 { | 8134 { |
7907 int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (c))) - 1; | 8135 int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (c))) - 1; |
7908 if (prec < HOST_BITS_PER_WIDE_INT) | 8136 if (prec < HOST_BITS_PER_WIDE_INT) |
7909 { | 8137 { |
7910 if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0) | 8138 if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0) |
7911 return 0; | 8139 return false; |
7912 } | 8140 } |
7913 else if (((((unsigned HOST_WIDE_INT) 1) | 8141 else if (((((unsigned HOST_WIDE_INT) 1) |
7914 << (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0) | 8142 << (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0) |
7915 return 0; | 8143 return false; |
7916 } | 8144 } |
7917 | 8145 |
7918 /* If we haven't been able to decide at this point, there nothing more we | 8146 /* If we haven't been able to decide at this point, there nothing more we |
7919 can check ourselves here. Look at the base type if we have one and it | 8147 can check ourselves here. Look at the base type if we have one and it |
7920 has the same precision. */ | 8148 has the same precision. */ |
7924 { | 8152 { |
7925 type = TREE_TYPE (type); | 8153 type = TREE_TYPE (type); |
7926 goto retry; | 8154 goto retry; |
7927 } | 8155 } |
7928 | 8156 |
7929 /* Or to fit_double_type, if nothing else. */ | 8157 /* Or to double_int_fits_to_tree_p, if nothing else. */ |
7930 return !fit_double_type (dc.low, dc.high, &dc.low, &dc.high, type); | 8158 return double_int_fits_to_tree_p (type, dc); |
7931 } | 8159 } |
7932 | 8160 |
7933 /* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant | 8161 /* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant |
7934 bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be | 8162 bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be |
7935 represented (assuming two's-complement arithmetic) within the bit | 8163 represented (assuming two's-complement arithmetic) within the bit |
8071 case QUAL_UNION_TYPE: | 8299 case QUAL_UNION_TYPE: |
8072 /* We can't see if any of the fields are variably-modified by the | 8300 /* We can't see if any of the fields are variably-modified by the |
8073 definition we normally use, since that would produce infinite | 8301 definition we normally use, since that would produce infinite |
8074 recursion via pointers. */ | 8302 recursion via pointers. */ |
8075 /* This is variably modified if some field's type is. */ | 8303 /* This is variably modified if some field's type is. */ |
8076 for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t)) | 8304 for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t)) |
8077 if (TREE_CODE (t) == FIELD_DECL) | 8305 if (TREE_CODE (t) == FIELD_DECL) |
8078 { | 8306 { |
8079 RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t)); | 8307 RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t)); |
8080 RETURN_TRUE_IF_VAR (DECL_SIZE (t)); | 8308 RETURN_TRUE_IF_VAR (DECL_SIZE (t)); |
8081 RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t)); | 8309 RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t)); |
8322 /* If we already have a name we know to be unique, just use that. */ | 8550 /* If we already have a name we know to be unique, just use that. */ |
8323 if (first_global_object_name) | 8551 if (first_global_object_name) |
8324 p = q = ASTRDUP (first_global_object_name); | 8552 p = q = ASTRDUP (first_global_object_name); |
8325 /* If the target is handling the constructors/destructors, they | 8553 /* If the target is handling the constructors/destructors, they |
8326 will be local to this file and the name is only necessary for | 8554 will be local to this file and the name is only necessary for |
8327 debugging purposes. */ | 8555 debugging purposes. |
8328 else if ((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors) | 8556 We also assign sub_I and sub_D sufixes to constructors called from |
8557 the global static constructors. These are always local. */ | |
8558 else if (((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors) | |
8559 || (strncmp (type, "sub_", 4) == 0 | |
8560 && (type[4] == 'I' || type[4] == 'D'))) | |
8329 { | 8561 { |
8330 const char *file = main_input_filename; | 8562 const char *file = main_input_filename; |
8331 if (! file) | 8563 if (! file) |
8332 file = input_filename; | 8564 file = input_filename; |
8333 /* Just use the file's basename, because the full pathname | 8565 /* Just use the file's basename, because the full pathname |
8658 TYPE_CANONICAL (t) | 8890 TYPE_CANONICAL (t) |
8659 = make_vector_type (TYPE_CANONICAL (innertype), nunits, VOIDmode); | 8891 = make_vector_type (TYPE_CANONICAL (innertype), nunits, VOIDmode); |
8660 | 8892 |
8661 layout_type (t); | 8893 layout_type (t); |
8662 | 8894 |
8663 { | |
8664 tree index = build_int_cst (NULL_TREE, nunits - 1); | |
8665 tree array = build_array_type (TYPE_MAIN_VARIANT (innertype), | |
8666 build_index_type (index)); | |
8667 tree rt = make_node (RECORD_TYPE); | |
8668 | |
8669 TYPE_FIELDS (rt) = build_decl (UNKNOWN_LOCATION, FIELD_DECL, | |
8670 get_identifier ("f"), array); | |
8671 DECL_CONTEXT (TYPE_FIELDS (rt)) = rt; | |
8672 layout_type (rt); | |
8673 TYPE_DEBUG_REPRESENTATION_TYPE (t) = rt; | |
8674 /* In dwarfout.c, type lookup uses TYPE_UID numbers. We want to output | |
8675 the representation type, and we want to find that die when looking up | |
8676 the vector type. This is most easily achieved by making the TYPE_UID | |
8677 numbers equal. */ | |
8678 TYPE_UID (rt) = TYPE_UID (t); | |
8679 } | |
8680 | |
8681 hashcode = iterative_hash_host_wide_int (VECTOR_TYPE, hashcode); | 8895 hashcode = iterative_hash_host_wide_int (VECTOR_TYPE, hashcode); |
8682 hashcode = iterative_hash_host_wide_int (nunits, hashcode); | 8896 hashcode = iterative_hash_host_wide_int (nunits, hashcode); |
8683 hashcode = iterative_hash_host_wide_int (mode, hashcode); | 8897 hashcode = iterative_hash_host_wide_int (mode, hashcode); |
8684 hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (t)), hashcode); | 8898 hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (t)), hashcode); |
8685 t = type_hash_canon (hashcode, t); | 8899 t = type_hash_canon (hashcode, t); |
8707 if (size == LONG_TYPE_SIZE) | 8921 if (size == LONG_TYPE_SIZE) |
8708 return unsignedp ? long_unsigned_type_node : long_integer_type_node; | 8922 return unsignedp ? long_unsigned_type_node : long_integer_type_node; |
8709 if (size == LONG_LONG_TYPE_SIZE) | 8923 if (size == LONG_LONG_TYPE_SIZE) |
8710 return (unsignedp ? long_long_unsigned_type_node | 8924 return (unsignedp ? long_long_unsigned_type_node |
8711 : long_long_integer_type_node); | 8925 : long_long_integer_type_node); |
8926 if (size == 128 && int128_integer_type_node) | |
8927 return (unsignedp ? int128_unsigned_type_node | |
8928 : int128_integer_type_node); | |
8712 | 8929 |
8713 if (unsignedp) | 8930 if (unsignedp) |
8714 return make_unsigned_type (size); | 8931 return make_unsigned_type (size); |
8715 else | 8932 else |
8716 return make_signed_type (size); | 8933 return make_signed_type (size); |
8822 unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE); | 9039 unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE); |
8823 long_integer_type_node = make_signed_type (LONG_TYPE_SIZE); | 9040 long_integer_type_node = make_signed_type (LONG_TYPE_SIZE); |
8824 long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE); | 9041 long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE); |
8825 long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE); | 9042 long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE); |
8826 long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE); | 9043 long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE); |
8827 | 9044 #if HOST_BITS_PER_WIDE_INT >= 64 |
9045 /* TODO: This isn't correct, but as logic depends at the moment on | |
9046 host's instead of target's wide-integer. | |
9047 If there is a target not supporting TImode, but has an 128-bit | |
9048 integer-scalar register, this target check needs to be adjusted. */ | |
9049 if (targetm.scalar_mode_supported_p (TImode)) | |
9050 { | |
9051 int128_integer_type_node = make_signed_type (128); | |
9052 int128_unsigned_type_node = make_unsigned_type (128); | |
9053 } | |
9054 #endif | |
8828 /* Define a boolean type. This type only represents boolean values but | 9055 /* Define a boolean type. This type only represents boolean values but |
8829 may be larger than char depending on the value of BOOL_TYPE_SIZE. | 9056 may be larger than char depending on the value of BOOL_TYPE_SIZE. |
8830 Front ends which want to override this size (i.e. Java) can redefine | 9057 Front ends which want to override this size (i.e. Java) can redefine |
8831 boolean_type_node before calling build_common_tree_nodes_2. */ | 9058 boolean_type_node before calling build_common_tree_nodes_2. */ |
8832 boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); | 9059 boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); |
8858 | 9085 |
8859 void | 9086 void |
8860 build_common_tree_nodes_2 (int short_double) | 9087 build_common_tree_nodes_2 (int short_double) |
8861 { | 9088 { |
8862 /* Define these next since types below may used them. */ | 9089 /* Define these next since types below may used them. */ |
8863 integer_zero_node = build_int_cst (NULL_TREE, 0); | 9090 integer_zero_node = build_int_cst (integer_type_node, 0); |
8864 integer_one_node = build_int_cst (NULL_TREE, 1); | 9091 integer_one_node = build_int_cst (integer_type_node, 1); |
8865 integer_minus_one_node = build_int_cst (NULL_TREE, -1); | 9092 integer_three_node = build_int_cst (integer_type_node, 3); |
9093 integer_minus_one_node = build_int_cst (integer_type_node, -1); | |
8866 | 9094 |
8867 size_zero_node = size_int (0); | 9095 size_zero_node = size_int (0); |
8868 size_one_node = size_int (1); | 9096 size_one_node = size_int (1); |
8869 bitsize_zero_node = bitsize_int (0); | 9097 bitsize_zero_node = bitsize_int (0); |
8870 bitsize_one_node = bitsize_int (1); | 9098 bitsize_one_node = bitsize_int (1); |
9025 TREE_THIS_VOLATILE (decl) = 1; | 9253 TREE_THIS_VOLATILE (decl) = 1; |
9026 if (ecf_flags & ECF_NOTHROW) | 9254 if (ecf_flags & ECF_NOTHROW) |
9027 TREE_NOTHROW (decl) = 1; | 9255 TREE_NOTHROW (decl) = 1; |
9028 if (ecf_flags & ECF_MALLOC) | 9256 if (ecf_flags & ECF_MALLOC) |
9029 DECL_IS_MALLOC (decl) = 1; | 9257 DECL_IS_MALLOC (decl) = 1; |
9258 if (ecf_flags & ECF_LEAF) | |
9259 DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), | |
9260 NULL, DECL_ATTRIBUTES (decl)); | |
9030 | 9261 |
9031 built_in_decls[code] = decl; | 9262 built_in_decls[code] = decl; |
9032 implicit_built_in_decls[code] = decl; | 9263 implicit_built_in_decls[code] = decl; |
9033 } | 9264 } |
9034 | 9265 |
9037 are relied upon by the tree optimizers and the middle-end. */ | 9268 are relied upon by the tree optimizers and the middle-end. */ |
9038 | 9269 |
9039 void | 9270 void |
9040 build_common_builtin_nodes (void) | 9271 build_common_builtin_nodes (void) |
9041 { | 9272 { |
9042 tree tmp, tmp2, ftype; | 9273 tree tmp, ftype; |
9043 | 9274 |
9044 if (built_in_decls[BUILT_IN_MEMCPY] == NULL | 9275 if (built_in_decls[BUILT_IN_MEMCPY] == NULL |
9045 || built_in_decls[BUILT_IN_MEMMOVE] == NULL) | 9276 || built_in_decls[BUILT_IN_MEMMOVE] == NULL) |
9046 { | 9277 { |
9047 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9278 ftype = build_function_type_list (ptr_type_node, |
9048 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9279 ptr_type_node, const_ptr_type_node, |
9049 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9280 size_type_node, NULL_TREE); |
9050 ftype = build_function_type (ptr_type_node, tmp); | |
9051 | 9281 |
9052 if (built_in_decls[BUILT_IN_MEMCPY] == NULL) | 9282 if (built_in_decls[BUILT_IN_MEMCPY] == NULL) |
9053 local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY, | 9283 local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY, |
9054 "memcpy", ECF_NOTHROW); | 9284 "memcpy", ECF_NOTHROW | ECF_LEAF); |
9055 if (built_in_decls[BUILT_IN_MEMMOVE] == NULL) | 9285 if (built_in_decls[BUILT_IN_MEMMOVE] == NULL) |
9056 local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE, | 9286 local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE, |
9057 "memmove", ECF_NOTHROW); | 9287 "memmove", ECF_NOTHROW | ECF_LEAF); |
9058 } | 9288 } |
9059 | 9289 |
9060 if (built_in_decls[BUILT_IN_MEMCMP] == NULL) | 9290 if (built_in_decls[BUILT_IN_MEMCMP] == NULL) |
9061 { | 9291 { |
9062 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9292 ftype = build_function_type_list (integer_type_node, const_ptr_type_node, |
9063 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9293 const_ptr_type_node, size_type_node, |
9064 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9294 NULL_TREE); |
9065 ftype = build_function_type (integer_type_node, tmp); | |
9066 local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP, | 9295 local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP, |
9067 "memcmp", ECF_PURE | ECF_NOTHROW); | 9296 "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9068 } | 9297 } |
9069 | 9298 |
9070 if (built_in_decls[BUILT_IN_MEMSET] == NULL) | 9299 if (built_in_decls[BUILT_IN_MEMSET] == NULL) |
9071 { | 9300 { |
9072 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9301 ftype = build_function_type_list (ptr_type_node, |
9073 tmp = tree_cons (NULL_TREE, integer_type_node, tmp); | 9302 ptr_type_node, integer_type_node, |
9074 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9303 size_type_node, NULL_TREE); |
9075 ftype = build_function_type (ptr_type_node, tmp); | |
9076 local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET, | 9304 local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET, |
9077 "memset", ECF_NOTHROW); | 9305 "memset", ECF_NOTHROW | ECF_LEAF); |
9078 } | 9306 } |
9079 | 9307 |
9080 if (built_in_decls[BUILT_IN_ALLOCA] == NULL) | 9308 if (built_in_decls[BUILT_IN_ALLOCA] == NULL) |
9081 { | 9309 { |
9082 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9310 ftype = build_function_type_list (ptr_type_node, |
9083 ftype = build_function_type (ptr_type_node, tmp); | 9311 size_type_node, NULL_TREE); |
9084 local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA, | 9312 local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA, |
9085 "alloca", ECF_MALLOC | ECF_NOTHROW); | 9313 "alloca", ECF_MALLOC | ECF_NOTHROW | ECF_LEAF); |
9086 } | 9314 } |
9087 | 9315 |
9088 /* If we're checking the stack, `alloca' can throw. */ | 9316 /* If we're checking the stack, `alloca' can throw. */ |
9089 if (flag_stack_check) | 9317 if (flag_stack_check) |
9090 TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA]) = 0; | 9318 TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA]) = 0; |
9091 | 9319 |
9092 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9320 ftype = build_function_type_list (void_type_node, |
9093 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9321 ptr_type_node, ptr_type_node, |
9094 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9322 ptr_type_node, NULL_TREE); |
9095 ftype = build_function_type (void_type_node, tmp); | |
9096 local_define_builtin ("__builtin_init_trampoline", ftype, | 9323 local_define_builtin ("__builtin_init_trampoline", ftype, |
9097 BUILT_IN_INIT_TRAMPOLINE, | 9324 BUILT_IN_INIT_TRAMPOLINE, |
9098 "__builtin_init_trampoline", ECF_NOTHROW); | 9325 "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF); |
9099 | 9326 |
9100 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9327 ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); |
9101 ftype = build_function_type (ptr_type_node, tmp); | |
9102 local_define_builtin ("__builtin_adjust_trampoline", ftype, | 9328 local_define_builtin ("__builtin_adjust_trampoline", ftype, |
9103 BUILT_IN_ADJUST_TRAMPOLINE, | 9329 BUILT_IN_ADJUST_TRAMPOLINE, |
9104 "__builtin_adjust_trampoline", | 9330 "__builtin_adjust_trampoline", |
9105 ECF_CONST | ECF_NOTHROW); | 9331 ECF_CONST | ECF_NOTHROW); |
9106 | 9332 |
9107 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9333 ftype = build_function_type_list (void_type_node, |
9108 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9334 ptr_type_node, ptr_type_node, NULL_TREE); |
9109 ftype = build_function_type (void_type_node, tmp); | |
9110 local_define_builtin ("__builtin_nonlocal_goto", ftype, | 9335 local_define_builtin ("__builtin_nonlocal_goto", ftype, |
9111 BUILT_IN_NONLOCAL_GOTO, | 9336 BUILT_IN_NONLOCAL_GOTO, |
9112 "__builtin_nonlocal_goto", | 9337 "__builtin_nonlocal_goto", |
9113 ECF_NORETURN | ECF_NOTHROW); | 9338 ECF_NORETURN | ECF_NOTHROW); |
9114 | 9339 |
9115 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9340 ftype = build_function_type_list (void_type_node, |
9116 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9341 ptr_type_node, ptr_type_node, NULL_TREE); |
9117 ftype = build_function_type (void_type_node, tmp); | |
9118 local_define_builtin ("__builtin_setjmp_setup", ftype, | 9342 local_define_builtin ("__builtin_setjmp_setup", ftype, |
9119 BUILT_IN_SETJMP_SETUP, | 9343 BUILT_IN_SETJMP_SETUP, |
9120 "__builtin_setjmp_setup", ECF_NOTHROW); | 9344 "__builtin_setjmp_setup", ECF_NOTHROW); |
9121 | 9345 |
9122 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9346 ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); |
9123 ftype = build_function_type (ptr_type_node, tmp); | |
9124 local_define_builtin ("__builtin_setjmp_dispatcher", ftype, | 9347 local_define_builtin ("__builtin_setjmp_dispatcher", ftype, |
9125 BUILT_IN_SETJMP_DISPATCHER, | 9348 BUILT_IN_SETJMP_DISPATCHER, |
9126 "__builtin_setjmp_dispatcher", | 9349 "__builtin_setjmp_dispatcher", |
9127 ECF_PURE | ECF_NOTHROW); | 9350 ECF_PURE | ECF_NOTHROW); |
9128 | 9351 |
9129 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9352 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9130 ftype = build_function_type (void_type_node, tmp); | |
9131 local_define_builtin ("__builtin_setjmp_receiver", ftype, | 9353 local_define_builtin ("__builtin_setjmp_receiver", ftype, |
9132 BUILT_IN_SETJMP_RECEIVER, | 9354 BUILT_IN_SETJMP_RECEIVER, |
9133 "__builtin_setjmp_receiver", ECF_NOTHROW); | 9355 "__builtin_setjmp_receiver", ECF_NOTHROW); |
9134 | 9356 |
9135 ftype = build_function_type (ptr_type_node, void_list_node); | 9357 ftype = build_function_type_list (ptr_type_node, NULL_TREE); |
9136 local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE, | 9358 local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE, |
9137 "__builtin_stack_save", ECF_NOTHROW); | 9359 "__builtin_stack_save", ECF_NOTHROW | ECF_LEAF); |
9138 | 9360 |
9139 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9361 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9140 ftype = build_function_type (void_type_node, tmp); | |
9141 local_define_builtin ("__builtin_stack_restore", ftype, | 9362 local_define_builtin ("__builtin_stack_restore", ftype, |
9142 BUILT_IN_STACK_RESTORE, | 9363 BUILT_IN_STACK_RESTORE, |
9143 "__builtin_stack_restore", ECF_NOTHROW); | 9364 "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF); |
9144 | |
9145 ftype = build_function_type (void_type_node, void_list_node); | |
9146 local_define_builtin ("__builtin_profile_func_enter", ftype, | |
9147 BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0); | |
9148 local_define_builtin ("__builtin_profile_func_exit", ftype, | |
9149 BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0); | |
9150 | 9365 |
9151 /* If there's a possibility that we might use the ARM EABI, build the | 9366 /* If there's a possibility that we might use the ARM EABI, build the |
9152 alternate __cxa_end_cleanup node used to resume from C++ and Java. */ | 9367 alternate __cxa_end_cleanup node used to resume from C++ and Java. */ |
9153 if (targetm.arm_eabi_unwinder) | 9368 if (targetm.arm_eabi_unwinder) |
9154 { | 9369 { |
9155 ftype = build_function_type (void_type_node, void_list_node); | 9370 ftype = build_function_type_list (void_type_node, NULL_TREE); |
9156 local_define_builtin ("__builtin_cxa_end_cleanup", ftype, | 9371 local_define_builtin ("__builtin_cxa_end_cleanup", ftype, |
9157 BUILT_IN_CXA_END_CLEANUP, | 9372 BUILT_IN_CXA_END_CLEANUP, |
9158 "__cxa_end_cleanup", ECF_NORETURN); | 9373 "__cxa_end_cleanup", ECF_NORETURN | ECF_LEAF); |
9159 } | 9374 } |
9160 | 9375 |
9161 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9376 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9162 ftype = build_function_type (void_type_node, tmp); | |
9163 local_define_builtin ("__builtin_unwind_resume", ftype, | 9377 local_define_builtin ("__builtin_unwind_resume", ftype, |
9164 BUILT_IN_UNWIND_RESUME, | 9378 BUILT_IN_UNWIND_RESUME, |
9165 (USING_SJLJ_EXCEPTIONS | 9379 ((targetm.except_unwind_info (&global_options) |
9380 == UI_SJLJ) | |
9166 ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), | 9381 ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), |
9167 ECF_NORETURN); | 9382 ECF_NORETURN); |
9168 | 9383 |
9169 /* The exception object and filter values from the runtime. The argument | 9384 /* The exception object and filter values from the runtime. The argument |
9170 must be zero before exception lowering, i.e. from the front end. After | 9385 must be zero before exception lowering, i.e. from the front end. After |
9171 exception lowering, it will be the region number for the exception | 9386 exception lowering, it will be the region number for the exception |
9172 landing pad. These functions are PURE instead of CONST to prevent | 9387 landing pad. These functions are PURE instead of CONST to prevent |
9173 them from being hoisted past the exception edge that will initialize | 9388 them from being hoisted past the exception edge that will initialize |
9174 its value in the landing pad. */ | 9389 its value in the landing pad. */ |
9175 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); | 9390 ftype = build_function_type_list (ptr_type_node, |
9176 ftype = build_function_type (ptr_type_node, tmp); | 9391 integer_type_node, NULL_TREE); |
9177 local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER, | 9392 local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER, |
9178 "__builtin_eh_pointer", ECF_PURE | ECF_NOTHROW); | 9393 "__builtin_eh_pointer", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9179 | 9394 |
9180 tmp2 = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); | 9395 tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); |
9181 ftype = build_function_type (tmp2, tmp); | 9396 ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE); |
9182 local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER, | 9397 local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER, |
9183 "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW); | 9398 "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9184 | 9399 |
9185 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); | 9400 ftype = build_function_type_list (void_type_node, |
9186 tmp = tree_cons (NULL_TREE, integer_type_node, tmp); | 9401 integer_type_node, integer_type_node, |
9187 ftype = build_function_type (void_type_node, tmp); | 9402 NULL_TREE); |
9188 local_define_builtin ("__builtin_eh_copy_values", ftype, | 9403 local_define_builtin ("__builtin_eh_copy_values", ftype, |
9189 BUILT_IN_EH_COPY_VALUES, | 9404 BUILT_IN_EH_COPY_VALUES, |
9190 "__builtin_eh_copy_values", ECF_NOTHROW); | 9405 "__builtin_eh_copy_values", ECF_NOTHROW); |
9191 | 9406 |
9192 /* Complex multiplication and division. These are handled as builtins | 9407 /* Complex multiplication and division. These are handled as builtins |
9206 type = lang_hooks.types.type_for_mode ((enum machine_mode) mode, 0); | 9421 type = lang_hooks.types.type_for_mode ((enum machine_mode) mode, 0); |
9207 if (type == NULL) | 9422 if (type == NULL) |
9208 continue; | 9423 continue; |
9209 inner_type = TREE_TYPE (type); | 9424 inner_type = TREE_TYPE (type); |
9210 | 9425 |
9211 tmp = tree_cons (NULL_TREE, inner_type, void_list_node); | 9426 ftype = build_function_type_list (type, inner_type, inner_type, |
9212 tmp = tree_cons (NULL_TREE, inner_type, tmp); | 9427 inner_type, inner_type, NULL_TREE); |
9213 tmp = tree_cons (NULL_TREE, inner_type, tmp); | |
9214 tmp = tree_cons (NULL_TREE, inner_type, tmp); | |
9215 ftype = build_function_type (type, tmp); | |
9216 | 9428 |
9217 mcode = ((enum built_in_function) | 9429 mcode = ((enum built_in_function) |
9218 (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); | 9430 (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); |
9219 dcode = ((enum built_in_function) | 9431 dcode = ((enum built_in_function) |
9220 (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); | 9432 (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); |
9223 *q = TOLOWER (*p); | 9435 *q = TOLOWER (*p); |
9224 *q = '\0'; | 9436 *q = '\0'; |
9225 | 9437 |
9226 built_in_names[mcode] = concat ("__mul", mode_name_buf, "3", NULL); | 9438 built_in_names[mcode] = concat ("__mul", mode_name_buf, "3", NULL); |
9227 local_define_builtin (built_in_names[mcode], ftype, mcode, | 9439 local_define_builtin (built_in_names[mcode], ftype, mcode, |
9228 built_in_names[mcode], ECF_CONST | ECF_NOTHROW); | 9440 built_in_names[mcode], ECF_CONST | ECF_NOTHROW | ECF_LEAF); |
9229 | 9441 |
9230 built_in_names[dcode] = concat ("__div", mode_name_buf, "3", NULL); | 9442 built_in_names[dcode] = concat ("__div", mode_name_buf, "3", NULL); |
9231 local_define_builtin (built_in_names[dcode], ftype, dcode, | 9443 local_define_builtin (built_in_names[dcode], ftype, dcode, |
9232 built_in_names[dcode], ECF_CONST | ECF_NOTHROW); | 9444 built_in_names[dcode], ECF_CONST | ECF_NOTHROW | ECF_LEAF); |
9233 } | 9445 } |
9234 } | 9446 } |
9235 } | 9447 } |
9236 | 9448 |
9237 /* HACK. GROSS. This is absolutely disgusting. I wish there was a | 9449 /* HACK. GROSS. This is absolutely disgusting. I wish there was a |
9436 int size, length; | 9648 int size, length; |
9437 | 9649 |
9438 length = omp_clause_num_ops[code]; | 9650 length = omp_clause_num_ops[code]; |
9439 size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); | 9651 size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); |
9440 | 9652 |
9441 t = GGC_NEWVAR (union tree_node, size); | 9653 t = ggc_alloc_tree_node (size); |
9442 memset (t, 0, size); | 9654 memset (t, 0, size); |
9443 TREE_SET_CODE (t, OMP_CLAUSE); | 9655 TREE_SET_CODE (t, OMP_CLAUSE); |
9444 OMP_CLAUSE_SET_CODE (t, code); | 9656 OMP_CLAUSE_SET_CODE (t, code); |
9445 OMP_CLAUSE_LOCATION (t) = loc; | 9657 OMP_CLAUSE_LOCATION (t) = loc; |
9446 | 9658 |
9469 #ifdef GATHER_STATISTICS | 9681 #ifdef GATHER_STATISTICS |
9470 tree_node_counts[(int) e_kind]++; | 9682 tree_node_counts[(int) e_kind]++; |
9471 tree_node_sizes[(int) e_kind] += length; | 9683 tree_node_sizes[(int) e_kind] += length; |
9472 #endif | 9684 #endif |
9473 | 9685 |
9474 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 9686 t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
9475 | |
9476 memset (t, 0, length); | |
9477 | 9687 |
9478 TREE_SET_CODE (t, code); | 9688 TREE_SET_CODE (t, code); |
9479 | 9689 |
9480 /* Can't use TREE_OPERAND to store the length because if checking is | 9690 /* Can't use TREE_OPERAND to store the length because if checking is |
9481 enabled, it will try to check the length before we store it. :-P */ | 9691 enabled, it will try to check the length before we store it. :-P */ |
9482 t->exp.operands[0] = build_int_cst (sizetype, len); | 9692 t->exp.operands[0] = build_int_cst (sizetype, len); |
9483 | 9693 |
9484 return t; | |
9485 } | |
9486 | |
9487 | |
9488 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE | |
9489 and FN and a null static chain slot. ARGLIST is a TREE_LIST of the | |
9490 arguments. */ | |
9491 | |
9492 tree | |
9493 build_call_list (tree return_type, tree fn, tree arglist) | |
9494 { | |
9495 tree t; | |
9496 int i; | |
9497 | |
9498 t = build_vl_exp (CALL_EXPR, list_length (arglist) + 3); | |
9499 TREE_TYPE (t) = return_type; | |
9500 CALL_EXPR_FN (t) = fn; | |
9501 CALL_EXPR_STATIC_CHAIN (t) = NULL_TREE; | |
9502 for (i = 0; arglist; arglist = TREE_CHAIN (arglist), i++) | |
9503 CALL_EXPR_ARG (t, i) = TREE_VALUE (arglist); | |
9504 process_call_operands (t); | |
9505 return t; | 9694 return t; |
9506 } | 9695 } |
9507 | 9696 |
9508 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and | 9697 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and |
9509 FN and a null static chain slot. NARGS is the number of call arguments | 9698 FN and a null static chain slot. NARGS is the number of call arguments |
9572 | 9761 |
9573 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); | 9762 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); |
9574 TREE_TYPE (ret) = return_type; | 9763 TREE_TYPE (ret) = return_type; |
9575 CALL_EXPR_FN (ret) = fn; | 9764 CALL_EXPR_FN (ret) = fn; |
9576 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; | 9765 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; |
9577 for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix) | 9766 FOR_EACH_VEC_ELT (tree, args, ix, t) |
9578 CALL_EXPR_ARG (ret, ix) = t; | 9767 CALL_EXPR_ARG (ret, ix) = t; |
9579 process_call_operands (ret); | 9768 process_call_operands (ret); |
9580 return ret; | 9769 return ret; |
9581 } | 9770 } |
9582 | 9771 |
9652 t = SSA_NAME_VAR (t); | 9841 t = SSA_NAME_VAR (t); |
9653 | 9842 |
9654 return (TREE_ADDRESSABLE (t) | 9843 return (TREE_ADDRESSABLE (t) |
9655 || is_global_var (t) | 9844 || is_global_var (t) |
9656 || (TREE_CODE (t) == RESULT_DECL | 9845 || (TREE_CODE (t) == RESULT_DECL |
9846 && !DECL_BY_REFERENCE (t) | |
9657 && aggregate_value_p (t, current_function_decl))); | 9847 && aggregate_value_p (t, current_function_decl))); |
9658 } | 9848 } |
9659 | 9849 |
9660 /* There are situations in which a language considers record types | 9850 /* There are situations in which a language considers record types |
9661 compatible which have different field lists. Decide if two fields | 9851 compatible which have different field lists. Decide if two fields |
10168 WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0)); | 10358 WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0)); |
10169 | 10359 |
10170 case BIND_EXPR: | 10360 case BIND_EXPR: |
10171 { | 10361 { |
10172 tree decl; | 10362 tree decl; |
10173 for (decl = BIND_EXPR_VARS (*tp); decl; decl = TREE_CHAIN (decl)) | 10363 for (decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl)) |
10174 { | 10364 { |
10175 /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk | 10365 /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk |
10176 into declarations that are just mentioned, rather than | 10366 into declarations that are just mentioned, rather than |
10177 declared; they don't really belong to this part of the tree. | 10367 declared; they don't really belong to this part of the tree. |
10178 And, we can see cycles: the initializer for a declaration | 10368 And, we can see cycles: the initializer for a declaration |
10283 if (RECORD_OR_UNION_TYPE_P (*type_p)) | 10473 if (RECORD_OR_UNION_TYPE_P (*type_p)) |
10284 { | 10474 { |
10285 tree field; | 10475 tree field; |
10286 | 10476 |
10287 for (field = TYPE_FIELDS (*type_p); field; | 10477 for (field = TYPE_FIELDS (*type_p); field; |
10288 field = TREE_CHAIN (field)) | 10478 field = DECL_CHAIN (field)) |
10289 { | 10479 { |
10290 /* We'd like to look at the type of the field, but we can | 10480 /* We'd like to look at the type of the field, but we can |
10291 easily get infinite recursion. So assume it's pointed | 10481 easily get infinite recursion. So assume it's pointed |
10292 to elsewhere in the tree. Also, ignore things that | 10482 to elsewhere in the tree. Also, ignore things that |
10293 aren't fields. */ | 10483 aren't fields. */ |
10417 } | 10607 } |
10418 | 10608 |
10419 /* Return true if TYPE has a variable argument list. */ | 10609 /* Return true if TYPE has a variable argument list. */ |
10420 | 10610 |
10421 bool | 10611 bool |
10422 stdarg_p (tree fntype) | 10612 stdarg_p (const_tree fntype) |
10423 { | 10613 { |
10424 function_args_iterator args_iter; | 10614 function_args_iterator args_iter; |
10425 tree n = NULL_TREE, t; | 10615 tree n = NULL_TREE, t; |
10426 | 10616 |
10427 if (!fntype) | 10617 if (!fntype) |
10584 tree t; | 10774 tree t; |
10585 void **slot; | 10775 void **slot; |
10586 | 10776 |
10587 /* Use the cache of optimization nodes. */ | 10777 /* Use the cache of optimization nodes. */ |
10588 | 10778 |
10589 cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node)); | 10779 cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node), |
10780 &global_options); | |
10590 | 10781 |
10591 slot = htab_find_slot (cl_option_hash_table, cl_optimization_node, INSERT); | 10782 slot = htab_find_slot (cl_option_hash_table, cl_optimization_node, INSERT); |
10592 t = (tree) *slot; | 10783 t = (tree) *slot; |
10593 if (!t) | 10784 if (!t) |
10594 { | 10785 { |
10611 tree t; | 10802 tree t; |
10612 void **slot; | 10803 void **slot; |
10613 | 10804 |
10614 /* Use the cache of optimization nodes. */ | 10805 /* Use the cache of optimization nodes. */ |
10615 | 10806 |
10616 cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node)); | 10807 cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node), |
10808 &global_options); | |
10617 | 10809 |
10618 slot = htab_find_slot (cl_option_hash_table, cl_target_option_node, INSERT); | 10810 slot = htab_find_slot (cl_option_hash_table, cl_target_option_node, INSERT); |
10619 t = (tree) *slot; | 10811 t = (tree) *slot; |
10620 if (!t) | 10812 if (!t) |
10621 { | 10813 { |
10768 | 10960 |
10769 tree | 10961 tree |
10770 lhd_gcc_personality (void) | 10962 lhd_gcc_personality (void) |
10771 { | 10963 { |
10772 if (!gcc_eh_personality_decl) | 10964 if (!gcc_eh_personality_decl) |
10773 gcc_eh_personality_decl | 10965 gcc_eh_personality_decl = build_personality_function ("gcc"); |
10774 = build_personality_function (USING_SJLJ_EXCEPTIONS | |
10775 ? "__gcc_personality_sj0" | |
10776 : "__gcc_personality_v0"); | |
10777 | |
10778 return gcc_eh_personality_decl; | 10966 return gcc_eh_personality_decl; |
10779 } | 10967 } |
10780 | 10968 |
10781 /* Try to find a base info of BINFO that would have its field decl at offset | 10969 /* Try to find a base info of BINFO that would have its field decl at offset |
10782 OFFSET within the BINFO type and which is of EXPECTED_TYPE. If it can be | 10970 OFFSET within the BINFO type and which is of EXPECTED_TYPE. If it can be |
10783 found, return, otherwise return NULL_TREE. */ | 10971 found, return, otherwise return NULL_TREE. */ |
10784 | 10972 |
10785 tree | 10973 tree |
10786 get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type) | 10974 get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type) |
10787 { | 10975 { |
10788 tree type; | 10976 tree type = BINFO_TYPE (binfo); |
10789 | 10977 |
10790 if (offset == 0) | 10978 while (true) |
10791 return binfo; | 10979 { |
10792 | |
10793 type = TREE_TYPE (binfo); | |
10794 while (offset > 0) | |
10795 { | |
10796 tree base_binfo, found_binfo; | |
10797 HOST_WIDE_INT pos, size; | 10980 HOST_WIDE_INT pos, size; |
10798 tree fld; | 10981 tree fld; |
10799 int i; | 10982 int i; |
10800 | 10983 |
10801 if (TREE_CODE (type) != RECORD_TYPE) | 10984 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (expected_type)) |
10985 return binfo; | |
10986 if (offset < 0) | |
10802 return NULL_TREE; | 10987 return NULL_TREE; |
10803 | 10988 |
10804 for (fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld)) | 10989 for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) |
10805 { | 10990 { |
10806 if (TREE_CODE (fld) != FIELD_DECL) | 10991 if (TREE_CODE (fld) != FIELD_DECL) |
10807 continue; | 10992 continue; |
10808 | 10993 |
10809 pos = int_bit_position (fld); | 10994 pos = int_bit_position (fld); |
10810 size = tree_low_cst (DECL_SIZE (fld), 1); | 10995 size = tree_low_cst (DECL_SIZE (fld), 1); |
10811 if (pos <= offset && (pos + size) > offset) | 10996 if (pos <= offset && (pos + size) > offset) |
10812 break; | 10997 break; |
10813 } | 10998 } |
10814 if (!fld) | 10999 if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE) |
10815 return NULL_TREE; | 11000 return NULL_TREE; |
10816 | 11001 |
10817 found_binfo = NULL_TREE; | 11002 if (!DECL_ARTIFICIAL (fld)) |
10818 for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) | 11003 { |
10819 if (TREE_TYPE (base_binfo) == TREE_TYPE (fld)) | 11004 binfo = TYPE_BINFO (TREE_TYPE (fld)); |
10820 { | 11005 if (!binfo) |
10821 found_binfo = base_binfo; | 11006 return NULL_TREE; |
10822 break; | 11007 } |
10823 } | 11008 /* Offset 0 indicates the primary base, whose vtable contents are |
10824 | 11009 represented in the binfo for the derived class. */ |
10825 if (!found_binfo) | 11010 else if (offset != 0) |
10826 return NULL_TREE; | 11011 { |
11012 tree base_binfo, found_binfo = NULL_TREE; | |
11013 for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) | |
11014 if (TREE_TYPE (base_binfo) == TREE_TYPE (fld)) | |
11015 { | |
11016 found_binfo = base_binfo; | |
11017 break; | |
11018 } | |
11019 if (!found_binfo) | |
11020 return NULL_TREE; | |
11021 binfo = found_binfo; | |
11022 } | |
10827 | 11023 |
10828 type = TREE_TYPE (fld); | 11024 type = TREE_TYPE (fld); |
10829 binfo = found_binfo; | |
10830 offset -= pos; | 11025 offset -= pos; |
10831 } | 11026 } |
10832 if (type != expected_type) | 11027 } |
10833 return NULL_TREE; | 11028 |
10834 return binfo; | 11029 /* Returns true if X is a typedef decl. */ |
11030 | |
11031 bool | |
11032 is_typedef_decl (tree x) | |
11033 { | |
11034 return (x && TREE_CODE (x) == TYPE_DECL | |
11035 && DECL_ORIGINAL_TYPE (x) != NULL_TREE); | |
11036 } | |
11037 | |
11038 /* Returns true iff TYPE is a type variant created for a typedef. */ | |
11039 | |
11040 bool | |
11041 typedef_variant_p (tree type) | |
11042 { | |
11043 return is_typedef_decl (TYPE_NAME (type)); | |
11044 } | |
11045 | |
11046 /* Warn about a use of an identifier which was marked deprecated. */ | |
11047 void | |
11048 warn_deprecated_use (tree node, tree attr) | |
11049 { | |
11050 const char *msg; | |
11051 | |
11052 if (node == 0 || !warn_deprecated_decl) | |
11053 return; | |
11054 | |
11055 if (!attr) | |
11056 { | |
11057 if (DECL_P (node)) | |
11058 attr = DECL_ATTRIBUTES (node); | |
11059 else if (TYPE_P (node)) | |
11060 { | |
11061 tree decl = TYPE_STUB_DECL (node); | |
11062 if (decl) | |
11063 attr = lookup_attribute ("deprecated", | |
11064 TYPE_ATTRIBUTES (TREE_TYPE (decl))); | |
11065 } | |
11066 } | |
11067 | |
11068 if (attr) | |
11069 attr = lookup_attribute ("deprecated", attr); | |
11070 | |
11071 if (attr) | |
11072 msg = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))); | |
11073 else | |
11074 msg = NULL; | |
11075 | |
11076 if (DECL_P (node)) | |
11077 { | |
11078 expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node)); | |
11079 if (msg) | |
11080 warning (OPT_Wdeprecated_declarations, | |
11081 "%qD is deprecated (declared at %s:%d): %s", | |
11082 node, xloc.file, xloc.line, msg); | |
11083 else | |
11084 warning (OPT_Wdeprecated_declarations, | |
11085 "%qD is deprecated (declared at %s:%d)", | |
11086 node, xloc.file, xloc.line); | |
11087 } | |
11088 else if (TYPE_P (node)) | |
11089 { | |
11090 tree what = NULL_TREE; | |
11091 tree decl = TYPE_STUB_DECL (node); | |
11092 | |
11093 if (TYPE_NAME (node)) | |
11094 { | |
11095 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
11096 what = TYPE_NAME (node); | |
11097 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL | |
11098 && DECL_NAME (TYPE_NAME (node))) | |
11099 what = DECL_NAME (TYPE_NAME (node)); | |
11100 } | |
11101 | |
11102 if (decl) | |
11103 { | |
11104 expanded_location xloc | |
11105 = expand_location (DECL_SOURCE_LOCATION (decl)); | |
11106 if (what) | |
11107 { | |
11108 if (msg) | |
11109 warning (OPT_Wdeprecated_declarations, | |
11110 "%qE is deprecated (declared at %s:%d): %s", | |
11111 what, xloc.file, xloc.line, msg); | |
11112 else | |
11113 warning (OPT_Wdeprecated_declarations, | |
11114 "%qE is deprecated (declared at %s:%d)", what, | |
11115 xloc.file, xloc.line); | |
11116 } | |
11117 else | |
11118 { | |
11119 if (msg) | |
11120 warning (OPT_Wdeprecated_declarations, | |
11121 "type is deprecated (declared at %s:%d): %s", | |
11122 xloc.file, xloc.line, msg); | |
11123 else | |
11124 warning (OPT_Wdeprecated_declarations, | |
11125 "type is deprecated (declared at %s:%d)", | |
11126 xloc.file, xloc.line); | |
11127 } | |
11128 } | |
11129 else | |
11130 { | |
11131 if (what) | |
11132 { | |
11133 if (msg) | |
11134 warning (OPT_Wdeprecated_declarations, "%qE is deprecated: %s", | |
11135 what, msg); | |
11136 else | |
11137 warning (OPT_Wdeprecated_declarations, "%qE is deprecated", what); | |
11138 } | |
11139 else | |
11140 { | |
11141 if (msg) | |
11142 warning (OPT_Wdeprecated_declarations, "type is deprecated: %s", | |
11143 msg); | |
11144 else | |
11145 warning (OPT_Wdeprecated_declarations, "type is deprecated"); | |
11146 } | |
11147 } | |
11148 } | |
10835 } | 11149 } |
10836 | 11150 |
10837 #include "gt-tree.h" | 11151 #include "gt-tree.h" |