xref: /netbsd-src/external/gpl3/gcc.old/dist/include/gcc-c-interface.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* Interface between GCC C FE and GDB
21debfc3dSmrg 
3*8feb0f0bSmrg    Copyright (C) 2014-2020 Free Software Foundation, Inc.
41debfc3dSmrg 
51debfc3dSmrg    This file is part of GCC.
61debfc3dSmrg 
71debfc3dSmrg    This program is free software; you can redistribute it and/or modify
81debfc3dSmrg    it under the terms of the GNU General Public License as published by
91debfc3dSmrg    the Free Software Foundation; either version 3 of the License, or
101debfc3dSmrg    (at your option) any later version.
111debfc3dSmrg 
121debfc3dSmrg    This program is distributed in the hope that it will be useful,
131debfc3dSmrg    but WITHOUT ANY WARRANTY; without even the implied warranty of
141debfc3dSmrg    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151debfc3dSmrg    GNU General Public License for more details.
161debfc3dSmrg 
171debfc3dSmrg    You should have received a copy of the GNU General Public License
181debfc3dSmrg    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
191debfc3dSmrg 
201debfc3dSmrg #ifndef GCC_C_INTERFACE_H
211debfc3dSmrg #define GCC_C_INTERFACE_H
221debfc3dSmrg 
231debfc3dSmrg #include "gcc-interface.h"
241debfc3dSmrg 
251debfc3dSmrg /* This header defines the interface to the GCC API.  It must be both
261debfc3dSmrg    valid C and valid C++, because it is included by both programs.  */
271debfc3dSmrg 
281debfc3dSmrg #ifdef __cplusplus
291debfc3dSmrg extern "C" {
301debfc3dSmrg #endif
311debfc3dSmrg 
321debfc3dSmrg /* Forward declaration.  */
331debfc3dSmrg 
341debfc3dSmrg struct gcc_c_context;
351debfc3dSmrg 
361debfc3dSmrg /*
371debfc3dSmrg  * Definitions and declarations for the C front end.
381debfc3dSmrg  */
391debfc3dSmrg 
401debfc3dSmrg /* Defined versions of the C front-end API.  */
411debfc3dSmrg 
421debfc3dSmrg enum gcc_c_api_version
431debfc3dSmrg {
441debfc3dSmrg   GCC_C_FE_VERSION_0 = 0,
451debfc3dSmrg 
461debfc3dSmrg   /* Added char_type.  Added new version of int_type and float_type,
471debfc3dSmrg      deprecated int_type_v0 and float_type_v0.  */
481debfc3dSmrg   GCC_C_FE_VERSION_1 = 1
491debfc3dSmrg };
501debfc3dSmrg 
511debfc3dSmrg /* Qualifiers.  */
521debfc3dSmrg 
531debfc3dSmrg enum gcc_qualifiers
541debfc3dSmrg {
551debfc3dSmrg   GCC_QUALIFIER_CONST = 1,
561debfc3dSmrg   GCC_QUALIFIER_VOLATILE = 2,
571debfc3dSmrg   GCC_QUALIFIER_RESTRICT = 4
581debfc3dSmrg };
591debfc3dSmrg 
601debfc3dSmrg /* This enumerates the kinds of decls that GDB can create.  */
611debfc3dSmrg 
621debfc3dSmrg enum gcc_c_symbol_kind
631debfc3dSmrg {
641debfc3dSmrg   /* A function.  */
651debfc3dSmrg 
661debfc3dSmrg   GCC_C_SYMBOL_FUNCTION,
671debfc3dSmrg 
681debfc3dSmrg   /* A variable.  */
691debfc3dSmrg 
701debfc3dSmrg   GCC_C_SYMBOL_VARIABLE,
711debfc3dSmrg 
721debfc3dSmrg   /* A typedef.  */
731debfc3dSmrg 
741debfc3dSmrg   GCC_C_SYMBOL_TYPEDEF,
751debfc3dSmrg 
761debfc3dSmrg   /* A label.  */
771debfc3dSmrg 
781debfc3dSmrg   GCC_C_SYMBOL_LABEL
791debfc3dSmrg };
801debfc3dSmrg 
811debfc3dSmrg /* This enumerates the types of symbols that GCC might request from
821debfc3dSmrg    GDB.  */
831debfc3dSmrg 
841debfc3dSmrg enum gcc_c_oracle_request
851debfc3dSmrg {
861debfc3dSmrg   /* An ordinary symbol -- a variable, function, typedef, or enum
871debfc3dSmrg      constant.  */
881debfc3dSmrg 
891debfc3dSmrg   GCC_C_ORACLE_SYMBOL,
901debfc3dSmrg 
911debfc3dSmrg   /* A struct, union, or enum tag.  */
921debfc3dSmrg 
931debfc3dSmrg   GCC_C_ORACLE_TAG,
941debfc3dSmrg 
951debfc3dSmrg   /* A label.  */
961debfc3dSmrg 
971debfc3dSmrg   GCC_C_ORACLE_LABEL
981debfc3dSmrg };
991debfc3dSmrg 
1001debfc3dSmrg /* The type of the function called by GCC to ask GDB for a symbol's
1011debfc3dSmrg    definition.  DATUM is an arbitrary value supplied when the oracle
1021debfc3dSmrg    function is registered.  CONTEXT is the GCC context in which the
1031debfc3dSmrg    request is being made.  REQUEST specifies what sort of symbol is
1041debfc3dSmrg    being requested, and IDENTIFIER is the name of the symbol.  */
1051debfc3dSmrg 
1061debfc3dSmrg typedef void gcc_c_oracle_function (void *datum,
1071debfc3dSmrg 				    struct gcc_c_context *context,
1081debfc3dSmrg 				    enum gcc_c_oracle_request request,
1091debfc3dSmrg 				    const char *identifier);
1101debfc3dSmrg 
1111debfc3dSmrg /* The type of the function called by GCC to ask GDB for a symbol's
1121debfc3dSmrg    address.  This should return 0 if the address is not known.  */
1131debfc3dSmrg 
1141debfc3dSmrg typedef gcc_address gcc_c_symbol_address_function (void *datum,
1151debfc3dSmrg 						   struct gcc_c_context *ctxt,
1161debfc3dSmrg 						   const char *identifier);
1171debfc3dSmrg 
1181debfc3dSmrg /* The vtable used by the C front end.  */
1191debfc3dSmrg 
1201debfc3dSmrg struct gcc_c_fe_vtable
1211debfc3dSmrg {
1221debfc3dSmrg   /* The version of the C interface.  The value is one of the
1231debfc3dSmrg      gcc_c_api_version constants.  */
1241debfc3dSmrg 
1251debfc3dSmrg   unsigned int c_version;
1261debfc3dSmrg 
1271debfc3dSmrg   /* Set the callbacks for this context.
1281debfc3dSmrg 
1291debfc3dSmrg      The binding oracle is called whenever the C parser needs to look
1301debfc3dSmrg      up a symbol.  This gives the caller a chance to lazily
1311debfc3dSmrg      instantiate symbols using other parts of the gcc_c_fe_interface
1321debfc3dSmrg      API.
1331debfc3dSmrg 
1341debfc3dSmrg      The address oracle is called whenever the C parser needs to look
1351debfc3dSmrg      up a symbol.  This is only called for symbols not provided by the
1361debfc3dSmrg      symbol oracle -- that is, just built-in functions where GCC
1371debfc3dSmrg      provides the declaration.
1381debfc3dSmrg 
1391debfc3dSmrg      DATUM is an arbitrary piece of data that is passed back verbatim
1401debfc3dSmrg      to the callbacks in requests.  */
1411debfc3dSmrg 
1421debfc3dSmrg   void (*set_callbacks) (struct gcc_c_context *self,
1431debfc3dSmrg 			 gcc_c_oracle_function *binding_oracle,
1441debfc3dSmrg 			 gcc_c_symbol_address_function *address_oracle,
1451debfc3dSmrg 			 void *datum);
1461debfc3dSmrg 
1471debfc3dSmrg #define GCC_METHOD0(R, N) \
1481debfc3dSmrg   R (*N) (struct gcc_c_context *);
1491debfc3dSmrg #define GCC_METHOD1(R, N, A) \
1501debfc3dSmrg   R (*N) (struct gcc_c_context *, A);
1511debfc3dSmrg #define GCC_METHOD2(R, N, A, B) \
1521debfc3dSmrg   R (*N) (struct gcc_c_context *, A, B);
1531debfc3dSmrg #define GCC_METHOD3(R, N, A, B, C) \
1541debfc3dSmrg   R (*N) (struct gcc_c_context *, A, B, C);
1551debfc3dSmrg #define GCC_METHOD4(R, N, A, B, C, D) \
1561debfc3dSmrg   R (*N) (struct gcc_c_context *, A, B, C, D);
1571debfc3dSmrg #define GCC_METHOD5(R, N, A, B, C, D, E) \
1581debfc3dSmrg   R (*N) (struct gcc_c_context *, A, B, C, D, E);
1591debfc3dSmrg #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
1601debfc3dSmrg   R (*N) (struct gcc_c_context *, A, B, C, D, E, F, G);
1611debfc3dSmrg 
1621debfc3dSmrg #include "gcc-c-fe.def"
1631debfc3dSmrg 
1641debfc3dSmrg #undef GCC_METHOD0
1651debfc3dSmrg #undef GCC_METHOD1
1661debfc3dSmrg #undef GCC_METHOD2
1671debfc3dSmrg #undef GCC_METHOD3
1681debfc3dSmrg #undef GCC_METHOD4
1691debfc3dSmrg #undef GCC_METHOD5
1701debfc3dSmrg #undef GCC_METHOD7
1711debfc3dSmrg 
1721debfc3dSmrg };
1731debfc3dSmrg 
1741debfc3dSmrg /* The C front end object.  */
1751debfc3dSmrg 
1761debfc3dSmrg struct gcc_c_context
1771debfc3dSmrg {
1781debfc3dSmrg   /* Base class.  */
1791debfc3dSmrg 
1801debfc3dSmrg   struct gcc_base_context base;
1811debfc3dSmrg 
1821debfc3dSmrg   /* Our vtable.  This is a separate field because this is simpler
1831debfc3dSmrg      than implementing a vtable inheritance scheme in C.  */
1841debfc3dSmrg 
1851debfc3dSmrg   const struct gcc_c_fe_vtable *c_ops;
1861debfc3dSmrg };
1871debfc3dSmrg 
1881debfc3dSmrg /* The name of the .so that the compiler builds.  We dlopen this
1891debfc3dSmrg    later.  */
1901debfc3dSmrg 
1911debfc3dSmrg #define GCC_C_FE_LIBCC libcc1.so
1921debfc3dSmrg 
1931debfc3dSmrg /* The compiler exports a single initialization function.  This macro
1941debfc3dSmrg    holds its name as a symbol.  */
1951debfc3dSmrg 
1961debfc3dSmrg #define GCC_C_FE_CONTEXT gcc_c_fe_context
1971debfc3dSmrg 
1981debfc3dSmrg /* The type of the initialization function.  The caller passes in the
1991debfc3dSmrg    desired base version and desired C-specific version.  If the
2001debfc3dSmrg    request can be satisfied, a compatible gcc_context object will be
2011debfc3dSmrg    returned.  Otherwise, the function returns NULL.  */
2021debfc3dSmrg 
2031debfc3dSmrg typedef struct gcc_c_context *gcc_c_fe_context_function
2041debfc3dSmrg     (enum gcc_base_api_version,
2051debfc3dSmrg      enum gcc_c_api_version);
2061debfc3dSmrg 
2071debfc3dSmrg #ifdef __cplusplus
2081debfc3dSmrg }
2091debfc3dSmrg #endif
2101debfc3dSmrg 
2111debfc3dSmrg #endif /* GCC_C_INTERFACE_H */
212