]> gcc.gnu.org Git - gcc.git/blame - gcc/ggc.h
ppc-asm.h (FUNC_START): Use USER_LABEL_PREFIX.
[gcc.git] / gcc / ggc.h
CommitLineData
0a25f1f5 1/* Garbage collection for the GNU compiler.
9311a396 2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
0a25f1f5
RH
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include "gansidecl.h"
22
23/* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with
24 an external gc library that might be linked in. */
25
a3770a81
RH
26/* Language-specific code defines this variable to be either one (if
27 it wants garbage collection), or zero (if it does not). */
28extern int ggc_p;
29
87ff9c8e
RH
30/* These structures are defined in various headers throughout the
31 compiler. However, rather than force everyone who includes this
32 header to include all the headers in which they are declared, we
33 just forward-declare them here. */
87ff9c8e
RH
34struct eh_status;
35struct emit_status;
fa51b01b 36struct expr_status;
b49a6a90
AS
37struct hash_table;
38struct label_node;
39struct rtvec_def;
87ff9c8e 40struct stmt_status;
b49a6a90 41union tree_node;
87ff9c8e 42struct varasm_status;
a3770a81 43struct varray_head_tag;
87ff9c8e 44
21a427cc
AS
45/* Constants for general use. */
46extern char *empty_string;
47
b49a6a90 48/* Manipulate global roots that are needed between calls to gc. */
3fe41456
KG
49void ggc_add_root PARAMS ((void *base, int nelt, int size, void (*)(void *)));
50void ggc_add_rtx_root PARAMS ((struct rtx_def **, int nelt));
51void ggc_add_tree_root PARAMS ((union tree_node **, int nelt));
52void ggc_add_string_root PARAMS ((char **, int nelt));
ef8288f7 53void ggc_add_rtx_varray_root PARAMS ((struct varray_head_tag **, int nelt));
3fe41456
KG
54void ggc_add_tree_varray_root PARAMS ((struct varray_head_tag **, int nelt));
55void ggc_add_tree_hash_table_root PARAMS ((struct hash_table **, int nelt));
56void ggc_del_root PARAMS ((void *base));
0a25f1f5 57
b49a6a90
AS
58/* Mark nodes from the gc_add_root callback. These functions follow
59 pointers to mark other objects too. */
ef8288f7 60extern void ggc_mark_rtx_varray PARAMS ((struct varray_head_tag *));
3fe41456
KG
61extern void ggc_mark_tree_varray PARAMS ((struct varray_head_tag *));
62extern void ggc_mark_tree_hash_table PARAMS ((struct hash_table *));
63extern void ggc_mark_roots PARAMS ((void));
96df4529 64
3fe41456
KG
65extern void ggc_mark_rtx_children PARAMS ((struct rtx_def *));
66extern void ggc_mark_rtvec_children PARAMS ((struct rtvec_def *));
67extern void ggc_mark_tree_children PARAMS ((union tree_node *));
96df4529 68
52a92176
AS
69/* If EXPR is not NULL and previously unmarked, mark it and evaluate
70 to true. Otherwise evaluate to false. */
71#define ggc_test_and_set_mark(EXPR) \
72 ((EXPR) != NULL && ! ggc_set_mark (EXPR))
73
74#define ggc_mark_rtx(EXPR) \
75 do { \
76 rtx r__ = (EXPR); \
77 if (ggc_test_and_set_mark (r__)) \
78 ggc_mark_rtx_children (r__); \
005537df
RH
79 } while (0)
80
52a92176
AS
81#define ggc_mark_tree(EXPR) \
82 do { \
83 tree t__ = (EXPR); \
84 if (ggc_test_and_set_mark (t__)) \
85 ggc_mark_tree_children (t__); \
005537df 86 } while (0)
74c937ca 87
52a92176
AS
88#define ggc_mark_rtvec(EXPR) \
89 do { \
90 rtvec v__ = (EXPR); \
91 if (ggc_test_and_set_mark (v__)) \
92 ggc_mark_rtvec_children (v__); \
96df4529
AS
93 } while (0)
94
005537df
RH
95#define ggc_mark_string(EXPR) \
96 do { \
97 char *s__ = (EXPR); \
98 if (s__ != NULL) \
99 ggc_set_mark (s__); \
96df4529 100 } while (0)
b49a6a90 101
005537df
RH
102#define ggc_mark(EXPR) \
103 do { \
104 void *a__ = (EXPR); \
105 if (a__ != NULL) \
106 ggc_set_mark (a__); \
107 } while (0)
108
109/* Mark, but only if it was allocated in collectable memory. */
3fe41456 110extern void ggc_mark_if_gcable PARAMS ((void *));
005537df 111
b49a6a90
AS
112/* A GC implementation must provide these functions. */
113
114/* Initialize the garbage collector. */
3fe41456 115extern void init_ggc PARAMS ((void));
0a25f1f5 116
21cd906e
MM
117/* Start a new GGC context. Memory allocated in previous contexts
118 will not be collected while the new context is active. */
3fe41456 119extern void ggc_push_context PARAMS ((void));
b49a6a90 120
21cd906e
MM
121/* Finish a GC context. Any uncollected memory in the new context
122 will be merged with the old context. */
3fe41456 123extern void ggc_pop_context PARAMS ((void));
21cd906e 124
0a25f1f5 125/* Allocation. */
005537df
RH
126
127/* The internal primitive. */
3fe41456 128void *ggc_alloc_obj PARAMS ((size_t, int));
005537df
RH
129
130#define ggc_alloc_rtx(NSLOTS) \
131 ((struct rtx_def *) ggc_alloc_obj (sizeof (struct rtx_def) \
132 + ((NSLOTS) - 1) * sizeof (rtunion), 1))
133
134#define ggc_alloc_rtvec(NELT) \
135 ((struct rtvec_def *) ggc_alloc_obj (sizeof (struct rtvec_def) \
136 + ((NELT) - 1) * sizeof (rtx), 1))
137
138#define ggc_alloc_tree(LENGTH) \
139 ((union tree_node *) ggc_alloc_obj ((LENGTH), 1))
140
141#define ggc_alloc(SIZE) ggc_alloc_obj((SIZE), 0)
142
3fe41456 143char *ggc_alloc_string PARAMS ((const char *contents, int length));
0a25f1f5
RH
144
145/* Invoke the collector. This is really just a hint, but in the case of
146 the simple collector, the only time it will happen. */
3fe41456 147void ggc_collect PARAMS ((void));
0a25f1f5 148
b49a6a90 149/* Actually set the mark on a particular region of memory, but don't
005537df
RH
150 follow pointers. This function is called by ggc_mark_*. It
151 returns zero if the object was not previously marked; non-zero if
152 the object was already marked, or if, for any other reason,
153 pointers in this data structure should not be traversed. */
3fe41456 154int ggc_set_mark PARAMS ((void *));
0a25f1f5 155
0a25f1f5
RH
156/* Callbacks to the languages. */
157
158/* This is the language's opportunity to mark nodes held through
159 the lang_specific hooks in the tree. */
3fe41456 160void lang_mark_tree PARAMS ((union tree_node *));
0a25f1f5 161
87ff9c8e
RH
162/* The FALSE_LABEL_STACK, declared in except.h, has
163 language-dependent semantics. Each front-end should define this
164 function appropriately. */
3fe41456 165void lang_mark_false_label_stack PARAMS ((struct label_node *));
87ff9c8e 166
0a25f1f5
RH
167/* Mark functions for various structs scattered about. */
168
3fe41456
KG
169void mark_eh_status PARAMS ((struct eh_status *));
170void mark_emit_status PARAMS ((struct emit_status *));
171void mark_expr_status PARAMS ((struct expr_status *));
172void mark_stmt_status PARAMS ((struct stmt_status *));
173void mark_varasm_status PARAMS ((struct varasm_status *));
174void mark_optab PARAMS ((void *));
3277221c
MM
175
176/* Statistics. */
177
178/* This structure contains the statistics common to all collectors.
179 Particular collectors can extend this structure. */
180typedef struct ggc_statistics
181{
182 /* The Ith element is the number of nodes allocated with code I. */
183 unsigned num_trees[256];
184 /* The Ith element is the number of bytes allocated by nodes with
185 code I. */
186 size_t size_trees[256];
187 /* The Ith element is the number of nodes allocated with code I. */
188 unsigned num_rtxs[256];
189 /* The Ith element is the number of bytes allocated by nodes with
190 code I. */
191 size_t size_rtxs[256];
3277221c
MM
192 /* The total size of the tree nodes allocated. */
193 size_t total_size_trees;
3277221c
MM
194 /* The total size of the RTL nodes allocated. */
195 size_t total_size_rtxs;
63408827
RH
196 /* The total number of tree nodes allocated. */
197 unsigned total_num_trees;
198 /* The total number of RTL nodes allocated. */
199 unsigned total_num_rtxs;
3277221c
MM
200} ggc_statistics;
201
202/* Return the number of bytes allocated at the indicated address. */
3fe41456 203size_t ggc_get_size PARAMS ((void *));
3277221c
MM
204
205/* Used by the various collectors to gather and print statistics that
206 do not depend on the collector in use. */
3fe41456 207void ggc_print_statistics PARAMS ((FILE *, ggc_statistics *));
This page took 0.152131 seconds and 5 git commands to generate.