OLD | NEW |
1 /* Routines for writing PPH data. | 1 /* Routines for writing PPH data. |
2 Copyright (C) 2011 Free Software Foundation, Inc. | 2 Copyright (C) 2011 Free Software Foundation, Inc. |
3 Contributed by Diego Novillo <dnovillo@google.com>. | 3 Contributed by Diego Novillo <dnovillo@google.com>. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it | 7 GCC is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by | 8 under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3, or (at your option) | 9 the Free Software Foundation; either version 3, or (at your option) |
10 any later version. | 10 any later version. |
(...skipping 25 matching lines...) Expand all Loading... |
36 /* FIXME pph. This holds the FILE handle for the current PPH file | 36 /* FIXME pph. This holds the FILE handle for the current PPH file |
37 that we are writing. It is necessary because the LTO callbacks do | 37 that we are writing. It is necessary because the LTO callbacks do |
38 not allow passing a FILE handle to them. */ | 38 not allow passing a FILE handle to them. */ |
39 static FILE *current_pph_file = NULL; | 39 static FILE *current_pph_file = NULL; |
40 | 40 |
41 /* List of declarations to register with the middle end. This is | 41 /* List of declarations to register with the middle end. This is |
42 collected as the compiler instantiates symbols and functions. Once | 42 collected as the compiler instantiates symbols and functions. Once |
43 we finish parsing the header file, this array is written out to the | 43 we finish parsing the header file, this array is written out to the |
44 PPH image. This way, the reader will be able to instantiate these | 44 PPH image. This way, the reader will be able to instantiate these |
45 symbols in the same order that they were instantiated originally. */ | 45 symbols in the same order that they were instantiated originally. */ |
46 static VEC(tree,heap) *decls_to_register = NULL; | 46 typedef struct decls_to_register_t { |
| 47 /* Table of all the declarations to register in declaration order. */ |
| 48 VEC(tree,heap) *v; |
| 49 |
| 50 /* Set of declarations to register used to avoid adding duplicate |
| 51 entries to the table. */ |
| 52 struct pointer_set_t *m; |
| 53 } decls_to_register_t; |
| 54 |
| 55 static decls_to_register_t decls_to_register = { NULL, NULL }; |
47 | 56 |
48 /* Callback for packing value fields in ASTs. BP is the bitpack· | 57 /* Callback for packing value fields in ASTs. BP is the bitpack· |
49 we are packing into. EXPR is the tree to pack. */ | 58 we are packing into. EXPR is the tree to pack. */ |
50 | 59 |
51 void | 60 void |
52 pph_pack_value_fields (struct bitpack_d *bp, tree expr) | 61 pph_pack_value_fields (struct bitpack_d *bp, tree expr) |
53 { | 62 { |
54 if (TYPE_P (expr)) | 63 if (TYPE_P (expr)) |
55 { | 64 { |
56 bp_pack_value (bp, TYPE_LANG_FLAG_0 (expr), 1); | 65 bp_pack_value (bp, TYPE_LANG_FLAG_0 (expr), 1); |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 original header files and out of PPH images. | 1238 original header files and out of PPH images. |
1230 | 1239 |
1231 REF_P is as in pph_out_tree. */ | 1240 REF_P is as in pph_out_tree. */ |
1232 | 1241 |
1233 static void | 1242 static void |
1234 pph_out_symtab (pph_stream *stream, bool ref_p) | 1243 pph_out_symtab (pph_stream *stream, bool ref_p) |
1235 { | 1244 { |
1236 tree decl; | 1245 tree decl; |
1237 unsigned i; | 1246 unsigned i; |
1238 | 1247 |
1239 pph_out_uint (stream, VEC_length (tree, decls_to_register)); | 1248 pph_out_uint (stream, VEC_length (tree, decls_to_register.v)); |
1240 FOR_EACH_VEC_ELT (tree, decls_to_register, i, decl) | 1249 FOR_EACH_VEC_ELT (tree, decls_to_register.v, i, decl) |
1241 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_STRUCT_FUNCTION (decl)) | 1250 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_STRUCT_FUNCTION (decl)) |
1242 { | 1251 { |
1243 if (DECL_SAVED_TREE (decl)) | 1252 if (DECL_SAVED_TREE (decl)) |
1244 pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION_BODY); | 1253 pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION_BODY); |
1245 else | 1254 else |
1246 pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION); | 1255 pph_out_symtab_marker (stream, PPH_SYMTAB_FUNCTION); |
1247 pph_out_struct_function (stream, DECL_STRUCT_FUNCTION (decl), ref_p); | 1256 pph_out_struct_function (stream, DECL_STRUCT_FUNCTION (decl), ref_p); |
1248 } | 1257 } |
1249 else | 1258 else |
1250 { | 1259 { |
1251 pph_out_symtab_marker (stream, PPH_SYMTAB_DECL); | 1260 pph_out_symtab_marker (stream, PPH_SYMTAB_DECL); |
1252 pph_out_tree (stream, decl, ref_p); | 1261 pph_out_tree (stream, decl, ref_p); |
1253 } | 1262 } |
1254 | 1263 |
1255 VEC_free (tree, heap, decls_to_register); | 1264 if (decls_to_register.m) |
| 1265 { |
| 1266 VEC_free (tree, heap, decls_to_register.v); |
| 1267 pointer_set_destroy (decls_to_register.m); |
| 1268 decls_to_register.m = NULL; |
| 1269 } |
1256 } | 1270 } |
1257 | 1271 |
1258 | 1272 |
1259 /* Write PPH output symbols and IDENTS_USED to STREAM as an object. */ | 1273 /* Write PPH output symbols and IDENTS_USED to STREAM as an object. */ |
1260 | 1274 |
1261 static void | 1275 static void |
1262 pph_write_file_contents (pph_stream *stream, cpp_idents_used *idents_used) | 1276 pph_write_file_contents (pph_stream *stream, cpp_idents_used *idents_used) |
1263 {· | 1277 {· |
1264 /* Emit all the identifiers and symbols in the global namespace. */ | 1278 /* Emit all the identifiers and symbols in the global namespace. */ |
1265 pph_out_identifiers (stream, idents_used); | 1279 pph_out_identifiers (stream, idents_used); |
| 1280 |
| 1281 /* Emit the bindings for the global namespace. */ |
1266 pph_out_scope_chain (stream, scope_chain, false); | 1282 pph_out_scope_chain (stream, scope_chain, false); |
1267 if (flag_pph_dump_tree) | 1283 if (flag_pph_dump_tree) |
1268 pph_dump_namespace (pph_logfile, global_namespace); | 1284 pph_dump_namespace (pph_logfile, global_namespace); |
1269 | 1285 |
1270 /* Emit other global state kept by the parser. FIXME pph, these | 1286 /* Emit other global state kept by the parser. FIXME pph, these |
1271 globals should be fields in struct cp_parser. */ | 1287 globals should be fields in struct cp_parser. */ |
1272 pph_out_tree (stream, keyed_classes, false); | 1288 pph_out_tree (stream, keyed_classes, false); |
1273 pph_out_tree_vec (stream, unemitted_tinfo_decls, false); | 1289 pph_out_tree_vec (stream, unemitted_tinfo_decls, false); |
1274 pph_out_tree (stream, static_aggregates, false); | 1290 pph_out_tree (stream, static_aggregates, false); |
1275 | 1291 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 } | 1674 } |
1659 | 1675 |
1660 | 1676 |
1661 /* Add DECL to the list of symbols that need to be registered with the | 1677 /* Add DECL to the list of symbols that need to be registered with the |
1662 middle end when reading current_pph_stream. */ | 1678 middle end when reading current_pph_stream. */ |
1663 | 1679 |
1664 void | 1680 void |
1665 pph_add_decl_to_register (tree decl) | 1681 pph_add_decl_to_register (tree decl) |
1666 { | 1682 { |
1667 if (decl) | 1683 if (decl) |
1668 VEC_safe_push (tree, heap, decls_to_register, decl); | 1684 { |
| 1685 if (decls_to_register.m == NULL) |
| 1686 » decls_to_register.m = pointer_set_create (); |
| 1687 |
| 1688 if (!pointer_set_insert (decls_to_register.m, decl)) |
| 1689 » VEC_safe_push (tree, heap, decls_to_register.v, decl); |
| 1690 } |
1669 } | 1691 } |
OLD | NEW |