This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[boehms-gc] Some updates to gengtype


Hi,

This patch does following:

1) Adds a special gt_types_enum_atomic_data to type enumeration - to
be used as a atomic GC-allocated memory data type tag.
2) Fixes a bug, where "lang structs" (whatever that means...) were not
getting their "struct" or "union" prepended in generated typed
allocation routines.
3) Makes gengtype generate more kinds of typed allocation routines:
for clearing allocated memory, for allocating vectors of objects, for
allocating cleared vectors of objects.

Commited to the boehms-gc branch.

Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 116164)
+++ gcc/gengtype.c	(working copy)
@@ -1099,7 +1099,7 @@
  {
    /* The order of files here matters very much.  */
    static const char *const ifiles [] = {
-      "config.h", "system.h", "coretypes.h", "tm.h", "varray.h",
+      "config.h", "system.h", "coretypes.h", "tm.h", "varray.h",
      "hashtab.h", "splay-tree.h",  "obstack.h", "bitmap.h", "input.h",
      "tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h",
      "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h",
@@ -2448,16 +2448,17 @@

      oprintf (header_file, " gt_ggc_e_");
      output_mangled_typename (header_file, s);
-      oprintf (header_file, ", \n");
+      oprintf (header_file, ",\n");
    }

  for (s = param_structs; s; s = s->next)
    {
      oprintf (header_file, " gt_e_");
      output_mangled_typename (header_file, s);
-      oprintf (header_file, ", \n");
+      oprintf (header_file, ",\n");
    }

+  oprintf (header_file, " gt_types_enum_atomic_data,\n");
  oprintf (header_file, " gt_types_enum_last\n");
  oprintf (header_file, "};\n");
}
@@ -2482,7 +2483,7 @@
	if (strcmp (o->name, "size_not_fixed") == 0)
	  have_size = 1;

-      if (s->kind == TYPE_STRUCT)
+      if (s->kind == TYPE_STRUCT || s->kind == TYPE_LANG_STRUCT)
	type_kind = "struct ";
      else if (s->kind == TYPE_UNION)
	type_kind = "union ";
@@ -2508,6 +2509,26 @@
      else
	oprintf (header_file, ", sizeof (%s%s))\n",
		 type_kind, s->u.s.tag);
+
+      oprintf (header_file, "#define ggc_alloc_vec_%s(%sn) \\\n",
+	       s->u.s.tag, (have_size ? "SIZE, " : ""));
+      oprintf (header_file, "  ggc_alloc_typed(gt_ggc_e_");
+      output_mangled_typename (header_file, s);
+      if (have_size)
+	oprintf (header_file, ", (n) * SIZE)\n");
+      else
+	oprintf (header_file, ", (n) * sizeof (%s%s))\n",
+		 type_kind, s->u.s.tag);
+
+      oprintf (header_file, "#define ggc_alloc_cleared_vec_%s(%sn) \\\n",
+	       s->u.s.tag, (have_size ? "SIZE, " : ""));
+      oprintf (header_file, "  ggc_alloc_cleared_typed(gt_ggc_e_");
+      output_mangled_typename (header_file, s);
+      if (have_size)
+	oprintf (header_file, ", (n) * SIZE)\n");
+      else
+	oprintf (header_file, ", (n) * sizeof (%s%s))\n",
+		 type_kind, s->u.s.tag);
    }
  oprintf (header_file,
           "\n/* Typed allocation for known typedefs.  */\n");
@@ -2534,6 +2555,20 @@
      output_mangled_typename (header_file, s);
      oprintf (header_file, ", sizeof (%s%s))\n",
	       s->kind == TYPE_STRUCT ? "struct " : "", s->u.s.tag);
+
+      oprintf (header_file, "#define ggc_alloc_vec_%s(%sn) \\\n",
+	       p->name, s->kind == TYPE_STRUCT ? "" : "__SIZE, ");
+      oprintf (header_file, "  ggc_alloc_typed(gt_ggc_e_");
+      output_mangled_typename (header_file, s);
+      oprintf (header_file, ", (n) * sizeof (%s%s))\n",
+	       s->kind == TYPE_STRUCT ? "struct " : "", s->u.s.tag);
+
+      oprintf (header_file, "#define ggc_alloc_cleared_vec_%s(%sn) \\\n",
+	       p->name, s->kind == TYPE_STRUCT ? "" : "__SIZE, ");
+      oprintf (header_file, "  ggc_alloc_cleared_typed(gt_ggc_e_");
+      output_mangled_typename (header_file, s);
+      oprintf (header_file, ", (n) * sizeof (%s%s))\n",
+	       s->kind == TYPE_STRUCT ? "struct " : "", s->u.s.tag);
    }
}



--
Laurynas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]