]>
Commit | Line | Data |
---|---|---|
4a4412b9 | 1 | /* Emit optimization information as JSON files. |
7adcbafe | 2 | Copyright (C) 2018-2022 Free Software Foundation, Inc. |
4a4412b9 DM |
3 | Contributed by David Malcolm <dmalcolm@redhat.com>. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #ifndef GCC_OPTINFO_EMIT_JSON_H | |
22 | #define GCC_OPTINFO_EMIT_JSON_H | |
23 | ||
8d1af516 | 24 | #include "json.h" |
4a4412b9 | 25 | |
8d1af516 | 26 | class optinfo; |
4a4412b9 | 27 | |
8d1af516 DM |
28 | /* A class for writing out optimization records in JSON format. */ |
29 | ||
30 | class optrecord_json_writer | |
31 | { | |
32 | public: | |
33 | optrecord_json_writer (); | |
34 | ~optrecord_json_writer (); | |
35 | void write () const; | |
36 | void add_record (const optinfo *optinfo); | |
37 | void pop_scope (); | |
38 | ||
39 | void add_record (json::object *obj); | |
40 | json::object *impl_location_to_json (dump_impl_location_t loc); | |
41 | json::object *location_to_json (location_t loc); | |
42 | json::object *profile_count_to_json (profile_count count); | |
43 | json::string *get_id_value_for_pass (opt_pass *pass); | |
44 | json::object *pass_to_json (opt_pass *pass); | |
45 | json::value *inlining_chain_to_json (location_t loc); | |
46 | json::object *optinfo_to_json (const optinfo *optinfo); | |
47 | void add_pass_list (json::array *arr, opt_pass *pass); | |
48 | ||
49 | private: | |
50 | /* The root value for the JSON file. | |
51 | Currently the JSON values are stored in memory, and flushed when the | |
52 | compiler exits. It would probably be better to simply write out | |
53 | the JSON as we go. */ | |
54 | json::array *m_root_tuple; | |
55 | ||
56 | /* The currently open scopes, for expressing nested optimization records. */ | |
57 | auto_vec<json::array *> m_scopes; | |
58 | }; | |
4a4412b9 DM |
59 | |
60 | #endif /* #ifndef GCC_OPTINFO_EMIT_JSON_H */ |