1 /* context.h - Holder for global state
2 Copyright (C) 2013 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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/>. */
27 /* GCC's internal state can be divided into zero or more
28 "parallel universe" of state; an instance of this class is one such
30 class GTY((user
)) context
33 /* Ensure that instances are allocated within the GC-heap. */
34 void *operator new (std::size_t size
);
38 /* Garbage-collector integration.
40 Each context assumes it has full control of the GC-heap that it
41 is associated with. It acts as a root for that GC-heap, owning
42 references to within it.
44 Note that context instances are allocated within their own GC
47 The methods are called the *first time* that the context is reached
48 during a ggc/pch traversal, rather than every time. */
52 void gt_pch_nx (gt_pointer_operator op
, void *cookie
);
54 /* Pass-management. */
56 pass_manager
*get_passes () { gcc_assert (passes_
); return passes_
; }
59 /* Pass-management. */
60 pass_manager
*passes_
;
66 /* The global singleton context aka "g".
67 (the name is chosen to be easy to type in a debugger). */
68 extern GTY(()) gcc::context
*g
;
70 /* Global hooks for ggc/pch.
72 The gcc::context class is marked with GTY((user)), which leads to
73 gengtype creating autogenerated functions for handling context within
76 void gt_ggc_mx_context (void *x_p);
77 void gt_pch_nx_context (void *x_p)
78 void gt_pch_p_7context (void *this_obj,
80 gt_pointer_operator op,
83 Those functions call the following global functions the first time
84 that the context is reached during a traversal, and the following
85 global functions in turn simply call the corresponding methods of the
86 context (so that they can access private fields of the context). */
89 gt_ggc_mx (gcc::context
*ctxt
)
95 gt_pch_nx (gcc::context
*ctxt
)
101 gt_pch_nx (gcc::context
*ctxt
, gt_pointer_operator op
, void *cookie
)
103 ctxt
->gt_pch_nx (op
, cookie
);
106 #endif /* ! GCC_CONTEXT_H */