]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/langhooks.h
* dyn-string.c: Add libgcc exception to copyright notice.
[thirdparty/gcc.git] / gcc / langhooks.h
CommitLineData
b0278d39 1/* The lang_hooks data structure.
20325f61 2 Copyright 2001, 2002 Free Software Foundation, Inc.
e8602e56 3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21#ifndef GCC_LANG_HOOKS_H
22#define GCC_LANG_HOOKS_H
23
b7fced5e 24/* A print hook for print_tree (). */
25typedef void (*lang_print_tree_hook) PARAMS ((FILE *, tree, int indent));
26
b0278d39 27/* The following hooks are documented in langhooks.c. Must not be
28 NULL. */
29
30struct lang_hooks_for_tree_inlining
31{
32 union tree_node *(*walk_subtrees) PARAMS ((union tree_node **, int *,
33 union tree_node *(*)
34 (union tree_node **,
35 int *, void *),
36 void *, void *));
37 int (*cannot_inline_tree_fn) PARAMS ((union tree_node **));
38 int (*disregard_inline_limits) PARAMS ((union tree_node *));
39 union tree_node *(*add_pending_fn_decls) PARAMS ((void *,
40 union tree_node *));
41 int (*tree_chain_matters_p) PARAMS ((union tree_node *));
42 int (*auto_var_in_fn_p) PARAMS ((union tree_node *, union tree_node *));
43 union tree_node *(*copy_res_decl_for_inlining) PARAMS ((union tree_node *,
44 union tree_node *,
45 union tree_node *,
46 void *, int *,
47 void *));
48 int (*anon_aggr_type_p) PARAMS ((union tree_node *));
054e01a7 49 int (*start_inlining) PARAMS ((union tree_node *));
50 void (*end_inlining) PARAMS ((union tree_node *));
78b80426 51 union tree_node *(*convert_parm_for_inlining) PARAMS ((union tree_node *,
52 union tree_node *,
53 union tree_node *));
b0278d39 54};
55
3119c950 56/* The following hooks are used by tree-dump.c. */
57
58struct lang_hooks_for_tree_dump
59{
60 /* Dump language-specific parts of tree nodes. Returns non-zero if it
61 does not want the usual dumping of the second argument. */
62 int (*dump_tree) PARAMS ((void *, tree));
63
64 /* Determine type qualifiers in a language-specific way. */
65 int (*type_quals) PARAMS ((tree));
66};
67
20325f61 68/* Language hooks related to decls and the symbol table. */
69
70struct lang_hooks_for_decls
71{
72 /* Enter a new lexical scope. Argument is always zero when called
73 from outside the front end. */
74 void (*pushlevel) PARAMS ((int));
75
76 /* Exit a lexical scope and return a BINDING for that scope.
77 Takes three arguments:
78 KEEP -- nonzero if there were declarations in this scope.
79 REVERSE -- reverse the order of decls before returning them.
80 FUNCTIONBODY -- nonzero if this level is the body of a function. */
81 tree (*poplevel) PARAMS ((int, int, int));
82
83 /* Returns non-zero if we are in the global binding level. Ada
84 returns -1 for an undocumented reason used in stor-layout.c. */
85 int (*global_bindings_p) PARAMS ((void));
86
87 /* Insert BLOCK at the end of the list of subblocks of the
88 current binding level. This is used when a BIND_EXPR is expanded,
89 to handle the BLOCK node inside the BIND_EXPR. */
90 void (*insert_block) PARAMS ((tree));
91
92 /* Set the BLOCK node for the current scope level. */
93 void (*set_block) PARAMS ((tree));
94
95 /* Function to add a decl to the current scope level. Takes one
96 argument, a decl to add. Returns that decl, or, if the same
97 symbol is already declared, may return a different decl for that
98 name. */
99 tree (*pushdecl) PARAMS ((tree));
100
101 /* Returns the chain of decls so far in the current scope level. */
102 tree (*getdecls) PARAMS ((void));
103};
104
b0278d39 105/* Language-specific hooks. See langhooks-def.h for defaults. */
106
107struct lang_hooks
108{
d19bd1f0 109 /* String identifying the front end. e.g. "GNU C++". */
110 const char *name;
111
112 /* sizeof (struct lang_identifier), so make_node () creates
113 identifier nodes long enough for the language-specific slots. */
114 size_t identifier_size;
115
435fb09b 116 /* The first callback made to the front end, for simple
117 initialization needed before any calls to decode_option. */
b0278d39 118 void (*init_options) PARAMS ((void));
119
120 /* Function called with an option vector as argument, to decode a
121 single option (typically starting with -f or -W or +). It should
122 return the number of command-line arguments it uses if it handles
123 the option, or 0 and not complain if it does not recognise the
124 option. If this function returns a negative number, then its
125 absolute value is the number of command-line arguments used, but,
126 in addition, no language-independent option processing should be
127 done for this option. */
128 int (*decode_option) PARAMS ((int, char **));
129
435fb09b 130 /* Called when all command line options have been parsed. Should do
131 any required consistency checks, modifications etc. Complex
132 initialization should be left to the "init" callback, since GC
133 and the identifier hashes are set up between now and then. */
b0278d39 134 void (*post_options) PARAMS ((void));
135
435fb09b 136 /* Called after post_options, to initialize the front end. The main
137 input filename is passed, which may be NULL; the front end should
138 return the original filename (e.g. foo.i -> foo.c). Return NULL
139 to indicate a serious error of some sort; in that case no
140 compilation is performed, and the finish hook is called
141 immediately. */
142 const char * (*init) PARAMS ((const char *));
143
144 /* Called at the end of compilation, as a finalizer. */
145 void (*finish) PARAMS ((void));
146
b78207a0 147 /* Parses the entire file. */
148 void (*parse_file) PARAMS ((void));
149
435fb09b 150 /* Called immediately after parsing to clear the binding stack. */
151 void (*clear_binding_stack) PARAMS ((void));
152
b0278d39 153 /* Called to obtain the alias set to be used for an expression or type.
154 Returns -1 if the language does nothing special for it. */
155 HOST_WIDE_INT (*get_alias_set) PARAMS ((tree));
156
b3187c7c 157 /* Called with an expression that is to be processed as a constant.
158 Returns either the same expression or a language-independent
159 constant equivalent to its input. */
160 tree (*expand_constant) PARAMS ((tree));
161
162 /* Hook called by safe_from_p for language-specific tree codes. It is
163 up to the language front-end to install a hook if it has any such
164 codes that safe_from_p needs to know about. Since same_from_p will
165 recursively explore the TREE_OPERANDs of an expression, this hook
166 should not reexamine those pieces. This routine may recursively
167 call safe_from_p; it should always pass `0' as the TOP_P
168 parameter. */
169 int (*safe_from_p) PARAMS ((rtx, tree));
170
f1833f1b 171 /* Hook called by staticp for language-specific tree codes. */
172 int (*staticp) PARAMS ((tree));
173
dbc42b78 174 /* Replace the DECL_LANG_SPECIFIC data, which may be NULL, of the
175 DECL_NODE with a newly GC-allocated copy. */
176 void (*dup_lang_specific_decl) PARAMS ((tree));
177
1d347c23 178 /* Called before its argument, an UNSAVE_EXPR, is to be
179 unsaved. Modify it in-place so that all the evaluate only once
180 things are cleared out. */
181 tree (*unsave_expr_now) PARAMS ((tree));
182
04745efb 183 /* Called by expand_expr to build and return the cleanup-expression
184 for the passed TARGET_EXPR. Return NULL if there is none. */
185 tree (*maybe_build_cleanup) PARAMS ((tree));
186
6d26a3ee 187 /* Mark nodes held through the lang_specific hooks in the tree. */
188 void (*mark_tree) PARAMS ((tree));
189
b0278d39 190 /* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored. */
191 bool honor_readonly;
192
b7fced5e 193 /* The front end can add its own statistics to -fmem-report with
194 this hook. It should output to stderr. */
195 void (*print_statistics) PARAMS ((void));
196
197 /* Called by print_tree when there is a tree of class 'x' that it
198 doesn't know how to display. */
199 lang_print_tree_hook print_xnode;
200
201 /* Called to print language-dependent parts of a class 'd', class
202 't', and IDENTIFIER_NODE nodes. */
203 lang_print_tree_hook print_decl;
204 lang_print_tree_hook print_type;
205 lang_print_tree_hook print_identifier;
206
96554925 207 /* Computes the name to use to print a declaration. DECL is the
208 non-NULL declaration in question. VERBOSITY determines what
209 information will be printed: 0: DECL_NAME, demangled as
210 necessary. 1: and scope information. 2: and any other
211 information that might be interesting, such as function parameter
212 types in C++. */
213 const char *(*decl_printable_name) PARAMS ((tree decl, int verbosity));
214
b7fced5e 215 /* Set yydebug for bison-based parsers, when -dy is given on the
216 command line. By default, if the parameter is non-zero, prints a
217 warning that the front end does not use such a parser. */
218 void (*set_yydebug) PARAMS ((int));
219
b0278d39 220 struct lang_hooks_for_tree_inlining tree_inlining;
3119c950 221
222 struct lang_hooks_for_tree_dump tree_dump;
b0278d39 223
20325f61 224 struct lang_hooks_for_decls decls;
225
3119c950 226 /* Whenever you add entries here, make sure you adjust langhooks-def.h
b0278d39 227 and langhooks.c accordingly. */
228};
229
230/* Each front end provides its own. */
d19bd1f0 231extern const struct lang_hooks lang_hooks;
e8602e56 232
233#endif /* GCC_LANG_HOOKS_H */