* target.def (narrow_volatile_bitfield): Note that the default
[official-gcc.git] / gcc / context.h
blob2211dc43ee9ebc6a9569cda70f43a9b9d91d5101
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
9 version.
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.
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/>. */
20 #ifndef GCC_CONTEXT_H
21 #define GCC_CONTEXT_H
23 namespace gcc {
25 class pass_manager;
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
29 context of state. */
30 class GTY((user)) context
32 public:
33 /* Ensure that instances are allocated within the GC-heap. */
34 void *operator new (std::size_t size);
36 context();
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
45 heap.
47 The methods are called the *first time* that the context is reached
48 during a ggc/pch traversal, rather than every time. */
50 void gt_ggc_mx ();
51 void gt_pch_nx ();
52 void gt_pch_nx (gt_pointer_operator op, void *cookie);
54 /* Pass-management. */
56 pass_manager *get_passes () { gcc_assert (passes_); return passes_; }
58 private:
59 /* Pass-management. */
60 pass_manager *passes_;
62 }; // class context
64 } // namespace gcc
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
74 gtype-desc.c:
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,
79 void *x_p,
80 gt_pointer_operator op,
81 void *cookie);
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). */
88 inline void
89 gt_ggc_mx (gcc::context *ctxt)
91 ctxt->gt_ggc_mx ();
94 inline void
95 gt_pch_nx (gcc::context *ctxt)
97 ctxt->gt_pch_nx ();
100 inline void
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 */