* ggc.h (ggc_alloc): New function.
[official-gcc.git] / gcc / ggc.h
blobb0673e0e05a43885d2df7d401b18d4bf1ed4de34
1 /* Garbage collection for the GNU compiler.
2 Copyright (C) 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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.
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.
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. */
21 #include "gansidecl.h"
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. */
26 /* Language-specific code defines this variable to be either one (if
27 it wants garbage collection), or zero (if it does not). */
28 extern int ggc_p;
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. */
34 struct label_node;
35 struct eh_status;
36 struct emit_status;
37 struct stmt_status;
38 struct varasm_status;
39 struct varray_head_tag;
40 struct hash_table;
42 /* Startup */
44 extern void init_ggc PROTO ((void));
46 /* Start a new GGC context. Memory allocated in previous contexts
47 will not be collected while the new context is active. */
48 extern void ggc_pop_context PROTO ((void));
49 /* Finish a GC context. Any uncollected memory in the new context
50 will be merged with the old context. */
51 extern void ggc_push_context PROTO ((void));
53 /* Allocation. */
55 struct rtx_def *ggc_alloc_rtx PROTO ((int nslots));
56 struct rtvec_def *ggc_alloc_rtvec PROTO ((int nelt));
57 union tree_node *ggc_alloc_tree PROTO ((int length));
58 char *ggc_alloc_string PROTO ((const char *contents, int length));
59 void *ggc_alloc PROTO ((size_t));
61 /* Invoke the collector. This is really just a hint, but in the case of
62 the simple collector, the only time it will happen. */
64 void ggc_collect PROTO ((void));
66 /* Manipulate global roots that are needed between calls to gc. */
67 void ggc_add_root PROTO ((void *base, int nelt, int size,
68 void (*)(void *)));
69 void ggc_add_rtx_root PROTO ((struct rtx_def **, int nelt));
70 void ggc_add_tree_root PROTO ((union tree_node **, int nelt));
71 void ggc_add_tree_varray_root PROTO ((struct varray_head_tag **, int nelt));
72 void ggc_add_tree_hash_table_root PROTO ((struct hash_table **, int nelt));
73 void ggc_del_root PROTO ((void *base));
75 /* Mark nodes from the gc_add_root callback. */
76 void ggc_mark_rtx PROTO ((struct rtx_def *));
77 void ggc_mark_rtvec PROTO ((struct rtvec_def *));
78 void ggc_mark_tree PROTO ((union tree_node *));
79 void ggc_mark_tree_varray PROTO ((struct varray_head_tag *));
80 void ggc_mark_tree_hash_table PROTO ((struct hash_table *));
81 void ggc_mark_string PROTO ((char *));
82 void ggc_mark PROTO ((void *));
84 /* Callbacks to the languages. */
86 /* This is the language's opportunity to mark nodes held through
87 the lang_specific hooks in the tree. */
88 void lang_mark_tree PROTO ((union tree_node *));
90 /* And similarly to free that data when the tree node is released. */
91 void lang_cleanup_tree PROTO ((union tree_node *));
93 /* The FALSE_LABEL_STACK, declared in except.h, has
94 language-dependent semantics. Each front-end should define this
95 function appropriately. */
96 void lang_mark_false_label_stack PROTO ((struct label_node *));
98 /* Mark functions for various structs scattered about. */
100 void mark_eh_state PROTO ((struct eh_status *));
101 void mark_stmt_state PROTO ((struct stmt_status *));
102 void mark_emit_state PROTO ((struct emit_status *));
103 void mark_varasm_state PROTO ((struct varasm_status *));
104 void mark_optab PROTO ((void *));