Daily bump.
[gcc.git] / libcc1 / libcc1plugin.cc
blobe64847466f4dfdb292a293d2ac581de916558007
1 /* Library interface to C front end
2 Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include <cc1plugin-config.h>
22 #undef PACKAGE_NAME
23 #undef PACKAGE_STRING
24 #undef PACKAGE_TARNAME
25 #undef PACKAGE_VERSION
27 #include "../gcc/config.h"
29 #undef PACKAGE_NAME
30 #undef PACKAGE_STRING
31 #undef PACKAGE_TARNAME
32 #undef PACKAGE_VERSION
34 #define INCLUDE_MEMORY
35 #define INCLUDE_VECTOR
36 #include "gcc-plugin.h"
37 #include "system.h"
38 #include "coretypes.h"
39 #include "stringpool.h"
41 #include "gcc-interface.h"
42 #include "hash-set.h"
43 #include "machmode.h"
44 #include "vec.h"
45 #include "double-int.h"
46 #include "input.h"
47 #include "alias.h"
48 #include "symtab.h"
49 #include "options.h"
50 #include "wide-int.h"
51 #include "inchash.h"
52 #include "tree.h"
53 #include "fold-const.h"
54 #include "stor-layout.h"
55 #include "c-tree.h"
56 #include "toplev.h"
57 #include "timevar.h"
58 #include "hash-table.h"
59 #include "tm.h"
60 #include "c-family/c-pragma.h"
61 #include "c-lang.h"
62 #include "diagnostic.h"
63 #include "langhooks.h"
64 #include "langhooks-def.h"
66 #include "callbacks.hh"
67 #include "connection.hh"
68 #include "marshall.hh"
69 #include "rpc.hh"
70 #include "gcc-c-interface.h"
71 #include "context.hh"
73 using namespace cc1_plugin;
77 // A wrapper for pushdecl that doesn't let gdb have a chance to
78 // instantiate a symbol.
80 static void
81 pushdecl_safe (tree decl)
83 void (*save) (enum c_oracle_request, tree identifier);
85 save = c_binding_oracle;
86 c_binding_oracle = NULL;
87 pushdecl (decl);
88 c_binding_oracle = save;
93 static void
94 plugin_binding_oracle (enum c_oracle_request kind, tree identifier)
96 enum gcc_c_oracle_request request;
98 gcc_assert (current_context != NULL);
100 switch (kind)
102 case C_ORACLE_SYMBOL:
103 request = GCC_C_ORACLE_SYMBOL;
104 break;
105 case C_ORACLE_TAG:
106 request = GCC_C_ORACLE_TAG;
107 break;
108 case C_ORACLE_LABEL:
109 request = GCC_C_ORACLE_LABEL;
110 break;
111 default:
112 abort ();
115 int ignore;
116 cc1_plugin::call (current_context, "binding_oracle", &ignore,
117 request, IDENTIFIER_POINTER (identifier));
120 static void
121 plugin_pragma_user_expression (cpp_reader *)
123 c_binding_oracle = plugin_binding_oracle;
126 static void
127 plugin_init_extra_pragmas (void *, void *)
129 c_register_pragma ("GCC", "user_expression", plugin_pragma_user_expression);
134 // Maybe rewrite a decl to its address.
135 static tree
136 address_rewriter (tree *in, int *walk_subtrees, void *arg)
138 plugin_context *ctx = (plugin_context *) arg;
140 if (!DECL_P (*in) || DECL_NAME (*in) == NULL_TREE)
141 return NULL_TREE;
143 decl_addr_value value;
144 value.decl = *in;
145 decl_addr_value *found_value = ctx->address_map.find (&value);
146 if (found_value != NULL)
148 else if (DECL_IS_UNDECLARED_BUILTIN (*in))
150 gcc_address address;
152 if (!cc1_plugin::call (ctx, "address_oracle", &address,
153 IDENTIFIER_POINTER (DECL_NAME (*in))))
154 return NULL_TREE;
155 if (address == 0)
156 return NULL_TREE;
158 // Insert the decl into the address map in case it is referenced
159 // again.
160 value.address = build_int_cst_type (ptr_type_node, address);
161 decl_addr_value **slot = ctx->address_map.find_slot (&value, INSERT);
162 gcc_assert (*slot == NULL);
163 *slot
164 = static_cast<decl_addr_value *> (xmalloc (sizeof (decl_addr_value)));
165 **slot = value;
166 found_value = *slot;
168 else
169 return NULL_TREE;
171 if (found_value->address != error_mark_node)
173 // We have an address for the decl, so rewrite the tree.
174 tree ptr_type = build_pointer_type (TREE_TYPE (*in));
175 *in = fold_build1 (INDIRECT_REF, TREE_TYPE (*in),
176 fold_build1 (CONVERT_EXPR, ptr_type,
177 found_value->address));
180 *walk_subtrees = 0;
182 return NULL_TREE;
185 // When generating code for gdb, we want to be able to use absolute
186 // addresses to refer to otherwise external objects that gdb knows
187 // about. gdb passes in these addresses when building decls, and then
188 // before gimplification we go through the trees, rewriting uses to
189 // the equivalent of "*(TYPE *) ADDR".
190 static void
191 rewrite_decls_to_addresses (void *function_in, void *)
193 tree function = (tree) function_in;
195 // Do nothing if we're not in gdb.
196 if (current_context == NULL)
197 return;
199 walk_tree (&DECL_SAVED_TREE (function), address_rewriter, current_context,
200 NULL);
205 gcc_decl
206 plugin_build_decl (cc1_plugin::connection *self,
207 const char *name,
208 enum gcc_c_symbol_kind sym_kind,
209 gcc_type sym_type_in,
210 const char *substitution_name,
211 gcc_address address,
212 const char *filename,
213 unsigned int line_number)
215 plugin_context *ctx = static_cast<plugin_context *> (self);
216 tree identifier = get_identifier (name);
217 enum tree_code code;
218 tree decl;
219 tree sym_type = convert_in (sym_type_in);
221 switch (sym_kind)
223 case GCC_C_SYMBOL_FUNCTION:
224 code = FUNCTION_DECL;
225 break;
227 case GCC_C_SYMBOL_VARIABLE:
228 code = VAR_DECL;
229 break;
231 case GCC_C_SYMBOL_TYPEDEF:
232 code = TYPE_DECL;
233 break;
235 case GCC_C_SYMBOL_LABEL:
236 // FIXME: we aren't ready to handle labels yet.
237 // It isn't clear how to translate them properly
238 // and in any case a "goto" isn't likely to work.
239 return convert_out (error_mark_node);
241 default:
242 abort ();
245 location_t loc = ctx->get_location_t (filename, line_number);
247 decl = build_decl (loc, code, identifier, sym_type);
248 TREE_USED (decl) = 1;
249 TREE_ADDRESSABLE (decl) = 1;
251 if (sym_kind != GCC_C_SYMBOL_TYPEDEF)
253 decl_addr_value value;
255 DECL_EXTERNAL (decl) = 1;
256 value.decl = decl;
257 if (substitution_name != NULL)
259 // If the translator gave us a name without a binding,
260 // we can just substitute error_mark_node, since we know the
261 // translator will be reporting an error anyhow.
262 value.address
263 = lookup_name (get_identifier (substitution_name));
264 if (value.address == NULL_TREE)
265 value.address = error_mark_node;
267 else
268 value.address = build_int_cst_type (ptr_type_node, address);
269 decl_addr_value **slot = ctx->address_map.find_slot (&value, INSERT);
270 gcc_assert (*slot == NULL);
271 *slot
272 = static_cast<decl_addr_value *> (xmalloc (sizeof (decl_addr_value)));
273 **slot = value;
276 return convert_out (ctx->preserve (decl));
280 plugin_bind (cc1_plugin::connection *,
281 gcc_decl decl_in, int is_global)
283 tree decl = convert_in (decl_in);
284 c_bind (DECL_SOURCE_LOCATION (decl), decl, is_global);
285 rest_of_decl_compilation (decl, is_global, 0);
286 return 1;
290 plugin_tagbind (cc1_plugin::connection *self,
291 const char *name, gcc_type tagged_type,
292 const char *filename, unsigned int line_number)
294 plugin_context *ctx = static_cast<plugin_context *> (self);
295 tree t = convert_in (tagged_type), x;
296 c_pushtag (ctx->get_location_t (filename, line_number),
297 get_identifier (name), t);
299 /* Propagate the newly-added type name so that previously-created
300 variant types are not disconnected from their main variants. */
301 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
302 TYPE_NAME (x) = TYPE_NAME (t);
304 return 1;
307 gcc_type
308 plugin_build_pointer_type (cc1_plugin::connection *,
309 gcc_type base_type)
311 // No need to preserve a pointer type as the base type is preserved.
312 return convert_out (build_pointer_type (convert_in (base_type)));
315 // TYPE_NAME needs to be a valid pointer, even if there is no name available.
317 static tree
318 build_anonymous_node (enum tree_code code)
320 tree node = make_node (code);
321 tree type_decl = build_decl (input_location, TYPE_DECL, NULL_TREE, node);
322 TYPE_NAME (node) = type_decl;
323 TYPE_STUB_DECL (node) = type_decl;
324 return node;
327 gcc_type
328 plugin_build_record_type (cc1_plugin::connection *self)
330 plugin_context *ctx = static_cast<plugin_context *> (self);
331 return convert_out (ctx->preserve (build_anonymous_node (RECORD_TYPE)));
334 gcc_type
335 plugin_build_union_type (cc1_plugin::connection *self)
337 plugin_context *ctx = static_cast<plugin_context *> (self);
338 return convert_out (ctx->preserve (build_anonymous_node (UNION_TYPE)));
342 plugin_build_add_field (cc1_plugin::connection *,
343 gcc_type record_or_union_type_in,
344 const char *field_name,
345 gcc_type field_type_in,
346 unsigned long bitsize,
347 unsigned long bitpos)
349 tree record_or_union_type = convert_in (record_or_union_type_in);
350 tree field_type = convert_in (field_type_in);
352 gcc_assert (TREE_CODE (record_or_union_type) == RECORD_TYPE
353 || TREE_CODE (record_or_union_type) == UNION_TYPE);
355 /* Note that gdb does not preserve the location of field decls, so
356 we can't provide a decent location here. */
357 tree decl = build_decl (BUILTINS_LOCATION, FIELD_DECL,
358 get_identifier (field_name), field_type);
359 DECL_FIELD_CONTEXT (decl) = record_or_union_type;
361 if (TREE_CODE (field_type) == INTEGER_TYPE
362 && TYPE_PRECISION (field_type) != bitsize)
364 DECL_BIT_FIELD_TYPE (decl) = field_type;
365 TREE_TYPE (decl)
366 = c_build_bitfield_integer_type (bitsize, TYPE_UNSIGNED (field_type));
369 SET_DECL_MODE (decl, TYPE_MODE (TREE_TYPE (decl)));
371 // There's no way to recover this from DWARF.
372 SET_DECL_OFFSET_ALIGN (decl, TYPE_PRECISION (pointer_sized_int_node));
374 tree pos = bitsize_int (bitpos);
375 pos_from_bit (&DECL_FIELD_OFFSET (decl), &DECL_FIELD_BIT_OFFSET (decl),
376 DECL_OFFSET_ALIGN (decl), pos);
378 DECL_SIZE (decl) = bitsize_int (bitsize);
379 DECL_SIZE_UNIT (decl) = size_int ((bitsize + BITS_PER_UNIT - 1)
380 / BITS_PER_UNIT);
382 DECL_CHAIN (decl) = TYPE_FIELDS (record_or_union_type);
383 TYPE_FIELDS (record_or_union_type) = decl;
385 return 1;
389 plugin_finish_record_with_alignment (cc1_plugin::connection *,
390 gcc_type record_or_union_type_in,
391 unsigned long size_in_bytes,
392 unsigned long align)
394 tree record_or_union_type = convert_in (record_or_union_type_in);
396 gcc_assert (TREE_CODE (record_or_union_type) == RECORD_TYPE
397 || TREE_CODE (record_or_union_type) == UNION_TYPE);
399 /* We built the field list in reverse order, so fix it now. */
400 TYPE_FIELDS (record_or_union_type)
401 = nreverse (TYPE_FIELDS (record_or_union_type));
403 if (TREE_CODE (record_or_union_type) == UNION_TYPE)
405 /* Unions can just be handled by the generic code. */
406 layout_type (record_or_union_type);
408 else
410 if (align == 0)
411 align = TYPE_PRECISION (pointer_sized_int_node);
413 SET_TYPE_ALIGN (record_or_union_type, align);
415 TYPE_SIZE (record_or_union_type) = bitsize_int (size_in_bytes
416 * BITS_PER_UNIT);
417 TYPE_SIZE_UNIT (record_or_union_type) = size_int (size_in_bytes);
419 compute_record_mode (record_or_union_type);
420 finish_bitfield_layout (record_or_union_type);
421 // FIXME we have no idea about TYPE_PACKED
424 tree t = record_or_union_type, x;
425 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
427 /* Like finish_struct, update the qualified variant types. */
428 TYPE_FIELDS (x) = TYPE_FIELDS (t);
429 TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
430 C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
431 C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
432 C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (t);
433 /* We copy these fields too. */
434 SET_TYPE_ALIGN (x, TYPE_ALIGN (t));
435 TYPE_SIZE (x) = TYPE_SIZE (t);
436 TYPE_SIZE_UNIT (x) = TYPE_SIZE_UNIT (t);
437 if (x != record_or_union_type)
438 compute_record_mode (x);
441 return 1;
445 plugin_finish_record_or_union (cc1_plugin::connection *conn,
446 gcc_type record_or_union_type_in,
447 unsigned long size_in_bytes)
449 return plugin_finish_record_with_alignment (conn, record_or_union_type_in,
450 size_in_bytes, 0);
453 gcc_type
454 plugin_build_enum_type (cc1_plugin::connection *self,
455 gcc_type underlying_int_type_in)
457 tree underlying_int_type = convert_in (underlying_int_type_in);
459 if (underlying_int_type == error_mark_node)
460 return convert_out (error_mark_node);
462 tree result = build_anonymous_node (ENUMERAL_TYPE);
464 TYPE_PRECISION (result) = TYPE_PRECISION (underlying_int_type);
465 TYPE_UNSIGNED (result) = TYPE_UNSIGNED (underlying_int_type);
466 ENUM_UNDERLYING_TYPE (result) = underlying_int_type;
468 plugin_context *ctx = static_cast<plugin_context *> (self);
469 return convert_out (ctx->preserve (result));
473 plugin_build_add_enum_constant (cc1_plugin::connection *,
474 gcc_type enum_type_in,
475 const char *name,
476 unsigned long value)
478 tree cst, decl, cons;
479 tree enum_type = convert_in (enum_type_in);
481 gcc_assert (TREE_CODE (enum_type) == ENUMERAL_TYPE);
483 cst = build_int_cst (enum_type, value);
484 /* Note that gdb does not preserve the location of enum constants,
485 so we can't provide a decent location here. */
486 decl = build_decl (BUILTINS_LOCATION, CONST_DECL,
487 get_identifier (name), enum_type);
488 DECL_INITIAL (decl) = cst;
489 pushdecl_safe (decl);
491 cons = tree_cons (DECL_NAME (decl), cst, TYPE_VALUES (enum_type));
492 TYPE_VALUES (enum_type) = cons;
494 return 1;
498 plugin_finish_enum_type (cc1_plugin::connection *,
499 gcc_type enum_type_in)
501 tree enum_type = convert_in (enum_type_in);
502 tree minnode, maxnode, iter;
504 iter = TYPE_VALUES (enum_type);
505 minnode = maxnode = TREE_VALUE (iter);
506 for (iter = TREE_CHAIN (iter);
507 iter != NULL_TREE;
508 iter = TREE_CHAIN (iter))
510 tree value = TREE_VALUE (iter);
511 if (tree_int_cst_lt (maxnode, value))
512 maxnode = value;
513 if (tree_int_cst_lt (value, minnode))
514 minnode = value;
516 TYPE_MIN_VALUE (enum_type) = minnode;
517 TYPE_MAX_VALUE (enum_type) = maxnode;
519 layout_type (enum_type);
521 return 1;
524 gcc_type
525 plugin_build_function_type (cc1_plugin::connection *self,
526 gcc_type return_type_in,
527 const struct gcc_type_array *argument_types_in,
528 int is_varargs)
530 tree return_type = convert_in (return_type_in);
531 tree result;
533 std::vector<tree> argument_types (argument_types_in->n_elements);
534 for (int i = 0; i < argument_types_in->n_elements; ++i)
535 argument_types[i] = convert_in (argument_types_in->elements[i]);
537 if (is_varargs)
538 result = build_varargs_function_type_array (return_type,
539 argument_types_in->n_elements,
540 argument_types.data ());
541 else
542 result = build_function_type_array (return_type,
543 argument_types_in->n_elements,
544 argument_types.data ());
546 plugin_context *ctx = static_cast<plugin_context *> (self);
547 return convert_out (ctx->preserve (result));
550 /* Return a builtin type associated with BUILTIN_NAME. */
552 static tree
553 safe_lookup_builtin_type (const char *builtin_name)
555 tree result = NULL_TREE;
557 if (!builtin_name)
558 return result;
560 result = identifier_global_value (get_identifier (builtin_name));
562 if (!result)
563 return result;
565 gcc_assert (TREE_CODE (result) == TYPE_DECL);
566 result = TREE_TYPE (result);
567 return TREE_CODE (result) == ERROR_MARK ? nullptr : result;
570 static gcc_type
571 plugin_int_check (cc1_plugin::connection *self,
572 int is_unsigned, unsigned long size_in_bytes,
573 tree result)
575 if (result == NULL_TREE)
576 result = error_mark_node;
577 else
579 gcc_assert (!TYPE_UNSIGNED (result) == !is_unsigned);
580 gcc_assert (TREE_CODE (TYPE_SIZE (result)) == INTEGER_CST);
581 gcc_assert (TYPE_PRECISION (result) == BITS_PER_UNIT * size_in_bytes);
583 plugin_context *ctx = static_cast<plugin_context *> (self);
584 ctx->preserve (result);
586 return convert_out (result);
589 gcc_type
590 plugin_int_type_v0 (cc1_plugin::connection *self,
591 int is_unsigned, unsigned long size_in_bytes)
593 tree result = c_common_type_for_size (BITS_PER_UNIT * size_in_bytes,
594 is_unsigned);
596 return plugin_int_check (self, is_unsigned, size_in_bytes, result);
599 gcc_type
600 plugin_int_type (cc1_plugin::connection *self,
601 int is_unsigned, unsigned long size_in_bytes,
602 const char *builtin_name)
604 if (builtin_name != nullptr)
606 tree result = safe_lookup_builtin_type (builtin_name);
607 gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE);
608 if (result != nullptr)
609 return plugin_int_check (self, is_unsigned, size_in_bytes, result);
611 return plugin_int_type_v0 (self, is_unsigned, size_in_bytes);
614 gcc_type
615 plugin_char_type (cc1_plugin::connection *)
617 return convert_out (char_type_node);
620 gcc_type
621 plugin_float_type_v0 (cc1_plugin::connection *,
622 unsigned long size_in_bytes)
624 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (float_type_node))
625 return convert_out (float_type_node);
626 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (double_type_node))
627 return convert_out (double_type_node);
628 if (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (long_double_type_node))
629 return convert_out (long_double_type_node);
630 return convert_out (error_mark_node);
633 gcc_type
634 plugin_float_type (cc1_plugin::connection *self,
635 unsigned long size_in_bytes,
636 const char *builtin_name)
638 if (!builtin_name)
639 return plugin_float_type_v0 (self, size_in_bytes);
641 tree result = safe_lookup_builtin_type (builtin_name);
643 if (!result)
644 return plugin_float_type_v0 (self, size_in_bytes);
646 gcc_assert (SCALAR_FLOAT_TYPE_P (result));
647 gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result));
649 return convert_out (result);
652 gcc_type
653 plugin_void_type (cc1_plugin::connection *)
655 return convert_out (void_type_node);
658 gcc_type
659 plugin_bool_type (cc1_plugin::connection *)
661 return convert_out (boolean_type_node);
664 gcc_type
665 plugin_build_array_type (cc1_plugin::connection *self,
666 gcc_type element_type_in, int num_elements)
668 tree element_type = convert_in (element_type_in);
669 tree result;
671 if (num_elements == -1)
672 result = build_array_type (element_type, NULL_TREE);
673 else
674 result = build_array_type_nelts (element_type, num_elements);
676 plugin_context *ctx = static_cast<plugin_context *> (self);
677 return convert_out (ctx->preserve (result));
680 gcc_type
681 plugin_build_vla_array_type (cc1_plugin::connection *self,
682 gcc_type element_type_in,
683 const char *upper_bound_name)
685 tree element_type = convert_in (element_type_in);
686 tree upper_bound = lookup_name (get_identifier (upper_bound_name));
687 tree range = build_index_type (upper_bound);
689 tree result = build_array_type (element_type, range);
690 C_TYPE_VARIABLE_SIZE (result) = 1;
692 plugin_context *ctx = static_cast<plugin_context *> (self);
693 return convert_out (ctx->preserve (result));
696 gcc_type
697 plugin_build_qualified_type (cc1_plugin::connection *,
698 gcc_type unqualified_type_in,
699 enum gcc_qualifiers qualifiers)
701 tree unqualified_type = convert_in (unqualified_type_in);
702 int quals = 0;
704 if ((qualifiers & GCC_QUALIFIER_CONST) != 0)
705 quals |= TYPE_QUAL_CONST;
706 if ((qualifiers & GCC_QUALIFIER_VOLATILE) != 0)
707 quals |= TYPE_QUAL_VOLATILE;
708 if ((qualifiers & GCC_QUALIFIER_RESTRICT) != 0)
709 quals |= TYPE_QUAL_RESTRICT;
711 return convert_out (build_qualified_type (unqualified_type, quals));
714 gcc_type
715 plugin_build_complex_type (cc1_plugin::connection *self,
716 gcc_type base_type)
718 plugin_context *ctx = static_cast<plugin_context *> (self);
719 return convert_out (ctx->preserve (build_complex_type (convert_in (base_type))));
722 gcc_type
723 plugin_build_vector_type (cc1_plugin::connection *self,
724 gcc_type base_type, int nunits)
726 plugin_context *ctx = static_cast<plugin_context *> (self);
727 return convert_out (ctx->preserve (build_vector_type (convert_in (base_type),
728 nunits)));
732 plugin_build_constant (cc1_plugin::connection *self, gcc_type type_in,
733 const char *name, unsigned long value,
734 const char *filename, unsigned int line_number)
736 plugin_context *ctx = static_cast<plugin_context *> (self);
737 tree cst, decl;
738 tree type = convert_in (type_in);
740 cst = build_int_cst (type, value);
741 decl = build_decl (ctx->get_location_t (filename, line_number),
742 CONST_DECL, get_identifier (name), type);
743 DECL_INITIAL (decl) = cst;
744 pushdecl_safe (decl);
746 return 1;
749 gcc_type
750 plugin_error (cc1_plugin::connection *,
751 const char *message)
753 error ("%s", message);
754 return convert_out (error_mark_node);
759 #ifdef __GNUC__
760 #pragma GCC visibility push(default)
761 #endif
764 plugin_init (struct plugin_name_args *plugin_info,
765 struct plugin_gcc_version *)
767 generic_plugin_init (plugin_info, GCC_C_FE_VERSION_2);
769 register_callback (plugin_info->base_name, PLUGIN_PRAGMAS,
770 plugin_init_extra_pragmas, NULL);
771 register_callback (plugin_info->base_name, PLUGIN_PRE_GENERICIZE,
772 rewrite_decls_to_addresses, NULL);
774 #define GCC_METHOD0(R, N) \
776 cc1_plugin::callback_ftype *fun \
777 = cc1_plugin::invoker<R>::invoke<plugin_ ## N>; \
778 current_context->add_callback (# N, fun); \
780 #define GCC_METHOD1(R, N, A) \
782 cc1_plugin::callback_ftype *fun \
783 = cc1_plugin::invoker<R, A>::invoke<plugin_ ## N>; \
784 current_context->add_callback (# N, fun); \
786 #define GCC_METHOD2(R, N, A, B) \
788 cc1_plugin::callback_ftype *fun \
789 = cc1_plugin::invoker<R, A, B>::invoke<plugin_ ## N>; \
790 current_context->add_callback (# N, fun); \
792 #define GCC_METHOD3(R, N, A, B, C) \
794 cc1_plugin::callback_ftype *fun \
795 = cc1_plugin::invoker<R, A, B, C>::invoke<plugin_ ## N>; \
796 current_context->add_callback (# N, fun); \
798 #define GCC_METHOD4(R, N, A, B, C, D) \
800 cc1_plugin::callback_ftype *fun \
801 = cc1_plugin::invoker<R, A, B, C, \
802 D>::invoke<plugin_ ## N>; \
803 current_context->add_callback (# N, fun); \
805 #define GCC_METHOD5(R, N, A, B, C, D, E) \
807 cc1_plugin::callback_ftype *fun \
808 = cc1_plugin::invoker<R, A, B, C, D, \
809 E>::invoke<plugin_ ## N>; \
810 current_context->add_callback (# N, fun); \
812 #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) \
814 cc1_plugin::callback_ftype *fun \
815 = cc1_plugin::invoker<R, A, B, C, D, \
816 E, F, G>::invoke<plugin_ ## N>; \
817 current_context->add_callback (# N, fun); \
820 #include "gcc-c-fe.def"
822 #undef GCC_METHOD0
823 #undef GCC_METHOD1
824 #undef GCC_METHOD2
825 #undef GCC_METHOD3
826 #undef GCC_METHOD4
827 #undef GCC_METHOD5
828 #undef GCC_METHOD7
830 return 0;