re PR ipa/64978 (ICE: in ipcp_verify_propagated_values, at ipa-cp.c:1060)
[official-gcc.git] / include / gcc-c-interface.h
blob25ef62f6e81f2bdd47490125f066c6429bf80f5e
1 /* Interface between GCC C FE and GDB
3 Copyright (C) 2014 Free Software Foundation, Inc.
5 This file is part of GCC.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_C_INTERFACE_H
21 #define GCC_C_INTERFACE_H
23 #include "gcc-interface.h"
25 /* This header defines the interface to the GCC API. It must be both
26 valid C and valid C++, because it is included by both programs. */
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 /* Forward declaration. */
34 struct gcc_c_context;
37 * Definitions and declarations for the C front end.
40 /* Defined versions of the C front-end API. */
42 enum gcc_c_api_version
44 GCC_C_FE_VERSION_0 = 0
47 /* Qualifiers. */
49 enum gcc_qualifiers
51 GCC_QUALIFIER_CONST = 1,
52 GCC_QUALIFIER_VOLATILE = 2,
53 GCC_QUALIFIER_RESTRICT = 4
56 /* This enumerates the kinds of decls that GDB can create. */
58 enum gcc_c_symbol_kind
60 /* A function. */
62 GCC_C_SYMBOL_FUNCTION,
64 /* A variable. */
66 GCC_C_SYMBOL_VARIABLE,
68 /* A typedef. */
70 GCC_C_SYMBOL_TYPEDEF,
72 /* A label. */
74 GCC_C_SYMBOL_LABEL
77 /* This enumerates the types of symbols that GCC might request from
78 GDB. */
80 enum gcc_c_oracle_request
82 /* An ordinary symbol -- a variable, function, typedef, or enum
83 constant. */
85 GCC_C_ORACLE_SYMBOL,
87 /* A struct, union, or enum tag. */
89 GCC_C_ORACLE_TAG,
91 /* A label. */
93 GCC_C_ORACLE_LABEL
96 /* The type of the function called by GCC to ask GDB for a symbol's
97 definition. DATUM is an arbitrary value supplied when the oracle
98 function is registered. CONTEXT is the GCC context in which the
99 request is being made. REQUEST specifies what sort of symbol is
100 being requested, and IDENTIFIER is the name of the symbol. */
102 typedef void gcc_c_oracle_function (void *datum,
103 struct gcc_c_context *context,
104 enum gcc_c_oracle_request request,
105 const char *identifier);
107 /* The type of the function called by GCC to ask GDB for a symbol's
108 address. This should return 0 if the address is not known. */
110 typedef gcc_address gcc_c_symbol_address_function (void *datum,
111 struct gcc_c_context *ctxt,
112 const char *identifier);
114 /* An array of types used for creating a function type. */
116 struct gcc_type_array
118 /* Number of elements. */
120 int n_elements;
122 /* The elements. */
124 gcc_type *elements;
127 /* The vtable used by the C front end. */
129 struct gcc_c_fe_vtable
131 /* The version of the C interface. The value is one of the
132 gcc_c_api_version constants. */
134 unsigned int c_version;
136 /* Set the callbacks for this context.
138 The binding oracle is called whenever the C parser needs to look
139 up a symbol. This gives the caller a chance to lazily
140 instantiate symbols using other parts of the gcc_c_fe_interface
141 API.
143 The address oracle is called whenever the C parser needs to look
144 up a symbol. This is only called for symbols not provided by the
145 symbol oracle -- that is, just built-in functions where GCC
146 provides the declaration.
148 DATUM is an arbitrary piece of data that is passed back verbatim
149 to the callbakcs in requests. */
151 void (*set_callbacks) (struct gcc_c_context *self,
152 gcc_c_oracle_function *binding_oracle,
153 gcc_c_symbol_address_function *address_oracle,
154 void *datum);
156 #define GCC_METHOD0(R, N) \
157 R (*N) (struct gcc_c_context *);
158 #define GCC_METHOD1(R, N, A) \
159 R (*N) (struct gcc_c_context *, A);
160 #define GCC_METHOD2(R, N, A, B) \
161 R (*N) (struct gcc_c_context *, A, B);
162 #define GCC_METHOD3(R, N, A, B, C) \
163 R (*N) (struct gcc_c_context *, A, B, C);
164 #define GCC_METHOD4(R, N, A, B, C, D) \
165 R (*N) (struct gcc_c_context *, A, B, C, D);
166 #define GCC_METHOD5(R, N, A, B, C, D, E) \
167 R (*N) (struct gcc_c_context *, A, B, C, D, E);
168 #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
169 R (*N) (struct gcc_c_context *, A, B, C, D, E, F, G);
171 #include "gcc-c-fe.def"
173 #undef GCC_METHOD0
174 #undef GCC_METHOD1
175 #undef GCC_METHOD2
176 #undef GCC_METHOD3
177 #undef GCC_METHOD4
178 #undef GCC_METHOD5
179 #undef GCC_METHOD7
183 /* The C front end object. */
185 struct gcc_c_context
187 /* Base class. */
189 struct gcc_base_context base;
191 /* Our vtable. This is a separate field because this is simpler
192 than implementing a vtable inheritance scheme in C. */
194 const struct gcc_c_fe_vtable *c_ops;
197 /* The name of the .so that the compiler builds. We dlopen this
198 later. */
200 #define GCC_C_FE_LIBCC libcc1.so
202 /* The compiler exports a single initialization function. This macro
203 holds its name as a symbol. */
205 #define GCC_C_FE_CONTEXT gcc_c_fe_context
207 /* The type of the initialization function. The caller passes in the
208 desired base version and desired C-specific version. If the
209 request can be satisfied, a compatible gcc_context object will be
210 returned. Otherwise, the function returns NULL. */
212 typedef struct gcc_c_context *gcc_c_fe_context_function
213 (enum gcc_base_api_version,
214 enum gcc_c_api_version);
216 #ifdef __cplusplus
218 #endif
220 #endif /* GCC_C_INTERFACE_H */