/* Process source files and output type information.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
-This file is part of GCC.
+ This file is part of GCC.
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later
+ version.
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
#include "bconfig.h"
#include "system.h"
#include "gengtype.h"
#include "errors.h" /* for fatal */
+#include "double-int.h"
/* Data types, macros, etc. used only in this file. */
{
pair_p p;
- /* temporary kludge - gengtype doesn't handle conditionals or macros.
- Ignore any attempt to typedef CUMULATIVE_ARGS, location_t,
- expanded_location, or source_locus, unless it is coming from
- this file (main() sets them up with safe dummy definitions). */
- if ((!strcmp (s, "CUMULATIVE_ARGS")
- || !strcmp (s, "location_t")
- || !strcmp (s, "source_locus")
- || !strcmp (s, "source_location")
- || !strcmp (s, "expanded_location"))
- && pos->file != this_file)
+ /* temporary kludge - gengtype doesn't handle conditionals or
+ macros. Ignore any attempt to typedef CUMULATIVE_ARGS, unless it
+ is coming from this file (main() sets them up with safe dummy
+ definitions). */
+ if (!strcmp (s, "CUMULATIVE_ARGS") && pos->file != this_file)
return;
for (p = typedefs; p != NULL; p = p->next)
case '0':
if (i == MEM && aindex == 1)
t = mem_attrs_tp, subname = "rt_mem";
- else if (i == JUMP_INSN && aindex == 9)
+ else if (i == JUMP_INSN && aindex == 8)
t = rtx_tp, subname = "rt_rtx";
else if (i == CODE_LABEL && aindex == 4)
t = scalar_tp, subname = "rt_int";
t = rtx_tp, subname = "rt_rtx";
else if (i == NOTE && aindex == 4)
t = note_union_tp, subname = "";
+ else if (i == NOTE && aindex == 5)
+ t = scalar_tp, subname = "rt_int";
else if (i == NOTE && aindex >= 7)
t = scalar_tp, subname = "rt_int";
else if (i == ADDR_DIFF_VEC && aindex == 4)
subfields->opt = nodot;
if (t == note_union_tp)
subfields->opt = create_option (subfields->opt, "desc",
- "NOTE_LINE_NUMBER (&%0)");
+ "NOTE_KIND (&%0)");
if (t == symbol_union_tp)
subfields->opt = create_option (subfields->opt, "desc",
"CONSTANT_POOL_ADDRESS_P (&%0)");
create_file (const char *name, const char *oname)
{
static const char *const hdr[] = {
- " Copyright (C) 2004 Free Software Foundation, Inc.\n",
+ " Copyright (C) 2004, 2007 Free Software Foundation, Inc.\n",
"\n",
"This file is part of GCC.\n",
"\n",
"GCC is free software; you can redistribute it and/or modify it under\n",
"the terms of the GNU General Public License as published by the Free\n",
- "Software Foundation; either version 2, or (at your option) any later\n",
+ "Software Foundation; either version 3, or (at your option) any later\n",
"version.\n",
"\n",
"GCC is distributed in the hope that it will be useful, but WITHOUT ANY\n",
"for more details.\n",
"\n",
"You should have received a copy of the GNU General Public License\n",
- "along with GCC; see the file COPYING. If not, write to the Free\n",
- "Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA\n",
- "02110-1301, USA. */\n",
+ "along with GCC; see the file COPYING3. If not see\n",
+ "<http://www.gnu.org/licenses/>. */\n",
"\n",
"/* This file is machine generated. Do not edit. */\n"
};
return f;
}
-/* Print, like fprintf, to O. */
+/* Print, like fprintf, to O.
+ N.B. You might think this could be implemented more efficiently
+ with vsnprintf(). Unfortunately, there are C libraries that
+ provide that function but without the C99 semantics for its return
+ value, making it impossible to know how much space is required. */
void
oprintf (outf_p o, const char *format, ...)
{
+ char *s;
size_t slength;
+ va_list ap;
- /* Try first with the assumption that there is enough space. */
- {
- va_list ap;
- va_start (ap, format);
- slength = vsnprintf (o->buf + o->bufused, o->buflength - o->bufused,
- format, ap);
- va_end (ap);
- }
+ va_start (ap, format);
+ slength = vasprintf (&s, format, ap);
+ if (s == NULL || (int)slength < 0)
+ fatal ("out of memory");
+ va_end (ap);
- if (o->bufused + slength >= o->buflength)
+ if (o->bufused + slength > o->buflength)
{
- /* There wasn't enough space. */
size_t new_len = o->buflength;
if (new_len == 0)
new_len = 1024;
} while (o->bufused + slength >= new_len);
o->buf = XRESIZEVEC (char, o->buf, new_len);
o->buflength = new_len;
-
- /* We now know that there is enough space. */
- {
- size_t slen2;
- va_list ap;
- va_start (ap, format);
- slen2 = vsnprintf (o->buf + o->bufused, o->buflength - o->bufused,
- format, ap);
- va_end (ap);
-
- gcc_assert (slen2 == slength);
- gcc_assert (o->bufused + slen2 < o->buflength);
- }
}
+ memcpy (o->buf + o->bufused, s, slength);
o->bufused += slength;
+ free (s);
}
/* Open the global header file and the language-specific header files. */
"hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h",
"optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
"tree-flow.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
- "cfglayout.h", "except.h", "output.h", NULL
+ "cfglayout.h", "except.h", "output.h", "cfgloop.h", NULL
};
const char *const *ifp;
outf_p gtype_desc_c;
gtype_desc_c = create_file ("GCC", "gtype-desc.c");
for (ifp = ifiles; *ifp; ifp++)
oprintf (gtype_desc_c, "#include \"%s\"\n", *ifp);
+
+ /* Make sure we handle "cfun" specially. */
+ oprintf (gtype_desc_c, "\n/* See definition in function.h. */\n");
+ oprintf (gtype_desc_c, "#undef cfun\n");
}
}
static void output_escaped_param (struct walk_type_data *d,
const char *, const char *);
-static void output_mangled_typename (outf_p, type_p);
+static void output_mangled_typename (outf_p, const_type_p);
static void walk_type (type_p t, struct walk_type_data *d);
static void write_func_for_structure
(type_p orig_s, type_p s, type_p * param,
/* Print a mangled name representing T to OF. */
static void
-output_mangled_typename (outf_p of, type_p t)
+output_mangled_typename (outf_p of, const_type_p t)
{
if (t == NULL)
oprintf (of, "Z");
for (opt = s->u.s.opt; opt; opt = opt->next)
if (strcmp (opt->name, "ptr_alias") == 0)
{
- type_p t = (type_p) opt->info;
+ const_type_p const t = (const_type_p) opt->info;
if (t->kind == TYPE_STRUCT
|| t->kind == TYPE_UNION
|| t->kind == TYPE_LANG_STRUCT)
for (opt = s->u.s.opt; opt; opt = opt->next)
if (strcmp (opt->name, "ptr_alias") == 0)
{
- type_p t = (type_p) opt->info;
+ const_type_p const t = (const_type_p) opt->info;
if (t->kind == TYPE_STRUCT
|| t->kind == TYPE_UNION
|| t->kind == TYPE_LANG_STRUCT)
skip_p = 1;
else if (strcmp (o->name, "desc") == 0)
desc = o->info;
+ else if (strcmp (o->name, "param_is") == 0)
+ ;
else
error_at_line (line,
"field `%s' of global `%s' has unknown option `%s'",
do_typedef (astratname, new_structure (astratname, 0, pos, field, 0), pos);
}
-/* Yet more temporary kludge since gengtype doesn't understand conditionals.
- This must be kept in sync with input.h. */
-static void
-define_location_structures (void)
-{
- pair_p fields;
- type_p locs;
- static struct fileloc pos = { this_file, __LINE__ };
- do_scalar_typedef ("source_location", &pos);
-
-#ifdef USE_MAPPED_LOCATION
- fields = create_field (0, &scalar_nonchar, "column");
- fields = create_field (fields, &scalar_nonchar, "line");
- fields = create_field (fields, &string_type, "file");
- locs = new_structure ("anon:expanded_location", 0, &pos, fields, 0);
-
- do_typedef ("expanded_location", locs, &pos);
- do_scalar_typedef ("location_t", &pos);
- do_scalar_typedef ("source_locus", &pos);
-#else
- fields = create_field (0, &scalar_nonchar, "line");
- fields = create_field (fields, &string_type, "file");
- locs = new_structure ("location_s", 0, &pos, fields, 0);
-
- do_typedef ("expanded_location", locs, &pos);
- do_typedef ("location_t", locs, &pos);
- do_typedef ("source_locus", create_pointer (locs), &pos);
-#endif
-}
-
\f
int
main (int argc, char **argv)
pos.line = __LINE__ + 1;
do_scalar_typedef ("CUMULATIVE_ARGS", &pos); pos.line++;
do_scalar_typedef ("REAL_VALUE_TYPE", &pos); pos.line++;
+ do_scalar_typedef ("FIXED_VALUE_TYPE", &pos); pos.line++;
do_scalar_typedef ("double_int", &pos); pos.line++;
do_scalar_typedef ("uint8", &pos); pos.line++;
do_scalar_typedef ("jword", &pos); pos.line++;
do_scalar_typedef ("JCF_u2", &pos); pos.line++;
do_scalar_typedef ("void", &pos); pos.line++;
do_typedef ("PTR", create_pointer (resolve_typedef ("void", &pos)), &pos);
- define_location_structures ();
for (i = 0; i < num_gt_files; i++)
parse_file (gt_files[i]);