directory. */
static char** plugin_files;
static size_t nb_plugin_files;
+/* the generated plugin output name & file */
+static outf_p plugin_output;
/* The output header file that is included into pretty much every
source file. */
/* In plugin mode, return NULL unless the input_file is one of the
plugin_files. */
- if (plugin_files && nb_plugin_files > 0)
- {
- int ix= -1;
+ if (plugin_files)
+ {
size_t i;
- for (i = 0; i < nb_plugin_files && ix < 0; i++)
- if (strcmp (input_file, plugin_files[i]) == 0)
- ix = i;
- if (ix < 0)
- return NULL;
+ for (i = 0; i < nb_plugin_files; i++)
+ if (strcmp (input_file, plugin_files[i]) == 0)
+ return plugin_output;
+
+ return NULL;
}
/* Determine the output file name. */
const char *tname, const char *lastname,
const char *name);
static void write_root (outf_p , pair_p, type_p, const char *, int,
- struct fileloc *, const char *);
+ struct fileloc *, const char *, bool);
static void write_array (outf_p f, pair_p v,
const struct write_types_data *wtd);
-static void write_roots (pair_p);
+static void write_roots (pair_p, bool);
/* Parameters for walk_type. */
static void
write_root (outf_p f, pair_p v, type_p type, const char *name, int has_length,
- struct fileloc *line, const char *if_marked)
+ struct fileloc *line, const char *if_marked, bool emit_pch)
{
switch (type->kind)
{
newname = xasprintf ("%s.%s.%s",
name, fld->name, validf->name);
write_root (f, v, validf->type, newname, 0, line,
- if_marked);
+ if_marked, emit_pch);
free (newname);
}
}
{
char *newname;
newname = xasprintf ("%s.%s", name, fld->name);
- write_root (f, v, fld->type, newname, 0, line, if_marked);
+ write_root (f, v, fld->type, newname, 0, line, if_marked,
+ emit_pch);
free (newname);
}
}
{
char *newname;
newname = xasprintf ("%s[0]", name);
- write_root (f, v, type->u.a.p, newname, has_length, line, if_marked);
+ write_root (f, v, type->u.a.p, newname, has_length, line, if_marked,
+ emit_pch);
free (newname);
}
break;
if (! has_length && UNION_OR_STRUCT_P (tp))
{
oprintf (f, " >_ggc_mx_%s,\n", tp->u.s.tag);
- oprintf (f, " >_pch_nx_%s", tp->u.s.tag);
+ if (emit_pch)
+ oprintf (f, " >_pch_nx_%s", tp->u.s.tag);
+ else
+ oprintf (f, " NULL");
}
else if (! has_length && tp->kind == TYPE_PARAM_STRUCT)
{
oprintf (f, " >_ggc_m_");
output_mangled_typename (f, tp);
- oprintf (f, ",\n >_pch_n_");
- output_mangled_typename (f, tp);
+ if (emit_pch)
+ {
+ oprintf (f, ",\n >_pch_n_");
+ output_mangled_typename (f, tp);
+ }
+ else
+ oprintf (f, ",\n NULL");
}
else if (has_length
&& (tp->kind == TYPE_POINTER || UNION_OR_STRUCT_P (tp)))
{
oprintf (f, " >_ggc_ma_%s,\n", name);
- oprintf (f, " >_pch_na_%s", name);
+ if (emit_pch)
+ oprintf (f, " >_pch_na_%s", name);
+ else
+ oprintf (f, " NULL");
}
else
{
/* Output a table describing the locations and types of VARIABLES. */
static void
-write_roots (pair_p variables)
+write_roots (pair_p variables, bool emit_pch)
{
pair_p v;
struct flist *flp = NULL;
oprintf (f, "[] = {\n");
}
- write_root (f, v, v->type, v->name, length_p, &v->line, NULL);
+ write_root (f, v, v->type, v->name, length_p, &v->line, NULL, emit_pch);
}
finish_root_table (flp, "ggc_r", "LAST_GGC_ROOT_TAB", "ggc_root_tab",
}
write_root (f, v, v->type->u.p->u.param_struct.param[0],
- v->name, length_p, &v->line, if_marked);
+ v->name, length_p, &v->line, if_marked, emit_pch);
}
finish_root_table (flp, "ggc_rc", "LAST_GGC_CACHE_TAB", "ggc_cache_tab",
"gt_ggc_cache_rtab");
+ if (!emit_pch)
+ return;
+
for (v = variables; v; v = v->next)
{
outf_p f = get_output_file_with_visibility (v->line.file);
oprintf (f, "[] = {\n");
}
- write_root (f, v, v->type, v->name, length_p, &v->line, NULL);
+ write_root (f, v, v->type, v->name, length_p, &v->line, NULL, emit_pch);
}
finish_root_table (flp, "pch_rc", "LAST_GGC_ROOT_TAB", "ggc_root_tab",
size_t i;
static struct fileloc pos = { this_file, 0 };
char* inputlist = 0;
+ outf_p output_header;
+ char* plugin_output_filename = NULL;
/* fatal uses this */
progname = "gengtype";
- if (argc >= 5 && !strcmp (argv[1], "-p"))
+ if (argc >= 6 && !strcmp (argv[1], "-P"))
{
- srcdir = argv[2];
- inputlist = argv[3];
- nb_plugin_files = argc-4;
+ plugin_output_filename = argv[2];
+ plugin_output = create_file ("GCC", plugin_output_filename);
+ srcdir = argv[3];
+ inputlist = argv[4];
+ nb_plugin_files = argc - 5;
plugin_files = XCNEWVEC (char *, nb_plugin_files);
for (i = 0; i < nb_plugin_files; i++)
{
/* Place an all zero lang_bitmap before the plugin file
name. */
- char *name = argv[i + 4];
+ char *name = argv[i + 5];
int len = strlen(name) + 1 + sizeof (lang_bitmap);
plugin_files[i] = XCNEWVEC (char, len) + sizeof (lang_bitmap);
strcpy (plugin_files[i], name);
inputlist = argv[2];
}
else
- fatal ("usage: gengtype [-p] srcdir input-list [file1 file2 ... fileN]");
+ fatal ("usage: gengtype [-P pluginout.h] srcdir input-list "
+ "[file1 file2 ... fileN]");
srcdir_len = strlen (srcdir);
open_base_files ();
write_enum_defn (structures, param_structs);
- write_types (header_file, structures, param_structs, &ggc_wtd);
- write_types (header_file, structures, param_structs, &pch_wtd);
- write_local (header_file, structures, param_structs);
- write_roots (variables);
+ output_header = plugin_output ? plugin_output : header_file;
+ write_types (output_header, structures, param_structs, &ggc_wtd);
+ if (plugin_files == NULL)
+ {
+ write_types (header_file, structures, param_structs, &pch_wtd);
+ write_local (header_file, structures, param_structs);
+ }
+ write_roots (variables, plugin_files == NULL);
write_rtx_next ();
close_output_files ();