Line data Source code
1 : /* context.h - Holder for global state
2 : Copyright (C) 2013-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : #ifndef GCC_CONTEXT_H
21 : #define GCC_CONTEXT_H
22 :
23 : namespace gcc {
24 :
25 : class pass_manager;
26 : class dump_manager;
27 : struct compiler_channels;
28 :
29 : /* GCC's internal state can be divided into zero or more
30 : "parallel universe" of state; an instance of this class is one such
31 : context of state. */
32 : class context
33 : {
34 : public:
35 : context ();
36 : ~context ();
37 :
38 : /* The flag shows if there are symbols to be streamed for offloading. */
39 : bool have_offload;
40 :
41 : /* Pass-management. */
42 :
43 285722 : void set_passes (pass_manager *m)
44 : {
45 285722 : gcc_assert (!m_passes);
46 285722 : m_passes = m;
47 285722 : }
48 :
49 7562675 : pass_manager *get_passes () { gcc_assert (m_passes); return m_passes; }
50 :
51 : /* Handling dump files. */
52 :
53 2136068973 : dump_manager *get_dumps () {gcc_assert (m_dumps); return m_dumps; }
54 :
55 : /* Publish/subscribe channels for events
56 : on various compiler-specific topics. */
57 : compiler_channels &
58 784626020 : get_channels () const
59 : {
60 784626020 : gcc_assert (m_channels);
61 784626020 : return *m_channels;
62 : }
63 :
64 : private:
65 : /* Pass-management. */
66 : pass_manager *m_passes;
67 :
68 : /* Dump files. */
69 : dump_manager *m_dumps;
70 :
71 : compiler_channels *m_channels;
72 :
73 : }; // class context
74 :
75 : } // namespace gcc
76 :
77 : /* The global singleton context aka "g".
78 : (the name is chosen to be easy to type in a debugger). */
79 : extern gcc::context *g;
80 :
81 : #endif /* ! GCC_CONTEXT_H */
|