Mercurial > hg > CbC > CbC_gcc
comparison gcc/tree.c @ 69:1b10fe6932e1
merge 69
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 07:53:12 +0900 |
parents | 326d9e06c2e3 f6334be47118 |
children | 3c5ea37d9068 |
comparison
equal
deleted
inserted
replaced
66:b362627d71ba | 69:1b10fe6932e1 |
---|---|
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 | 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 |
33 #include "system.h" | 33 #include "system.h" |
34 #include "coretypes.h" | 34 #include "coretypes.h" |
35 #include "tm.h" | 35 #include "tm.h" |
36 #include "flags.h" | 36 #include "flags.h" |
37 #include "tree.h" | 37 #include "tree.h" |
38 #include "real.h" | |
39 #include "tm_p.h" | 38 #include "tm_p.h" |
40 #include "function.h" | 39 #include "function.h" |
41 #include "obstack.h" | 40 #include "obstack.h" |
42 #include "toplev.h" | 41 #include "toplev.h" |
43 #include "ggc.h" | 42 #include "ggc.h" |
49 #include "tree-iterator.h" | 48 #include "tree-iterator.h" |
50 #include "basic-block.h" | 49 #include "basic-block.h" |
51 #include "tree-flow.h" | 50 #include "tree-flow.h" |
52 #include "params.h" | 51 #include "params.h" |
53 #include "pointer-set.h" | 52 #include "pointer-set.h" |
54 #include "fixed-value.h" | |
55 #include "tree-pass.h" | 53 #include "tree-pass.h" |
56 #include "langhooks-def.h" | 54 #include "langhooks-def.h" |
57 #include "diagnostic.h" | 55 #include "diagnostic.h" |
56 #include "tree-diagnostic.h" | |
57 #include "tree-pretty-print.h" | |
58 #include "cgraph.h" | 58 #include "cgraph.h" |
59 #include "timevar.h" | 59 #include "timevar.h" |
60 #include "except.h" | 60 #include "except.h" |
61 #include "debug.h" | 61 #include "debug.h" |
62 #include "intl.h" | 62 #include "intl.h" |
138 "stmts", | 138 "stmts", |
139 "refs", | 139 "refs", |
140 "exprs", | 140 "exprs", |
141 "constants", | 141 "constants", |
142 "identifiers", | 142 "identifiers", |
143 "perm_tree_lists", | |
144 "temp_tree_lists", | |
145 "vecs", | 143 "vecs", |
146 "binfos", | 144 "binfos", |
147 "ssa names", | 145 "ssa names", |
148 "constructors", | 146 "constructors", |
149 "random kinds", | 147 "random kinds", |
198 htab_t cl_option_hash_table; | 196 htab_t cl_option_hash_table; |
199 | 197 |
200 /* General tree->tree mapping structure for use in hash tables. */ | 198 /* General tree->tree mapping structure for use in hash tables. */ |
201 | 199 |
202 | 200 |
203 static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) | 201 static GTY ((if_marked ("tree_decl_map_marked_p"), param_is (struct tree_decl_map))) |
204 htab_t debug_expr_for_decl; | 202 htab_t debug_expr_for_decl; |
205 | 203 |
206 static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) | 204 static GTY ((if_marked ("tree_decl_map_marked_p"), param_is (struct tree_decl_map))) |
207 htab_t value_expr_for_decl; | 205 htab_t value_expr_for_decl; |
208 | 206 |
209 static GTY ((if_marked ("tree_priority_map_marked_p"), | 207 static GTY ((if_marked ("tree_priority_map_marked_p"), |
210 param_is (struct tree_priority_map))) | 208 param_is (struct tree_priority_map))) |
211 htab_t init_priority_for_decl; | 209 htab_t init_priority_for_decl; |
298 return TS_CONST_DECL; | 296 return TS_CONST_DECL; |
299 case TYPE_DECL: | 297 case TYPE_DECL: |
300 return TS_TYPE_DECL; | 298 return TS_TYPE_DECL; |
301 case FUNCTION_DECL: | 299 case FUNCTION_DECL: |
302 return TS_FUNCTION_DECL; | 300 return TS_FUNCTION_DECL; |
301 case TRANSLATION_UNIT_DECL: | |
302 return TS_TRANSLATION_UNIT_DECL; | |
303 default: | 303 default: |
304 return TS_DECL_NON_COMMON; | 304 return TS_DECL_NON_COMMON; |
305 } | 305 } |
306 } | 306 } |
307 case tcc_type: | 307 case tcc_type: |
468 case TS_TYPE_DECL: | 468 case TS_TYPE_DECL: |
469 case TS_FUNCTION_DECL: | 469 case TS_FUNCTION_DECL: |
470 MARK_TS_DECL_NON_COMMON (code); | 470 MARK_TS_DECL_NON_COMMON (code); |
471 break; | 471 break; |
472 | 472 |
473 case TS_TRANSLATION_UNIT_DECL: | |
474 MARK_TS_DECL_COMMON (code); | |
475 break; | |
476 | |
473 default: | 477 default: |
474 gcc_unreachable (); | 478 gcc_unreachable (); |
475 } | 479 } |
476 } | 480 } |
477 | 481 |
478 /* Basic consistency checks for attributes used in fold. */ | 482 /* Basic consistency checks for attributes used in fold. */ |
479 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]); | 483 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON]); |
480 gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_NON_COMMON]); | |
481 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]); | 484 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON]); |
482 gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]); | 485 gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_COMMON]); |
483 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]); | 486 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_COMMON]); |
484 gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]); | 487 gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_COMMON]); |
485 gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]); | 488 gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_COMMON]); |
504 gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]); | 507 gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_MINIMAL]); |
505 gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]); | 508 gcc_assert (tree_contains_struct[FIELD_DECL][TS_DECL_MINIMAL]); |
506 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]); | 509 gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_WITH_VIS]); |
507 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]); | 510 gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WITH_VIS]); |
508 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]); | 511 gcc_assert (tree_contains_struct[TYPE_DECL][TS_DECL_WITH_VIS]); |
509 gcc_assert (tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_WITH_VIS]); | |
510 gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]); | 512 gcc_assert (tree_contains_struct[VAR_DECL][TS_VAR_DECL]); |
511 gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]); | 513 gcc_assert (tree_contains_struct[FIELD_DECL][TS_FIELD_DECL]); |
512 gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]); | 514 gcc_assert (tree_contains_struct[PARM_DECL][TS_PARM_DECL]); |
513 gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]); | 515 gcc_assert (tree_contains_struct[LABEL_DECL][TS_LABEL_DECL]); |
514 gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]); | 516 gcc_assert (tree_contains_struct[RESULT_DECL][TS_RESULT_DECL]); |
535 { | 537 { |
536 /* Initialize the hash table of types. */ | 538 /* Initialize the hash table of types. */ |
537 type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, | 539 type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash, |
538 type_hash_eq, 0); | 540 type_hash_eq, 0); |
539 | 541 |
540 debug_expr_for_decl = htab_create_ggc (512, tree_map_hash, | 542 debug_expr_for_decl = htab_create_ggc (512, tree_decl_map_hash, |
541 tree_map_eq, 0); | 543 tree_decl_map_eq, 0); |
542 | 544 |
543 value_expr_for_decl = htab_create_ggc (512, tree_map_hash, | 545 value_expr_for_decl = htab_create_ggc (512, tree_decl_map_hash, |
544 tree_map_eq, 0); | 546 tree_decl_map_eq, 0); |
545 init_priority_for_decl = htab_create_ggc (512, tree_priority_map_hash, | 547 init_priority_for_decl = htab_create_ggc (512, tree_priority_map_hash, |
546 tree_priority_map_eq, 0); | 548 tree_priority_map_eq, 0); |
547 | 549 |
548 int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash, | 550 int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash, |
549 int_cst_hash_eq, NULL); | 551 int_cst_hash_eq, NULL); |
855 | 857 |
856 tree_node_counts[(int) kind]++; | 858 tree_node_counts[(int) kind]++; |
857 tree_node_sizes[(int) kind] += length; | 859 tree_node_sizes[(int) kind] += length; |
858 #endif | 860 #endif |
859 | 861 |
860 if (code == IDENTIFIER_NODE) | 862 t = ggc_alloc_zone_cleared_tree_node_stat ( |
861 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_id_zone); | 863 (code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone, |
862 else | 864 length PASS_MEM_STAT); |
863 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | |
864 | |
865 memset (t, 0, length); | |
866 | |
867 TREE_SET_CODE (t, code); | 865 TREE_SET_CODE (t, code); |
868 | 866 |
869 switch (type) | 867 switch (type) |
870 { | 868 { |
871 case tcc_statement: | 869 case tcc_statement: |
885 } | 883 } |
886 DECL_SOURCE_LOCATION (t) = input_location; | 884 DECL_SOURCE_LOCATION (t) = input_location; |
887 if (TREE_CODE (t) == DEBUG_EXPR_DECL) | 885 if (TREE_CODE (t) == DEBUG_EXPR_DECL) |
888 DECL_UID (t) = --next_debug_decl_uid; | 886 DECL_UID (t) = --next_debug_decl_uid; |
889 else | 887 else |
890 DECL_UID (t) = next_decl_uid++; | 888 { |
889 DECL_UID (t) = next_decl_uid++; | |
890 SET_DECL_PT_UID (t, -1); | |
891 } | |
891 if (TREE_CODE (t) == LABEL_DECL) | 892 if (TREE_CODE (t) == LABEL_DECL) |
892 LABEL_DECL_UID (t) = -1; | 893 LABEL_DECL_UID (t) = -1; |
893 | 894 |
894 break; | 895 break; |
895 | 896 |
951 size_t length; | 952 size_t length; |
952 | 953 |
953 gcc_assert (code != STATEMENT_LIST); | 954 gcc_assert (code != STATEMENT_LIST); |
954 | 955 |
955 length = tree_size (node); | 956 length = tree_size (node); |
956 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 957 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
957 memcpy (t, node, length); | 958 memcpy (t, node, length); |
958 | 959 |
959 TREE_CHAIN (t) = 0; | 960 TREE_CHAIN (t) = 0; |
960 TREE_ASM_WRITTEN (t) = 0; | 961 TREE_ASM_WRITTEN (t) = 0; |
961 TREE_VISITED (t) = 0; | 962 TREE_VISITED (t) = 0; |
965 if (TREE_CODE_CLASS (code) == tcc_declaration) | 966 if (TREE_CODE_CLASS (code) == tcc_declaration) |
966 { | 967 { |
967 if (code == DEBUG_EXPR_DECL) | 968 if (code == DEBUG_EXPR_DECL) |
968 DECL_UID (t) = --next_debug_decl_uid; | 969 DECL_UID (t) = --next_debug_decl_uid; |
969 else | 970 else |
970 DECL_UID (t) = next_decl_uid++; | 971 { |
972 DECL_UID (t) = next_decl_uid++; | |
973 if (DECL_PT_UID_SET_P (node)) | |
974 SET_DECL_PT_UID (t, DECL_PT_UID (node)); | |
975 } | |
971 if ((TREE_CODE (node) == PARM_DECL || TREE_CODE (node) == VAR_DECL) | 976 if ((TREE_CODE (node) == PARM_DECL || TREE_CODE (node) == VAR_DECL) |
972 && DECL_HAS_VALUE_EXPR_P (node)) | 977 && DECL_HAS_VALUE_EXPR_P (node)) |
973 { | 978 { |
974 SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node)); | 979 SET_DECL_VALUE_EXPR (t, DECL_VALUE_EXPR (node)); |
975 DECL_HAS_VALUE_EXPR_P (t) = 1; | 980 DECL_HAS_VALUE_EXPR_P (t) = 1; |
1036 type = integer_type_node; | 1041 type = integer_type_node; |
1037 | 1042 |
1038 return build_int_cst_wide (type, low, low < 0 ? -1 : 0); | 1043 return build_int_cst_wide (type, low, low < 0 ? -1 : 0); |
1039 } | 1044 } |
1040 | 1045 |
1041 /* Create an INT_CST node with a LOW value zero extended. */ | |
1042 | |
1043 tree | |
1044 build_int_cstu (tree type, unsigned HOST_WIDE_INT low) | |
1045 { | |
1046 return build_int_cst_wide (type, low, 0); | |
1047 } | |
1048 | |
1049 /* Create an INT_CST node with a LOW value in TYPE. The value is sign extended | 1046 /* Create an INT_CST node with a LOW value in TYPE. The value is sign extended |
1050 if it is negative. This function is similar to build_int_cst, but | 1047 if it is negative. This function is similar to build_int_cst, but |
1051 the extra bits outside of the type precision are cleared. Constants | 1048 the extra bits outside of the type precision are cleared. Constants |
1052 with these extra bits may confuse the fold so that it detects overflows | 1049 with these extra bits may confuse the fold so that it detects overflows |
1053 even in cases when they do not occur, and in general should be avoided. | 1050 even in cases when they do not occur, and in general should be avoided. |
1056 precision of the integer constants. */ | 1053 precision of the integer constants. */ |
1057 | 1054 |
1058 tree | 1055 tree |
1059 build_int_cst_type (tree type, HOST_WIDE_INT low) | 1056 build_int_cst_type (tree type, HOST_WIDE_INT low) |
1060 { | 1057 { |
1061 unsigned HOST_WIDE_INT low1; | |
1062 HOST_WIDE_INT hi; | |
1063 | |
1064 gcc_assert (type); | 1058 gcc_assert (type); |
1065 | 1059 |
1066 fit_double_type (low, low < 0 ? -1 : 0, &low1, &hi, type); | 1060 return double_int_to_tree (type, shwi_to_double_int (low)); |
1067 | 1061 } |
1068 return build_int_cst_wide (type, low1, hi); | 1062 |
1069 } | 1063 /* Constructs tree in type TYPE from with value given by CST. Signedness |
1070 | 1064 of CST is assumed to be the same as the signedness of TYPE. */ |
1071 /* Create an INT_CST node of TYPE and value HI:LOW. The value is truncated | 1065 |
1072 and sign extended according to the value range of TYPE. */ | 1066 tree |
1073 | 1067 double_int_to_tree (tree type, double_int cst) |
1074 tree | 1068 { |
1075 build_int_cst_wide_type (tree type, | 1069 /* Size types *are* sign extended. */ |
1076 unsigned HOST_WIDE_INT low, HOST_WIDE_INT high) | 1070 bool sign_extended_type = (!TYPE_UNSIGNED (type) |
1077 { | 1071 || (TREE_CODE (type) == INTEGER_TYPE |
1078 fit_double_type (low, high, &low, &high, type); | 1072 && TYPE_IS_SIZETYPE (type))); |
1079 return build_int_cst_wide (type, low, high); | 1073 |
1074 cst = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); | |
1075 | |
1076 return build_int_cst_wide (type, cst.low, cst.high); | |
1077 } | |
1078 | |
1079 /* Returns true if CST fits into range of TYPE. Signedness of CST is assumed | |
1080 to be the same as the signedness of TYPE. */ | |
1081 | |
1082 bool | |
1083 double_int_fits_to_tree_p (const_tree type, double_int cst) | |
1084 { | |
1085 /* Size types *are* sign extended. */ | |
1086 bool sign_extended_type = (!TYPE_UNSIGNED (type) | |
1087 || (TREE_CODE (type) == INTEGER_TYPE | |
1088 && TYPE_IS_SIZETYPE (type))); | |
1089 | |
1090 double_int ext | |
1091 = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); | |
1092 | |
1093 return double_int_equal_p (cst, ext); | |
1094 } | |
1095 | |
1096 /* We force the double_int CST to the range of the type TYPE by sign or | |
1097 zero extending it. OVERFLOWABLE indicates if we are interested in | |
1098 overflow of the value, when >0 we are only interested in signed | |
1099 overflow, for <0 we are interested in any overflow. OVERFLOWED | |
1100 indicates whether overflow has already occurred. CONST_OVERFLOWED | |
1101 indicates whether constant overflow has already occurred. We force | |
1102 T's value to be within range of T's type (by setting to 0 or 1 all | |
1103 the bits outside the type's range). We set TREE_OVERFLOWED if, | |
1104 OVERFLOWED is nonzero, | |
1105 or OVERFLOWABLE is >0 and signed overflow occurs | |
1106 or OVERFLOWABLE is <0 and any overflow occurs | |
1107 We return a new tree node for the extended double_int. The node | |
1108 is shared if no overflow flags are set. */ | |
1109 | |
1110 | |
1111 tree | |
1112 force_fit_type_double (tree type, double_int cst, int overflowable, | |
1113 bool overflowed) | |
1114 { | |
1115 bool sign_extended_type; | |
1116 | |
1117 /* Size types *are* sign extended. */ | |
1118 sign_extended_type = (!TYPE_UNSIGNED (type) | |
1119 || (TREE_CODE (type) == INTEGER_TYPE | |
1120 && TYPE_IS_SIZETYPE (type))); | |
1121 | |
1122 /* If we need to set overflow flags, return a new unshared node. */ | |
1123 if (overflowed || !double_int_fits_to_tree_p(type, cst)) | |
1124 { | |
1125 if (overflowed | |
1126 || overflowable < 0 | |
1127 || (overflowable > 0 && sign_extended_type)) | |
1128 { | |
1129 tree t = make_node (INTEGER_CST); | |
1130 TREE_INT_CST (t) = double_int_ext (cst, TYPE_PRECISION (type), | |
1131 !sign_extended_type); | |
1132 TREE_TYPE (t) = type; | |
1133 TREE_OVERFLOW (t) = 1; | |
1134 return t; | |
1135 } | |
1136 } | |
1137 | |
1138 /* Else build a shared node. */ | |
1139 return double_int_to_tree (type, cst); | |
1080 } | 1140 } |
1081 | 1141 |
1082 /* These are the hash table functions for the hash table of INTEGER_CST | 1142 /* These are the hash table functions for the hash table of INTEGER_CST |
1083 nodes of a sizetype. */ | 1143 nodes of a sizetype. */ |
1084 | 1144 |
1120 | 1180 |
1121 gcc_assert (type); | 1181 gcc_assert (type); |
1122 | 1182 |
1123 switch (TREE_CODE (type)) | 1183 switch (TREE_CODE (type)) |
1124 { | 1184 { |
1185 case NULLPTR_TYPE: | |
1186 gcc_assert (hi == 0 && low == 0); | |
1187 /* Fallthru. */ | |
1188 | |
1125 case POINTER_TYPE: | 1189 case POINTER_TYPE: |
1126 case REFERENCE_TYPE: | 1190 case REFERENCE_TYPE: |
1127 /* Cache NULL pointer. */ | 1191 /* Cache NULL pointer. */ |
1128 if (!hi && !low) | 1192 if (!hi && !low) |
1129 { | 1193 { |
1223 and the rest are zeros. */ | 1287 and the rest are zeros. */ |
1224 | 1288 |
1225 tree | 1289 tree |
1226 build_low_bits_mask (tree type, unsigned bits) | 1290 build_low_bits_mask (tree type, unsigned bits) |
1227 { | 1291 { |
1228 unsigned HOST_WIDE_INT low; | 1292 double_int mask; |
1229 HOST_WIDE_INT high; | |
1230 unsigned HOST_WIDE_INT all_ones = ~(unsigned HOST_WIDE_INT) 0; | |
1231 | 1293 |
1232 gcc_assert (bits <= TYPE_PRECISION (type)); | 1294 gcc_assert (bits <= TYPE_PRECISION (type)); |
1233 | 1295 |
1234 if (bits == TYPE_PRECISION (type) | 1296 if (bits == TYPE_PRECISION (type) |
1235 && !TYPE_UNSIGNED (type)) | 1297 && !TYPE_UNSIGNED (type)) |
1236 { | 1298 /* Sign extended all-ones mask. */ |
1237 /* Sign extended all-ones mask. */ | 1299 mask = double_int_minus_one; |
1238 low = all_ones; | |
1239 high = -1; | |
1240 } | |
1241 else if (bits <= HOST_BITS_PER_WIDE_INT) | |
1242 { | |
1243 low = all_ones >> (HOST_BITS_PER_WIDE_INT - bits); | |
1244 high = 0; | |
1245 } | |
1246 else | 1300 else |
1247 { | 1301 mask = double_int_mask (bits); |
1248 bits -= HOST_BITS_PER_WIDE_INT; | 1302 |
1249 low = all_ones; | 1303 return build_int_cst_wide (type, mask.low, mask.high); |
1250 high = all_ones >> (HOST_BITS_PER_WIDE_INT - bits); | |
1251 } | |
1252 | |
1253 return build_int_cst_wide (type, low, high); | |
1254 } | 1304 } |
1255 | 1305 |
1256 /* Checks that X is integer constant that can be expressed in (unsigned) | 1306 /* Checks that X is integer constant that can be expressed in (unsigned) |
1257 HOST_WIDE_INT without loss of precision. */ | 1307 HOST_WIDE_INT without loss of precision. */ |
1258 | 1308 |
1276 build_vector (tree type, tree vals) | 1326 build_vector (tree type, tree vals) |
1277 { | 1327 { |
1278 tree v = make_node (VECTOR_CST); | 1328 tree v = make_node (VECTOR_CST); |
1279 int over = 0; | 1329 int over = 0; |
1280 tree link; | 1330 tree link; |
1331 unsigned cnt = 0; | |
1281 | 1332 |
1282 TREE_VECTOR_CST_ELTS (v) = vals; | 1333 TREE_VECTOR_CST_ELTS (v) = vals; |
1283 TREE_TYPE (v) = type; | 1334 TREE_TYPE (v) = type; |
1284 | 1335 |
1285 /* Iterate through elements and check for overflow. */ | 1336 /* Iterate through elements and check for overflow. */ |
1286 for (link = vals; link; link = TREE_CHAIN (link)) | 1337 for (link = vals; link; link = TREE_CHAIN (link)) |
1287 { | 1338 { |
1288 tree value = TREE_VALUE (link); | 1339 tree value = TREE_VALUE (link); |
1340 cnt++; | |
1289 | 1341 |
1290 /* Don't crash if we get an address constant. */ | 1342 /* Don't crash if we get an address constant. */ |
1291 if (!CONSTANT_CLASS_P (value)) | 1343 if (!CONSTANT_CLASS_P (value)) |
1292 continue; | 1344 continue; |
1293 | 1345 |
1294 over |= TREE_OVERFLOW (value); | 1346 over |= TREE_OVERFLOW (value); |
1295 } | 1347 } |
1296 | 1348 |
1349 gcc_assert (cnt == TYPE_VECTOR_SUBPARTS (type)); | |
1350 | |
1297 TREE_OVERFLOW (v) = over; | 1351 TREE_OVERFLOW (v) = over; |
1298 return v; | 1352 return v; |
1299 } | 1353 } |
1300 | 1354 |
1301 /* Return a new VECTOR_CST node whose type is TYPE and whose values | 1355 /* Return a new VECTOR_CST node whose type is TYPE and whose values |
1308 unsigned HOST_WIDE_INT idx; | 1362 unsigned HOST_WIDE_INT idx; |
1309 tree value; | 1363 tree value; |
1310 | 1364 |
1311 FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) | 1365 FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) |
1312 list = tree_cons (NULL_TREE, value, list); | 1366 list = tree_cons (NULL_TREE, value, list); |
1367 for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx) | |
1368 list = tree_cons (NULL_TREE, | |
1369 build_zero_cst (TREE_TYPE (type)), list); | |
1313 return build_vector (type, nreverse (list)); | 1370 return build_vector (type, nreverse (list)); |
1371 } | |
1372 | |
1373 /* Build a vector of type VECTYPE where all the elements are SCs. */ | |
1374 tree | |
1375 build_vector_from_val (tree vectype, tree sc) | |
1376 { | |
1377 int i, nunits = TYPE_VECTOR_SUBPARTS (vectype); | |
1378 VEC(constructor_elt, gc) *v = NULL; | |
1379 | |
1380 if (sc == error_mark_node) | |
1381 return sc; | |
1382 | |
1383 /* Verify that the vector type is suitable for SC. Note that there | |
1384 is some inconsistency in the type-system with respect to restrict | |
1385 qualifications of pointers. Vector types always have a main-variant | |
1386 element type and the qualification is applied to the vector-type. | |
1387 So TREE_TYPE (vector-type) does not return a properly qualified | |
1388 vector element-type. */ | |
1389 gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)), | |
1390 TREE_TYPE (vectype))); | |
1391 | |
1392 v = VEC_alloc (constructor_elt, gc, nunits); | |
1393 for (i = 0; i < nunits; ++i) | |
1394 CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc); | |
1395 | |
1396 if (CONSTANT_CLASS_P (sc)) | |
1397 return build_vector_from_ctor (vectype, v); | |
1398 else | |
1399 return build_constructor (vectype, v); | |
1314 } | 1400 } |
1315 | 1401 |
1316 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values | 1402 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values |
1317 are in the VEC pointed to by VALS. */ | 1403 are in the VEC pointed to by VALS. */ |
1318 tree | 1404 tree |
1319 build_constructor (tree type, VEC(constructor_elt,gc) *vals) | 1405 build_constructor (tree type, VEC(constructor_elt,gc) *vals) |
1320 { | 1406 { |
1321 tree c = make_node (CONSTRUCTOR); | 1407 tree c = make_node (CONSTRUCTOR); |
1408 unsigned int i; | |
1409 constructor_elt *elt; | |
1410 bool constant_p = true; | |
1411 | |
1322 TREE_TYPE (c) = type; | 1412 TREE_TYPE (c) = type; |
1323 CONSTRUCTOR_ELTS (c) = vals; | 1413 CONSTRUCTOR_ELTS (c) = vals; |
1414 | |
1415 FOR_EACH_VEC_ELT (constructor_elt, vals, i, elt) | |
1416 if (!TREE_CONSTANT (elt->value)) | |
1417 { | |
1418 constant_p = false; | |
1419 break; | |
1420 } | |
1421 | |
1422 TREE_CONSTANT (c) = constant_p; | |
1423 | |
1324 return c; | 1424 return c; |
1325 } | 1425 } |
1326 | 1426 |
1327 /* Build a CONSTRUCTOR node made of a single initializer, with the specified | 1427 /* Build a CONSTRUCTOR node made of a single initializer, with the specified |
1328 INDEX and VALUE. */ | 1428 INDEX and VALUE. */ |
1329 tree | 1429 tree |
1330 build_constructor_single (tree type, tree index, tree value) | 1430 build_constructor_single (tree type, tree index, tree value) |
1331 { | 1431 { |
1332 VEC(constructor_elt,gc) *v; | 1432 VEC(constructor_elt,gc) *v; |
1333 constructor_elt *elt; | 1433 constructor_elt *elt; |
1334 tree t; | |
1335 | 1434 |
1336 v = VEC_alloc (constructor_elt, gc, 1); | 1435 v = VEC_alloc (constructor_elt, gc, 1); |
1337 elt = VEC_quick_push (constructor_elt, v, NULL); | 1436 elt = VEC_quick_push (constructor_elt, v, NULL); |
1338 elt->index = index; | 1437 elt->index = index; |
1339 elt->value = value; | 1438 elt->value = value; |
1340 | 1439 |
1341 t = build_constructor (type, v); | 1440 return build_constructor (type, v); |
1342 TREE_CONSTANT (t) = TREE_CONSTANT (value); | |
1343 return t; | |
1344 } | 1441 } |
1345 | 1442 |
1346 | 1443 |
1347 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values | 1444 /* Return a new CONSTRUCTOR node whose type is TYPE and whose values |
1348 are in a list pointed to by VALS. */ | 1445 are in a list pointed to by VALS. */ |
1349 tree | 1446 tree |
1350 build_constructor_from_list (tree type, tree vals) | 1447 build_constructor_from_list (tree type, tree vals) |
1351 { | 1448 { |
1352 tree t, val; | 1449 tree t; |
1353 VEC(constructor_elt,gc) *v = NULL; | 1450 VEC(constructor_elt,gc) *v = NULL; |
1354 bool constant_p = true; | |
1355 | 1451 |
1356 if (vals) | 1452 if (vals) |
1357 { | 1453 { |
1358 v = VEC_alloc (constructor_elt, gc, list_length (vals)); | 1454 v = VEC_alloc (constructor_elt, gc, list_length (vals)); |
1359 for (t = vals; t; t = TREE_CHAIN (t)) | 1455 for (t = vals; t; t = TREE_CHAIN (t)) |
1360 { | 1456 CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t)); |
1361 constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL); | 1457 } |
1362 val = TREE_VALUE (t); | 1458 |
1363 elt->index = TREE_PURPOSE (t); | 1459 return build_constructor (type, v); |
1364 elt->value = val; | |
1365 if (!TREE_CONSTANT (val)) | |
1366 constant_p = false; | |
1367 } | |
1368 } | |
1369 | |
1370 t = build_constructor (type, v); | |
1371 TREE_CONSTANT (t) = constant_p; | |
1372 return t; | |
1373 } | 1460 } |
1374 | 1461 |
1375 /* Return a new FIXED_CST node whose type is TYPE and value is F. */ | 1462 /* Return a new FIXED_CST node whose type is TYPE and value is F. */ |
1376 | 1463 |
1377 tree | 1464 tree |
1379 { | 1466 { |
1380 tree v; | 1467 tree v; |
1381 FIXED_VALUE_TYPE *fp; | 1468 FIXED_VALUE_TYPE *fp; |
1382 | 1469 |
1383 v = make_node (FIXED_CST); | 1470 v = make_node (FIXED_CST); |
1384 fp = GGC_NEW (FIXED_VALUE_TYPE); | 1471 fp = ggc_alloc_fixed_value (); |
1385 memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE)); | 1472 memcpy (fp, &f, sizeof (FIXED_VALUE_TYPE)); |
1386 | 1473 |
1387 TREE_TYPE (v) = type; | 1474 TREE_TYPE (v) = type; |
1388 TREE_FIXED_CST_PTR (v) = fp; | 1475 TREE_FIXED_CST_PTR (v) = fp; |
1389 return v; | 1476 return v; |
1400 | 1487 |
1401 /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE. | 1488 /* ??? Used to check for overflow here via CHECK_FLOAT_TYPE. |
1402 Consider doing it via real_convert now. */ | 1489 Consider doing it via real_convert now. */ |
1403 | 1490 |
1404 v = make_node (REAL_CST); | 1491 v = make_node (REAL_CST); |
1405 dp = GGC_NEW (REAL_VALUE_TYPE); | 1492 dp = ggc_alloc_real_value (); |
1406 memcpy (dp, &d, sizeof (REAL_VALUE_TYPE)); | 1493 memcpy (dp, &d, sizeof (REAL_VALUE_TYPE)); |
1407 | 1494 |
1408 TREE_TYPE (v) = type; | 1495 TREE_TYPE (v) = type; |
1409 TREE_REAL_CST_PTR (v) = dp; | 1496 TREE_REAL_CST_PTR (v) = dp; |
1410 TREE_OVERFLOW (v) = overflow; | 1497 TREE_OVERFLOW (v) = overflow; |
1460 #ifdef GATHER_STATISTICS | 1547 #ifdef GATHER_STATISTICS |
1461 tree_node_counts[(int) c_kind]++; | 1548 tree_node_counts[(int) c_kind]++; |
1462 tree_node_sizes[(int) c_kind] += length; | 1549 tree_node_sizes[(int) c_kind] += length; |
1463 #endif | 1550 #endif |
1464 | 1551 |
1465 s = ggc_alloc_tree (length); | 1552 s = ggc_alloc_tree_node (length); |
1466 | 1553 |
1467 memset (s, 0, sizeof (struct tree_common)); | 1554 memset (s, 0, sizeof (struct tree_common)); |
1468 TREE_SET_CODE (s, STRING_CST); | 1555 TREE_SET_CODE (s, STRING_CST); |
1469 TREE_CONSTANT (s) = 1; | 1556 TREE_CONSTANT (s) = 1; |
1470 TREE_STRING_LENGTH (s) = len; | 1557 TREE_STRING_LENGTH (s) = len; |
1512 gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); | 1599 gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); |
1513 return build_fixed (type, FCONST1(TYPE_MODE (type))); | 1600 return build_fixed (type, FCONST1(TYPE_MODE (type))); |
1514 | 1601 |
1515 case VECTOR_TYPE: | 1602 case VECTOR_TYPE: |
1516 { | 1603 { |
1517 tree scalar, cst; | 1604 tree scalar = build_one_cst (TREE_TYPE (type)); |
1518 int i; | 1605 |
1519 | 1606 return build_vector_from_val (type, scalar); |
1520 scalar = build_one_cst (TREE_TYPE (type)); | |
1521 | |
1522 /* Create 'vect_cst_ = {cst,cst,...,cst}' */ | |
1523 cst = NULL_TREE; | |
1524 for (i = TYPE_VECTOR_SUBPARTS (type); --i >= 0; ) | |
1525 cst = tree_cons (NULL_TREE, scalar, cst); | |
1526 | |
1527 return build_vector (type, cst); | |
1528 } | 1607 } |
1529 | 1608 |
1530 case COMPLEX_TYPE: | 1609 case COMPLEX_TYPE: |
1531 return build_complex (type, | 1610 return build_complex (type, |
1532 build_one_cst (TREE_TYPE (type)), | 1611 build_one_cst (TREE_TYPE (type)), |
1533 fold_convert (TREE_TYPE (type), integer_zero_node)); | 1612 build_zero_cst (TREE_TYPE (type))); |
1534 | 1613 |
1535 default: | 1614 default: |
1536 gcc_unreachable (); | 1615 gcc_unreachable (); |
1537 } | 1616 } |
1538 } | 1617 } |
1618 | |
1619 /* Build 0 constant of type TYPE. This is used by constructor folding | |
1620 and thus the constant should be represented in memory by | |
1621 zero(es). */ | |
1622 | |
1623 tree | |
1624 build_zero_cst (tree type) | |
1625 { | |
1626 switch (TREE_CODE (type)) | |
1627 { | |
1628 case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: | |
1629 case POINTER_TYPE: case REFERENCE_TYPE: | |
1630 case OFFSET_TYPE: | |
1631 return build_int_cst (type, 0); | |
1632 | |
1633 case REAL_TYPE: | |
1634 return build_real (type, dconst0); | |
1635 | |
1636 case FIXED_POINT_TYPE: | |
1637 return build_fixed (type, FCONST0 (TYPE_MODE (type))); | |
1638 | |
1639 case VECTOR_TYPE: | |
1640 { | |
1641 tree scalar = build_zero_cst (TREE_TYPE (type)); | |
1642 | |
1643 return build_vector_from_val (type, scalar); | |
1644 } | |
1645 | |
1646 case COMPLEX_TYPE: | |
1647 { | |
1648 tree zero = build_zero_cst (TREE_TYPE (type)); | |
1649 | |
1650 return build_complex (type, zero, zero); | |
1651 } | |
1652 | |
1653 default: | |
1654 if (!AGGREGATE_TYPE_P (type)) | |
1655 return fold_convert (type, integer_zero_node); | |
1656 return build_constructor (type, NULL); | |
1657 } | |
1658 } | |
1659 | |
1539 | 1660 |
1540 /* Build a BINFO with LEN language slots. */ | 1661 /* Build a BINFO with LEN language slots. */ |
1541 | 1662 |
1542 tree | 1663 tree |
1543 make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL) | 1664 make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL) |
1549 #ifdef GATHER_STATISTICS | 1670 #ifdef GATHER_STATISTICS |
1550 tree_node_counts[(int) binfo_kind]++; | 1671 tree_node_counts[(int) binfo_kind]++; |
1551 tree_node_sizes[(int) binfo_kind] += length; | 1672 tree_node_sizes[(int) binfo_kind] += length; |
1552 #endif | 1673 #endif |
1553 | 1674 |
1554 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 1675 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
1555 | 1676 |
1556 memset (t, 0, offsetof (struct tree_binfo, base_binfos)); | 1677 memset (t, 0, offsetof (struct tree_binfo, base_binfos)); |
1557 | 1678 |
1558 TREE_SET_CODE (t, TREE_BINFO); | 1679 TREE_SET_CODE (t, TREE_BINFO); |
1559 | 1680 |
1574 #ifdef GATHER_STATISTICS | 1695 #ifdef GATHER_STATISTICS |
1575 tree_node_counts[(int) vec_kind]++; | 1696 tree_node_counts[(int) vec_kind]++; |
1576 tree_node_sizes[(int) vec_kind] += length; | 1697 tree_node_sizes[(int) vec_kind] += length; |
1577 #endif | 1698 #endif |
1578 | 1699 |
1579 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 1700 t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
1580 | |
1581 memset (t, 0, length); | |
1582 | 1701 |
1583 TREE_SET_CODE (t, TREE_VEC); | 1702 TREE_SET_CODE (t, TREE_VEC); |
1584 TREE_VEC_LENGTH (t) = len; | 1703 TREE_VEC_LENGTH (t) = len; |
1585 | 1704 |
1586 return t; | 1705 return t; |
1917 list = TREE_CHAIN (list); | 2036 list = TREE_CHAIN (list); |
1918 } | 2037 } |
1919 return NULL_TREE; | 2038 return NULL_TREE; |
1920 } | 2039 } |
1921 | 2040 |
2041 /* Return true if ELEM is in V. */ | |
2042 | |
2043 bool | |
2044 vec_member (const_tree elem, VEC(tree,gc) *v) | |
2045 { | |
2046 unsigned ix; | |
2047 tree t; | |
2048 FOR_EACH_VEC_ELT (tree, v, ix, t) | |
2049 if (elem == t) | |
2050 return true; | |
2051 return false; | |
2052 } | |
2053 | |
1922 /* Returns element number IDX (zero-origin) of chain CHAIN, or | 2054 /* Returns element number IDX (zero-origin) of chain CHAIN, or |
1923 NULL_TREE. */ | 2055 NULL_TREE. */ |
1924 | 2056 |
1925 tree | 2057 tree |
1926 chain_index (int idx, tree chain) | 2058 chain_index (int idx, tree chain) |
1937 { | 2069 { |
1938 while (chain) | 2070 while (chain) |
1939 { | 2071 { |
1940 if (elem == chain) | 2072 if (elem == chain) |
1941 return 1; | 2073 return 1; |
1942 chain = TREE_CHAIN (chain); | 2074 chain = DECL_CHAIN (chain); |
1943 } | 2075 } |
1944 | 2076 |
1945 return 0; | 2077 return 0; |
1946 } | 2078 } |
1947 | 2079 |
1978 fields_length (const_tree type) | 2110 fields_length (const_tree type) |
1979 { | 2111 { |
1980 tree t = TYPE_FIELDS (type); | 2112 tree t = TYPE_FIELDS (type); |
1981 int count = 0; | 2113 int count = 0; |
1982 | 2114 |
1983 for (; t; t = TREE_CHAIN (t)) | 2115 for (; t; t = DECL_CHAIN (t)) |
1984 if (TREE_CODE (t) == FIELD_DECL) | 2116 if (TREE_CODE (t) == FIELD_DECL) |
1985 ++count; | 2117 ++count; |
1986 | 2118 |
1987 return count; | 2119 return count; |
2120 } | |
2121 | |
2122 /* Returns the first FIELD_DECL in the TYPE_FIELDS of the RECORD_TYPE or | |
2123 UNION_TYPE TYPE, or NULL_TREE if none. */ | |
2124 | |
2125 tree | |
2126 first_field (const_tree type) | |
2127 { | |
2128 tree t = TYPE_FIELDS (type); | |
2129 while (t && TREE_CODE (t) != FIELD_DECL) | |
2130 t = TREE_CHAIN (t); | |
2131 return t; | |
1988 } | 2132 } |
1989 | 2133 |
1990 /* Concatenate two chains of nodes (chained through TREE_CHAIN) | 2134 /* Concatenate two chains of nodes (chained through TREE_CHAIN) |
1991 by modifying the last node in chain 1 to point to chain 2. | 2135 by modifying the last node in chain 1 to point to chain 2. |
1992 This is the Lisp primitive `nconc'. */ | 2136 This is the Lisp primitive `nconc'. */ |
2035 nreverse (tree t) | 2179 nreverse (tree t) |
2036 { | 2180 { |
2037 tree prev = 0, decl, next; | 2181 tree prev = 0, decl, next; |
2038 for (decl = t; decl; decl = next) | 2182 for (decl = t; decl; decl = next) |
2039 { | 2183 { |
2184 /* We shouldn't be using this function to reverse BLOCK chains; we | |
2185 have blocks_nreverse for that. */ | |
2186 gcc_checking_assert (TREE_CODE (decl) != BLOCK); | |
2040 next = TREE_CHAIN (decl); | 2187 next = TREE_CHAIN (decl); |
2041 TREE_CHAIN (decl) = prev; | 2188 TREE_CHAIN (decl) = prev; |
2042 prev = decl; | 2189 prev = decl; |
2043 } | 2190 } |
2044 return prev; | 2191 return prev; |
2063 { | 2210 { |
2064 tree ret = NULL_TREE; | 2211 tree ret = NULL_TREE; |
2065 tree *pp = &ret; | 2212 tree *pp = &ret; |
2066 unsigned int i; | 2213 unsigned int i; |
2067 tree t; | 2214 tree t; |
2068 for (i = 0; VEC_iterate (tree, vec, i, t); ++i) | 2215 FOR_EACH_VEC_ELT (tree, vec, i, t) |
2069 { | 2216 { |
2070 *pp = build_tree_list_stat (NULL, t PASS_MEM_STAT); | 2217 *pp = build_tree_list_stat (NULL, t PASS_MEM_STAT); |
2071 pp = &TREE_CHAIN (*pp); | 2218 pp = &TREE_CHAIN (*pp); |
2072 } | 2219 } |
2073 return ret; | 2220 return ret; |
2075 | 2222 |
2076 /* Return a newly created TREE_LIST node whose | 2223 /* Return a newly created TREE_LIST node whose |
2077 purpose and value fields are PURPOSE and VALUE | 2224 purpose and value fields are PURPOSE and VALUE |
2078 and whose TREE_CHAIN is CHAIN. */ | 2225 and whose TREE_CHAIN is CHAIN. */ |
2079 | 2226 |
2080 tree | 2227 tree |
2081 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) | 2228 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) |
2082 { | 2229 { |
2083 tree node; | 2230 tree node; |
2084 | 2231 |
2085 node = (tree) ggc_alloc_zone_pass_stat (sizeof (struct tree_list), &tree_zone); | 2232 node = ggc_alloc_zone_tree_node_stat (&tree_zone, sizeof (struct tree_list) |
2086 | 2233 PASS_MEM_STAT); |
2087 memset (node, 0, sizeof (struct tree_common)); | 2234 memset (node, 0, sizeof (struct tree_common)); |
2088 | 2235 |
2089 #ifdef GATHER_STATISTICS | 2236 #ifdef GATHER_STATISTICS |
2090 tree_node_counts[(int) x_kind]++; | 2237 tree_node_counts[(int) x_kind]++; |
2091 tree_node_sizes[(int) x_kind] += sizeof (struct tree_list); | 2238 tree_node_sizes[(int) x_kind] += sizeof (struct tree_list); |
2094 TREE_SET_CODE (node, TREE_LIST); | 2241 TREE_SET_CODE (node, TREE_LIST); |
2095 TREE_CHAIN (node) = chain; | 2242 TREE_CHAIN (node) = chain; |
2096 TREE_PURPOSE (node) = purpose; | 2243 TREE_PURPOSE (node) = purpose; |
2097 TREE_VALUE (node) = value; | 2244 TREE_VALUE (node) = value; |
2098 return node; | 2245 return node; |
2099 } | |
2100 | |
2101 /* Return the elements of a CONSTRUCTOR as a TREE_LIST. */ | |
2102 | |
2103 tree | |
2104 ctor_to_list (tree ctor) | |
2105 { | |
2106 tree list = NULL_TREE; | |
2107 tree *p = &list; | |
2108 unsigned ix; | |
2109 tree purpose, val; | |
2110 | |
2111 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), ix, purpose, val) | |
2112 { | |
2113 *p = build_tree_list (purpose, val); | |
2114 p = &TREE_CHAIN (*p); | |
2115 } | |
2116 | |
2117 return list; | |
2118 } | 2246 } |
2119 | 2247 |
2120 /* Return the values of the elements of a CONSTRUCTOR as a vector of | 2248 /* Return the values of the elements of a CONSTRUCTOR as a vector of |
2121 trees. */ | 2249 trees. */ |
2122 | 2250 |
2379 return staticp (TREE_OPERAND (arg, 0)); | 2507 return staticp (TREE_OPERAND (arg, 0)); |
2380 | 2508 |
2381 case BIT_FIELD_REF: | 2509 case BIT_FIELD_REF: |
2382 return NULL; | 2510 return NULL; |
2383 | 2511 |
2384 case MISALIGNED_INDIRECT_REF: | |
2385 case ALIGN_INDIRECT_REF: | |
2386 case INDIRECT_REF: | 2512 case INDIRECT_REF: |
2387 return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL; | 2513 return TREE_CONSTANT (TREE_OPERAND (arg, 0)) ? arg : NULL; |
2388 | 2514 |
2389 case ARRAY_REF: | 2515 case ARRAY_REF: |
2390 case ARRAY_RANGE_REF: | 2516 case ARRAY_RANGE_REF: |
2420 case LABEL_DECL: | 2546 case LABEL_DECL: |
2421 case FUNCTION_DECL: | 2547 case FUNCTION_DECL: |
2422 return true; | 2548 return true; |
2423 | 2549 |
2424 case VAR_DECL: | 2550 case VAR_DECL: |
2425 if (((TREE_STATIC (op) || DECL_EXTERNAL (op)) | 2551 if ((TREE_STATIC (op) || DECL_EXTERNAL (op)) |
2426 && !DECL_DLLIMPORT_P (op)) | |
2427 || DECL_THREAD_LOCAL_P (op) | 2552 || DECL_THREAD_LOCAL_P (op) |
2428 || DECL_CONTEXT (op) == current_function_decl | 2553 || DECL_CONTEXT (op) == current_function_decl |
2429 || decl_function_context (op) == current_function_decl) | 2554 || decl_function_context (op) == current_function_decl) |
2430 return true; | 2555 return true; |
2431 break; | 2556 break; |
2678 | 2803 |
2679 TREE_SIDE_EFFECTS (t) = side_effects; | 2804 TREE_SIDE_EFFECTS (t) = side_effects; |
2680 TREE_READONLY (t) = read_only; | 2805 TREE_READONLY (t) = read_only; |
2681 } | 2806 } |
2682 | 2807 |
2683 /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size | 2808 /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a |
2684 or offset that depends on a field within a record. */ | 2809 size or offset that depends on a field within a record. */ |
2685 | 2810 |
2686 bool | 2811 bool |
2687 contains_placeholder_p (const_tree exp) | 2812 contains_placeholder_p (const_tree exp) |
2688 { | 2813 { |
2689 enum tree_code code; | 2814 enum tree_code code; |
2765 return 0; | 2890 return 0; |
2766 } | 2891 } |
2767 return 0; | 2892 return 0; |
2768 } | 2893 } |
2769 | 2894 |
2770 /* Return true if any part of the computation of TYPE involves a | 2895 /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR |
2771 PLACEHOLDER_EXPR. This includes size, bounds, qualifiers | 2896 directly. This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and |
2772 (for QUAL_UNION_TYPE) and field positions. */ | 2897 field positions. */ |
2773 | 2898 |
2774 static bool | 2899 static bool |
2775 type_contains_placeholder_1 (const_tree type) | 2900 type_contains_placeholder_1 (const_tree type) |
2776 { | 2901 { |
2777 /* If the size contains a placeholder or the parent type (component type in | 2902 /* If the size contains a placeholder or the parent type (component type in |
2778 the case of arrays) type involves a placeholder, this type does. */ | 2903 the case of arrays) type involves a placeholder, this type does. */ |
2779 if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)) | 2904 if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)) |
2780 || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type)) | 2905 || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type)) |
2781 || (TREE_TYPE (type) != 0 | 2906 || (!POINTER_TYPE_P (type) |
2907 && TREE_TYPE (type) | |
2782 && type_contains_placeholder_p (TREE_TYPE (type)))) | 2908 && type_contains_placeholder_p (TREE_TYPE (type)))) |
2783 return true; | 2909 return true; |
2784 | 2910 |
2785 /* Now do type-specific checks. Note that the last part of the check above | 2911 /* Now do type-specific checks. Note that the last part of the check above |
2786 greatly limits what we have to do below. */ | 2912 greatly limits what we have to do below. */ |
2804 /* Here we just check the bounds. */ | 2930 /* Here we just check the bounds. */ |
2805 return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type)) | 2931 return (CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (type)) |
2806 || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type))); | 2932 || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type))); |
2807 | 2933 |
2808 case ARRAY_TYPE: | 2934 case ARRAY_TYPE: |
2809 /* We're already checked the component type (TREE_TYPE), so just check | 2935 /* We have already checked the component type above, so just check the |
2810 the index type. */ | 2936 domain type. */ |
2811 return type_contains_placeholder_p (TYPE_DOMAIN (type)); | 2937 return type_contains_placeholder_p (TYPE_DOMAIN (type)); |
2812 | 2938 |
2813 case RECORD_TYPE: | 2939 case RECORD_TYPE: |
2814 case UNION_TYPE: | 2940 case UNION_TYPE: |
2815 case QUAL_UNION_TYPE: | 2941 case QUAL_UNION_TYPE: |
2816 { | 2942 { |
2817 tree field; | 2943 tree field; |
2818 | 2944 |
2819 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) | 2945 for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) |
2820 if (TREE_CODE (field) == FIELD_DECL | 2946 if (TREE_CODE (field) == FIELD_DECL |
2821 && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field)) | 2947 && (CONTAINS_PLACEHOLDER_P (DECL_FIELD_OFFSET (field)) |
2822 || (TREE_CODE (type) == QUAL_UNION_TYPE | 2948 || (TREE_CODE (type) == QUAL_UNION_TYPE |
2823 && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field))) | 2949 && CONTAINS_PLACEHOLDER_P (DECL_QUALIFIER (field))) |
2824 || type_contains_placeholder_p (TREE_TYPE (field)))) | 2950 || type_contains_placeholder_p (TREE_TYPE (field)))) |
2830 default: | 2956 default: |
2831 gcc_unreachable (); | 2957 gcc_unreachable (); |
2832 } | 2958 } |
2833 } | 2959 } |
2834 | 2960 |
2961 /* Wrapper around above function used to cache its result. */ | |
2962 | |
2835 bool | 2963 bool |
2836 type_contains_placeholder_p (tree type) | 2964 type_contains_placeholder_p (tree type) |
2837 { | 2965 { |
2838 bool result; | 2966 bool result; |
2839 | 2967 |
2861 push_without_duplicates (tree exp, VEC (tree, heap) **queue) | 2989 push_without_duplicates (tree exp, VEC (tree, heap) **queue) |
2862 { | 2990 { |
2863 unsigned int i; | 2991 unsigned int i; |
2864 tree iter; | 2992 tree iter; |
2865 | 2993 |
2866 for (i = 0; VEC_iterate (tree, *queue, i, iter); i++) | 2994 FOR_EACH_VEC_ELT (tree, *queue, i, iter) |
2867 if (simple_cst_equal (iter, exp) == 1) | 2995 if (simple_cst_equal (iter, exp) == 1) |
2868 break; | 2996 break; |
2869 | 2997 |
2870 if (!iter) | 2998 if (!iter) |
2871 VEC_safe_push (tree, heap, *queue, exp); | 2999 VEC_safe_push (tree, heap, *queue, exp); |
3118 default: | 3246 default: |
3119 gcc_unreachable (); | 3247 gcc_unreachable (); |
3120 } | 3248 } |
3121 | 3249 |
3122 TREE_READONLY (new_tree) |= TREE_READONLY (exp); | 3250 TREE_READONLY (new_tree) |= TREE_READONLY (exp); |
3251 | |
3252 if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) | |
3253 TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); | |
3254 | |
3123 return new_tree; | 3255 return new_tree; |
3124 } | 3256 } |
3125 | 3257 |
3126 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement | 3258 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement |
3127 for it within OBJ, a tree that is an object or a chain of references. */ | 3259 for it within OBJ, a tree that is an object or a chain of references. */ |
3285 default: | 3417 default: |
3286 gcc_unreachable (); | 3418 gcc_unreachable (); |
3287 } | 3419 } |
3288 | 3420 |
3289 TREE_READONLY (new_tree) |= TREE_READONLY (exp); | 3421 TREE_READONLY (new_tree) |= TREE_READONLY (exp); |
3422 | |
3423 if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) | |
3424 TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); | |
3425 | |
3290 return new_tree; | 3426 return new_tree; |
3291 } | 3427 } |
3292 | 3428 |
3293 /* Stabilize a reference so that we can use it any number of times | 3429 /* Stabilize a reference so that we can use it any number of times |
3294 without causing its operands to be evaluated more than once. | 3430 without causing its operands to be evaluated more than once. |
3512 /* Now see what's inside. If it's an INDIRECT_REF, copy our properties from | 3648 /* Now see what's inside. If it's an INDIRECT_REF, copy our properties from |
3513 the address, since &(*a)->b is a form of addition. If it's a constant, the | 3649 the address, since &(*a)->b is a form of addition. If it's a constant, the |
3514 address is constant too. If it's a decl, its address is constant if the | 3650 address is constant too. If it's a decl, its address is constant if the |
3515 decl is static. Everything else is not constant and, furthermore, | 3651 decl is static. Everything else is not constant and, furthermore, |
3516 taking the address of a volatile variable is not volatile. */ | 3652 taking the address of a volatile variable is not volatile. */ |
3517 if (TREE_CODE (node) == INDIRECT_REF) | 3653 if (TREE_CODE (node) == INDIRECT_REF |
3654 || TREE_CODE (node) == MEM_REF) | |
3518 UPDATE_FLAGS (TREE_OPERAND (node, 0)); | 3655 UPDATE_FLAGS (TREE_OPERAND (node, 0)); |
3519 else if (CONSTANT_CLASS_P (node)) | 3656 else if (CONSTANT_CLASS_P (node)) |
3520 ; | 3657 ; |
3521 else if (DECL_P (node)) | 3658 else if (DECL_P (node)) |
3522 tc &= (staticp (node) != NULL_TREE); | 3659 tc &= (staticp (node) != NULL_TREE); |
3579 tree_node_sizes[(int) kind] += length; | 3716 tree_node_sizes[(int) kind] += length; |
3580 #endif | 3717 #endif |
3581 | 3718 |
3582 gcc_assert (TREE_CODE_LENGTH (code) == 1); | 3719 gcc_assert (TREE_CODE_LENGTH (code) == 1); |
3583 | 3720 |
3584 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 3721 t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
3585 | 3722 |
3586 memset (t, 0, sizeof (struct tree_common)); | 3723 memset (t, 0, sizeof (struct tree_common)); |
3587 | 3724 |
3588 TREE_SET_CODE (t, code); | 3725 TREE_SET_CODE (t, code); |
3589 | 3726 |
3606 operands are. */ | 3743 operands are. */ |
3607 TREE_SIDE_EFFECTS (t) = 1; | 3744 TREE_SIDE_EFFECTS (t) = 1; |
3608 TREE_READONLY (t) = 0; | 3745 TREE_READONLY (t) = 0; |
3609 break; | 3746 break; |
3610 | 3747 |
3611 case MISALIGNED_INDIRECT_REF: | |
3612 case ALIGN_INDIRECT_REF: | |
3613 case INDIRECT_REF: | 3748 case INDIRECT_REF: |
3614 /* Whether a dereference is readonly has nothing to do with whether | 3749 /* Whether a dereference is readonly has nothing to do with whether |
3615 its operand is readonly. */ | 3750 its operand is readonly. */ |
3616 TREE_READONLY (t) = 0; | 3751 TREE_READONLY (t) = 0; |
3617 break; | 3752 break; |
3642 { \ | 3777 { \ |
3643 if (TREE_SIDE_EFFECTS (arg##N)) \ | 3778 if (TREE_SIDE_EFFECTS (arg##N)) \ |
3644 side_effects = 1; \ | 3779 side_effects = 1; \ |
3645 if (!TREE_READONLY (arg##N) \ | 3780 if (!TREE_READONLY (arg##N) \ |
3646 && !CONSTANT_CLASS_P (arg##N)) \ | 3781 && !CONSTANT_CLASS_P (arg##N)) \ |
3647 read_only = 0; \ | 3782 (void) (read_only = 0); \ |
3648 if (!TREE_CONSTANT (arg##N)) \ | 3783 if (!TREE_CONSTANT (arg##N)) \ |
3649 constant = 0; \ | 3784 (void) (constant = 0); \ |
3650 } \ | 3785 } \ |
3651 } while (0) | 3786 } while (0) |
3652 | 3787 |
3653 tree | 3788 tree |
3654 build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL) | 3789 build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL) |
3814 PROCESS_ARG(0); | 3949 PROCESS_ARG(0); |
3815 PROCESS_ARG(1); | 3950 PROCESS_ARG(1); |
3816 PROCESS_ARG(2); | 3951 PROCESS_ARG(2); |
3817 PROCESS_ARG(3); | 3952 PROCESS_ARG(3); |
3818 PROCESS_ARG(4); | 3953 PROCESS_ARG(4); |
3954 if (code == TARGET_MEM_REF) | |
3955 side_effects = 0; | |
3819 PROCESS_ARG(5); | 3956 PROCESS_ARG(5); |
3820 | 3957 |
3821 TREE_SIDE_EFFECTS (t) = side_effects; | 3958 TREE_SIDE_EFFECTS (t) = side_effects; |
3822 TREE_THIS_VOLATILE (t) = 0; | 3959 TREE_THIS_VOLATILE (t) |
3960 = (code == TARGET_MEM_REF | |
3961 && arg5 && TREE_THIS_VOLATILE (arg5)); | |
3823 | 3962 |
3824 return t; | 3963 return t; |
3964 } | |
3965 | |
3966 /* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF | |
3967 on the pointer PTR. */ | |
3968 | |
3969 tree | |
3970 build_simple_mem_ref_loc (location_t loc, tree ptr) | |
3971 { | |
3972 HOST_WIDE_INT offset = 0; | |
3973 tree ptype = TREE_TYPE (ptr); | |
3974 tree tem; | |
3975 /* For convenience allow addresses that collapse to a simple base | |
3976 and offset. */ | |
3977 if (TREE_CODE (ptr) == ADDR_EXPR | |
3978 && (handled_component_p (TREE_OPERAND (ptr, 0)) | |
3979 || TREE_CODE (TREE_OPERAND (ptr, 0)) == MEM_REF)) | |
3980 { | |
3981 ptr = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &offset); | |
3982 gcc_assert (ptr); | |
3983 ptr = build_fold_addr_expr (ptr); | |
3984 gcc_assert (is_gimple_reg (ptr) || is_gimple_min_invariant (ptr)); | |
3985 } | |
3986 tem = build2 (MEM_REF, TREE_TYPE (ptype), | |
3987 ptr, build_int_cst (ptype, offset)); | |
3988 SET_EXPR_LOCATION (tem, loc); | |
3989 return tem; | |
3990 } | |
3991 | |
3992 /* Return the constant offset of a MEM_REF or TARGET_MEM_REF tree T. */ | |
3993 | |
3994 double_int | |
3995 mem_ref_offset (const_tree t) | |
3996 { | |
3997 tree toff = TREE_OPERAND (t, 1); | |
3998 return double_int_sext (tree_to_double_int (toff), | |
3999 TYPE_PRECISION (TREE_TYPE (toff))); | |
4000 } | |
4001 | |
4002 /* Return the pointer-type relevant for TBAA purposes from the | |
4003 gimple memory reference tree T. This is the type to be used for | |
4004 the offset operand of MEM_REF or TARGET_MEM_REF replacements of T. */ | |
4005 | |
4006 tree | |
4007 reference_alias_ptr_type (const_tree t) | |
4008 { | |
4009 const_tree base = t; | |
4010 while (handled_component_p (base)) | |
4011 base = TREE_OPERAND (base, 0); | |
4012 if (TREE_CODE (base) == MEM_REF) | |
4013 return TREE_TYPE (TREE_OPERAND (base, 1)); | |
4014 else if (TREE_CODE (base) == TARGET_MEM_REF) | |
4015 return TREE_TYPE (TMR_OFFSET (base)); | |
4016 else | |
4017 return build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (base))); | |
3825 } | 4018 } |
3826 | 4019 |
3827 /* Similar except don't specify the TREE_TYPE | 4020 /* Similar except don't specify the TREE_TYPE |
3828 and leave the TREE_SIDE_EFFECTS as 0. | 4021 and leave the TREE_SIDE_EFFECTS as 0. |
3829 It is permissible for arguments to be null, | 4022 It is permissible for arguments to be null, |
3849 | 4042 |
3850 va_end (p); | 4043 va_end (p); |
3851 return t; | 4044 return t; |
3852 } | 4045 } |
3853 | 4046 |
3854 /* Similar to build_nt, but for creating a CALL_EXPR object with | |
3855 ARGLIST passed as a list. */ | |
3856 | |
3857 tree | |
3858 build_nt_call_list (tree fn, tree arglist) | |
3859 { | |
3860 tree t; | |
3861 int i; | |
3862 | |
3863 t = build_vl_exp (CALL_EXPR, list_length (arglist) + 3); | |
3864 CALL_EXPR_FN (t) = fn; | |
3865 CALL_EXPR_STATIC_CHAIN (t) = NULL_TREE; | |
3866 for (i = 0; arglist; arglist = TREE_CHAIN (arglist), i++) | |
3867 CALL_EXPR_ARG (t, i) = TREE_VALUE (arglist); | |
3868 return t; | |
3869 } | |
3870 | |
3871 /* Similar to build_nt, but for creating a CALL_EXPR object with a | 4047 /* Similar to build_nt, but for creating a CALL_EXPR object with a |
3872 tree VEC. */ | 4048 tree VEC. */ |
3873 | 4049 |
3874 tree | 4050 tree |
3875 build_nt_call_vec (tree fn, VEC(tree,gc) *args) | 4051 build_nt_call_vec (tree fn, VEC(tree,gc) *args) |
3878 unsigned int ix; | 4054 unsigned int ix; |
3879 | 4055 |
3880 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); | 4056 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); |
3881 CALL_EXPR_FN (ret) = fn; | 4057 CALL_EXPR_FN (ret) = fn; |
3882 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; | 4058 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; |
3883 for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix) | 4059 FOR_EACH_VEC_ELT (tree, args, ix, t) |
3884 CALL_EXPR_ARG (ret, ix) = t; | 4060 CALL_EXPR_ARG (ret, ix) = t; |
3885 return ret; | 4061 return ret; |
3886 } | 4062 } |
3887 | 4063 |
3888 /* Create a DECL_... node of code CODE, name NAME and data type TYPE. | 4064 /* Create a DECL_... node of code CODE, name NAME and data type TYPE. |
3928 TREE_PUBLIC (decl) = 1; | 4104 TREE_PUBLIC (decl) = 1; |
3929 DECL_ARTIFICIAL (decl) = 1; | 4105 DECL_ARTIFICIAL (decl) = 1; |
3930 TREE_NOTHROW (decl) = 1; | 4106 TREE_NOTHROW (decl) = 1; |
3931 | 4107 |
3932 return decl; | 4108 return decl; |
4109 } | |
4110 | |
4111 VEC(tree,gc) *all_translation_units; | |
4112 | |
4113 /* Builds a new translation-unit decl with name NAME, queues it in the | |
4114 global list of translation-unit decls and returns it. */ | |
4115 | |
4116 tree | |
4117 build_translation_unit_decl (tree name) | |
4118 { | |
4119 tree tu = build_decl (UNKNOWN_LOCATION, TRANSLATION_UNIT_DECL, | |
4120 name, NULL_TREE); | |
4121 TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name; | |
4122 VEC_safe_push (tree, gc, all_translation_units, tu); | |
4123 return tu; | |
3933 } | 4124 } |
3934 | 4125 |
3935 | 4126 |
3936 /* BLOCK nodes are used to represent the structure of binding contours | 4127 /* BLOCK nodes are used to represent the structure of binding contours |
3937 and declarations, once those contours have been exited and their contents | 4128 and declarations, once those contours have been exited and their contents |
3945 BLOCK_VARS (block) = vars; | 4136 BLOCK_VARS (block) = vars; |
3946 BLOCK_SUBBLOCKS (block) = subblocks; | 4137 BLOCK_SUBBLOCKS (block) = subblocks; |
3947 BLOCK_SUPERCONTEXT (block) = supercontext; | 4138 BLOCK_SUPERCONTEXT (block) = supercontext; |
3948 BLOCK_CHAIN (block) = chain; | 4139 BLOCK_CHAIN (block) = chain; |
3949 return block; | 4140 return block; |
3950 } | |
3951 | |
3952 expanded_location | |
3953 expand_location (source_location loc) | |
3954 { | |
3955 expanded_location xloc; | |
3956 if (loc <= BUILTINS_LOCATION) | |
3957 { | |
3958 xloc.file = loc == UNKNOWN_LOCATION ? NULL : _("<built-in>"); | |
3959 xloc.line = 0; | |
3960 xloc.column = 0; | |
3961 xloc.sysp = 0; | |
3962 } | |
3963 else | |
3964 { | |
3965 const struct line_map *map = linemap_lookup (line_table, loc); | |
3966 xloc.file = map->to_file; | |
3967 xloc.line = SOURCE_LINE (map, loc); | |
3968 xloc.column = SOURCE_COLUMN (map, loc); | |
3969 xloc.sysp = map->sysp != 0; | |
3970 }; | |
3971 return xloc; | |
3972 } | 4141 } |
3973 | 4142 |
3974 | 4143 |
3975 /* Like SET_EXPR_LOCATION, but make sure the tree can have a location. | 4144 /* Like SET_EXPR_LOCATION, but make sure the tree can have a location. |
3976 | 4145 |
4143 return build_type_attribute_qual_variant (ttype, attribute, | 4312 return build_type_attribute_qual_variant (ttype, attribute, |
4144 TYPE_QUALS (ttype)); | 4313 TYPE_QUALS (ttype)); |
4145 } | 4314 } |
4146 | 4315 |
4147 | 4316 |
4317 /* Reset the expression *EXPR_P, a size or position. | |
4318 | |
4319 ??? We could reset all non-constant sizes or positions. But it's cheap | |
4320 enough to not do so and refrain from adding workarounds to dwarf2out.c. | |
4321 | |
4322 We need to reset self-referential sizes or positions because they cannot | |
4323 be gimplified and thus can contain a CALL_EXPR after the gimplification | |
4324 is finished, which will run afoul of LTO streaming. And they need to be | |
4325 reset to something essentially dummy but not constant, so as to preserve | |
4326 the properties of the object they are attached to. */ | |
4327 | |
4328 static inline void | |
4329 free_lang_data_in_one_sizepos (tree *expr_p) | |
4330 { | |
4331 tree expr = *expr_p; | |
4332 if (CONTAINS_PLACEHOLDER_P (expr)) | |
4333 *expr_p = build0 (PLACEHOLDER_EXPR, TREE_TYPE (expr)); | |
4334 } | |
4335 | |
4336 | |
4148 /* Reset all the fields in a binfo node BINFO. We only keep | 4337 /* Reset all the fields in a binfo node BINFO. We only keep |
4149 BINFO_VIRTUALS, which is used by gimple_fold_obj_type_ref. */ | 4338 BINFO_VIRTUALS, which is used by gimple_fold_obj_type_ref. */ |
4150 | 4339 |
4151 static void | 4340 static void |
4152 free_lang_data_in_binfo (tree binfo) | 4341 free_lang_data_in_binfo (tree binfo) |
4159 BINFO_VTABLE (binfo) = NULL_TREE; | 4348 BINFO_VTABLE (binfo) = NULL_TREE; |
4160 BINFO_BASE_ACCESSES (binfo) = NULL; | 4349 BINFO_BASE_ACCESSES (binfo) = NULL; |
4161 BINFO_INHERITANCE_CHAIN (binfo) = NULL_TREE; | 4350 BINFO_INHERITANCE_CHAIN (binfo) = NULL_TREE; |
4162 BINFO_SUBVTT_INDEX (binfo) = NULL_TREE; | 4351 BINFO_SUBVTT_INDEX (binfo) = NULL_TREE; |
4163 | 4352 |
4164 for (i = 0; VEC_iterate (tree, BINFO_BASE_BINFOS (binfo), i, t); i++) | 4353 FOR_EACH_VEC_ELT (tree, BINFO_BASE_BINFOS (binfo), i, t) |
4165 free_lang_data_in_binfo (t); | 4354 free_lang_data_in_binfo (t); |
4166 } | 4355 } |
4167 | 4356 |
4168 | 4357 |
4169 /* Reset all language specific information still present in TYPE. */ | 4358 /* Reset all language specific information still present in TYPE. */ |
4249 else | 4438 else |
4250 { | 4439 { |
4251 /* For non-aggregate types, clear out the language slot (which | 4440 /* For non-aggregate types, clear out the language slot (which |
4252 overloads TYPE_BINFO). */ | 4441 overloads TYPE_BINFO). */ |
4253 TYPE_LANG_SLOT_1 (type) = NULL_TREE; | 4442 TYPE_LANG_SLOT_1 (type) = NULL_TREE; |
4254 } | 4443 |
4255 | 4444 if (INTEGRAL_TYPE_P (type) |
4256 TYPE_CONTEXT (type) = NULL_TREE; | 4445 || SCALAR_FLOAT_TYPE_P (type) |
4446 || FIXED_POINT_TYPE_P (type)) | |
4447 { | |
4448 free_lang_data_in_one_sizepos (&TYPE_MIN_VALUE (type)); | |
4449 free_lang_data_in_one_sizepos (&TYPE_MAX_VALUE (type)); | |
4450 } | |
4451 } | |
4452 | |
4453 free_lang_data_in_one_sizepos (&TYPE_SIZE (type)); | |
4454 free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type)); | |
4455 | |
4456 if (debug_info_level < DINFO_LEVEL_TERSE | |
4457 || (TYPE_CONTEXT (type) | |
4458 && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL | |
4459 && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL)) | |
4460 TYPE_CONTEXT (type) = NULL_TREE; | |
4461 | |
4257 if (debug_info_level < DINFO_LEVEL_TERSE) | 4462 if (debug_info_level < DINFO_LEVEL_TERSE) |
4258 TYPE_STUB_DECL (type) = NULL_TREE; | 4463 TYPE_STUB_DECL (type) = NULL_TREE; |
4259 } | 4464 } |
4260 | 4465 |
4261 | 4466 |
4306 | 4511 |
4307 return true; | 4512 return true; |
4308 } | 4513 } |
4309 | 4514 |
4310 | 4515 |
4311 /* Remove all the non-variable decls from BLOCK. LOCALS is the set of | |
4312 variables in DECL_STRUCT_FUNCTION (FN)->local_decls. Every decl | |
4313 in BLOCK that is not in LOCALS is removed. */ | |
4314 | |
4315 static void | |
4316 free_lang_data_in_block (tree fn, tree block, struct pointer_set_t *locals) | |
4317 { | |
4318 tree *tp, t; | |
4319 | |
4320 tp = &BLOCK_VARS (block); | |
4321 while (*tp) | |
4322 { | |
4323 if (!pointer_set_contains (locals, *tp)) | |
4324 *tp = TREE_CHAIN (*tp); | |
4325 else | |
4326 tp = &TREE_CHAIN (*tp); | |
4327 } | |
4328 | |
4329 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t)) | |
4330 free_lang_data_in_block (fn, t, locals); | |
4331 } | |
4332 | |
4333 | |
4334 /* Reset all language specific information still present in symbol | 4516 /* Reset all language specific information still present in symbol |
4335 DECL. */ | 4517 DECL. */ |
4336 | 4518 |
4337 static void | 4519 static void |
4338 free_lang_data_in_decl (tree decl) | 4520 free_lang_data_in_decl (tree decl) |
4352 | 4534 |
4353 /* Identifiers need not have a type. */ | 4535 /* Identifiers need not have a type. */ |
4354 if (DECL_NAME (decl)) | 4536 if (DECL_NAME (decl)) |
4355 TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; | 4537 TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; |
4356 | 4538 |
4357 /* Ignore any intervening types, because we are going to clear their | 4539 free_lang_data_in_one_sizepos (&DECL_SIZE (decl)); |
4358 TYPE_CONTEXT fields. */ | 4540 free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl)); |
4359 if (TREE_CODE (decl) != FIELD_DECL) | 4541 if (TREE_CODE (decl) == FIELD_DECL) |
4360 DECL_CONTEXT (decl) = decl_function_context (decl); | 4542 free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl)); |
4361 | |
4362 if (DECL_CONTEXT (decl) | |
4363 && TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL) | |
4364 DECL_CONTEXT (decl) = NULL_TREE; | |
4365 | |
4366 if (TREE_CODE (decl) == VAR_DECL) | |
4367 { | |
4368 tree context = DECL_CONTEXT (decl); | |
4369 | |
4370 if (context) | |
4371 { | |
4372 enum tree_code code = TREE_CODE (context); | |
4373 if (code == FUNCTION_DECL && DECL_ABSTRACT (context)) | |
4374 { | |
4375 /* Do not clear the decl context here, that will promote | |
4376 all vars to global ones. */ | |
4377 DECL_INITIAL (decl) = NULL_TREE; | |
4378 } | |
4379 | |
4380 if (TREE_STATIC (decl)) | |
4381 DECL_CONTEXT (decl) = NULL_TREE; | |
4382 } | |
4383 } | |
4384 | |
4385 /* ??? We could free non-constant DECL_SIZE, DECL_SIZE_UNIT | |
4386 and DECL_FIELD_OFFSET. But it's cheap enough to not do | |
4387 that and refrain from adding workarounds to dwarf2out.c */ | |
4388 | 4543 |
4389 /* DECL_FCONTEXT is only used for debug info generation. */ | 4544 /* DECL_FCONTEXT is only used for debug info generation. */ |
4390 if (TREE_CODE (decl) == FIELD_DECL | 4545 if (TREE_CODE (decl) == FIELD_DECL |
4391 && debug_info_level < DINFO_LEVEL_TERSE) | 4546 && debug_info_level < DINFO_LEVEL_TERSE) |
4392 DECL_FCONTEXT (decl) = NULL_TREE; | 4547 DECL_FCONTEXT (decl) = NULL_TREE; |
4394 if (TREE_CODE (decl) == FUNCTION_DECL) | 4549 if (TREE_CODE (decl) == FUNCTION_DECL) |
4395 { | 4550 { |
4396 if (gimple_has_body_p (decl)) | 4551 if (gimple_has_body_p (decl)) |
4397 { | 4552 { |
4398 tree t; | 4553 tree t; |
4399 struct pointer_set_t *locals; | |
4400 | 4554 |
4401 /* If DECL has a gimple body, then the context for its | 4555 /* If DECL has a gimple body, then the context for its |
4402 arguments must be DECL. Otherwise, it doesn't really | 4556 arguments must be DECL. Otherwise, it doesn't really |
4403 matter, as we will not be emitting any code for DECL. In | 4557 matter, as we will not be emitting any code for DECL. In |
4404 general, there may be other instances of DECL created by | 4558 general, there may be other instances of DECL created by |
4407 created. The only time where DECL_CONTEXT is important | 4561 created. The only time where DECL_CONTEXT is important |
4408 is for the FUNCTION_DECLs that have a gimple body (since | 4562 is for the FUNCTION_DECLs that have a gimple body (since |
4409 the PARM_DECL will be used in the function's body). */ | 4563 the PARM_DECL will be used in the function's body). */ |
4410 for (t = DECL_ARGUMENTS (decl); t; t = TREE_CHAIN (t)) | 4564 for (t = DECL_ARGUMENTS (decl); t; t = TREE_CHAIN (t)) |
4411 DECL_CONTEXT (t) = decl; | 4565 DECL_CONTEXT (t) = decl; |
4412 | |
4413 /* Collect all the symbols declared in DECL. */ | |
4414 locals = pointer_set_create (); | |
4415 t = DECL_STRUCT_FUNCTION (decl)->local_decls; | |
4416 for (; t; t = TREE_CHAIN (t)) | |
4417 { | |
4418 pointer_set_insert (locals, TREE_VALUE (t)); | |
4419 | |
4420 /* All the local symbols should have DECL as their | |
4421 context. */ | |
4422 DECL_CONTEXT (TREE_VALUE (t)) = decl; | |
4423 } | |
4424 | |
4425 /* Get rid of any decl not in local_decls. */ | |
4426 free_lang_data_in_block (decl, DECL_INITIAL (decl), locals); | |
4427 | |
4428 pointer_set_destroy (locals); | |
4429 } | 4566 } |
4430 | 4567 |
4431 /* DECL_SAVED_TREE holds the GENERIC representation for DECL. | 4568 /* DECL_SAVED_TREE holds the GENERIC representation for DECL. |
4432 At this point, it is not needed anymore. */ | 4569 At this point, it is not needed anymore. */ |
4433 DECL_SAVED_TREE (decl) = NULL_TREE; | 4570 DECL_SAVED_TREE (decl) = NULL_TREE; |
4571 | |
4572 /* Clear the abstract origin if it refers to a method. Otherwise | |
4573 dwarf2out.c will ICE as we clear TYPE_METHODS and thus the | |
4574 origin will not be output correctly. */ | |
4575 if (DECL_ABSTRACT_ORIGIN (decl) | |
4576 && DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl)) | |
4577 && RECORD_OR_UNION_TYPE_P | |
4578 (DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl)))) | |
4579 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; | |
4434 } | 4580 } |
4435 else if (TREE_CODE (decl) == VAR_DECL) | 4581 else if (TREE_CODE (decl) == VAR_DECL) |
4436 { | 4582 { |
4437 tree expr = DECL_DEBUG_EXPR (decl); | 4583 if ((DECL_EXTERNAL (decl) |
4438 if (expr | 4584 && (!TREE_STATIC (decl) || !TREE_READONLY (decl))) |
4439 && TREE_CODE (expr) == VAR_DECL | 4585 || (decl_function_context (decl) && !TREE_STATIC (decl))) |
4440 && !TREE_STATIC (expr) && !DECL_EXTERNAL (expr)) | |
4441 SET_DECL_DEBUG_EXPR (decl, NULL_TREE); | |
4442 | |
4443 if (DECL_EXTERNAL (decl) | |
4444 && (!TREE_STATIC (decl) || !TREE_READONLY (decl))) | |
4445 DECL_INITIAL (decl) = NULL_TREE; | 4586 DECL_INITIAL (decl) = NULL_TREE; |
4446 } | 4587 } |
4447 else if (TREE_CODE (decl) == TYPE_DECL) | 4588 else if (TREE_CODE (decl) == TYPE_DECL) |
4448 { | 4589 DECL_INITIAL (decl) = NULL_TREE; |
4449 DECL_INITIAL (decl) = NULL_TREE; | 4590 else if (TREE_CODE (decl) == TRANSLATION_UNIT_DECL |
4450 | 4591 && DECL_INITIAL (decl) |
4451 /* DECL_CONTEXT is overloaded as DECL_FIELD_CONTEXT for | 4592 && TREE_CODE (DECL_INITIAL (decl)) == BLOCK) |
4452 FIELD_DECLs, which should be preserved. Otherwise, | 4593 { |
4453 we shouldn't be concerned with source-level lexical | 4594 /* Strip builtins from the translation-unit BLOCK. We still have |
4454 nesting beyond this point. */ | 4595 targets without builtin_decl support and also builtins are |
4455 DECL_CONTEXT (decl) = NULL_TREE; | 4596 shared nodes and thus we can't use TREE_CHAIN in multiple |
4597 lists. */ | |
4598 tree *nextp = &BLOCK_VARS (DECL_INITIAL (decl)); | |
4599 while (*nextp) | |
4600 { | |
4601 tree var = *nextp; | |
4602 if (TREE_CODE (var) == FUNCTION_DECL | |
4603 && DECL_BUILT_IN (var)) | |
4604 *nextp = TREE_CHAIN (var); | |
4605 else | |
4606 nextp = &TREE_CHAIN (var); | |
4607 } | |
4456 } | 4608 } |
4457 } | 4609 } |
4458 | 4610 |
4459 | 4611 |
4460 /* Data used when collecting DECLs and TYPEs for language data removal. */ | 4612 /* Data used when collecting DECLs and TYPEs for language data removal. */ |
4596 { | 4748 { |
4597 fld_worklist_push (DECL_SECTION_NAME (t), fld); | 4749 fld_worklist_push (DECL_SECTION_NAME (t), fld); |
4598 fld_worklist_push (DECL_COMDAT_GROUP (t), fld); | 4750 fld_worklist_push (DECL_COMDAT_GROUP (t), fld); |
4599 } | 4751 } |
4600 | 4752 |
4601 if (TREE_CODE (t) != FIELD_DECL) | 4753 if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL) |
4754 && DECL_HAS_VALUE_EXPR_P (t)) | |
4755 fld_worklist_push (DECL_VALUE_EXPR (t), fld); | |
4756 | |
4757 if (TREE_CODE (t) != FIELD_DECL | |
4758 && TREE_CODE (t) != TYPE_DECL) | |
4602 fld_worklist_push (TREE_CHAIN (t), fld); | 4759 fld_worklist_push (TREE_CHAIN (t), fld); |
4603 *ws = 0; | 4760 *ws = 0; |
4604 } | 4761 } |
4605 else if (TYPE_P (t)) | 4762 else if (TYPE_P (t)) |
4606 { | 4763 { |
4614 fld_worklist_push (TYPE_SIZE_UNIT (t), fld); | 4771 fld_worklist_push (TYPE_SIZE_UNIT (t), fld); |
4615 fld_worklist_push (TYPE_ATTRIBUTES (t), fld); | 4772 fld_worklist_push (TYPE_ATTRIBUTES (t), fld); |
4616 fld_worklist_push (TYPE_POINTER_TO (t), fld); | 4773 fld_worklist_push (TYPE_POINTER_TO (t), fld); |
4617 fld_worklist_push (TYPE_REFERENCE_TO (t), fld); | 4774 fld_worklist_push (TYPE_REFERENCE_TO (t), fld); |
4618 fld_worklist_push (TYPE_NAME (t), fld); | 4775 fld_worklist_push (TYPE_NAME (t), fld); |
4619 fld_worklist_push (TYPE_MINVAL (t), fld); | 4776 /* Do not walk TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO. We do not stream |
4777 them and thus do not and want not to reach unused pointer types | |
4778 this way. */ | |
4779 if (!POINTER_TYPE_P (t)) | |
4780 fld_worklist_push (TYPE_MINVAL (t), fld); | |
4620 if (!RECORD_OR_UNION_TYPE_P (t)) | 4781 if (!RECORD_OR_UNION_TYPE_P (t)) |
4621 fld_worklist_push (TYPE_MAXVAL (t), fld); | 4782 fld_worklist_push (TYPE_MAXVAL (t), fld); |
4622 fld_worklist_push (TYPE_MAIN_VARIANT (t), fld); | 4783 fld_worklist_push (TYPE_MAIN_VARIANT (t), fld); |
4623 fld_worklist_push (TYPE_NEXT_VARIANT (t), fld); | 4784 /* Do not walk TYPE_NEXT_VARIANT. We do not stream it and thus |
4785 do not and want not to reach unused variants this way. */ | |
4624 fld_worklist_push (TYPE_CONTEXT (t), fld); | 4786 fld_worklist_push (TYPE_CONTEXT (t), fld); |
4625 fld_worklist_push (TYPE_CANONICAL (t), fld); | 4787 /* Do not walk TYPE_CANONICAL. We do not stream it and thus do not |
4788 and want not to reach unused types this way. */ | |
4626 | 4789 |
4627 if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t)) | 4790 if (RECORD_OR_UNION_TYPE_P (t) && TYPE_BINFO (t)) |
4628 { | 4791 { |
4629 unsigned i; | 4792 unsigned i; |
4630 tree tem; | 4793 tree tem; |
4657 } | 4820 } |
4658 | 4821 |
4659 fld_worklist_push (TREE_CHAIN (t), fld); | 4822 fld_worklist_push (TREE_CHAIN (t), fld); |
4660 *ws = 0; | 4823 *ws = 0; |
4661 } | 4824 } |
4662 | 4825 else if (TREE_CODE (t) == BLOCK) |
4663 fld_worklist_push (TREE_TYPE (t), fld); | 4826 { |
4827 tree tem; | |
4828 for (tem = BLOCK_VARS (t); tem; tem = TREE_CHAIN (tem)) | |
4829 fld_worklist_push (tem, fld); | |
4830 for (tem = BLOCK_SUBBLOCKS (t); tem; tem = BLOCK_CHAIN (tem)) | |
4831 fld_worklist_push (tem, fld); | |
4832 fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld); | |
4833 } | |
4834 | |
4835 if (TREE_CODE (t) != IDENTIFIER_NODE) | |
4836 fld_worklist_push (TREE_TYPE (t), fld); | |
4664 | 4837 |
4665 return NULL_TREE; | 4838 return NULL_TREE; |
4666 } | 4839 } |
4667 | 4840 |
4668 | 4841 |
4756 static void | 4929 static void |
4757 find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) | 4930 find_decls_types_in_node (struct cgraph_node *n, struct free_lang_data_d *fld) |
4758 { | 4931 { |
4759 basic_block bb; | 4932 basic_block bb; |
4760 struct function *fn; | 4933 struct function *fn; |
4934 unsigned ix; | |
4761 tree t; | 4935 tree t; |
4762 | 4936 |
4763 find_decls_types (n->decl, fld); | 4937 find_decls_types (n->decl, fld); |
4764 | 4938 |
4765 if (!gimple_has_body_p (n->decl)) | 4939 if (!gimple_has_body_p (n->decl)) |
4768 gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); | 4942 gcc_assert (current_function_decl == NULL_TREE && cfun == NULL); |
4769 | 4943 |
4770 fn = DECL_STRUCT_FUNCTION (n->decl); | 4944 fn = DECL_STRUCT_FUNCTION (n->decl); |
4771 | 4945 |
4772 /* Traverse locals. */ | 4946 /* Traverse locals. */ |
4773 for (t = fn->local_decls; t; t = TREE_CHAIN (t)) | 4947 FOR_EACH_LOCAL_DECL (fn, ix, t) |
4774 find_decls_types (TREE_VALUE (t), fld); | 4948 find_decls_types (t, fld); |
4775 | 4949 |
4776 /* Traverse EH regions in FN. */ | 4950 /* Traverse EH regions in FN. */ |
4777 { | 4951 { |
4778 eh_region r; | 4952 eh_region r; |
4779 FOR_ALL_EH_REGION_FN (r, fn) | 4953 FOR_ALL_EH_REGION_FN (r, fn) |
4821 find_decls_types_in_var (struct varpool_node *v, struct free_lang_data_d *fld) | 4995 find_decls_types_in_var (struct varpool_node *v, struct free_lang_data_d *fld) |
4822 { | 4996 { |
4823 find_decls_types (v->decl, fld); | 4997 find_decls_types (v->decl, fld); |
4824 } | 4998 } |
4825 | 4999 |
5000 /* If T needs an assembler name, have one created for it. */ | |
5001 | |
5002 void | |
5003 assign_assembler_name_if_neeeded (tree t) | |
5004 { | |
5005 if (need_assembler_name_p (t)) | |
5006 { | |
5007 /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit | |
5008 diagnostics that use input_location to show locus | |
5009 information. The problem here is that, at this point, | |
5010 input_location is generally anchored to the end of the file | |
5011 (since the parser is long gone), so we don't have a good | |
5012 position to pin it to. | |
5013 | |
5014 To alleviate this problem, this uses the location of T's | |
5015 declaration. Examples of this are | |
5016 testsuite/g++.dg/template/cond2.C and | |
5017 testsuite/g++.dg/template/pr35240.C. */ | |
5018 location_t saved_location = input_location; | |
5019 input_location = DECL_SOURCE_LOCATION (t); | |
5020 | |
5021 decl_assembler_name (t); | |
5022 | |
5023 input_location = saved_location; | |
5024 } | |
5025 } | |
5026 | |
4826 | 5027 |
4827 /* Free language specific information for every operand and expression | 5028 /* Free language specific information for every operand and expression |
4828 in every node of the call graph. This process operates in three stages: | 5029 in every node of the call graph. This process operates in three stages: |
4829 | 5030 |
4830 1- Every callgraph node and varpool node is traversed looking for | 5031 1- Every callgraph node and varpool node is traversed looking for |
4859 | 5060 |
4860 /* Find decls and types in the body of every function in the callgraph. */ | 5061 /* Find decls and types in the body of every function in the callgraph. */ |
4861 for (n = cgraph_nodes; n; n = n->next) | 5062 for (n = cgraph_nodes; n; n = n->next) |
4862 find_decls_types_in_node (n, &fld); | 5063 find_decls_types_in_node (n, &fld); |
4863 | 5064 |
4864 for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++) | 5065 FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p) |
4865 find_decls_types (p->decl, &fld); | 5066 find_decls_types (p->decl, &fld); |
4866 | 5067 |
4867 /* Find decls and types in every varpool symbol. */ | 5068 /* Find decls and types in every varpool symbol. */ |
4868 for (v = varpool_nodes_queue; v; v = v->next_needed) | 5069 for (v = varpool_nodes; v; v = v->next) |
4869 find_decls_types_in_var (v, &fld); | 5070 find_decls_types_in_var (v, &fld); |
4870 | 5071 |
4871 /* Set the assembler name on every decl found. We need to do this | 5072 /* Set the assembler name on every decl found. We need to do this |
4872 now because free_lang_data_in_decl will invalidate data needed | 5073 now because free_lang_data_in_decl will invalidate data needed |
4873 for mangling. This breaks mangling on interdependent decls. */ | 5074 for mangling. This breaks mangling on interdependent decls. */ |
4874 for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) | 5075 FOR_EACH_VEC_ELT (tree, fld.decls, i, t) |
4875 if (need_assembler_name_p (t)) | 5076 assign_assembler_name_if_neeeded (t); |
4876 { | |
4877 /* When setting DECL_ASSEMBLER_NAME, the C++ mangler may emit | |
4878 diagnostics that use input_location to show locus | |
4879 information. The problem here is that, at this point, | |
4880 input_location is generally anchored to the end of the file | |
4881 (since the parser is long gone), so we don't have a good | |
4882 position to pin it to. | |
4883 | |
4884 To alleviate this problem, this uses the location of T's | |
4885 declaration. Examples of this are | |
4886 testsuite/g++.dg/template/cond2.C and | |
4887 testsuite/g++.dg/template/pr35240.C. */ | |
4888 location_t saved_location = input_location; | |
4889 input_location = DECL_SOURCE_LOCATION (t); | |
4890 | |
4891 decl_assembler_name (t); | |
4892 | |
4893 input_location = saved_location; | |
4894 } | |
4895 | 5077 |
4896 /* Traverse every decl found freeing its language data. */ | 5078 /* Traverse every decl found freeing its language data. */ |
4897 for (i = 0; VEC_iterate (tree, fld.decls, i, t); i++) | 5079 FOR_EACH_VEC_ELT (tree, fld.decls, i, t) |
4898 free_lang_data_in_decl (t); | 5080 free_lang_data_in_decl (t); |
4899 | 5081 |
4900 /* Traverse every type found freeing its language data. */ | 5082 /* Traverse every type found freeing its language data. */ |
4901 for (i = 0; VEC_iterate (tree, fld.types, i, t); i++) | 5083 FOR_EACH_VEC_ELT (tree, fld.types, i, t) |
4902 free_lang_data_in_type (t); | 5084 free_lang_data_in_type (t); |
4903 | 5085 |
4904 pointer_set_destroy (fld.pset); | 5086 pointer_set_destroy (fld.pset); |
4905 VEC_free (tree, heap, fld.worklist); | 5087 VEC_free (tree, heap, fld.worklist); |
4906 VEC_free (tree, heap, fld.decls); | 5088 VEC_free (tree, heap, fld.decls); |
4957 still be used indirectly via the get_alias_set langhook. */ | 5139 still be used indirectly via the get_alias_set langhook. */ |
4958 lang_hooks.callgraph.analyze_expr = NULL; | 5140 lang_hooks.callgraph.analyze_expr = NULL; |
4959 lang_hooks.dwarf_name = lhd_dwarf_name; | 5141 lang_hooks.dwarf_name = lhd_dwarf_name; |
4960 lang_hooks.decl_printable_name = gimple_decl_printable_name; | 5142 lang_hooks.decl_printable_name = gimple_decl_printable_name; |
4961 lang_hooks.set_decl_assembler_name = lhd_set_decl_assembler_name; | 5143 lang_hooks.set_decl_assembler_name = lhd_set_decl_assembler_name; |
4962 lang_hooks.fold_obj_type_ref = gimple_fold_obj_type_ref; | |
4963 | 5144 |
4964 /* Reset diagnostic machinery. */ | 5145 /* Reset diagnostic machinery. */ |
4965 diagnostic_starter (global_dc) = default_diagnostic_starter; | 5146 diagnostic_starter (global_dc) = default_tree_diagnostic_starter; |
4966 diagnostic_finalizer (global_dc) = default_diagnostic_finalizer; | 5147 diagnostic_finalizer (global_dc) = default_diagnostic_finalizer; |
4967 diagnostic_format_decoder (global_dc) = default_tree_printer; | 5148 diagnostic_format_decoder (global_dc) = default_tree_printer; |
4968 | 5149 |
4969 return 0; | 5150 return 0; |
4970 } | 5151 } |
5356 | 5537 |
5357 if (*no_add_attrs == false) | 5538 if (*no_add_attrs == false) |
5358 DECL_DLLIMPORT_P (node) = 1; | 5539 DECL_DLLIMPORT_P (node) = 1; |
5359 } | 5540 } |
5360 else if (TREE_CODE (node) == FUNCTION_DECL | 5541 else if (TREE_CODE (node) == FUNCTION_DECL |
5361 && DECL_DECLARED_INLINE_P (node)) | 5542 && DECL_DECLARED_INLINE_P (node) |
5543 && flag_keep_inline_dllexport) | |
5362 /* An exported function, even if inline, must be emitted. */ | 5544 /* An exported function, even if inline, must be emitted. */ |
5363 DECL_EXTERNAL (node) = 0; | 5545 DECL_EXTERNAL (node) = 0; |
5364 | 5546 |
5365 /* Report error if symbol is not accessible at global scope. */ | 5547 /* Report error if symbol is not accessible at global scope. */ |
5366 if (!TREE_PUBLIC (node) | 5548 if (!TREE_PUBLIC (node) |
5412 { | 5594 { |
5413 return (TYPE_QUALS (cand) == type_quals | 5595 return (TYPE_QUALS (cand) == type_quals |
5414 && TYPE_NAME (cand) == TYPE_NAME (base) | 5596 && TYPE_NAME (cand) == TYPE_NAME (base) |
5415 /* Apparently this is needed for Objective-C. */ | 5597 /* Apparently this is needed for Objective-C. */ |
5416 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) | 5598 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) |
5599 /* Check alignment. */ | |
5600 && TYPE_ALIGN (cand) == TYPE_ALIGN (base) | |
5601 && attribute_list_equal (TYPE_ATTRIBUTES (cand), | |
5602 TYPE_ATTRIBUTES (base))); | |
5603 } | |
5604 | |
5605 /* Returns true iff CAND is equivalent to BASE with ALIGN. */ | |
5606 | |
5607 static bool | |
5608 check_aligned_type (const_tree cand, const_tree base, unsigned int align) | |
5609 { | |
5610 return (TYPE_QUALS (cand) == TYPE_QUALS (base) | |
5611 && TYPE_NAME (cand) == TYPE_NAME (base) | |
5612 /* Apparently this is needed for Objective-C. */ | |
5613 && TYPE_CONTEXT (cand) == TYPE_CONTEXT (base) | |
5614 /* Check alignment. */ | |
5615 && TYPE_ALIGN (cand) == align | |
5417 && attribute_list_equal (TYPE_ATTRIBUTES (cand), | 5616 && attribute_list_equal (TYPE_ATTRIBUTES (cand), |
5418 TYPE_ATTRIBUTES (base))); | 5617 TYPE_ATTRIBUTES (base))); |
5419 } | 5618 } |
5420 | 5619 |
5421 /* Return a version of the TYPE, qualified as indicated by the | 5620 /* Return a version of the TYPE, qualified as indicated by the |
5472 } | 5671 } |
5473 | 5672 |
5474 return t; | 5673 return t; |
5475 } | 5674 } |
5476 | 5675 |
5676 /* Create a variant of type T with alignment ALIGN. */ | |
5677 | |
5678 tree | |
5679 build_aligned_type (tree type, unsigned int align) | |
5680 { | |
5681 tree t; | |
5682 | |
5683 if (TYPE_PACKED (type) | |
5684 || TYPE_ALIGN (type) == align) | |
5685 return type; | |
5686 | |
5687 for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) | |
5688 if (check_aligned_type (t, type, align)) | |
5689 return t; | |
5690 | |
5691 t = build_variant_type_copy (type); | |
5692 TYPE_ALIGN (t) = align; | |
5693 | |
5694 return t; | |
5695 } | |
5696 | |
5477 /* Create a new distinct copy of TYPE. The new type is made its own | 5697 /* Create a new distinct copy of TYPE. The new type is made its own |
5478 MAIN_VARIANT. If TYPE requires structural equality checks, the | 5698 MAIN_VARIANT. If TYPE requires structural equality checks, the |
5479 resulting type requires structural equality checks; otherwise, its | 5699 resulting type requires structural equality checks; otherwise, its |
5480 TYPE_CANONICAL points to itself. */ | 5700 TYPE_CANONICAL points to itself. */ |
5481 | 5701 |
5538 const struct tree_map_base *const a = (const struct tree_map_base *) va, | 5758 const struct tree_map_base *const a = (const struct tree_map_base *) va, |
5539 *const b = (const struct tree_map_base *) vb; | 5759 *const b = (const struct tree_map_base *) vb; |
5540 return (a->from == b->from); | 5760 return (a->from == b->from); |
5541 } | 5761 } |
5542 | 5762 |
5543 /* Hash a from tree in a tree_map. */ | 5763 /* Hash a from tree in a tree_base_map. */ |
5544 | 5764 |
5545 unsigned int | 5765 unsigned int |
5546 tree_map_base_hash (const void *item) | 5766 tree_map_base_hash (const void *item) |
5547 { | 5767 { |
5548 return htab_hash_pointer (((const struct tree_map_base *)item)->from); | 5768 return htab_hash_pointer (((const struct tree_map_base *)item)->from); |
5556 tree_map_base_marked_p (const void *p) | 5776 tree_map_base_marked_p (const void *p) |
5557 { | 5777 { |
5558 return ggc_marked_p (((const struct tree_map_base *) p)->from); | 5778 return ggc_marked_p (((const struct tree_map_base *) p)->from); |
5559 } | 5779 } |
5560 | 5780 |
5781 /* Hash a from tree in a tree_map. */ | |
5782 | |
5561 unsigned int | 5783 unsigned int |
5562 tree_map_hash (const void *item) | 5784 tree_map_hash (const void *item) |
5563 { | 5785 { |
5564 return (((const struct tree_map *) item)->hash); | 5786 return (((const struct tree_map *) item)->hash); |
5787 } | |
5788 | |
5789 /* Hash a from tree in a tree_decl_map. */ | |
5790 | |
5791 unsigned int | |
5792 tree_decl_map_hash (const void *item) | |
5793 { | |
5794 return DECL_UID (((const struct tree_decl_map *) item)->base.from); | |
5565 } | 5795 } |
5566 | 5796 |
5567 /* Return the initialization priority for DECL. */ | 5797 /* Return the initialization priority for DECL. */ |
5568 | 5798 |
5569 priority_type | 5799 priority_type |
5606 in.base.from = decl; | 5836 in.base.from = decl; |
5607 loc = htab_find_slot (init_priority_for_decl, &in, INSERT); | 5837 loc = htab_find_slot (init_priority_for_decl, &in, INSERT); |
5608 h = (struct tree_priority_map *) *loc; | 5838 h = (struct tree_priority_map *) *loc; |
5609 if (!h) | 5839 if (!h) |
5610 { | 5840 { |
5611 h = GGC_CNEW (struct tree_priority_map); | 5841 h = ggc_alloc_cleared_tree_priority_map (); |
5612 *loc = h; | 5842 *loc = h; |
5613 h->base.from = decl; | 5843 h->base.from = decl; |
5614 h->init = DEFAULT_INIT_PRIORITY; | 5844 h->init = DEFAULT_INIT_PRIORITY; |
5615 h->fini = DEFAULT_INIT_PRIORITY; | 5845 h->fini = DEFAULT_INIT_PRIORITY; |
5616 } | 5846 } |
5667 /* Lookup a debug expression for FROM, and return it if we find one. */ | 5897 /* Lookup a debug expression for FROM, and return it if we find one. */ |
5668 | 5898 |
5669 tree | 5899 tree |
5670 decl_debug_expr_lookup (tree from) | 5900 decl_debug_expr_lookup (tree from) |
5671 { | 5901 { |
5672 struct tree_map *h, in; | 5902 struct tree_decl_map *h, in; |
5673 in.base.from = from; | 5903 in.base.from = from; |
5674 | 5904 |
5675 h = (struct tree_map *) htab_find_with_hash (debug_expr_for_decl, &in, | 5905 h = (struct tree_decl_map *) |
5676 htab_hash_pointer (from)); | 5906 htab_find_with_hash (debug_expr_for_decl, &in, DECL_UID (from)); |
5677 if (h) | 5907 if (h) |
5678 return h->to; | 5908 return h->to; |
5679 return NULL_TREE; | 5909 return NULL_TREE; |
5680 } | 5910 } |
5681 | 5911 |
5682 /* Insert a mapping FROM->TO in the debug expression hashtable. */ | 5912 /* Insert a mapping FROM->TO in the debug expression hashtable. */ |
5683 | 5913 |
5684 void | 5914 void |
5685 decl_debug_expr_insert (tree from, tree to) | 5915 decl_debug_expr_insert (tree from, tree to) |
5686 { | 5916 { |
5687 struct tree_map *h; | 5917 struct tree_decl_map *h; |
5688 void **loc; | 5918 void **loc; |
5689 | 5919 |
5690 h = GGC_NEW (struct tree_map); | 5920 h = ggc_alloc_tree_decl_map (); |
5691 h->hash = htab_hash_pointer (from); | |
5692 h->base.from = from; | 5921 h->base.from = from; |
5693 h->to = to; | 5922 h->to = to; |
5694 loc = htab_find_slot_with_hash (debug_expr_for_decl, h, h->hash, INSERT); | 5923 loc = htab_find_slot_with_hash (debug_expr_for_decl, h, DECL_UID (from), |
5695 *(struct tree_map **) loc = h; | 5924 INSERT); |
5925 *(struct tree_decl_map **) loc = h; | |
5696 } | 5926 } |
5697 | 5927 |
5698 /* Lookup a value expression for FROM, and return it if we find one. */ | 5928 /* Lookup a value expression for FROM, and return it if we find one. */ |
5699 | 5929 |
5700 tree | 5930 tree |
5701 decl_value_expr_lookup (tree from) | 5931 decl_value_expr_lookup (tree from) |
5702 { | 5932 { |
5703 struct tree_map *h, in; | 5933 struct tree_decl_map *h, in; |
5704 in.base.from = from; | 5934 in.base.from = from; |
5705 | 5935 |
5706 h = (struct tree_map *) htab_find_with_hash (value_expr_for_decl, &in, | 5936 h = (struct tree_decl_map *) |
5707 htab_hash_pointer (from)); | 5937 htab_find_with_hash (value_expr_for_decl, &in, DECL_UID (from)); |
5708 if (h) | 5938 if (h) |
5709 return h->to; | 5939 return h->to; |
5710 return NULL_TREE; | 5940 return NULL_TREE; |
5711 } | 5941 } |
5712 | 5942 |
5713 /* Insert a mapping FROM->TO in the value expression hashtable. */ | 5943 /* Insert a mapping FROM->TO in the value expression hashtable. */ |
5714 | 5944 |
5715 void | 5945 void |
5716 decl_value_expr_insert (tree from, tree to) | 5946 decl_value_expr_insert (tree from, tree to) |
5717 { | 5947 { |
5718 struct tree_map *h; | 5948 struct tree_decl_map *h; |
5719 void **loc; | 5949 void **loc; |
5720 | 5950 |
5721 h = GGC_NEW (struct tree_map); | 5951 h = ggc_alloc_tree_decl_map (); |
5722 h->hash = htab_hash_pointer (from); | |
5723 h->base.from = from; | 5952 h->base.from = from; |
5724 h->to = to; | 5953 h->to = to; |
5725 loc = htab_find_slot_with_hash (value_expr_for_decl, h, h->hash, INSERT); | 5954 loc = htab_find_slot_with_hash (value_expr_for_decl, h, DECL_UID (from), |
5726 *(struct tree_map **) loc = h; | 5955 INSERT); |
5956 *(struct tree_decl_map **) loc = h; | |
5727 } | 5957 } |
5728 | 5958 |
5729 /* Hashing of types so that we don't make duplicates. | 5959 /* Hashing of types so that we don't make duplicates. |
5730 The entry point is `type_hash_canon'. */ | 5960 The entry point is `type_hash_canon'. */ |
5731 | 5961 |
5760 if (a->hash != b->hash | 5990 if (a->hash != b->hash |
5761 || TREE_CODE (a->type) != TREE_CODE (b->type) | 5991 || TREE_CODE (a->type) != TREE_CODE (b->type) |
5762 || TREE_TYPE (a->type) != TREE_TYPE (b->type) | 5992 || TREE_TYPE (a->type) != TREE_TYPE (b->type) |
5763 || !attribute_list_equal (TYPE_ATTRIBUTES (a->type), | 5993 || !attribute_list_equal (TYPE_ATTRIBUTES (a->type), |
5764 TYPE_ATTRIBUTES (b->type)) | 5994 TYPE_ATTRIBUTES (b->type)) |
5765 || TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) | |
5766 || TYPE_MODE (a->type) != TYPE_MODE (b->type) | |
5767 || (TREE_CODE (a->type) != COMPLEX_TYPE | 5995 || (TREE_CODE (a->type) != COMPLEX_TYPE |
5768 && TYPE_NAME (a->type) != TYPE_NAME (b->type))) | 5996 && TYPE_NAME (a->type) != TYPE_NAME (b->type))) |
5997 return 0; | |
5998 | |
5999 /* Be careful about comparing arrays before and after the element type | |
6000 has been completed; don't compare TYPE_ALIGN unless both types are | |
6001 complete. */ | |
6002 if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type) | |
6003 && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) | |
6004 || TYPE_MODE (a->type) != TYPE_MODE (b->type))) | |
5769 return 0; | 6005 return 0; |
5770 | 6006 |
5771 switch (TREE_CODE (a->type)) | 6007 switch (TREE_CODE (a->type)) |
5772 { | 6008 { |
5773 case VOID_TYPE: | 6009 case VOID_TYPE: |
5806 | 6042 |
5807 case OFFSET_TYPE: | 6043 case OFFSET_TYPE: |
5808 return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type); | 6044 return TYPE_OFFSET_BASETYPE (a->type) == TYPE_OFFSET_BASETYPE (b->type); |
5809 | 6045 |
5810 case METHOD_TYPE: | 6046 case METHOD_TYPE: |
5811 return (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type) | 6047 if (TYPE_METHOD_BASETYPE (a->type) == TYPE_METHOD_BASETYPE (b->type) |
5812 && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type) | 6048 && (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type) |
5813 || (TYPE_ARG_TYPES (a->type) | 6049 || (TYPE_ARG_TYPES (a->type) |
5814 && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST | 6050 && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST |
5815 && TYPE_ARG_TYPES (b->type) | 6051 && TYPE_ARG_TYPES (b->type) |
5816 && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST | 6052 && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST |
5817 && type_list_equal (TYPE_ARG_TYPES (a->type), | 6053 && type_list_equal (TYPE_ARG_TYPES (a->type), |
5818 TYPE_ARG_TYPES (b->type))))); | 6054 TYPE_ARG_TYPES (b->type))))) |
5819 | 6055 break; |
6056 return 0; | |
5820 case ARRAY_TYPE: | 6057 case ARRAY_TYPE: |
5821 return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type); | 6058 return TYPE_DOMAIN (a->type) == TYPE_DOMAIN (b->type); |
5822 | 6059 |
5823 case RECORD_TYPE: | 6060 case RECORD_TYPE: |
5824 case UNION_TYPE: | 6061 case UNION_TYPE: |
5889 type_hash_add (hashval_t hashcode, tree type) | 6126 type_hash_add (hashval_t hashcode, tree type) |
5890 { | 6127 { |
5891 struct type_hash *h; | 6128 struct type_hash *h; |
5892 void **loc; | 6129 void **loc; |
5893 | 6130 |
5894 h = GGC_NEW (struct type_hash); | 6131 h = ggc_alloc_type_hash (); |
5895 h->hash = hashcode; | 6132 h->hash = hashcode; |
5896 h->type = type; | 6133 h->type = type; |
5897 loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT); | 6134 loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT); |
5898 *loc = (void *)h; | 6135 *loc = (void *)h; |
5899 } | 6136 } |
5913 tree t1; | 6150 tree t1; |
5914 | 6151 |
5915 /* The hash table only contains main variants, so ensure that's what we're | 6152 /* The hash table only contains main variants, so ensure that's what we're |
5916 being passed. */ | 6153 being passed. */ |
5917 gcc_assert (TYPE_MAIN_VARIANT (type) == type); | 6154 gcc_assert (TYPE_MAIN_VARIANT (type) == type); |
5918 | |
5919 if (!lang_hooks.types.hash_types) | |
5920 return type; | |
5921 | 6155 |
5922 /* See if the type is in the hash table already. If so, return it. | 6156 /* See if the type is in the hash table already. If so, return it. |
5923 Otherwise, add the type. */ | 6157 Otherwise, add the type. */ |
5924 t1 = type_hash_lookup (hashcode, type); | 6158 t1 = type_hash_lookup (hashcode, type); |
5925 if (t1 != 0) | 6159 if (t1 != 0) |
5937 } | 6171 } |
5938 } | 6172 } |
5939 | 6173 |
5940 /* See if the data pointed to by the type hash table is marked. We consider | 6174 /* See if the data pointed to by the type hash table is marked. We consider |
5941 it marked if the type is marked or if a debug type number or symbol | 6175 it marked if the type is marked or if a debug type number or symbol |
5942 table entry has been made for the type. This reduces the amount of | 6176 table entry has been made for the type. */ |
5943 debugging output and eliminates that dependency of the debug output on | |
5944 the number of garbage collections. */ | |
5945 | 6177 |
5946 static int | 6178 static int |
5947 type_hash_marked_p (const void *p) | 6179 type_hash_marked_p (const void *p) |
5948 { | 6180 { |
5949 const_tree const type = ((const struct type_hash *) p)->type; | 6181 const_tree const type = ((const struct type_hash *) p)->type; |
5950 | 6182 |
5951 return ggc_marked_p (type) || TYPE_SYMTAB_POINTER (type); | 6183 return ggc_marked_p (type); |
5952 } | 6184 } |
5953 | 6185 |
5954 static void | 6186 static void |
5955 print_type_hash_statistics (void) | 6187 print_type_hash_statistics (void) |
5956 { | 6188 { |
6501 break; | 6733 break; |
6502 } | 6734 } |
6503 return false; | 6735 return false; |
6504 } | 6736 } |
6505 | 6737 |
6738 /* Return true if CODE represents a ternary tree code for which the | |
6739 first two operands are commutative. Otherwise return false. */ | |
6740 bool | |
6741 commutative_ternary_tree_code (enum tree_code code) | |
6742 { | |
6743 switch (code) | |
6744 { | |
6745 case WIDEN_MULT_PLUS_EXPR: | |
6746 case WIDEN_MULT_MINUS_EXPR: | |
6747 return true; | |
6748 | |
6749 default: | |
6750 break; | |
6751 } | |
6752 return false; | |
6753 } | |
6754 | |
6506 /* Generate a hash value for an expression. This can be used iteratively | 6755 /* Generate a hash value for an expression. This can be used iteratively |
6507 by passing a previous result as the VAL argument. | 6756 by passing a previous result as the VAL argument. |
6508 | 6757 |
6509 This function is intended to produce the same hash for expressions which | 6758 This function is intended to produce the same hash for expressions which |
6510 would compare equal using operand_equal_p. */ | 6759 would compare equal using operand_equal_p. */ |
6546 case COMPLEX_CST: | 6795 case COMPLEX_CST: |
6547 val = iterative_hash_expr (TREE_REALPART (t), val); | 6796 val = iterative_hash_expr (TREE_REALPART (t), val); |
6548 return iterative_hash_expr (TREE_IMAGPART (t), val); | 6797 return iterative_hash_expr (TREE_IMAGPART (t), val); |
6549 case VECTOR_CST: | 6798 case VECTOR_CST: |
6550 return iterative_hash_expr (TREE_VECTOR_CST_ELTS (t), val); | 6799 return iterative_hash_expr (TREE_VECTOR_CST_ELTS (t), val); |
6551 | |
6552 case SSA_NAME: | 6800 case SSA_NAME: |
6553 /* we can just compare by pointer. */ | 6801 /* We can just compare by pointer. */ |
6554 return iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val); | 6802 return iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val); |
6555 | 6803 case PLACEHOLDER_EXPR: |
6804 /* The node itself doesn't matter. */ | |
6805 return val; | |
6556 case TREE_LIST: | 6806 case TREE_LIST: |
6557 /* A list of expressions, for a CALL_EXPR or as the elements of a | 6807 /* A list of expressions, for a CALL_EXPR or as the elements of a |
6558 VECTOR_CST. */ | 6808 VECTOR_CST. */ |
6559 for (; t; t = TREE_CHAIN (t)) | 6809 for (; t; t = TREE_CHAIN (t)) |
6560 val = iterative_hash_expr (TREE_VALUE (t), val); | 6810 val = iterative_hash_expr (TREE_VALUE (t), val); |
6568 val = iterative_hash_expr (field, val); | 6818 val = iterative_hash_expr (field, val); |
6569 val = iterative_hash_expr (value, val); | 6819 val = iterative_hash_expr (value, val); |
6570 } | 6820 } |
6571 return val; | 6821 return val; |
6572 } | 6822 } |
6823 case MEM_REF: | |
6824 { | |
6825 /* The type of the second operand is relevant, except for | |
6826 its top-level qualifiers. */ | |
6827 tree type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (t, 1))); | |
6828 | |
6829 val = iterative_hash_object (TYPE_HASH (type), val); | |
6830 | |
6831 /* We could use the standard hash computation from this point | |
6832 on. */ | |
6833 val = iterative_hash_object (code, val); | |
6834 val = iterative_hash_expr (TREE_OPERAND (t, 1), val); | |
6835 val = iterative_hash_expr (TREE_OPERAND (t, 0), val); | |
6836 return val; | |
6837 } | |
6573 case FUNCTION_DECL: | 6838 case FUNCTION_DECL: |
6574 /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. | 6839 /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form. |
6575 Otherwise nodes that compare equal according to operand_equal_p might | 6840 Otherwise nodes that compare equal according to operand_equal_p might |
6576 get different hash codes. However, don't do this for machine specific | 6841 get different hash codes. However, don't do this for machine specific |
6577 or front end builtins, since the function code is overloaded in those | 6842 or front end builtins, since the function code is overloaded in those |
6819 default: | 7084 default: |
6820 return TYPE_MAIN_VARIANT (t); | 7085 return TYPE_MAIN_VARIANT (t); |
6821 } | 7086 } |
6822 } | 7087 } |
6823 | 7088 |
6824 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. | 7089 #define MAX_INT_CACHED_PREC \ |
6825 MAXVAL should be the maximum value in the domain | 7090 (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64) |
6826 (one less than the length of the array). | 7091 static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2]; |
6827 | |
6828 The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT. | |
6829 We don't enforce this limit, that is up to caller (e.g. language front end). | |
6830 The limit exists because the result is a signed type and we don't handle | |
6831 sizes that use more than one HOST_WIDE_INT. */ | |
6832 | |
6833 tree | |
6834 build_index_type (tree maxval) | |
6835 { | |
6836 tree itype = make_node (INTEGER_TYPE); | |
6837 | |
6838 TREE_TYPE (itype) = sizetype; | |
6839 TYPE_PRECISION (itype) = TYPE_PRECISION (sizetype); | |
6840 TYPE_MIN_VALUE (itype) = size_zero_node; | |
6841 TYPE_MAX_VALUE (itype) = fold_convert (sizetype, maxval); | |
6842 SET_TYPE_MODE (itype, TYPE_MODE (sizetype)); | |
6843 TYPE_SIZE (itype) = TYPE_SIZE (sizetype); | |
6844 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (sizetype); | |
6845 TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype); | |
6846 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (sizetype); | |
6847 | |
6848 if (host_integerp (maxval, 1)) | |
6849 return type_hash_canon (tree_low_cst (maxval, 1), itype); | |
6850 else | |
6851 { | |
6852 /* Since we cannot hash this type, we need to compare it using | |
6853 structural equality checks. */ | |
6854 SET_TYPE_STRUCTURAL_EQUALITY (itype); | |
6855 return itype; | |
6856 } | |
6857 } | |
6858 | 7092 |
6859 /* Builds a signed or unsigned integer type of precision PRECISION. | 7093 /* Builds a signed or unsigned integer type of precision PRECISION. |
6860 Used for C bitfields whose precision does not match that of | 7094 Used for C bitfields whose precision does not match that of |
6861 built-in target types. */ | 7095 built-in target types. */ |
6862 tree | 7096 tree |
6863 build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision, | 7097 build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision, |
6864 int unsignedp) | 7098 int unsignedp) |
6865 { | 7099 { |
6866 tree itype = make_node (INTEGER_TYPE); | 7100 tree itype, ret; |
6867 | 7101 |
7102 if (unsignedp) | |
7103 unsignedp = MAX_INT_CACHED_PREC + 1; | |
7104 | |
7105 if (precision <= MAX_INT_CACHED_PREC) | |
7106 { | |
7107 itype = nonstandard_integer_type_cache[precision + unsignedp]; | |
7108 if (itype) | |
7109 return itype; | |
7110 } | |
7111 | |
7112 itype = make_node (INTEGER_TYPE); | |
6868 TYPE_PRECISION (itype) = precision; | 7113 TYPE_PRECISION (itype) = precision; |
6869 | 7114 |
6870 if (unsignedp) | 7115 if (unsignedp) |
6871 fixup_unsigned_type (itype); | 7116 fixup_unsigned_type (itype); |
6872 else | 7117 else |
6873 fixup_signed_type (itype); | 7118 fixup_signed_type (itype); |
6874 | 7119 |
7120 ret = itype; | |
6875 if (host_integerp (TYPE_MAX_VALUE (itype), 1)) | 7121 if (host_integerp (TYPE_MAX_VALUE (itype), 1)) |
6876 return type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype); | 7122 ret = type_hash_canon (tree_low_cst (TYPE_MAX_VALUE (itype), 1), itype); |
6877 | 7123 if (precision <= MAX_INT_CACHED_PREC) |
6878 return itype; | 7124 nonstandard_integer_type_cache[precision + unsignedp] = ret; |
6879 } | 7125 |
6880 | 7126 return ret; |
6881 /* Create a range of some discrete type TYPE (an INTEGER_TYPE, | 7127 } |
6882 ENUMERAL_TYPE or BOOLEAN_TYPE), with low bound LOWVAL and | 7128 |
6883 high bound HIGHVAL. If TYPE is NULL, sizetype is used. */ | 7129 /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE |
6884 | 7130 or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL. If SHARED |
6885 tree | 7131 is true, reuse such a type that has already been constructed. */ |
6886 build_range_type (tree type, tree lowval, tree highval) | 7132 |
7133 static tree | |
7134 build_range_type_1 (tree type, tree lowval, tree highval, bool shared) | |
6887 { | 7135 { |
6888 tree itype = make_node (INTEGER_TYPE); | 7136 tree itype = make_node (INTEGER_TYPE); |
7137 hashval_t hashcode = 0; | |
6889 | 7138 |
6890 TREE_TYPE (itype) = type; | 7139 TREE_TYPE (itype) = type; |
6891 if (type == NULL_TREE) | |
6892 type = sizetype; | |
6893 | 7140 |
6894 TYPE_MIN_VALUE (itype) = fold_convert (type, lowval); | 7141 TYPE_MIN_VALUE (itype) = fold_convert (type, lowval); |
6895 TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL; | 7142 TYPE_MAX_VALUE (itype) = highval ? fold_convert (type, highval) : NULL; |
6896 | 7143 |
6897 TYPE_PRECISION (itype) = TYPE_PRECISION (type); | 7144 TYPE_PRECISION (itype) = TYPE_PRECISION (type); |
6899 TYPE_SIZE (itype) = TYPE_SIZE (type); | 7146 TYPE_SIZE (itype) = TYPE_SIZE (type); |
6900 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type); | 7147 TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (type); |
6901 TYPE_ALIGN (itype) = TYPE_ALIGN (type); | 7148 TYPE_ALIGN (itype) = TYPE_ALIGN (type); |
6902 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type); | 7149 TYPE_USER_ALIGN (itype) = TYPE_USER_ALIGN (type); |
6903 | 7150 |
6904 if (host_integerp (lowval, 0) && highval != 0 && host_integerp (highval, 0)) | 7151 if (!shared) |
6905 return type_hash_canon (tree_low_cst (highval, 0) | |
6906 - tree_low_cst (lowval, 0), | |
6907 itype); | |
6908 else | |
6909 return itype; | 7152 return itype; |
7153 | |
7154 if ((TYPE_MIN_VALUE (itype) | |
7155 && TREE_CODE (TYPE_MIN_VALUE (itype)) != INTEGER_CST) | |
7156 || (TYPE_MAX_VALUE (itype) | |
7157 && TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST)) | |
7158 { | |
7159 /* Since we cannot reliably merge this type, we need to compare it using | |
7160 structural equality checks. */ | |
7161 SET_TYPE_STRUCTURAL_EQUALITY (itype); | |
7162 return itype; | |
7163 } | |
7164 | |
7165 hashcode = iterative_hash_expr (TYPE_MIN_VALUE (itype), hashcode); | |
7166 hashcode = iterative_hash_expr (TYPE_MAX_VALUE (itype), hashcode); | |
7167 hashcode = iterative_hash_hashval_t (TYPE_HASH (type), hashcode); | |
7168 itype = type_hash_canon (hashcode, itype); | |
7169 | |
7170 return itype; | |
7171 } | |
7172 | |
7173 /* Wrapper around build_range_type_1 with SHARED set to true. */ | |
7174 | |
7175 tree | |
7176 build_range_type (tree type, tree lowval, tree highval) | |
7177 { | |
7178 return build_range_type_1 (type, lowval, highval, true); | |
7179 } | |
7180 | |
7181 /* Wrapper around build_range_type_1 with SHARED set to false. */ | |
7182 | |
7183 tree | |
7184 build_nonshared_range_type (tree type, tree lowval, tree highval) | |
7185 { | |
7186 return build_range_type_1 (type, lowval, highval, false); | |
7187 } | |
7188 | |
7189 /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. | |
7190 MAXVAL should be the maximum value in the domain | |
7191 (one less than the length of the array). | |
7192 | |
7193 The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT. | |
7194 We don't enforce this limit, that is up to caller (e.g. language front end). | |
7195 The limit exists because the result is a signed type and we don't handle | |
7196 sizes that use more than one HOST_WIDE_INT. */ | |
7197 | |
7198 tree | |
7199 build_index_type (tree maxval) | |
7200 { | |
7201 return build_range_type (sizetype, size_zero_node, maxval); | |
6910 } | 7202 } |
6911 | 7203 |
6912 /* Return true if the debug information for TYPE, a subtype, should be emitted | 7204 /* Return true if the debug information for TYPE, a subtype, should be emitted |
6913 as a subrange type. If so, set LOWVAL to the low bound and HIGHVAL to the | 7205 as a subrange type. If so, set LOWVAL to the low bound and HIGHVAL to the |
6914 high bound, respectively. Sometimes doing so unnecessarily obfuscates the | 7206 high bound, respectively. Sometimes doing so unnecessarily obfuscates the |
6958 if (highval) | 7250 if (highval) |
6959 *highval = high; | 7251 *highval = high; |
6960 return true; | 7252 return true; |
6961 } | 7253 } |
6962 | 7254 |
6963 /* Just like build_index_type, but takes lowval and highval instead | |
6964 of just highval (maxval). */ | |
6965 | |
6966 tree | |
6967 build_index_2_type (tree lowval, tree highval) | |
6968 { | |
6969 return build_range_type (sizetype, lowval, highval); | |
6970 } | |
6971 | |
6972 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE | 7255 /* Construct, lay out and return the type of arrays of elements with ELT_TYPE |
6973 and number of elements specified by the range of values of INDEX_TYPE. | 7256 and number of elements specified by the range of values of INDEX_TYPE. |
6974 If such a type has already been constructed, reuse it. */ | 7257 If SHARED is true, reuse such a type that has already been constructed. */ |
6975 | 7258 |
6976 tree | 7259 static tree |
6977 build_array_type (tree elt_type, tree index_type) | 7260 build_array_type_1 (tree elt_type, tree index_type, bool shared) |
6978 { | 7261 { |
6979 tree t; | 7262 tree t; |
6980 hashval_t hashcode = 0; | |
6981 | 7263 |
6982 if (TREE_CODE (elt_type) == FUNCTION_TYPE) | 7264 if (TREE_CODE (elt_type) == FUNCTION_TYPE) |
6983 { | 7265 { |
6984 error ("arrays of functions are not meaningful"); | 7266 error ("arrays of functions are not meaningful"); |
6985 elt_type = integer_type_node; | 7267 elt_type = integer_type_node; |
6995 structural equality. Do not record these types in the canonical | 7277 structural equality. Do not record these types in the canonical |
6996 type hashtable. */ | 7278 type hashtable. */ |
6997 if (TYPE_STRUCTURAL_EQUALITY_P (t)) | 7279 if (TYPE_STRUCTURAL_EQUALITY_P (t)) |
6998 return t; | 7280 return t; |
6999 | 7281 |
7000 hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode); | 7282 if (shared) |
7001 if (index_type) | 7283 { |
7002 hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); | 7284 hashval_t hashcode = iterative_hash_object (TYPE_HASH (elt_type), 0); |
7003 t = type_hash_canon (hashcode, t); | 7285 if (index_type) |
7286 hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); | |
7287 t = type_hash_canon (hashcode, t); | |
7288 } | |
7004 | 7289 |
7005 if (TYPE_CANONICAL (t) == t) | 7290 if (TYPE_CANONICAL (t) == t) |
7006 { | 7291 { |
7007 if (TYPE_STRUCTURAL_EQUALITY_P (elt_type) | 7292 if (TYPE_STRUCTURAL_EQUALITY_P (elt_type) |
7008 || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))) | 7293 || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type))) |
7009 SET_TYPE_STRUCTURAL_EQUALITY (t); | 7294 SET_TYPE_STRUCTURAL_EQUALITY (t); |
7010 else if (TYPE_CANONICAL (elt_type) != elt_type | 7295 else if (TYPE_CANONICAL (elt_type) != elt_type |
7011 || (index_type && TYPE_CANONICAL (index_type) != index_type)) | 7296 || (index_type && TYPE_CANONICAL (index_type) != index_type)) |
7012 TYPE_CANONICAL (t) | 7297 TYPE_CANONICAL (t) |
7013 = build_array_type (TYPE_CANONICAL (elt_type), | 7298 = build_array_type_1 (TYPE_CANONICAL (elt_type), |
7014 index_type ? TYPE_CANONICAL (index_type) : NULL); | 7299 index_type |
7300 ? TYPE_CANONICAL (index_type) : NULL_TREE, | |
7301 shared); | |
7015 } | 7302 } |
7016 | 7303 |
7017 return t; | 7304 return t; |
7305 } | |
7306 | |
7307 /* Wrapper around build_array_type_1 with SHARED set to true. */ | |
7308 | |
7309 tree | |
7310 build_array_type (tree elt_type, tree index_type) | |
7311 { | |
7312 return build_array_type_1 (elt_type, index_type, true); | |
7313 } | |
7314 | |
7315 /* Wrapper around build_array_type_1 with SHARED set to false. */ | |
7316 | |
7317 tree | |
7318 build_nonshared_array_type (tree elt_type, tree index_type) | |
7319 { | |
7320 return build_array_type_1 (elt_type, index_type, false); | |
7018 } | 7321 } |
7019 | 7322 |
7020 /* Recursively examines the array elements of TYPE, until a non-array | 7323 /* Recursively examines the array elements of TYPE, until a non-array |
7021 element type is found. */ | 7324 element type is found. */ |
7022 | 7325 |
7201 When we are asked to remove it, we need to build new FUNCTION_TYPE | 7504 When we are asked to remove it, we need to build new FUNCTION_TYPE |
7202 instead. */ | 7505 instead. */ |
7203 if (TREE_CODE (orig_type) != METHOD_TYPE | 7506 if (TREE_CODE (orig_type) != METHOD_TYPE |
7204 || !bitmap_bit_p (args_to_skip, 0)) | 7507 || !bitmap_bit_p (args_to_skip, 0)) |
7205 { | 7508 { |
7206 new_type = copy_node (orig_type); | 7509 new_type = build_distinct_type_copy (orig_type); |
7207 TYPE_ARG_TYPES (new_type) = new_reversed; | 7510 TYPE_ARG_TYPES (new_type) = new_reversed; |
7208 } | 7511 } |
7209 else | 7512 else |
7210 { | 7513 { |
7211 new_type | 7514 new_type |
7232 } | 7535 } |
7233 | 7536 |
7234 /* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP. | 7537 /* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP. |
7235 | 7538 |
7236 Arguments from DECL_ARGUMENTS list can't be removed now, since they are | 7539 Arguments from DECL_ARGUMENTS list can't be removed now, since they are |
7237 linked by TREE_CHAIN directly. It is caller responsibility to eliminate | 7540 linked by TREE_CHAIN directly. The caller is responsible for eliminating |
7238 them when they are being duplicated (i.e. copy_arguments_for_versioning). */ | 7541 them when they are being duplicated (i.e. copy_arguments_for_versioning). */ |
7239 | 7542 |
7240 tree | 7543 tree |
7241 build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip) | 7544 build_function_decl_skip_args (tree orig_decl, bitmap args_to_skip) |
7242 { | 7545 { |
7250 | 7553 |
7251 /* For declarations setting DECL_VINDEX (i.e. methods) | 7554 /* For declarations setting DECL_VINDEX (i.e. methods) |
7252 we expect first argument to be THIS pointer. */ | 7555 we expect first argument to be THIS pointer. */ |
7253 if (bitmap_bit_p (args_to_skip, 0)) | 7556 if (bitmap_bit_p (args_to_skip, 0)) |
7254 DECL_VINDEX (new_decl) = NULL_TREE; | 7557 DECL_VINDEX (new_decl) = NULL_TREE; |
7558 | |
7559 /* When signature changes, we need to clear builtin info. */ | |
7560 if (DECL_BUILT_IN (new_decl) && !bitmap_empty_p (args_to_skip)) | |
7561 { | |
7562 DECL_BUILT_IN_CLASS (new_decl) = NOT_BUILT_IN; | |
7563 DECL_FUNCTION_CODE (new_decl) = (enum built_in_function) 0; | |
7564 } | |
7255 return new_decl; | 7565 return new_decl; |
7256 } | 7566 } |
7257 | 7567 |
7258 /* Build a function type. The RETURN_TYPE is the type returned by the | 7568 /* Build a function type. The RETURN_TYPE is the type returned by the |
7259 function. If VAARGS is set, no void_type_node is appended to the | 7569 function. If VAARGS is set, no void_type_node is appended to the |
7260 the list. ARGP muse be alway be terminated be a NULL_TREE. */ | 7570 the list. ARGP must be always be terminated be a NULL_TREE. */ |
7261 | 7571 |
7262 static tree | 7572 static tree |
7263 build_function_type_list_1 (bool vaargs, tree return_type, va_list argp) | 7573 build_function_type_list_1 (bool vaargs, tree return_type, va_list argp) |
7264 { | 7574 { |
7265 tree t, args, last; | 7575 tree t, args, last; |
7271 if (vaargs) | 7581 if (vaargs) |
7272 { | 7582 { |
7273 last = args; | 7583 last = args; |
7274 if (args != NULL_TREE) | 7584 if (args != NULL_TREE) |
7275 args = nreverse (args); | 7585 args = nreverse (args); |
7276 gcc_assert (args != NULL_TREE && last != void_list_node); | 7586 gcc_assert (last != void_list_node); |
7277 } | 7587 } |
7278 else if (args == NULL_TREE) | 7588 else if (args == NULL_TREE) |
7279 args = void_list_node; | 7589 args = void_list_node; |
7280 else | 7590 else |
7281 { | 7591 { |
7635 win = op; | 7945 win = op; |
7636 } | 7946 } |
7637 } | 7947 } |
7638 } | 7948 } |
7639 | 7949 |
7950 /* If we finally reach a constant see if it fits in for_type and | |
7951 in that case convert it. */ | |
7952 if (for_type | |
7953 && TREE_CODE (win) == INTEGER_CST | |
7954 && TREE_TYPE (win) != for_type | |
7955 && int_fits_type_p (win, for_type)) | |
7956 win = fold_convert (for_type, win); | |
7957 | |
7640 return win; | 7958 return win; |
7641 } | 7959 } |
7642 | 7960 |
7643 /* Return OP or a simpler expression for a narrower value | 7961 /* Return OP or a simpler expression for a narrower value |
7644 which can be sign-extended or zero-extended to give back OP. | 7962 which can be sign-extended or zero-extended to give back OP. |
7732 | 8050 |
7733 *unsignedp_ptr = uns; | 8051 *unsignedp_ptr = uns; |
7734 return win; | 8052 return win; |
7735 } | 8053 } |
7736 | 8054 |
7737 /* Nonzero if integer constant C has a value that is permissible | 8055 /* Returns true if integer constant C has a value that is permissible |
7738 for type TYPE (an INTEGER_TYPE). */ | 8056 for type TYPE (an INTEGER_TYPE). */ |
7739 | 8057 |
7740 int | 8058 bool |
7741 int_fits_type_p (const_tree c, const_tree type) | 8059 int_fits_type_p (const_tree c, const_tree type) |
7742 { | 8060 { |
7743 tree type_low_bound, type_high_bound; | 8061 tree type_low_bound, type_high_bound; |
7744 bool ok_for_low_bound, ok_for_high_bound, unsc; | 8062 bool ok_for_low_bound, ok_for_high_bound, unsc; |
7745 double_int dc, dd; | 8063 double_int dc, dd; |
7764 type_high_bound = TYPE_MAX_VALUE (type); | 8082 type_high_bound = TYPE_MAX_VALUE (type); |
7765 | 8083 |
7766 /* If at least one bound of the type is a constant integer, we can check | 8084 /* If at least one bound of the type is a constant integer, we can check |
7767 ourselves and maybe make a decision. If no such decision is possible, but | 8085 ourselves and maybe make a decision. If no such decision is possible, but |
7768 this type is a subtype, try checking against that. Otherwise, use | 8086 this type is a subtype, try checking against that. Otherwise, use |
7769 fit_double_type, which checks against the precision. | 8087 double_int_fits_to_tree_p, which checks against the precision. |
7770 | 8088 |
7771 Compute the status for each possibly constant bound, and return if we see | 8089 Compute the status for each possibly constant bound, and return if we see |
7772 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1 | 8090 one does not match. Use ok_for_xxx_bound for this purpose, assigning -1 |
7773 for "unknown if constant fits", 0 for "constant known *not* to fit" and 1 | 8091 for "unknown if constant fits", 0 for "constant known *not* to fit" and 1 |
7774 for "constant known to fit". */ | 8092 for "constant known to fit". */ |
7785 { | 8103 { |
7786 int c_neg = (!unsc && double_int_negative_p (dc)); | 8104 int c_neg = (!unsc && double_int_negative_p (dc)); |
7787 int t_neg = (unsc && double_int_negative_p (dd)); | 8105 int t_neg = (unsc && double_int_negative_p (dd)); |
7788 | 8106 |
7789 if (c_neg && !t_neg) | 8107 if (c_neg && !t_neg) |
7790 return 0; | 8108 return false; |
7791 if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0) | 8109 if ((c_neg || !t_neg) && double_int_ucmp (dc, dd) < 0) |
7792 return 0; | 8110 return false; |
7793 } | 8111 } |
7794 else if (double_int_cmp (dc, dd, unsc) < 0) | 8112 else if (double_int_cmp (dc, dd, unsc) < 0) |
7795 return 0; | 8113 return false; |
7796 ok_for_low_bound = true; | 8114 ok_for_low_bound = true; |
7797 } | 8115 } |
7798 else | 8116 else |
7799 ok_for_low_bound = false; | 8117 ok_for_low_bound = false; |
7800 | 8118 |
7810 { | 8128 { |
7811 int c_neg = (!unsc && double_int_negative_p (dc)); | 8129 int c_neg = (!unsc && double_int_negative_p (dc)); |
7812 int t_neg = (unsc && double_int_negative_p (dd)); | 8130 int t_neg = (unsc && double_int_negative_p (dd)); |
7813 | 8131 |
7814 if (t_neg && !c_neg) | 8132 if (t_neg && !c_neg) |
7815 return 0; | 8133 return false; |
7816 if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0) | 8134 if ((t_neg || !c_neg) && double_int_ucmp (dc, dd) > 0) |
7817 return 0; | 8135 return false; |
7818 } | 8136 } |
7819 else if (double_int_cmp (dc, dd, unsc) > 0) | 8137 else if (double_int_cmp (dc, dd, unsc) > 0) |
7820 return 0; | 8138 return false; |
7821 ok_for_high_bound = true; | 8139 ok_for_high_bound = true; |
7822 } | 8140 } |
7823 else | 8141 else |
7824 ok_for_high_bound = false; | 8142 ok_for_high_bound = false; |
7825 | 8143 |
7826 /* If the constant fits both bounds, the result is known. */ | 8144 /* If the constant fits both bounds, the result is known. */ |
7827 if (ok_for_low_bound && ok_for_high_bound) | 8145 if (ok_for_low_bound && ok_for_high_bound) |
7828 return 1; | 8146 return true; |
7829 | 8147 |
7830 /* Perform some generic filtering which may allow making a decision | 8148 /* Perform some generic filtering which may allow making a decision |
7831 even if the bounds are not constant. First, negative integers | 8149 even if the bounds are not constant. First, negative integers |
7832 never fit in unsigned types, */ | 8150 never fit in unsigned types, */ |
7833 if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc)) | 8151 if (TYPE_UNSIGNED (type) && !unsc && double_int_negative_p (dc)) |
7834 return 0; | 8152 return false; |
7835 | 8153 |
7836 /* Second, narrower types always fit in wider ones. */ | 8154 /* Second, narrower types always fit in wider ones. */ |
7837 if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c))) | 8155 if (TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (c))) |
7838 return 1; | 8156 return true; |
7839 | 8157 |
7840 /* Third, unsigned integers with top bit set never fit signed types. */ | 8158 /* Third, unsigned integers with top bit set never fit signed types. */ |
7841 if (! TYPE_UNSIGNED (type) && unsc) | 8159 if (! TYPE_UNSIGNED (type) && unsc) |
7842 { | 8160 { |
7843 int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (c))) - 1; | 8161 int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (c))) - 1; |
7844 if (prec < HOST_BITS_PER_WIDE_INT) | 8162 if (prec < HOST_BITS_PER_WIDE_INT) |
7845 { | 8163 { |
7846 if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0) | 8164 if (((((unsigned HOST_WIDE_INT) 1) << prec) & dc.low) != 0) |
7847 return 0; | 8165 return false; |
7848 } | 8166 } |
7849 else if (((((unsigned HOST_WIDE_INT) 1) | 8167 else if (((((unsigned HOST_WIDE_INT) 1) |
7850 << (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0) | 8168 << (prec - HOST_BITS_PER_WIDE_INT)) & dc.high) != 0) |
7851 return 0; | 8169 return false; |
7852 } | 8170 } |
7853 | 8171 |
7854 /* If we haven't been able to decide at this point, there nothing more we | 8172 /* If we haven't been able to decide at this point, there nothing more we |
7855 can check ourselves here. Look at the base type if we have one and it | 8173 can check ourselves here. Look at the base type if we have one and it |
7856 has the same precision. */ | 8174 has the same precision. */ |
7860 { | 8178 { |
7861 type = TREE_TYPE (type); | 8179 type = TREE_TYPE (type); |
7862 goto retry; | 8180 goto retry; |
7863 } | 8181 } |
7864 | 8182 |
7865 /* Or to fit_double_type, if nothing else. */ | 8183 /* Or to double_int_fits_to_tree_p, if nothing else. */ |
7866 return !fit_double_type (dc.low, dc.high, &dc.low, &dc.high, type); | 8184 return double_int_fits_to_tree_p (type, dc); |
7867 } | 8185 } |
7868 | 8186 |
7869 /* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant | 8187 /* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant |
7870 bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be | 8188 bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be |
7871 represented (assuming two's-complement arithmetic) within the bit | 8189 represented (assuming two's-complement arithmetic) within the bit |
7911 | 8229 |
7912 bool | 8230 bool |
7913 auto_var_in_fn_p (const_tree var, const_tree fn) | 8231 auto_var_in_fn_p (const_tree var, const_tree fn) |
7914 { | 8232 { |
7915 return (DECL_P (var) && DECL_CONTEXT (var) == fn | 8233 return (DECL_P (var) && DECL_CONTEXT (var) == fn |
7916 && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL) | 8234 && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var)) |
8235 || TREE_CODE (var) == PARM_DECL) | |
7917 && ! TREE_STATIC (var)) | 8236 && ! TREE_STATIC (var)) |
7918 || TREE_CODE (var) == LABEL_DECL | 8237 || TREE_CODE (var) == LABEL_DECL |
7919 || TREE_CODE (var) == RESULT_DECL)); | 8238 || TREE_CODE (var) == RESULT_DECL)); |
7920 } | 8239 } |
7921 | 8240 |
8006 case QUAL_UNION_TYPE: | 8325 case QUAL_UNION_TYPE: |
8007 /* We can't see if any of the fields are variably-modified by the | 8326 /* We can't see if any of the fields are variably-modified by the |
8008 definition we normally use, since that would produce infinite | 8327 definition we normally use, since that would produce infinite |
8009 recursion via pointers. */ | 8328 recursion via pointers. */ |
8010 /* This is variably modified if some field's type is. */ | 8329 /* This is variably modified if some field's type is. */ |
8011 for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t)) | 8330 for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t)) |
8012 if (TREE_CODE (t) == FIELD_DECL) | 8331 if (TREE_CODE (t) == FIELD_DECL) |
8013 { | 8332 { |
8014 RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t)); | 8333 RETURN_TRUE_IF_VAR (DECL_FIELD_OFFSET (t)); |
8015 RETURN_TRUE_IF_VAR (DECL_SIZE (t)); | 8334 RETURN_TRUE_IF_VAR (DECL_SIZE (t)); |
8016 RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t)); | 8335 RETURN_TRUE_IF_VAR (DECL_SIZE_UNIT (t)); |
8257 /* If we already have a name we know to be unique, just use that. */ | 8576 /* If we already have a name we know to be unique, just use that. */ |
8258 if (first_global_object_name) | 8577 if (first_global_object_name) |
8259 p = q = ASTRDUP (first_global_object_name); | 8578 p = q = ASTRDUP (first_global_object_name); |
8260 /* If the target is handling the constructors/destructors, they | 8579 /* If the target is handling the constructors/destructors, they |
8261 will be local to this file and the name is only necessary for | 8580 will be local to this file and the name is only necessary for |
8262 debugging purposes. */ | 8581 debugging purposes. |
8263 else if ((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors) | 8582 We also assign sub_I and sub_D sufixes to constructors called from |
8583 the global static constructors. These are always local. */ | |
8584 else if (((type[0] == 'I' || type[0] == 'D') && targetm.have_ctors_dtors) | |
8585 || (strncmp (type, "sub_", 4) == 0 | |
8586 && (type[4] == 'I' || type[4] == 'D'))) | |
8264 { | 8587 { |
8265 const char *file = main_input_filename; | 8588 const char *file = main_input_filename; |
8266 if (! file) | 8589 if (! file) |
8267 file = input_filename; | 8590 file = input_filename; |
8268 /* Just use the file's basename, because the full pathname | 8591 /* Just use the file's basename, because the full pathname |
8593 TYPE_CANONICAL (t) | 8916 TYPE_CANONICAL (t) |
8594 = make_vector_type (TYPE_CANONICAL (innertype), nunits, VOIDmode); | 8917 = make_vector_type (TYPE_CANONICAL (innertype), nunits, VOIDmode); |
8595 | 8918 |
8596 layout_type (t); | 8919 layout_type (t); |
8597 | 8920 |
8598 { | |
8599 tree index = build_int_cst (NULL_TREE, nunits - 1); | |
8600 tree array = build_array_type (TYPE_MAIN_VARIANT (innertype), | |
8601 build_index_type (index)); | |
8602 tree rt = make_node (RECORD_TYPE); | |
8603 | |
8604 TYPE_FIELDS (rt) = build_decl (UNKNOWN_LOCATION, FIELD_DECL, | |
8605 get_identifier ("f"), array); | |
8606 DECL_CONTEXT (TYPE_FIELDS (rt)) = rt; | |
8607 layout_type (rt); | |
8608 TYPE_DEBUG_REPRESENTATION_TYPE (t) = rt; | |
8609 /* In dwarfout.c, type lookup uses TYPE_UID numbers. We want to output | |
8610 the representation type, and we want to find that die when looking up | |
8611 the vector type. This is most easily achieved by making the TYPE_UID | |
8612 numbers equal. */ | |
8613 TYPE_UID (rt) = TYPE_UID (t); | |
8614 } | |
8615 | |
8616 hashcode = iterative_hash_host_wide_int (VECTOR_TYPE, hashcode); | 8921 hashcode = iterative_hash_host_wide_int (VECTOR_TYPE, hashcode); |
8617 hashcode = iterative_hash_host_wide_int (nunits, hashcode); | 8922 hashcode = iterative_hash_host_wide_int (nunits, hashcode); |
8618 hashcode = iterative_hash_host_wide_int (mode, hashcode); | 8923 hashcode = iterative_hash_host_wide_int (mode, hashcode); |
8619 hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (t)), hashcode); | 8924 hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (t)), hashcode); |
8620 t = type_hash_canon (hashcode, t); | 8925 t = type_hash_canon (hashcode, t); |
8642 if (size == LONG_TYPE_SIZE) | 8947 if (size == LONG_TYPE_SIZE) |
8643 return unsignedp ? long_unsigned_type_node : long_integer_type_node; | 8948 return unsignedp ? long_unsigned_type_node : long_integer_type_node; |
8644 if (size == LONG_LONG_TYPE_SIZE) | 8949 if (size == LONG_LONG_TYPE_SIZE) |
8645 return (unsignedp ? long_long_unsigned_type_node | 8950 return (unsignedp ? long_long_unsigned_type_node |
8646 : long_long_integer_type_node); | 8951 : long_long_integer_type_node); |
8952 if (size == 128 && int128_integer_type_node) | |
8953 return (unsignedp ? int128_unsigned_type_node | |
8954 : int128_integer_type_node); | |
8647 | 8955 |
8648 if (unsignedp) | 8956 if (unsignedp) |
8649 return make_unsigned_type (size); | 8957 return make_unsigned_type (size); |
8650 else | 8958 else |
8651 return make_signed_type (size); | 8959 return make_signed_type (size); |
8728 /* Create nodes for all integer types (and error_mark_node) using the sizes | 9036 /* Create nodes for all integer types (and error_mark_node) using the sizes |
8729 of C datatypes. The caller should call set_sizetype soon after calling | 9037 of C datatypes. The caller should call set_sizetype soon after calling |
8730 this function to select one of the types as sizetype. */ | 9038 this function to select one of the types as sizetype. */ |
8731 | 9039 |
8732 void | 9040 void |
8733 build_common_tree_nodes (bool signed_char, bool signed_sizetype) | 9041 build_common_tree_nodes (bool signed_char) |
8734 { | 9042 { |
8735 error_mark_node = make_node (ERROR_MARK); | 9043 error_mark_node = make_node (ERROR_MARK); |
8736 TREE_TYPE (error_mark_node) = error_mark_node; | 9044 TREE_TYPE (error_mark_node) = error_mark_node; |
8737 | 9045 |
8738 initialize_sizetypes (signed_sizetype); | 9046 initialize_sizetypes (); |
8739 | 9047 |
8740 /* Define both `signed char' and `unsigned char'. */ | 9048 /* Define both `signed char' and `unsigned char'. */ |
8741 signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE); | 9049 signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE); |
8742 TYPE_STRING_FLAG (signed_char_type_node) = 1; | 9050 TYPE_STRING_FLAG (signed_char_type_node) = 1; |
8743 unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE); | 9051 unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE); |
8757 unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE); | 9065 unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE); |
8758 long_integer_type_node = make_signed_type (LONG_TYPE_SIZE); | 9066 long_integer_type_node = make_signed_type (LONG_TYPE_SIZE); |
8759 long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE); | 9067 long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE); |
8760 long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE); | 9068 long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE); |
8761 long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE); | 9069 long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE); |
8762 | 9070 #if HOST_BITS_PER_WIDE_INT >= 64 |
9071 /* TODO: This isn't correct, but as logic depends at the moment on | |
9072 host's instead of target's wide-integer. | |
9073 If there is a target not supporting TImode, but has an 128-bit | |
9074 integer-scalar register, this target check needs to be adjusted. */ | |
9075 if (targetm.scalar_mode_supported_p (TImode)) | |
9076 { | |
9077 int128_integer_type_node = make_signed_type (128); | |
9078 int128_unsigned_type_node = make_unsigned_type (128); | |
9079 } | |
9080 #endif | |
8763 /* Define a boolean type. This type only represents boolean values but | 9081 /* Define a boolean type. This type only represents boolean values but |
8764 may be larger than char depending on the value of BOOL_TYPE_SIZE. | 9082 may be larger than char depending on the value of BOOL_TYPE_SIZE. |
8765 Front ends which want to override this size (i.e. Java) can redefine | 9083 Front ends which want to override this size (i.e. Java) can redefine |
8766 boolean_type_node before calling build_common_tree_nodes_2. */ | 9084 boolean_type_node before calling build_common_tree_nodes_2. */ |
8767 boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); | 9085 boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); |
8793 | 9111 |
8794 void | 9112 void |
8795 build_common_tree_nodes_2 (int short_double) | 9113 build_common_tree_nodes_2 (int short_double) |
8796 { | 9114 { |
8797 /* Define these next since types below may used them. */ | 9115 /* Define these next since types below may used them. */ |
8798 integer_zero_node = build_int_cst (NULL_TREE, 0); | 9116 integer_zero_node = build_int_cst (integer_type_node, 0); |
8799 integer_one_node = build_int_cst (NULL_TREE, 1); | 9117 integer_one_node = build_int_cst (integer_type_node, 1); |
8800 integer_minus_one_node = build_int_cst (NULL_TREE, -1); | 9118 integer_three_node = build_int_cst (integer_type_node, 3); |
9119 integer_minus_one_node = build_int_cst (integer_type_node, -1); | |
8801 | 9120 |
8802 size_zero_node = size_int (0); | 9121 size_zero_node = size_int (0); |
8803 size_one_node = size_int (1); | 9122 size_one_node = size_int (1); |
8804 bitsize_zero_node = bitsize_int (0); | 9123 bitsize_zero_node = bitsize_int (0); |
8805 bitsize_one_node = bitsize_int (1); | 9124 bitsize_one_node = bitsize_int (1); |
8960 TREE_THIS_VOLATILE (decl) = 1; | 9279 TREE_THIS_VOLATILE (decl) = 1; |
8961 if (ecf_flags & ECF_NOTHROW) | 9280 if (ecf_flags & ECF_NOTHROW) |
8962 TREE_NOTHROW (decl) = 1; | 9281 TREE_NOTHROW (decl) = 1; |
8963 if (ecf_flags & ECF_MALLOC) | 9282 if (ecf_flags & ECF_MALLOC) |
8964 DECL_IS_MALLOC (decl) = 1; | 9283 DECL_IS_MALLOC (decl) = 1; |
9284 if (ecf_flags & ECF_LEAF) | |
9285 DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"), | |
9286 NULL, DECL_ATTRIBUTES (decl)); | |
8965 | 9287 |
8966 built_in_decls[code] = decl; | 9288 built_in_decls[code] = decl; |
8967 implicit_built_in_decls[code] = decl; | 9289 implicit_built_in_decls[code] = decl; |
8968 } | 9290 } |
8969 | 9291 |
8972 are relied upon by the tree optimizers and the middle-end. */ | 9294 are relied upon by the tree optimizers and the middle-end. */ |
8973 | 9295 |
8974 void | 9296 void |
8975 build_common_builtin_nodes (void) | 9297 build_common_builtin_nodes (void) |
8976 { | 9298 { |
8977 tree tmp, tmp2, ftype; | 9299 tree tmp, ftype; |
8978 | 9300 |
8979 if (built_in_decls[BUILT_IN_MEMCPY] == NULL | 9301 if (built_in_decls[BUILT_IN_MEMCPY] == NULL |
8980 || built_in_decls[BUILT_IN_MEMMOVE] == NULL) | 9302 || built_in_decls[BUILT_IN_MEMMOVE] == NULL) |
8981 { | 9303 { |
8982 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9304 ftype = build_function_type_list (ptr_type_node, |
8983 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9305 ptr_type_node, const_ptr_type_node, |
8984 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9306 size_type_node, NULL_TREE); |
8985 ftype = build_function_type (ptr_type_node, tmp); | |
8986 | 9307 |
8987 if (built_in_decls[BUILT_IN_MEMCPY] == NULL) | 9308 if (built_in_decls[BUILT_IN_MEMCPY] == NULL) |
8988 local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY, | 9309 local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY, |
8989 "memcpy", ECF_NOTHROW); | 9310 "memcpy", ECF_NOTHROW | ECF_LEAF); |
8990 if (built_in_decls[BUILT_IN_MEMMOVE] == NULL) | 9311 if (built_in_decls[BUILT_IN_MEMMOVE] == NULL) |
8991 local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE, | 9312 local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE, |
8992 "memmove", ECF_NOTHROW); | 9313 "memmove", ECF_NOTHROW | ECF_LEAF); |
8993 } | 9314 } |
8994 | 9315 |
8995 if (built_in_decls[BUILT_IN_MEMCMP] == NULL) | 9316 if (built_in_decls[BUILT_IN_MEMCMP] == NULL) |
8996 { | 9317 { |
8997 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9318 ftype = build_function_type_list (integer_type_node, const_ptr_type_node, |
8998 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9319 const_ptr_type_node, size_type_node, |
8999 tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp); | 9320 NULL_TREE); |
9000 ftype = build_function_type (integer_type_node, tmp); | |
9001 local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP, | 9321 local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP, |
9002 "memcmp", ECF_PURE | ECF_NOTHROW); | 9322 "memcmp", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9003 } | 9323 } |
9004 | 9324 |
9005 if (built_in_decls[BUILT_IN_MEMSET] == NULL) | 9325 if (built_in_decls[BUILT_IN_MEMSET] == NULL) |
9006 { | 9326 { |
9007 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9327 ftype = build_function_type_list (ptr_type_node, |
9008 tmp = tree_cons (NULL_TREE, integer_type_node, tmp); | 9328 ptr_type_node, integer_type_node, |
9009 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9329 size_type_node, NULL_TREE); |
9010 ftype = build_function_type (ptr_type_node, tmp); | |
9011 local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET, | 9330 local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET, |
9012 "memset", ECF_NOTHROW); | 9331 "memset", ECF_NOTHROW | ECF_LEAF); |
9013 } | 9332 } |
9014 | 9333 |
9015 if (built_in_decls[BUILT_IN_ALLOCA] == NULL) | 9334 if (built_in_decls[BUILT_IN_ALLOCA] == NULL) |
9016 { | 9335 { |
9017 tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); | 9336 ftype = build_function_type_list (ptr_type_node, |
9018 ftype = build_function_type (ptr_type_node, tmp); | 9337 size_type_node, NULL_TREE); |
9019 local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA, | 9338 local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA, |
9020 "alloca", | 9339 "alloca", ECF_MALLOC | ECF_NOTHROW | ECF_LEAF); |
9021 ECF_MALLOC | (flag_stack_check ? 0 : ECF_NOTHROW)); | 9340 } |
9022 } | 9341 |
9023 | 9342 /* If we're checking the stack, `alloca' can throw. */ |
9024 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9343 if (flag_stack_check) |
9025 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9344 TREE_NOTHROW (built_in_decls[BUILT_IN_ALLOCA]) = 0; |
9026 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9345 |
9027 ftype = build_function_type (void_type_node, tmp); | 9346 ftype = build_function_type_list (void_type_node, |
9347 ptr_type_node, ptr_type_node, | |
9348 ptr_type_node, NULL_TREE); | |
9028 local_define_builtin ("__builtin_init_trampoline", ftype, | 9349 local_define_builtin ("__builtin_init_trampoline", ftype, |
9029 BUILT_IN_INIT_TRAMPOLINE, | 9350 BUILT_IN_INIT_TRAMPOLINE, |
9030 "__builtin_init_trampoline", ECF_NOTHROW); | 9351 "__builtin_init_trampoline", ECF_NOTHROW | ECF_LEAF); |
9031 | 9352 |
9032 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9353 ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); |
9033 ftype = build_function_type (ptr_type_node, tmp); | |
9034 local_define_builtin ("__builtin_adjust_trampoline", ftype, | 9354 local_define_builtin ("__builtin_adjust_trampoline", ftype, |
9035 BUILT_IN_ADJUST_TRAMPOLINE, | 9355 BUILT_IN_ADJUST_TRAMPOLINE, |
9036 "__builtin_adjust_trampoline", | 9356 "__builtin_adjust_trampoline", |
9037 ECF_CONST | ECF_NOTHROW); | 9357 ECF_CONST | ECF_NOTHROW); |
9038 | 9358 |
9039 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9359 ftype = build_function_type_list (void_type_node, |
9040 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9360 ptr_type_node, ptr_type_node, NULL_TREE); |
9041 ftype = build_function_type (void_type_node, tmp); | |
9042 local_define_builtin ("__builtin_nonlocal_goto", ftype, | 9361 local_define_builtin ("__builtin_nonlocal_goto", ftype, |
9043 BUILT_IN_NONLOCAL_GOTO, | 9362 BUILT_IN_NONLOCAL_GOTO, |
9044 "__builtin_nonlocal_goto", | 9363 "__builtin_nonlocal_goto", |
9045 ECF_NORETURN | ECF_NOTHROW); | 9364 ECF_NORETURN | ECF_NOTHROW); |
9046 | 9365 |
9047 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9366 ftype = build_function_type_list (void_type_node, |
9048 tmp = tree_cons (NULL_TREE, ptr_type_node, tmp); | 9367 ptr_type_node, ptr_type_node, NULL_TREE); |
9049 ftype = build_function_type (void_type_node, tmp); | |
9050 local_define_builtin ("__builtin_setjmp_setup", ftype, | 9368 local_define_builtin ("__builtin_setjmp_setup", ftype, |
9051 BUILT_IN_SETJMP_SETUP, | 9369 BUILT_IN_SETJMP_SETUP, |
9052 "__builtin_setjmp_setup", ECF_NOTHROW); | 9370 "__builtin_setjmp_setup", ECF_NOTHROW); |
9053 | 9371 |
9054 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9372 ftype = build_function_type_list (ptr_type_node, ptr_type_node, NULL_TREE); |
9055 ftype = build_function_type (ptr_type_node, tmp); | |
9056 local_define_builtin ("__builtin_setjmp_dispatcher", ftype, | 9373 local_define_builtin ("__builtin_setjmp_dispatcher", ftype, |
9057 BUILT_IN_SETJMP_DISPATCHER, | 9374 BUILT_IN_SETJMP_DISPATCHER, |
9058 "__builtin_setjmp_dispatcher", | 9375 "__builtin_setjmp_dispatcher", |
9059 ECF_PURE | ECF_NOTHROW); | 9376 ECF_PURE | ECF_NOTHROW); |
9060 | 9377 |
9061 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9378 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9062 ftype = build_function_type (void_type_node, tmp); | |
9063 local_define_builtin ("__builtin_setjmp_receiver", ftype, | 9379 local_define_builtin ("__builtin_setjmp_receiver", ftype, |
9064 BUILT_IN_SETJMP_RECEIVER, | 9380 BUILT_IN_SETJMP_RECEIVER, |
9065 "__builtin_setjmp_receiver", ECF_NOTHROW); | 9381 "__builtin_setjmp_receiver", ECF_NOTHROW); |
9066 | 9382 |
9067 ftype = build_function_type (ptr_type_node, void_list_node); | 9383 ftype = build_function_type_list (ptr_type_node, NULL_TREE); |
9068 local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE, | 9384 local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE, |
9069 "__builtin_stack_save", ECF_NOTHROW); | 9385 "__builtin_stack_save", ECF_NOTHROW | ECF_LEAF); |
9070 | 9386 |
9071 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9387 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9072 ftype = build_function_type (void_type_node, tmp); | |
9073 local_define_builtin ("__builtin_stack_restore", ftype, | 9388 local_define_builtin ("__builtin_stack_restore", ftype, |
9074 BUILT_IN_STACK_RESTORE, | 9389 BUILT_IN_STACK_RESTORE, |
9075 "__builtin_stack_restore", ECF_NOTHROW); | 9390 "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF); |
9076 | |
9077 ftype = build_function_type (void_type_node, void_list_node); | |
9078 local_define_builtin ("__builtin_profile_func_enter", ftype, | |
9079 BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0); | |
9080 local_define_builtin ("__builtin_profile_func_exit", ftype, | |
9081 BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0); | |
9082 | 9391 |
9083 /* If there's a possibility that we might use the ARM EABI, build the | 9392 /* If there's a possibility that we might use the ARM EABI, build the |
9084 alternate __cxa_end_cleanup node used to resume from C++ and Java. */ | 9393 alternate __cxa_end_cleanup node used to resume from C++ and Java. */ |
9085 if (targetm.arm_eabi_unwinder) | 9394 if (targetm.arm_eabi_unwinder) |
9086 { | 9395 { |
9087 ftype = build_function_type (void_type_node, void_list_node); | 9396 ftype = build_function_type_list (void_type_node, NULL_TREE); |
9088 local_define_builtin ("__builtin_cxa_end_cleanup", ftype, | 9397 local_define_builtin ("__builtin_cxa_end_cleanup", ftype, |
9089 BUILT_IN_CXA_END_CLEANUP, | 9398 BUILT_IN_CXA_END_CLEANUP, |
9090 "__cxa_end_cleanup", ECF_NORETURN); | 9399 "__cxa_end_cleanup", ECF_NORETURN | ECF_LEAF); |
9091 } | 9400 } |
9092 | 9401 |
9093 tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); | 9402 ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); |
9094 ftype = build_function_type (void_type_node, tmp); | |
9095 local_define_builtin ("__builtin_unwind_resume", ftype, | 9403 local_define_builtin ("__builtin_unwind_resume", ftype, |
9096 BUILT_IN_UNWIND_RESUME, | 9404 BUILT_IN_UNWIND_RESUME, |
9097 (USING_SJLJ_EXCEPTIONS | 9405 ((targetm.except_unwind_info (&global_options) |
9406 == UI_SJLJ) | |
9098 ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), | 9407 ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), |
9099 ECF_NORETURN); | 9408 ECF_NORETURN); |
9100 | 9409 |
9101 /* The exception object and filter values from the runtime. The argument | 9410 /* The exception object and filter values from the runtime. The argument |
9102 must be zero before exception lowering, i.e. from the front end. After | 9411 must be zero before exception lowering, i.e. from the front end. After |
9103 exception lowering, it will be the region number for the exception | 9412 exception lowering, it will be the region number for the exception |
9104 landing pad. These functions are PURE instead of CONST to prevent | 9413 landing pad. These functions are PURE instead of CONST to prevent |
9105 them from being hoisted past the exception edge that will initialize | 9414 them from being hoisted past the exception edge that will initialize |
9106 its value in the landing pad. */ | 9415 its value in the landing pad. */ |
9107 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); | 9416 ftype = build_function_type_list (ptr_type_node, |
9108 ftype = build_function_type (ptr_type_node, tmp); | 9417 integer_type_node, NULL_TREE); |
9109 local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER, | 9418 local_define_builtin ("__builtin_eh_pointer", ftype, BUILT_IN_EH_POINTER, |
9110 "__builtin_eh_pointer", ECF_PURE | ECF_NOTHROW); | 9419 "__builtin_eh_pointer", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9111 | 9420 |
9112 tmp2 = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); | 9421 tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); |
9113 ftype = build_function_type (tmp2, tmp); | 9422 ftype = build_function_type_list (tmp, integer_type_node, NULL_TREE); |
9114 local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER, | 9423 local_define_builtin ("__builtin_eh_filter", ftype, BUILT_IN_EH_FILTER, |
9115 "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW); | 9424 "__builtin_eh_filter", ECF_PURE | ECF_NOTHROW | ECF_LEAF); |
9116 | 9425 |
9117 tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); | 9426 ftype = build_function_type_list (void_type_node, |
9118 tmp = tree_cons (NULL_TREE, integer_type_node, tmp); | 9427 integer_type_node, integer_type_node, |
9119 ftype = build_function_type (void_type_node, tmp); | 9428 NULL_TREE); |
9120 local_define_builtin ("__builtin_eh_copy_values", ftype, | 9429 local_define_builtin ("__builtin_eh_copy_values", ftype, |
9121 BUILT_IN_EH_COPY_VALUES, | 9430 BUILT_IN_EH_COPY_VALUES, |
9122 "__builtin_eh_copy_values", ECF_NOTHROW); | 9431 "__builtin_eh_copy_values", ECF_NOTHROW); |
9123 | 9432 |
9124 /* Complex multiplication and division. These are handled as builtins | 9433 /* Complex multiplication and division. These are handled as builtins |
9138 type = lang_hooks.types.type_for_mode ((enum machine_mode) mode, 0); | 9447 type = lang_hooks.types.type_for_mode ((enum machine_mode) mode, 0); |
9139 if (type == NULL) | 9448 if (type == NULL) |
9140 continue; | 9449 continue; |
9141 inner_type = TREE_TYPE (type); | 9450 inner_type = TREE_TYPE (type); |
9142 | 9451 |
9143 tmp = tree_cons (NULL_TREE, inner_type, void_list_node); | 9452 ftype = build_function_type_list (type, inner_type, inner_type, |
9144 tmp = tree_cons (NULL_TREE, inner_type, tmp); | 9453 inner_type, inner_type, NULL_TREE); |
9145 tmp = tree_cons (NULL_TREE, inner_type, tmp); | |
9146 tmp = tree_cons (NULL_TREE, inner_type, tmp); | |
9147 ftype = build_function_type (type, tmp); | |
9148 | 9454 |
9149 mcode = ((enum built_in_function) | 9455 mcode = ((enum built_in_function) |
9150 (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); | 9456 (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); |
9151 dcode = ((enum built_in_function) | 9457 dcode = ((enum built_in_function) |
9152 (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); | 9458 (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT)); |
9155 *q = TOLOWER (*p); | 9461 *q = TOLOWER (*p); |
9156 *q = '\0'; | 9462 *q = '\0'; |
9157 | 9463 |
9158 built_in_names[mcode] = concat ("__mul", mode_name_buf, "3", NULL); | 9464 built_in_names[mcode] = concat ("__mul", mode_name_buf, "3", NULL); |
9159 local_define_builtin (built_in_names[mcode], ftype, mcode, | 9465 local_define_builtin (built_in_names[mcode], ftype, mcode, |
9160 built_in_names[mcode], ECF_CONST | ECF_NOTHROW); | 9466 built_in_names[mcode], ECF_CONST | ECF_NOTHROW | ECF_LEAF); |
9161 | 9467 |
9162 built_in_names[dcode] = concat ("__div", mode_name_buf, "3", NULL); | 9468 built_in_names[dcode] = concat ("__div", mode_name_buf, "3", NULL); |
9163 local_define_builtin (built_in_names[dcode], ftype, dcode, | 9469 local_define_builtin (built_in_names[dcode], ftype, dcode, |
9164 built_in_names[dcode], ECF_CONST | ECF_NOTHROW); | 9470 built_in_names[dcode], ECF_CONST | ECF_NOTHROW | ECF_LEAF); |
9165 } | 9471 } |
9166 } | 9472 } |
9167 } | 9473 } |
9168 | 9474 |
9169 /* HACK. GROSS. This is absolutely disgusting. I wish there was a | 9475 /* HACK. GROSS. This is absolutely disgusting. I wish there was a |
9327 if (!initializer_zerop (elt)) | 9633 if (!initializer_zerop (elt)) |
9328 return false; | 9634 return false; |
9329 return true; | 9635 return true; |
9330 } | 9636 } |
9331 | 9637 |
9638 case STRING_CST: | |
9639 { | |
9640 int i; | |
9641 | |
9642 /* We need to loop through all elements to handle cases like | |
9643 "\0" and "\0foobar". */ | |
9644 for (i = 0; i < TREE_STRING_LENGTH (init); ++i) | |
9645 if (TREE_STRING_POINTER (init)[i] != '\0') | |
9646 return false; | |
9647 | |
9648 return true; | |
9649 } | |
9650 | |
9332 default: | 9651 default: |
9333 return false; | 9652 return false; |
9334 } | 9653 } |
9335 } | 9654 } |
9336 | 9655 |
9355 int size, length; | 9674 int size, length; |
9356 | 9675 |
9357 length = omp_clause_num_ops[code]; | 9676 length = omp_clause_num_ops[code]; |
9358 size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); | 9677 size = (sizeof (struct tree_omp_clause) + (length - 1) * sizeof (tree)); |
9359 | 9678 |
9360 t = GGC_NEWVAR (union tree_node, size); | 9679 t = ggc_alloc_tree_node (size); |
9361 memset (t, 0, size); | 9680 memset (t, 0, size); |
9362 TREE_SET_CODE (t, OMP_CLAUSE); | 9681 TREE_SET_CODE (t, OMP_CLAUSE); |
9363 OMP_CLAUSE_SET_CODE (t, code); | 9682 OMP_CLAUSE_SET_CODE (t, code); |
9364 OMP_CLAUSE_LOCATION (t) = loc; | 9683 OMP_CLAUSE_LOCATION (t) = loc; |
9365 | 9684 |
9388 #ifdef GATHER_STATISTICS | 9707 #ifdef GATHER_STATISTICS |
9389 tree_node_counts[(int) e_kind]++; | 9708 tree_node_counts[(int) e_kind]++; |
9390 tree_node_sizes[(int) e_kind] += length; | 9709 tree_node_sizes[(int) e_kind] += length; |
9391 #endif | 9710 #endif |
9392 | 9711 |
9393 t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone); | 9712 t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT); |
9394 | |
9395 memset (t, 0, length); | |
9396 | 9713 |
9397 TREE_SET_CODE (t, code); | 9714 TREE_SET_CODE (t, code); |
9398 | 9715 |
9399 /* Can't use TREE_OPERAND to store the length because if checking is | 9716 /* Can't use TREE_OPERAND to store the length because if checking is |
9400 enabled, it will try to check the length before we store it. :-P */ | 9717 enabled, it will try to check the length before we store it. :-P */ |
9401 t->exp.operands[0] = build_int_cst (sizetype, len); | 9718 t->exp.operands[0] = build_int_cst (sizetype, len); |
9402 | 9719 |
9403 return t; | |
9404 } | |
9405 | |
9406 | |
9407 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE | |
9408 and FN and a null static chain slot. ARGLIST is a TREE_LIST of the | |
9409 arguments. */ | |
9410 | |
9411 tree | |
9412 build_call_list (tree return_type, tree fn, tree arglist) | |
9413 { | |
9414 tree t; | |
9415 int i; | |
9416 | |
9417 t = build_vl_exp (CALL_EXPR, list_length (arglist) + 3); | |
9418 TREE_TYPE (t) = return_type; | |
9419 CALL_EXPR_FN (t) = fn; | |
9420 CALL_EXPR_STATIC_CHAIN (t) = NULL_TREE; | |
9421 for (i = 0; arglist; arglist = TREE_CHAIN (arglist), i++) | |
9422 CALL_EXPR_ARG (t, i) = TREE_VALUE (arglist); | |
9423 process_call_operands (t); | |
9424 return t; | 9720 return t; |
9425 } | 9721 } |
9426 | 9722 |
9427 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and | 9723 /* Build a CALL_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE and |
9428 FN and a null static chain slot. NARGS is the number of call arguments | 9724 FN and a null static chain slot. NARGS is the number of call arguments |
9491 | 9787 |
9492 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); | 9788 ret = build_vl_exp (CALL_EXPR, VEC_length (tree, args) + 3); |
9493 TREE_TYPE (ret) = return_type; | 9789 TREE_TYPE (ret) = return_type; |
9494 CALL_EXPR_FN (ret) = fn; | 9790 CALL_EXPR_FN (ret) = fn; |
9495 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; | 9791 CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE; |
9496 for (ix = 0; VEC_iterate (tree, args, ix, t); ++ix) | 9792 FOR_EACH_VEC_ELT (tree, args, ix, t) |
9497 CALL_EXPR_ARG (ret, ix) = t; | 9793 CALL_EXPR_ARG (ret, ix) = t; |
9498 process_call_operands (ret); | 9794 process_call_operands (ret); |
9499 return ret; | 9795 return ret; |
9500 } | 9796 } |
9501 | 9797 |
9571 t = SSA_NAME_VAR (t); | 9867 t = SSA_NAME_VAR (t); |
9572 | 9868 |
9573 return (TREE_ADDRESSABLE (t) | 9869 return (TREE_ADDRESSABLE (t) |
9574 || is_global_var (t) | 9870 || is_global_var (t) |
9575 || (TREE_CODE (t) == RESULT_DECL | 9871 || (TREE_CODE (t) == RESULT_DECL |
9872 && !DECL_BY_REFERENCE (t) | |
9576 && aggregate_value_p (t, current_function_decl))); | 9873 && aggregate_value_p (t, current_function_decl))); |
9577 } | 9874 } |
9578 | 9875 |
9579 /* There are situations in which a language considers record types | 9876 /* There are situations in which a language considers record types |
9580 compatible which have different field lists. Decide if two fields | 9877 compatible which have different field lists. Decide if two fields |
10087 WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0)); | 10384 WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0)); |
10088 | 10385 |
10089 case BIND_EXPR: | 10386 case BIND_EXPR: |
10090 { | 10387 { |
10091 tree decl; | 10388 tree decl; |
10092 for (decl = BIND_EXPR_VARS (*tp); decl; decl = TREE_CHAIN (decl)) | 10389 for (decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl)) |
10093 { | 10390 { |
10094 /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk | 10391 /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk |
10095 into declarations that are just mentioned, rather than | 10392 into declarations that are just mentioned, rather than |
10096 declared; they don't really belong to this part of the tree. | 10393 declared; they don't really belong to this part of the tree. |
10097 And, we can see cycles: the initializer for a declaration | 10394 And, we can see cycles: the initializer for a declaration |
10202 if (RECORD_OR_UNION_TYPE_P (*type_p)) | 10499 if (RECORD_OR_UNION_TYPE_P (*type_p)) |
10203 { | 10500 { |
10204 tree field; | 10501 tree field; |
10205 | 10502 |
10206 for (field = TYPE_FIELDS (*type_p); field; | 10503 for (field = TYPE_FIELDS (*type_p); field; |
10207 field = TREE_CHAIN (field)) | 10504 field = DECL_CHAIN (field)) |
10208 { | 10505 { |
10209 /* We'd like to look at the type of the field, but we can | 10506 /* We'd like to look at the type of the field, but we can |
10210 easily get infinite recursion. So assume it's pointed | 10507 easily get infinite recursion. So assume it's pointed |
10211 to elsewhere in the tree. Also, ignore things that | 10508 to elsewhere in the tree. Also, ignore things that |
10212 aren't fields. */ | 10509 aren't fields. */ |
10292 return &t->exp.block; | 10589 return &t->exp.block; |
10293 gcc_unreachable (); | 10590 gcc_unreachable (); |
10294 return NULL; | 10591 return NULL; |
10295 } | 10592 } |
10296 | 10593 |
10297 /* Build and return a TREE_LIST of arguments in the CALL_EXPR exp. | |
10298 FIXME: don't use this function. It exists for compatibility with | |
10299 the old representation of CALL_EXPRs where a list was used to hold the | |
10300 arguments. Places that currently extract the arglist from a CALL_EXPR | |
10301 ought to be rewritten to use the CALL_EXPR itself. */ | |
10302 tree | |
10303 call_expr_arglist (tree exp) | |
10304 { | |
10305 tree arglist = NULL_TREE; | |
10306 int i; | |
10307 for (i = call_expr_nargs (exp) - 1; i >= 0; i--) | |
10308 arglist = tree_cons (NULL_TREE, CALL_EXPR_ARG (exp, i), arglist); | |
10309 return arglist; | |
10310 } | |
10311 | |
10312 | |
10313 /* Create a nameless artificial label and put it in the current | 10594 /* Create a nameless artificial label and put it in the current |
10314 function context. The label has a location of LOC. Returns the | 10595 function context. The label has a location of LOC. Returns the |
10315 newly created label. */ | 10596 newly created label. */ |
10316 | 10597 |
10317 tree | 10598 tree |
10352 } | 10633 } |
10353 | 10634 |
10354 /* Return true if TYPE has a variable argument list. */ | 10635 /* Return true if TYPE has a variable argument list. */ |
10355 | 10636 |
10356 bool | 10637 bool |
10357 stdarg_p (tree fntype) | 10638 stdarg_p (const_tree fntype) |
10358 { | 10639 { |
10359 function_args_iterator args_iter; | 10640 function_args_iterator args_iter; |
10360 tree n = NULL_TREE, t; | 10641 tree n = NULL_TREE, t; |
10361 | 10642 |
10362 if (!fntype) | 10643 if (!fntype) |
10519 tree t; | 10800 tree t; |
10520 void **slot; | 10801 void **slot; |
10521 | 10802 |
10522 /* Use the cache of optimization nodes. */ | 10803 /* Use the cache of optimization nodes. */ |
10523 | 10804 |
10524 cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node)); | 10805 cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node), |
10806 &global_options); | |
10525 | 10807 |
10526 slot = htab_find_slot (cl_option_hash_table, cl_optimization_node, INSERT); | 10808 slot = htab_find_slot (cl_option_hash_table, cl_optimization_node, INSERT); |
10527 t = (tree) *slot; | 10809 t = (tree) *slot; |
10528 if (!t) | 10810 if (!t) |
10529 { | 10811 { |
10546 tree t; | 10828 tree t; |
10547 void **slot; | 10829 void **slot; |
10548 | 10830 |
10549 /* Use the cache of optimization nodes. */ | 10831 /* Use the cache of optimization nodes. */ |
10550 | 10832 |
10551 cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node)); | 10833 cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node), |
10834 &global_options); | |
10552 | 10835 |
10553 slot = htab_find_slot (cl_option_hash_table, cl_target_option_node, INSERT); | 10836 slot = htab_find_slot (cl_option_hash_table, cl_target_option_node, INSERT); |
10554 t = (tree) *slot; | 10837 t = (tree) *slot; |
10555 if (!t) | 10838 if (!t) |
10556 { | 10839 { |
10636 if (TREE_OPERAND (exp, 0) == error_mark_node) | 10919 if (TREE_OPERAND (exp, 0) == error_mark_node) |
10637 return false; | 10920 return false; |
10638 | 10921 |
10639 outer_type = TREE_TYPE (exp); | 10922 outer_type = TREE_TYPE (exp); |
10640 inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); | 10923 inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); |
10924 | |
10925 if (!inner_type) | |
10926 return false; | |
10641 | 10927 |
10642 /* Use precision rather then machine mode when we can, which gives | 10928 /* Use precision rather then machine mode when we can, which gives |
10643 the correct answer even for submode (bit-field) types. */ | 10929 the correct answer even for submode (bit-field) types. */ |
10644 if ((INTEGRAL_TYPE_P (outer_type) | 10930 if ((INTEGRAL_TYPE_P (outer_type) |
10645 || POINTER_TYPE_P (outer_type) | 10931 || POINTER_TYPE_P (outer_type) |
10700 | 10986 |
10701 tree | 10987 tree |
10702 lhd_gcc_personality (void) | 10988 lhd_gcc_personality (void) |
10703 { | 10989 { |
10704 if (!gcc_eh_personality_decl) | 10990 if (!gcc_eh_personality_decl) |
10705 gcc_eh_personality_decl | 10991 gcc_eh_personality_decl = build_personality_function ("gcc"); |
10706 = build_personality_function (USING_SJLJ_EXCEPTIONS | |
10707 ? "__gcc_personality_sj0" | |
10708 : "__gcc_personality_v0"); | |
10709 | |
10710 return gcc_eh_personality_decl; | 10992 return gcc_eh_personality_decl; |
10711 } | 10993 } |
10712 | 10994 |
10995 /* Try to find a base info of BINFO that would have its field decl at offset | |
10996 OFFSET within the BINFO type and which is of EXPECTED_TYPE. If it can be | |
10997 found, return, otherwise return NULL_TREE. */ | |
10998 | |
10999 tree | |
11000 get_binfo_at_offset (tree binfo, HOST_WIDE_INT offset, tree expected_type) | |
11001 { | |
11002 tree type = BINFO_TYPE (binfo); | |
11003 | |
11004 while (true) | |
11005 { | |
11006 HOST_WIDE_INT pos, size; | |
11007 tree fld; | |
11008 int i; | |
11009 | |
11010 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (expected_type)) | |
11011 return binfo; | |
11012 if (offset < 0) | |
11013 return NULL_TREE; | |
11014 | |
11015 for (fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) | |
11016 { | |
11017 if (TREE_CODE (fld) != FIELD_DECL) | |
11018 continue; | |
11019 | |
11020 pos = int_bit_position (fld); | |
11021 size = tree_low_cst (DECL_SIZE (fld), 1); | |
11022 if (pos <= offset && (pos + size) > offset) | |
11023 break; | |
11024 } | |
11025 if (!fld || TREE_CODE (TREE_TYPE (fld)) != RECORD_TYPE) | |
11026 return NULL_TREE; | |
11027 | |
11028 if (!DECL_ARTIFICIAL (fld)) | |
11029 { | |
11030 binfo = TYPE_BINFO (TREE_TYPE (fld)); | |
11031 if (!binfo) | |
11032 return NULL_TREE; | |
11033 } | |
11034 /* Offset 0 indicates the primary base, whose vtable contents are | |
11035 represented in the binfo for the derived class. */ | |
11036 else if (offset != 0) | |
11037 { | |
11038 tree base_binfo, found_binfo = NULL_TREE; | |
11039 for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) | |
11040 if (TREE_TYPE (base_binfo) == TREE_TYPE (fld)) | |
11041 { | |
11042 found_binfo = base_binfo; | |
11043 break; | |
11044 } | |
11045 if (!found_binfo) | |
11046 return NULL_TREE; | |
11047 binfo = found_binfo; | |
11048 } | |
11049 | |
11050 type = TREE_TYPE (fld); | |
11051 offset -= pos; | |
11052 } | |
11053 } | |
11054 | |
11055 /* Returns true if X is a typedef decl. */ | |
11056 | |
11057 bool | |
11058 is_typedef_decl (tree x) | |
11059 { | |
11060 return (x && TREE_CODE (x) == TYPE_DECL | |
11061 && DECL_ORIGINAL_TYPE (x) != NULL_TREE); | |
11062 } | |
11063 | |
11064 /* Returns true iff TYPE is a type variant created for a typedef. */ | |
11065 | |
11066 bool | |
11067 typedef_variant_p (tree type) | |
11068 { | |
11069 return is_typedef_decl (TYPE_NAME (type)); | |
11070 } | |
11071 | |
11072 /* Warn about a use of an identifier which was marked deprecated. */ | |
11073 void | |
11074 warn_deprecated_use (tree node, tree attr) | |
11075 { | |
11076 const char *msg; | |
11077 | |
11078 if (node == 0 || !warn_deprecated_decl) | |
11079 return; | |
11080 | |
11081 if (!attr) | |
11082 { | |
11083 if (DECL_P (node)) | |
11084 attr = DECL_ATTRIBUTES (node); | |
11085 else if (TYPE_P (node)) | |
11086 { | |
11087 tree decl = TYPE_STUB_DECL (node); | |
11088 if (decl) | |
11089 attr = lookup_attribute ("deprecated", | |
11090 TYPE_ATTRIBUTES (TREE_TYPE (decl))); | |
11091 } | |
11092 } | |
11093 | |
11094 if (attr) | |
11095 attr = lookup_attribute ("deprecated", attr); | |
11096 | |
11097 if (attr) | |
11098 msg = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))); | |
11099 else | |
11100 msg = NULL; | |
11101 | |
11102 if (DECL_P (node)) | |
11103 { | |
11104 expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node)); | |
11105 if (msg) | |
11106 warning (OPT_Wdeprecated_declarations, | |
11107 "%qD is deprecated (declared at %s:%d): %s", | |
11108 node, xloc.file, xloc.line, msg); | |
11109 else | |
11110 warning (OPT_Wdeprecated_declarations, | |
11111 "%qD is deprecated (declared at %s:%d)", | |
11112 node, xloc.file, xloc.line); | |
11113 } | |
11114 else if (TYPE_P (node)) | |
11115 { | |
11116 tree what = NULL_TREE; | |
11117 tree decl = TYPE_STUB_DECL (node); | |
11118 | |
11119 if (TYPE_NAME (node)) | |
11120 { | |
11121 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) | |
11122 what = TYPE_NAME (node); | |
11123 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL | |
11124 && DECL_NAME (TYPE_NAME (node))) | |
11125 what = DECL_NAME (TYPE_NAME (node)); | |
11126 } | |
11127 | |
11128 if (decl) | |
11129 { | |
11130 expanded_location xloc | |
11131 = expand_location (DECL_SOURCE_LOCATION (decl)); | |
11132 if (what) | |
11133 { | |
11134 if (msg) | |
11135 warning (OPT_Wdeprecated_declarations, | |
11136 "%qE is deprecated (declared at %s:%d): %s", | |
11137 what, xloc.file, xloc.line, msg); | |
11138 else | |
11139 warning (OPT_Wdeprecated_declarations, | |
11140 "%qE is deprecated (declared at %s:%d)", what, | |
11141 xloc.file, xloc.line); | |
11142 } | |
11143 else | |
11144 { | |
11145 if (msg) | |
11146 warning (OPT_Wdeprecated_declarations, | |
11147 "type is deprecated (declared at %s:%d): %s", | |
11148 xloc.file, xloc.line, msg); | |
11149 else | |
11150 warning (OPT_Wdeprecated_declarations, | |
11151 "type is deprecated (declared at %s:%d)", | |
11152 xloc.file, xloc.line); | |
11153 } | |
11154 } | |
11155 else | |
11156 { | |
11157 if (what) | |
11158 { | |
11159 if (msg) | |
11160 warning (OPT_Wdeprecated_declarations, "%qE is deprecated: %s", | |
11161 what, msg); | |
11162 else | |
11163 warning (OPT_Wdeprecated_declarations, "%qE is deprecated", what); | |
11164 } | |
11165 else | |
11166 { | |
11167 if (msg) | |
11168 warning (OPT_Wdeprecated_declarations, "type is deprecated: %s", | |
11169 msg); | |
11170 else | |
11171 warning (OPT_Wdeprecated_declarations, "type is deprecated"); | |
11172 } | |
11173 } | |
11174 } | |
11175 } | |
11176 | |
10713 #include "gt-tree.h" | 11177 #include "gt-tree.h" |