This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PCH] use gengtype & GGC for more things
- From: Geoffrey Keating <geoffk at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 9 Mar 2002 23:24:00 -0800
- Subject: [PCH] use gengtype & GGC for more things
This adds gengtype markers to various new structures, and GCs them if
they're not GCed already. Done mostly for convenience.
Bootstrapped & tested on i686-pc-linux-gnu with gcac checking.
--
Geoff Keating <geoffk@redhat.com>
===File ~/patches/pchbranch-optabgc.patch===================
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 1.12690.2.10
diff -p -u -p -r1.12690.2.10 ChangeLog
--- ChangeLog 2002/03/09 10:55:47 1.12690.2.10
+++ ChangeLog 2002/03/10 07:03:29
@@ -1,5 +1,29 @@
2002-03-09 Geoffrey Keating <geoffk@redhat.com>
+ * tree.c (struct type_hash): Use gengtype.
+ (init_obstacks): Use canonical name for type_hash_mark.
+ (type_hash_mark): Delete.
+ Include gt-tree.h.
+ * rtl.h (struct mem_attrs): Use gengtype.
+ * optabs.h (struct optab): Use gengtype.
+ * optabs.c (expand_binop): Squish signed/unsigned warning.
+ (mark_optab): Make local, use canonical name, use autogenerated
+ marker procedure.
+ (init_optabs): Use canonical name for mark_optab.
+ * ggc.h: Delete mark_optab prototype.
+ * ggc-common.c (ggc_mark_rtx_children): Use canonical name for
+ mem_attrs marker procedure.
+ * gengtype.c (get_output_file): Include headers in gtype-desc.c
+ explicitly rather than deducing them from file names.
+ (write_gc_structure_fields): Handle arrays of structures.
+ (main): Return non-zero exit code if errors occur during output.
+ * emit-rtl.c (mem_attrs_mark): Delete.
+ (init_emit_once): Use canonical name for mem_attrs marker procedure.
+ * Makefile.in (gtype-desc.o): Explicitly name dependencies.
+ (tree.o): Depend on gt-tree.h.
+ (GTFILES): Add rtl.h, optabs.h, tree.c.
+ (gt-tree.h): Add it to s-gtype rule.
+
* .cvsignore: Ignore gengtype flex/bison generated files.
* Makefile.in (GGC_H): Add gtype-desc.h.
(OBJS): Add gtype-desc.o.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.822.2.3
diff -p -u -p -r1.822.2.3 Makefile.in
--- Makefile.in 2002/03/09 10:56:06 1.822.2.3
+++ Makefile.in 2002/03/10 07:03:35
@@ -1299,8 +1299,8 @@ dumpvers: dumpvers.c
version.o: version.c version.h
-gtype-desc.o: gtype-desc.c varray.h $(RTL_H) $(CONFIG_H) $(SYSTEM_H) \
- function.h
+gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) varray.h $(TREE_H) \
+ $(RTL_H) function.h insn-config.h expr.h $(OPTABS_H) $(GGC_H)
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) \
flags.h $(GGC_H) varray.h hash.h $(HASHTAB_H) $(TM_P_H)
@@ -1331,7 +1331,8 @@ convert.o: convert.c $(CONFIG_H) $(SYSTE
langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) toplev.h \
tree-inline.h $(RTL_H) insn-config.h integrate.h langhooks.h langhooks-def.h
tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h function.h toplev.h \
- $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h
+ $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h \
+ gt-tree.h
tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
flags.h langhooks.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
$(EXPR_H) $(SPLAY_TREE_H) tree-dump.h
@@ -1772,13 +1773,13 @@ s-preds: genpreds$(build_exeext) $(srcdi
$(SHELL) $(srcdir)/move-if-change tmp-preds.h tm-preds.h
$(STAMP) s-preds
-GTFILES = config.h $(build_xm_file_list) $(out_file) \
- $(srcdir)/function.h \
+GTFILES = config.h \
+ $(srcdir)/function.h $(srcdir)/rtl.h $(srcdir)/optabs.h \
$(srcdir)/except.c $(srcdir)/function.c $(srcdir)/integrate.c \
- $(srcdir)/stmt.c $(srcdir)/varasm.c
+ $(srcdir)/stmt.c $(srcdir)/tree.c $(srcdir)/varasm.c
gtype-desc.h gtype-desc.c gtype-c.h gt-except.h gt-function.h : s-gtype; @true
-gt-integrate.h gt-stmt.h gt-varasm.h : s-gtype; @true
+gt-integrate.h gt-stmt.h gt-tree.h gt-varasm.h : s-gtype; @true
s-gtype: gengtype$(build_exeext) $(GTFILES)
./gengtype $(GTFILES)
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.242.4.3
diff -p -u -p -r1.242.4.3 emit-rtl.c
--- emit-rtl.c 2002/03/09 10:56:13 1.242.4.3
+++ emit-rtl.c 2002/03/10 07:03:38
@@ -190,7 +190,6 @@ static int const_int_htab_eq
static hashval_t mem_attrs_htab_hash PARAMS ((const void *));
static int mem_attrs_htab_eq PARAMS ((const void *,
const void *));
-static void mem_attrs_mark PARAMS ((const void *));
static mem_attrs *get_mem_attrs PARAMS ((HOST_WIDE_INT, tree, rtx,
rtx, unsigned int,
enum machine_mode));
@@ -251,25 +250,6 @@ mem_attrs_htab_eq (x, y)
&& p->size == q->size && p->align == q->align);
}
-/* This routine is called when we determine that we need a mem_attrs entry.
- It marks the associated decl and RTL as being used, if present. */
-
-static void
-mem_attrs_mark (x)
- const void *x;
-{
- mem_attrs *p = (mem_attrs *) x;
-
- if (p->expr)
- ggc_mark_tree (p->expr);
-
- if (p->offset)
- ggc_mark_rtx (p->offset);
-
- if (p->size)
- ggc_mark_rtx (p->size);
-}
-
/* Allocate a new mem_attrs structure and insert it into the hash table if
one identical to it is not already in the table. We are doing this for
MEM of mode MODE. */
@@ -4741,7 +4721,7 @@ init_emit_once (line_numbers)
mem_attrs_htab = htab_create (37, mem_attrs_htab_hash,
mem_attrs_htab_eq, NULL);
- ggc_add_deletable_htab (mem_attrs_htab, 0, mem_attrs_mark);
+ ggc_add_deletable_htab (mem_attrs_htab, 0, gt_ggc_m_mem_attrs);
no_line_numbers = ! line_numbers;
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype.c,v
retrieving revision 1.1.2.1
diff -p -u -p -r1.1.2.1 gengtype.c
--- gengtype.c 2002/03/09 10:56:18 1.1.2.1
+++ gengtype.c 2002/03/10 07:03:40
@@ -310,13 +310,15 @@ get_output_file (input_file)
fputs ("#include \"config.h\"\n", fm->output);
fputs ("#include \"system.h\"\n", fm->output);
fputs ("#include \"varray.h\"\n", fm->output);
- fputs ("#include \"rtl.h\"\n", fm->output);
fputs ("#include \"tree.h\"\n", fm->output);
+ fputs ("#include \"rtl.h\"\n", fm->output);
+ fputs ("#include \"function.h\"\n", fm->output);
+ fputs ("#include \"insn-config.h\"\n", fm->output);
+ fputs ("#include \"expr.h\"\n", fm->output);
+ fputs ("#include \"optabs.h\"\n", fm->output);
fputs ("#include \"ggc.h\"\n", fm->output);
}
- fprintf (fm->output, "#include \"%s\"\n", input_file);
-
return fm->output;
}
@@ -644,6 +646,26 @@ write_gc_structure_fields (of, s, val, p
fprintf (of, "[i%d_%d]", loopcounter, i);
fputs (");\n", of);
}
+ else if (t->kind == TYPE_STRUCT || t->kind == TYPE_UNION)
+ {
+ char *newval;
+ int len;
+
+ len = strlen (val) + strlen (f->name) + 2;
+ for (t = f->type; t->kind == TYPE_ARRAY; t = t->u.a.p)
+ len += sizeof ("[i_]") + 2*6;
+
+ newval = xmalloc (len);
+ sprintf (newval, "%s.%s", val, f->name);
+ for (t = f->type, i=0;
+ t->kind == TYPE_ARRAY;
+ t = t->u.a.p, i++)
+ sprintf (newval + strlen (newval), "[i%d_%d]",
+ loopcounter, i);
+ write_gc_structure_fields (of, f->type->u.p, newval, val,
+ f->opt, indent, &f->line);
+ free (newval);
+ }
else
error_at_line (&f->line,
"field `%s' is array of unimplemented type",
@@ -742,5 +764,6 @@ main(argc, argv)
open_base_files ();
write_gc_types (structures);
close_output_files ();
- return 0;
+
+ return (hit_error != 0);
}
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-common.c,v
retrieving revision 1.46.4.2
diff -p -u -p -r1.46.4.2 ggc-common.c
--- ggc-common.c 2002/02/18 17:11:45 1.46.4.2
+++ ggc-common.c 2002/03/10 07:03:41
@@ -299,7 +299,7 @@ ggc_mark_rtx_children (r)
switch (code)
{
case MEM:
- ggc_mark (MEM_ATTRS (r));
+ gt_ggc_m_mem_attrs (MEM_ATTRS (r));
break;
case JUMP_INSN:
ggc_mark_rtx (JUMP_LABEL (r));
Index: ggc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc.h,v
retrieving revision 1.39.6.2
diff -p -u -p -r1.39.6.2 ggc.h
--- ggc.h 2002/03/09 10:56:18 1.39.6.2
+++ ggc.h 2002/03/10 07:03:41
@@ -202,7 +202,6 @@ extern void (*lang_mark_false_label_stac
void mark_eh_status PARAMS ((struct eh_status *));
void mark_stmt_status PARAMS ((struct stmt_status *));
-void mark_optab PARAMS ((void *));
/* Statistics. */
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.122
diff -p -u -p -r1.122 optabs.c
--- optabs.c 2002/01/12 14:05:32 1.122
+++ optabs.c 2002/03/10 07:03:44
@@ -1186,7 +1186,7 @@ expand_binop (mode, binoptab, op0, op1,
&& GET_MODE_SIZE (mode) >= 2 * UNITS_PER_WORD
&& binoptab->handlers[(int) word_mode].insn_code != CODE_FOR_nothing)
{
- int i;
+ unsigned int i;
optab otheroptab = binoptab == add_optab ? sub_optab : add_optab;
unsigned int nwords = GET_MODE_BITSIZE (mode) / BITS_PER_WORD;
rtx carry_in = NULL_RTX, carry_out = NULL_RTX;
@@ -1273,7 +1273,7 @@ expand_binop (mode, binoptab, op0, op1,
carry_in = carry_out;
}
- if (i == GET_MODE_BITSIZE (mode) / BITS_PER_WORD)
+ if (i == GET_MODE_BITSIZE (mode) / (unsigned) BITS_PER_WORD)
{
if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
{
@@ -4572,7 +4572,7 @@ static optab
new_optab ()
{
int i;
- optab op = (optab) xmalloc (sizeof (struct optab));
+ optab op = (optab) ggc_alloc (sizeof (struct optab));
for (i = 0; i < NUM_MACHINE_MODES; i++)
{
op->handlers[i].insn_code = CODE_FOR_nothing;
@@ -4705,15 +4705,12 @@ init_one_libfunc (name)
/* Mark ARG (which is really an OPTAB *) for GC. */
-void
-mark_optab (arg)
+static void gt_ggc_mp_optab PARAMS ((void *));
+static void
+gt_ggc_mp_optab (arg)
void *arg;
{
- optab o = *(optab *) arg;
- int i;
-
- for (i = 0; i < NUM_MACHINE_MODES; ++i)
- ggc_mark_rtx (o->handlers[i].libfunc);
+ gt_ggc_m_optab (*(optab *) arg);
}
/* Call this once to initialize the contents of the optabs
@@ -5067,7 +5064,7 @@ init_optabs ()
#endif
/* Add these GC roots. */
- ggc_add_root (optab_table, OTI_MAX, sizeof(optab), mark_optab);
+ ggc_add_root (optab_table, OTI_MAX, sizeof(optab), gt_ggc_mp_optab);
ggc_add_rtx_root (libfunc_table, LTI_MAX);
}
Index: optabs.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.h,v
retrieving revision 1.5
diff -p -u -p -r1.5 optabs.h
--- optabs.h 2001/11/15 23:44:57 1.5
+++ optabs.h 2002/03/10 07:03:44
@@ -38,14 +38,15 @@ Boston, MA 02111-1307, USA. */
A few optabs, such as move_optab and cmp_optab, are used
by special code. */
-typedef struct optab
+struct optab GTY(())
{
enum rtx_code code;
- struct {
+ struct optab_handlers {
enum insn_code insn_code;
rtx libfunc;
} handlers [NUM_MACHINE_MODES];
-} * optab;
+};
+typedef struct optab * optab;
/* Given an enum insn_code, access the function to construct
the body of that kind of insn. */
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.324.4.1
diff -p -u -p -r1.324.4.1 rtl.h
--- rtl.h 2002/02/13 23:35:38 1.324.4.1
+++ rtl.h 2002/03/10 07:03:44
@@ -89,7 +89,7 @@ typedef struct
so MEMs that the same attributes share a data structure. This means
they cannot be modified in place. If any element is nonzero, it means
the value of the corresponding attribute is unknown. */
-typedef struct
+typedef struct mem_attrs GTY(())
{
HOST_WIDE_INT alias; /* Memory alias set. */
tree expr; /* expr corresponding to MEM. */
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.230.2.1
diff -p -u -p -r1.230.2.1 tree.c
--- tree.c 2002/02/13 23:35:46 1.230.2.1
+++ tree.c 2002/03/10 07:03:44
@@ -137,7 +137,7 @@ static int next_type_uid = 1;
/* Since we cannot rehash a type after it is in the table, we have to
keep the hash code. */
-struct type_hash
+struct type_hash GTY(())
{
unsigned long hash;
tree type;
@@ -227,7 +227,7 @@ init_obstacks ()
type_hash_table = htab_create (TYPE_HASH_INITIAL_SIZE, type_hash_hash,
type_hash_eq, 0);
ggc_add_deletable_htab (type_hash_table, type_hash_marked_p,
- type_hash_mark);
+ gt_ggc_m_type_hash);
ggc_add_tree_root (global_trees, TI_MAX);
ggc_add_tree_root (integer_types, itk_none);
@@ -3187,18 +3187,6 @@ type_hash_marked_p (p)
return ggc_marked_p (type) || TYPE_SYMTAB_POINTER (type);
}
-/* Mark the entry in the type hash table the type it points to is marked.
- Also mark the type in case we are considering this entry "marked" by
- virtue of TYPE_SYMTAB_POINTER being set. */
-
-static void
-type_hash_mark (p)
- const void *p;
-{
- ggc_mark (p);
- ggc_mark_tree (((struct type_hash *) p)->type);
-}
-
/* Mark the hashtable slot pointed to by ENTRY (which is really a
`tree**') for GC. */
@@ -4944,3 +4932,5 @@ make_vector (mode, innertype, unsignedp)
return t;
}
+
+#include "gt-tree.h"
============================================================