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]

[PATCH] compiling gcc with a C++ compiler 1/n


Hi,

as my copyright assignment is now finally in place, I will start posting
patches to make gcc compatible with a C++ compiler, as stated by the GCC
Coding Conventions. Besides portability, C++ compatibility is desirable
as using a C++ compiler can uncover bugs. In fact I found some, e.g. in
the current patch genautomata.c allocated memory sized for a struct decl
although it wanted a struct regexp.
Full C++ compatibility requires changing quite a few files (I got
--enable-languages=C working), but most changes are harmless and only
affect individual C files. I send the fixes incrementally, as proper
organization and testing takes some time.

I will try to cluster related changes together to help in reviewing, and
start with getting the various generator programs C++ compatible.
Boostrapped and tested on x86_64. Please apply if you find it useful (or
send me comments for corrections).

Thomas

* genrecog.c: Move enum out of struct namespace.
* genrecog.c: Use typesafe memory macros.
* genrecog.c: Avoid C++ keywords, cast as needed.
* gengtype.c: Declare const arrays as extern.
* gengtype.c (note_def_vec): Avoid C++ keywords.
* gengtype.h (note_def_vec): Avoid C++ keywords.
* gengenrtl.c (genmacro): Case as needed.
* genoutput.c: Avoid C++ keywords.
* gensupport.c (record_insn_name): Avoid C++ keywords.
* gensupport.c (record_insn_name): Use typesafe memory macros.keywords.
* genextract.c (gen_insn): Cast as needed.
* genautomata.c: Use typesafe create_node/copy_node macros.
* genautomata.c: Call htab_find_slot with enum instead of int constant.
* genautomata.c: Use typesafe memory macros.
* genautomata.c: Insert missing casts in the generated code.
* genemit.c (gen_insn): Avoid C++ keywords.
* gengtype-lex.l: Case as needed.
* genattrtab.c: Use typesafe memory macros.
* genattrtab.c Avoid C++ keywords.
* genattrtab.c (write_length_unit_log): Declare length_unit_log extern.
* optc-gen.awk: Place VarExists entries behind real entries.
* genpreds.c: Cast as needed.
* genchecksum.c: Declare executable_checksum as extern.

Index: gcc/genrecog.c
===================================================================
--- gcc/genrecog.c	(revision 124625)
+++ gcc/genrecog.c	(working copy)
@@ -71,6 +71,17 @@ struct decision_head
   struct decision *last;
 };
 
+/* These types are roughly in the order in which we'd like to test them.  */
+enum decision_type
+{
+  DT_num_insns,
+  DT_mode, DT_code, DT_veclen,
+  DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe,
+  DT_const_int,
+  DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
+  DT_accept_op, DT_accept_insn
+};
+
 /* A single test.  The two accept types aren't tests per-se, but
    their equality (or lack thereof) does affect tree merging so
    it is convenient to keep them here.  */
@@ -81,15 +92,7 @@ struct decision_test
   struct decision_test *next;
 
   /* These types are roughly in the order in which we'd like to test them.  */
-  enum decision_type
-    {
-      DT_num_insns,
-      DT_mode, DT_code, DT_veclen,
-      DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe,
-      DT_const_int,
-      DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
-      DT_accept_op, DT_accept_insn
-    } type;
+  enum decision_type type;
 
   union
   {
@@ -366,7 +369,7 @@ compute_predicate_codes (rtx exp, char c
 static void
 process_define_predicate (rtx desc)
 {
-  struct pred_data *pred = xcalloc (sizeof (struct pred_data), 1);
+  struct pred_data *pred = XCNEW(struct pred_data);
   char codes[NUM_RTX_CODE];
   bool seen_one = false;
   int i;
@@ -395,7 +398,7 @@ process_define_predicate (rtx desc)
 	  pred->singleton = UNKNOWN;
 	else
 	  {
-	    pred->singleton = i;
+	    pred->singleton = (enum rtx_code) i;
 	    seen_one = true;
 	  }
       }
@@ -493,14 +496,14 @@ extern void debug_decision_list
 static struct decision *
 new_decision (const char *position, struct decision_head *last)
 {
-  struct decision *new = xcalloc (1, sizeof (struct decision));
+  struct decision *result = XCNEW(struct decision);
 
-  new->success = *last;
-  new->position = xstrdup (position);
-  new->number = next_number++;
+  result->success = *last;
+  result->position = xstrdup (position);
+  result->number = next_number++;
 
-  last->first = last->last = new;
-  return new;
+  last->first = last->last = result;
+  return result;
 }
 
 /* Create a new test and link it in at PLACE.  */
@@ -896,7 +899,7 @@ add_to_sequence (rtx pattern, struct dec
 		 enum routine_type insn_type, int top)
 {
   RTX_CODE code;
-  struct decision *this, *sub;
+  struct decision *current, *sub;
   struct decision_test *test;
   struct decision_test **place;
   char *subpos;
@@ -909,12 +912,12 @@ add_to_sequence (rtx pattern, struct dec
   if (depth > max_depth)
     max_depth = depth;
 
-  subpos = xmalloc (depth + 2);
+  subpos = XNEWVEC(char, depth + 2);
   strcpy (subpos, position);
   subpos[depth + 1] = 0;
 
-  sub = this = new_decision (position, last);
-  place = &this->tests;
+  sub = current = new_decision (position, last);
+  place = &current->tests;
 
  restart:
   mode = GET_MODE (pattern);
@@ -1161,20 +1164,20 @@ add_to_sequence (rtx pattern, struct dec
      before any of the nodes we may have added above.  */
   if (code != UNKNOWN)
     {
-      place = &this->tests;
+      place = &current->tests;
       test = new_decision_test (DT_code, &place);
       test->u.code = code;
     }
 
   if (mode != VOIDmode)
     {
-      place = &this->tests;
+      place = &current->tests;
       test = new_decision_test (DT_mode, &place);
       test->u.mode = mode;
     }
 
   /* If we didn't insert any tests or accept nodes, hork.  */
-  gcc_assert (this->tests);
+  gcc_assert (current->tests);
 
  ret:
   free (subpos);
@@ -1262,7 +1265,7 @@ maybe_both_true_2 (struct decision_test 
 	  else if (d2->type == DT_pred && d2->u.pred.data)
 	    {
 	      bool common = false;
-	      enum rtx_code c;
+	      unsigned c;
 
 	      for (c = 0; c < NUM_RTX_CODE; c++)
 		if (d1->u.pred.data->codes[c] && d2->u.pred.data->codes[c])
@@ -1611,7 +1614,7 @@ factor_tests (struct decision_head *head
   for (first = head->first; first && first->next; first = next)
     {
       enum decision_type type;
-      struct decision *new, *old_last;
+      struct decision *new_node, *old_last;
 
       type = first->tests->type;
       next = first->next;
@@ -1634,8 +1637,8 @@ factor_tests (struct decision_head *head
          below our first test.  */
       if (first->tests->next != NULL)
 	{
-	  new = new_decision (first->position, &first->success);
-	  new->tests = first->tests->next;
+	  new_node = new_decision (first->position, &first->success);
+	  new_node->tests = first->tests->next;
 	  first->tests->next = NULL;
 	}
 
@@ -1652,14 +1655,14 @@ factor_tests (struct decision_head *head
 
 	  if (next->tests->next != NULL)
 	    {
-	      new = new_decision (next->position, &next->success);
-	      new->tests = next->tests->next;
+	      new_node = new_decision (next->position, &next->success);
+	      new_node->tests = next->tests->next;
 	      next->tests->next = NULL;
 	    }
-	  new = next;
+	  new_node = next;
 	  next = next->next;
-	  new->next = NULL;
-	  h.first = h.last = new;
+	  new_node->next = NULL;
+	  h.first = h.last = new_node;
 
 	  merge_trees (head, &h);
 	}
@@ -1940,7 +1943,7 @@ write_switch (struct decision *start, in
       while (p && p->tests->type == DT_pred && p->tests->u.pred.data)
 	{
 	  const struct pred_data *data = p->tests->u.pred.data;
-	  RTX_CODE c;
+	  unsigned c;
 	  for (c = 0; c < NUM_RTX_CODE; c++)
 	    if (codemap[c] && data->codes[c])
 	      goto pred_done;
@@ -1949,7 +1952,7 @@ write_switch (struct decision *start, in
 	    if (data->codes[c])
 	      {
 		fputs ("    case ", stdout);
-		print_code (c);
+		print_code ((enum rtx_code) c);
 		fputs (":\n", stdout);
 		codemap[c] = 1;
 	      }
@@ -2636,25 +2639,25 @@ make_insn_sequence (rtx insn, enum routi
 
 	  if (i != XVECLEN (x, 0))
 	    {
-	      rtx new;
+	      rtx newrtx;
 	      struct decision_head clobber_head;
 
 	      /* Build a similar insn without the clobbers.  */
 	      if (i == 1)
-		new = XVECEXP (x, 0, 0);
+		newrtx = XVECEXP (x, 0, 0);
 	      else
 		{
 		  int j;
 
-		  new = rtx_alloc (PARALLEL);
-		  XVEC (new, 0) = rtvec_alloc (i);
+		  newrtx = rtx_alloc (PARALLEL);
+		  XVEC (newrtx, 0) = rtvec_alloc (i);
 		  for (j = i - 1; j >= 0; j--)
-		    XVECEXP (new, 0, j) = XVECEXP (x, 0, j);
+		    XVECEXP (newrtx, 0, j) = XVECEXP (x, 0, j);
 		}
 
 	      /* Recognize it.  */
 	      memset (&clobber_head, 0, sizeof(clobber_head));
-	      last = add_to_sequence (new, &clobber_head, "", type, 1);
+	      last = add_to_sequence (newrtx, &clobber_head, "", type, 1);
 
 	      /* Find the end of the test chain on the last node.  */
 	      for (test = last->tests; test->next; test = test->next)
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 124625)
+++ gcc/gengtype.c	(working copy)
@@ -960,6 +960,7 @@ write_rtx_next (void)
   int i;
 
   oprintf (f, "\n/* Used to implement the RTX_NEXT macro.  */\n");
+  oprintf (f, "extern const unsigned char rtx_next[NUM_RTX_CODE];\n");
   oprintf (f, "const unsigned char rtx_next[NUM_RTX_CODE] = {\n");
   for (i = 0; i < NUM_RTX_CODE; i++)
     if (rtx_next_new[i] == -1)
@@ -3253,6 +3254,9 @@ write_roots (pair_p variables)
 	{
 	  fli->started_p = 1;
 
+	  oprintf (f, "extern const struct ggc_root_tab gt_ggc_r_");
+	  put_mangled_filename (f, v->line.file);
+	  oprintf (f, "[];");
 	  oprintf (f, "const struct ggc_root_tab gt_ggc_r_");
 	  put_mangled_filename (f, v->line.file);
 	  oprintf (f, "[] = {\n");
@@ -3287,6 +3291,9 @@ write_roots (pair_p variables)
 	{
 	  fli->started_p = 1;
 
+	  oprintf (f, "extern const struct ggc_root_tab gt_ggc_rd_");
+	  put_mangled_filename (f, v->line.file);
+	  oprintf (f, "[];\n");
 	  oprintf (f, "const struct ggc_root_tab gt_ggc_rd_");
 	  put_mangled_filename (f, v->line.file);
 	  oprintf (f, "[] = {\n");
@@ -3331,6 +3338,9 @@ write_roots (pair_p variables)
 	{
 	  fli->started_p = 1;
 
+	  oprintf (f, "extern const struct ggc_cache_tab gt_ggc_rc_");
+	  put_mangled_filename (f, v->line.file);
+	  oprintf (f, "[];\n");
 	  oprintf (f, "const struct ggc_cache_tab gt_ggc_rc_");
 	  put_mangled_filename (f, v->line.file);
 	  oprintf (f, "[] = {\n");
@@ -3367,6 +3377,9 @@ write_roots (pair_p variables)
 	{
 	  fli->started_p = 1;
 
+	  oprintf (f, "extern const struct ggc_root_tab gt_pch_rc_");
+	  put_mangled_filename (f, v->line.file);
+	  oprintf (f, "[];\n");
 	  oprintf (f, "const struct ggc_root_tab gt_pch_rc_");
 	  put_mangled_filename (f, v->line.file);
 	  oprintf (f, "[] = {\n");
@@ -3403,6 +3416,9 @@ write_roots (pair_p variables)
 	{
 	  fli->started_p = 1;
 
+	  oprintf (f, "extern const struct ggc_root_tab gt_pch_rs_");
+	  put_mangled_filename (f, v->line.file);
+	  oprintf (f, "[];\n");
 	  oprintf (f, "const struct ggc_root_tab gt_pch_rs_");
 	  put_mangled_filename (f, v->line.file);
 	  oprintf (f, "[] = {\n");
@@ -3428,22 +3444,22 @@ write_roots (pair_p variables)
    where the GTY(()) tags are only present if is_scalar is _false_.  */
 
 void
-note_def_vec (const char *typename, bool is_scalar, struct fileloc *pos)
+note_def_vec (const char *type, bool is_scalar, struct fileloc *pos)
 {
   pair_p fields;
   type_p t;
   options_p o;
   type_p len_ty = create_scalar_type ("unsigned");
-  const char *name = concat ("VEC_", typename, "_base", (char *)0);
+  const char *name = concat ("VEC_", type, "_base", (char *)0);
 
   if (is_scalar)
     {
-      t = create_scalar_type (typename);
+      t = create_scalar_type (type);
       o = 0;
     }
   else
     {
-      t = resolve_typedef (typename, pos);
+      t = resolve_typedef (type, pos);
       o = create_option (0, "length", "%h.num");
     }
 
Index: gcc/gengtype.h
===================================================================
--- gcc/gengtype.h	(revision 124625)
+++ gcc/gengtype.h	(working copy)
@@ -64,7 +64,7 @@ extern pair_p nreverse_pairs (pair_p lis
 extern type_p adjust_field_type (type_p, options_p);
 extern void note_variable (const char *s, type_p t, options_p o,
 			   struct fileloc *pos);
-extern void note_def_vec (const char *typename, bool is_scalar,
+extern void note_def_vec (const char *type, bool is_scalar,
 			  struct fileloc *pos);
 extern void note_def_vec_alloc (const char *type, const char *astrat,
 				struct fileloc *pos);
Index: gcc/gengenrtl.c
===================================================================
--- gcc/gengenrtl.c	(revision 124625)
+++ gcc/gengenrtl.c	(working copy)
@@ -235,7 +235,7 @@ genmacro (int idx)
     if (*p != '0')
       printf (", ARG%d", i++);
 
-  printf (") \\\n  gen_rtx_fmt_%s (%s, (MODE)",
+  printf (") \\\n  gen_rtx_fmt_%s (%s, (enum machine_mode) (MODE)",
 	  defs[idx].format, defs[idx].enumname);
 
   for (p = defs[idx].format, i = 0; *p != 0; p++)
Index: gcc/genoutput.c
===================================================================
--- gcc/genoutput.c	(revision 124625)
+++ gcc/genoutput.c	(working copy)
@@ -29,7 +29,7 @@ Software Foundation, 51 Franklin Street,
      a. `name' is the name for that pattern.  Nameless patterns are
      given a name.
 
-     b. `output' hold either the output template, an array of output
+     b. `output' hold either the output pattern, an array of output
      templates, or an output function.
 
      c. `genfun' is the function to generate a body for that pattern,
@@ -80,7 +80,7 @@ Software Foundation, 51 Franklin Street,
       "clrd %0")
 
   assuming it is the 25th entry present, would cause
-  insn_data[24].template to be "clrd %0", and
+  insn_data[24].pattern to be "clrd %0", and
   insn_data[24].n_operands to be 1.  */
 
 #include "bconfig.h"
@@ -155,7 +155,7 @@ struct data
 {
   struct data *next;
   const char *name;
-  const char *template;
+  const char *pattern;
   int code_number;
   int index_number;
   const char *filename;
@@ -337,7 +337,7 @@ output_insn_data (void)
 	  break;
 	case INSN_OUTPUT_FORMAT_SINGLE:
 	  {
-	    const char *p = d->template;
+	    const char *p = d->pattern;
 	    char prev = 0;
 
 	    printf ("#if HAVE_DESIGNATED_INITIALIZERS\n");
@@ -657,36 +657,36 @@ place_operands (struct data *d)
    templates, or C code to generate the assembler code template.  */
 
 static void
-process_template (struct data *d, const char *template)
+process_template (struct data *d, const char *pattern)
 {
   const char *cp;
   int i;
 
-  /* Templates starting with * contain straight code to be run.  */
-  if (template[0] == '*')
+  /* Patterns starting with * contain straight code to be run.  */
+  if (pattern[0] == '*')
     {
-      d->template = 0;
+      d->pattern = 0;
       d->output_format = INSN_OUTPUT_FORMAT_FUNCTION;
 
       puts ("\nstatic const char *");
       printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, rtx insn ATTRIBUTE_UNUSED)\n",
 	      d->code_number);
       puts ("{");
-      print_rtx_ptr_loc (template);
-      puts (template + 1);
+      print_rtx_ptr_loc (pattern);
+      puts (pattern + 1);
       puts ("}");
     }
 
   /* If the assembler code template starts with a @ it is a newline-separated
      list of assembler code templates, one for each alternative.  */
-  else if (template[0] == '@')
+  else if (pattern[0] == '@')
     {
-      d->template = 0;
+      d->pattern = 0;
       d->output_format = INSN_OUTPUT_FORMAT_MULTI;
 
       printf ("\nstatic const char * const output_%d[] = {\n", d->code_number);
 
-      for (i = 0, cp = &template[1]; *cp; )
+      for (i = 0, cp = &pattern[1]; *cp; )
 	{
 	  const char *ep, *sp;
 
@@ -726,7 +726,7 @@ process_template (struct data *d, const 
     }
   else
     {
-      d->template = template;
+      d->pattern = pattern;
       d->output_format = INSN_OUTPUT_FORMAT_SINGLE;
     }
 }
@@ -953,7 +953,7 @@ gen_expand (rtx insn, int lineno)
 
   d->n_operands = max_opno + 1;
   d->n_dups = num_dups;
-  d->template = 0;
+  d->pattern = 0;
   d->output_format = INSN_OUTPUT_FORMAT_NONE;
 
   validate_insn_alternatives (d);
@@ -994,7 +994,7 @@ gen_split (rtx split, int lineno)
   d->n_operands = max_opno + 1;
   d->n_dups = 0;
   d->n_alternatives = 0;
-  d->template = 0;
+  d->pattern = 0;
   d->output_format = INSN_OUTPUT_FORMAT_NONE;
 
   place_operands (d);
@@ -1121,7 +1121,7 @@ note_constraint (rtx exp, int lineno)
 {
   const char *name = XSTR (exp, 0);
   unsigned int namelen = strlen (name);
-  struct constraint_data **iter, **slot, *new;
+  struct constraint_data **iter, **slot, *result;
 
   if (strchr (indep_constraints, name[0]))
     {
@@ -1171,12 +1171,13 @@ note_constraint (rtx exp, int lineno)
 	  return;
 	}
     }
-  new = xmalloc (sizeof (struct constraint_data) + namelen);
-  strcpy ((char *)new + offsetof(struct constraint_data, name), name);
-  new->namelen = namelen;
-  new->lineno = lineno;
-  new->next_this_letter = *slot;
-  *slot = new;
+  result = (struct constraint_data *) xmalloc (sizeof (struct constraint_data)
+					       + namelen);
+  strcpy ((char *)result + offsetof(struct constraint_data, name), name);
+  result->namelen = namelen;
+  result->lineno = lineno;
+  result->next_this_letter = *slot;
+  *slot = result;
 }
 
 /* Return the length of the constraint name beginning at position S
Index: gcc/gensupport.c
===================================================================
--- gcc/gensupport.c	(revision 124625)
+++ gcc/gensupport.c	(working copy)
@@ -1412,13 +1412,13 @@ record_insn_name (int code, const char *
 {
   static const char *last_real_name = "insn";
   static int last_real_code = 0;
-  char *new;
+  char *new_name;
 
   if (insn_name_ptr_size <= code)
     {
       int new_size;
       new_size = (insn_name_ptr_size ? insn_name_ptr_size * 2 : 512);
-      insn_name_ptr = xrealloc (insn_name_ptr, sizeof(char *) * new_size);
+      insn_name_ptr = XRESIZEVEC(char*, insn_name_ptr, new_size);
       memset (insn_name_ptr + insn_name_ptr_size, 0,
 	      sizeof(char *) * (new_size - insn_name_ptr_size));
       insn_name_ptr_size = new_size;
@@ -1426,14 +1426,14 @@ record_insn_name (int code, const char *
 
   if (!name || name[0] == '\0')
     {
-      new = xmalloc (strlen (last_real_name) + 10);
-      sprintf (new, "%s+%d", last_real_name, code - last_real_code);
+      new_name = XNEWVEC(char, strlen (last_real_name) + 10);
+      sprintf (new_name, "%s+%d", last_real_name, code - last_real_code);
     }
   else
     {
-      last_real_name = new = xstrdup (name);
+      last_real_name = new_name = xstrdup (name);
       last_real_code = code;
     }
 
-  insn_name_ptr[code] = new;
+  insn_name_ptr[code] = new_name;
 }
Index: gcc/genextract.c
===================================================================
--- gcc/genextract.c	(revision 124625)
+++ gcc/genextract.c	(working copy)
@@ -153,10 +153,10 @@ gen_insn (rtx insn, int insn_code_number
   /* Otherwise, make a new extraction method.  We stash the arrays
      after the extraction structure in memory.  */
 
-  p = xmalloc (sizeof (struct extraction)
-	       + op_count*sizeof (char *)
-	       + dup_count*sizeof (char *)
-	       + dup_count*sizeof (int));
+  p = (struct extraction*) xmalloc (sizeof (struct extraction)
+				    + op_count*sizeof (char *)
+				    + dup_count*sizeof (char *)
+				    + dup_count*sizeof (int));
   p->op_count = op_count;
   p->dup_count = dup_count;
   p->next = extractions;
Index: gcc/genautomata.c
===================================================================
--- gcc/genautomata.c	(revision 124625)
+++ gcc/genautomata.c	(working copy)
@@ -1083,7 +1083,7 @@ regexp_mode_check_failed (enum regexp_mo
 
 /* Create IR structure (node).  */
 static void *
-create_node (size_t size)
+create_node_untyped (size_t size)
 {
   void *result;
 
@@ -1097,13 +1097,19 @@ create_node (size_t size)
 
 /* Copy IR structure (node).  */
 static void *
-copy_node (const void *from, size_t size)
+copy_node_untyped (const void *from, size_t size)
 {
-  void *const result = create_node (size);
+  void *const result = create_node_untyped (size);
   memcpy (result, from, size);
   return result;
 }
 
+/* Wrapper macros handling node types */
+#define create_node(type, extra)				\
+   ((type*) create_node_untyped (sizeof(type) + (extra)))
+#define copy_node(from, type, extra)				\
+   ((type*) copy_node_untyped (from, sizeof(type) + (extra)))
+
 /* The function checks that NAME does not contain quotes (`"').  */
 static const char *
 check_name (const char * name, pos_t pos ATTRIBUTE_UNUSED)
@@ -1238,7 +1244,7 @@ gen_cpu_unit (rtx def)
     fatal ("invalid string `%s' in define_cpu_unit", XSTR (def, 0));
   for (i = 0; i < vect_length; i++)
     {
-      decl = create_node (sizeof (struct decl));
+      decl = create_node (struct decl, 0);
       decl->mode = dm_unit;
       decl->pos = 0;
       DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
@@ -1268,7 +1274,7 @@ gen_query_cpu_unit (rtx def)
     fatal ("invalid string `%s' in define_query_cpu_unit", XSTR (def, 0));
   for (i = 0; i < vect_length; i++)
     {
-      decl = create_node (sizeof (struct decl));
+      decl = create_node (struct decl, 0);
       decl->mode = dm_unit;
       decl->pos = 0;
       DECL_UNIT (decl)->name = check_name (str_cpu_units [i], decl->pos);
@@ -1302,7 +1308,7 @@ gen_bypass (rtx def)
   for (i = 0; i < out_length; i++)
     for (j = 0; j < in_length; j++)
       {
-	decl = create_node (sizeof (struct decl));
+	decl = create_node (struct decl, 0);
 	decl->mode = dm_bypass;
 	decl->pos = 0;
 	DECL_BYPASS (decl)->latency = XINT (def, 0);
@@ -1337,7 +1343,7 @@ gen_excl_set (rtx def)
   if (second_str_cpu_units == NULL)
     fatal ("invalid second string `%s' in exclusion_set", XSTR (def, 1));
   length += first_vect_length;
-  decl = create_node (sizeof (struct decl) + (length - 1) * sizeof (char *));
+  decl = create_node (struct decl, (length - 1) * sizeof (char *));
   decl->mode = dm_excl;
   decl->pos = 0;
   DECL_EXCL (decl)->all_names_num = length;
@@ -1390,14 +1396,15 @@ gen_presence_absence_set (rtx def, int p
 	    : (final_p
 	       ? "invalid second string `%s' in final_absence_set"
 	       : "invalid second string `%s' in absence_set")), XSTR (def, 1));
-  str_patterns = obstack_alloc (&irp, patterns_length * sizeof (char **));
+  str_patterns = (char***) obstack_alloc (&irp,
+					  patterns_length * sizeof (char **));
   for (i = 0; i < patterns_length; i++)
     {
       str_patterns [i] = get_str_vect (str_pattern_lists [i],
 				       &length, ' ', FALSE);
       gcc_assert (str_patterns [i]);
     }
-  decl = create_node (sizeof (struct decl));
+  decl = create_node (struct decl, 0);
   decl->pos = 0;
   if (presence_p)
     {
@@ -1482,7 +1489,7 @@ gen_automaton (rtx def)
     fatal ("invalid string `%s' in define_automaton", XSTR (def, 0));
   for (i = 0; i < vect_length; i++)
     {
-      decl = create_node (sizeof (struct decl));
+      decl = create_node (struct decl, 0);
       decl->mode = dm_automaton;
       decl->pos = 0;
       DECL_AUTOMATON (decl)->name = check_name (str_automata [i], decl->pos);
@@ -1535,19 +1542,19 @@ gen_regexp_el (const char *str)
       len = strlen (str);
       if (str [len - 1] != ')')
 	fatal ("garbage after ) in reservation `%s'", reserv_str);
-      dstr = alloca (len - 1);
+      dstr = (char*) alloca (len - 1);
       memcpy (dstr, str + 1, len - 2);
       dstr [len-2] = '\0';
       regexp = gen_regexp_sequence (dstr);
     }
   else if (strcmp (str, NOTHING_NAME) == 0)
     {
-      regexp = create_node (sizeof (struct decl));
+      regexp = create_node (struct regexp, 0);
       regexp->mode = rm_nothing;
     }
   else
     {
-      regexp = create_node (sizeof (struct decl));
+      regexp = create_node (struct regexp, 0);
       regexp->mode = rm_unit;
       REGEXP_UNIT (regexp)->name = str;
     }
@@ -1572,7 +1579,7 @@ gen_regexp_repeat (const char *str)
       regexp = gen_regexp_el (repeat_vect [0]);
       for (i = 1; i < els_num; i++)
 	{
-	  repeat = create_node (sizeof (struct regexp));
+	  repeat = create_node (struct regexp, 0);
 	  repeat->mode = rm_repeat;
 	  REGEXP_REPEAT (repeat)->regexp = regexp;
 	  REGEXP_REPEAT (repeat)->repeat_num = atoi (repeat_vect [i]);
@@ -1601,8 +1608,7 @@ gen_regexp_allof (const char *str)
     fatal ("invalid `%s' in reservation `%s'", str, reserv_str);
   if (els_num > 1)
     {
-      allof = create_node (sizeof (struct regexp)
-			   + sizeof (regexp_t) * (els_num - 1));
+      allof = create_node (struct regexp, sizeof (regexp_t) * (els_num - 1));
       allof->mode = rm_allof;
       REGEXP_ALLOF (allof)->regexps_num = els_num;
       for (i = 0; i < els_num; i++)
@@ -1627,8 +1633,7 @@ gen_regexp_oneof (const char *str)
     fatal ("invalid `%s' in reservation `%s'", str, reserv_str);
   if (els_num > 1)
     {
-      oneof = create_node (sizeof (struct regexp)
-			   + sizeof (regexp_t) * (els_num - 1));
+      oneof = create_node (struct regexp, sizeof (regexp_t) * (els_num - 1));
       oneof->mode = rm_oneof;
       REGEXP_ONEOF (oneof)->regexps_num = els_num;
       for (i = 0; i < els_num; i++)
@@ -1651,8 +1656,8 @@ gen_regexp_sequence (const char *str)
   sequence_vect = get_str_vect (str, &els_num, ',', TRUE);
   if (els_num > 1)
     {
-      sequence = create_node (sizeof (struct regexp)
-			      + sizeof (regexp_t) * (els_num - 1));
+      sequence = create_node (struct regexp,
+			      sizeof (regexp_t) * (els_num - 1));
       sequence->mode = rm_sequence;
       REGEXP_SEQUENCE (sequence)->regexps_num = els_num;
       for (i = 0; i < els_num; i++)
@@ -1682,7 +1687,7 @@ gen_reserv (rtx def)
 {
   decl_t decl;
 
-  decl = create_node (sizeof (struct decl));
+  decl = create_node (struct decl, 0);
   decl->mode = dm_reserv;
   decl->pos = 0;
   DECL_RESERV (decl)->name = check_name (XSTR (def, 0), decl->pos);
@@ -1700,7 +1705,7 @@ gen_insn_reserv (rtx def)
 {
   decl_t decl;
 
-  decl = create_node (sizeof (struct decl));
+  decl = create_node (struct decl, 0);
   decl->mode = dm_insn_reserv;
   decl->pos = 0;
   DECL_INSN_RESERV (decl)->name
@@ -1777,7 +1782,7 @@ insert_automaton_decl (decl_t automaton_
 {
   void **entry_ptr;
 
-  entry_ptr = htab_find_slot (automaton_decl_table, automaton_decl, 1);
+  entry_ptr = htab_find_slot (automaton_decl_table, automaton_decl, INSERT);
   if (*entry_ptr == NULL)
     *entry_ptr = (void *) automaton_decl;
   return (decl_t) *entry_ptr;
@@ -1876,7 +1881,7 @@ insert_insn_decl (decl_t insn_decl)
 {
   void **entry_ptr;
 
-  entry_ptr = htab_find_slot (insn_decl_table, insn_decl, 1);
+  entry_ptr = htab_find_slot (insn_decl_table, insn_decl, INSERT);
   if (*entry_ptr == NULL)
     *entry_ptr = (void *) insn_decl;
   return (decl_t) *entry_ptr;
@@ -1977,7 +1982,7 @@ insert_decl (decl_t decl)
 {
   void **entry_ptr;
 
-  entry_ptr = htab_find_slot (decl_table, decl, 1);
+  entry_ptr = htab_find_slot (decl_table, decl, INSERT);
   if (*entry_ptr == NULL)
     *entry_ptr = (void *) decl;
   return (decl_t) *entry_ptr;
@@ -2048,7 +2053,7 @@ process_excls (char **names, int num, po
 	error ("`%s' in exclusion is not unit", names [i]);
       else
 	{
-	  new_el = create_node (sizeof (struct unit_set_el));
+	  new_el = create_node (struct unit_set_el, 0);
 	  new_el->unit_decl = DECL_UNIT (decl_in_table);
 	  new_el->next_unit_set_el = NULL;
 	  if (last_el == NULL)
@@ -2101,7 +2106,7 @@ add_excls (unit_set_el_t dest_list, unit
 	if (curr_el == NULL)
 	  {
 	    /* Element not found - insert.  */
-	    copy = copy_node (src, sizeof (*src));
+	    copy = copy_node (src, struct unit_set_el, 0);
 	    copy->next_unit_set_el = NULL;
 	    if (prev_el == NULL)
 	      dst->unit_decl->excl_list = copy;
@@ -2148,7 +2153,7 @@ process_presence_absence_names (char **n
 		   : "`%s' in absence set is not unit")), names [i]);
       else
 	{
-	  new_el = create_node (sizeof (struct unit_set_el));
+	  new_el = create_node (struct unit_set_el, 0);
 	  new_el->unit_decl = DECL_UNIT (decl_in_table);
 	  new_el->next_unit_set_el = NULL;
 	  if (last_el == NULL)
@@ -2183,8 +2188,8 @@ process_presence_absence_patterns (char 
     {
       for (j = 0; patterns [i] [j] != NULL; j++)
 	;
-      new_el = create_node (sizeof (struct pattern_set_el)
-			    + sizeof (struct unit_decl *) * j);
+      new_el = create_node (struct pattern_set_el,
+			    sizeof (struct unit_decl *) * j);
       new_el->unit_decls
 	= (struct unit_decl **) ((char *) new_el
 				 + sizeof (struct pattern_set_el));
@@ -2330,7 +2335,7 @@ add_presence_absence (unit_set_el_t dest
 		     prev_el != NULL && prev_el->next_pattern_set_el != NULL;
 		     prev_el = prev_el->next_pattern_set_el)
 		  ;
-		copy = copy_node (pat, sizeof (*pat));
+		copy = copy_node (pat, struct pattern_set_el, 0);
 		copy->next_pattern_set_el = NULL;
 		if (prev_el == NULL)
 		  {
@@ -2660,7 +2665,7 @@ process_regexp (regexp_t regexp)
 
 	  case dm_reserv:
 	    DECL_RESERV (decl_in_table)->reserv_is_used = 1;
-	    new_regexp = create_node (sizeof (struct regexp));
+	    new_regexp = create_node (struct regexp, 0);
 	    new_regexp->mode = rm_reserv;
 	    new_regexp->pos = regexp->pos;
 	    REGEXP_RESERV (new_regexp)->name = REGEXP_UNIT (regexp)->name;
@@ -3101,7 +3106,7 @@ static decl_t advance_cycle_insn_decl;
 static void
 add_advance_cycle_insn_decl (void)
 {
-  advance_cycle_insn_decl = create_node (sizeof (struct decl));
+  advance_cycle_insn_decl = create_node (struct decl, 0);
   advance_cycle_insn_decl->mode = dm_insn_reserv;
   advance_cycle_insn_decl->pos = no_pos;
   DECL_INSN_RESERV (advance_cycle_insn_decl)->regexp = NULL;
@@ -3144,7 +3149,7 @@ get_free_alt_state (void)
 #ifndef NDEBUG
       allocated_alt_states_num++;
 #endif
-      result = create_node (sizeof (struct alt_state));
+      result = create_node (struct alt_state, 0);
     }
   result->state = NULL;
   result->next_alt_state = NULL;
@@ -3619,7 +3624,7 @@ get_free_state (int with_reservs, automa
 #ifndef NDEBUG
       allocated_states_num++;
 #endif
-      result = create_node (sizeof (struct state));
+      result = create_node (struct state, 0);
       result->automaton = automaton;
       result->first_out_arc = NULL;
       result->unique_num = curr_unique_state_num;
@@ -3709,7 +3714,7 @@ insert_state (state_t state)
 {
   void **entry_ptr;
 
-  entry_ptr = htab_find_slot (state_table, (void *) state, 1);
+  entry_ptr = htab_find_slot (state_table, (void *) state, INSERT);
   if (*entry_ptr == NULL)
     *entry_ptr = (void *) state;
   return (state_t) *entry_ptr;
@@ -3886,7 +3891,7 @@ add_arc (state_t from_state, state_t to_
 #ifndef NDEBUG
       allocated_arcs_num++;
 #endif
-      new_arc = create_node (sizeof (struct arc));
+      new_arc = create_node (struct arc, 0);
       new_arc->to_state = NULL;
       new_arc->insn = NULL;
       new_arc->next_out_arc = NULL;
@@ -3960,7 +3965,7 @@ get_free_automata_list_el (void)
 	= first_free_automata_list_el->next_automata_list_el;
     }
   else
-    result = create_node (sizeof (struct automata_list_el));
+    result = create_node (struct automata_list_el, 0);
   result->automaton = NULL;
   result->next_automata_list_el = NULL;
   return result;
@@ -4065,7 +4070,7 @@ automata_list_finish (void)
   if (current_automata_list == NULL)
     return NULL;
   entry_ptr = htab_find_slot (automata_list_table,
-			      (void *) current_automata_list, 1);
+			      (void *) current_automata_list, INSERT);
   if (*entry_ptr == NULL)
     *entry_ptr = (void *) current_automata_list;
   else
@@ -4187,7 +4192,7 @@ form_reserv_sets_list (pattern_set_el_t 
   prev = first = NULL;
   for (el = pattern_list; el != NULL; el = el->next_pattern_set_el)
     {
-      curr = create_node (sizeof (struct pattern_reserv));
+      curr = create_node (struct pattern_reserv, 0);
       curr->reserv = alloc_empty_reserv_sets ();
       curr->next_pattern_reserv = NULL;
       for (i = 0; i < el->units_num; i++)
@@ -4358,18 +4363,18 @@ copy_insn_regexp (regexp_t regexp)
       break;
 
     case rm_unit:
-      result = copy_node (regexp, sizeof (struct regexp));
+      result = copy_node (regexp, struct regexp, 0);
       break;
 
     case rm_repeat:
-      result = copy_node (regexp, sizeof (struct regexp));
+      result = copy_node (regexp, struct regexp, 0);
       REGEXP_REPEAT (result)->regexp
         = copy_insn_regexp (REGEXP_REPEAT (regexp)->regexp);
       break;
 
     case rm_sequence:
-      result = copy_node (regexp,
-                          sizeof (struct regexp) + sizeof (regexp_t)
+      result = copy_node (regexp, struct regexp,
+			  sizeof (regexp_t)
 			  * (REGEXP_SEQUENCE (regexp)->regexps_num - 1));
       for (i = 0; i <REGEXP_SEQUENCE (regexp)->regexps_num; i++)
 	REGEXP_SEQUENCE (result)->regexps [i]
@@ -4377,8 +4382,8 @@ copy_insn_regexp (regexp_t regexp)
       break;
 
     case rm_allof:
-      result = copy_node (regexp,
-                          sizeof (struct regexp) + sizeof (regexp_t)
+      result = copy_node (regexp, struct regexp,
+			  sizeof (regexp_t)
 			  * (REGEXP_ALLOF (regexp)->regexps_num - 1));
       for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
 	REGEXP_ALLOF (result)->regexps [i]
@@ -4386,8 +4391,8 @@ copy_insn_regexp (regexp_t regexp)
       break;
 
     case rm_oneof:
-      result = copy_node (regexp,
-                          sizeof (struct regexp) + sizeof (regexp_t)
+      result = copy_node (regexp, struct regexp,
+			  sizeof (regexp_t)
 			  * (REGEXP_ONEOF (regexp)->regexps_num - 1));
       for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
 	REGEXP_ONEOF (result)->regexps [i]
@@ -4395,7 +4400,7 @@ copy_insn_regexp (regexp_t regexp)
       break;
 
     case rm_nothing:
-      result = copy_node (regexp, sizeof (struct regexp));
+      result = copy_node (regexp, struct regexp, 0);
       break;
 
     default:
@@ -4424,7 +4429,7 @@ transform_1 (regexp_t regexp)
       gcc_assert (repeat_num > 1);
       operand = REGEXP_REPEAT (regexp)->regexp;
       pos = regexp->mode;
-      regexp = create_node (sizeof (struct regexp) + sizeof (regexp_t)
+      regexp = create_node (struct regexp, sizeof (regexp_t)
 			    * (repeat_num - 1));
       regexp->mode = rm_sequence;
       regexp->pos = pos;
@@ -4461,8 +4466,7 @@ transform_2 (regexp_t regexp)
 	{
 	  gcc_assert (REGEXP_SEQUENCE (sequence)->regexps_num > 1
 		      && REGEXP_SEQUENCE (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-                                + sizeof (regexp_t)
+	  result = create_node (struct regexp, sizeof (regexp_t)
 				* (REGEXP_SEQUENCE (regexp)->regexps_num
                                    + REGEXP_SEQUENCE (sequence)->regexps_num
                                    - 2));
@@ -4505,8 +4509,7 @@ transform_2 (regexp_t regexp)
 	{
 	  gcc_assert (REGEXP_ALLOF (allof)->regexps_num > 1
 		      && REGEXP_ALLOF (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-                                + sizeof (regexp_t)
+	  result = create_node (struct regexp, sizeof (regexp_t)
 				* (REGEXP_ALLOF (regexp)->regexps_num
                                    + REGEXP_ALLOF (allof)->regexps_num - 2));
 	  result->mode = rm_allof;
@@ -4548,8 +4551,7 @@ transform_2 (regexp_t regexp)
 	{
 	  gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1
 		      && REGEXP_ONEOF (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-				+ sizeof (regexp_t)
+	  result = create_node (struct regexp, sizeof (regexp_t)
 				* (REGEXP_ONEOF (regexp)->regexps_num
                                    + REGEXP_ONEOF (oneof)->regexps_num - 2));
 	  result->mode = rm_oneof;
@@ -4603,8 +4605,7 @@ transform_3 (regexp_t regexp)
 	{
 	  gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1
 		      && REGEXP_SEQUENCE (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-				+ sizeof (regexp_t)
+	  result = create_node (struct regexp, sizeof (regexp_t)
 				* (REGEXP_ONEOF (oneof)->regexps_num - 1));
 	  result->mode = rm_oneof;
 	  result->pos = regexp->pos;
@@ -4613,8 +4614,7 @@ transform_3 (regexp_t regexp)
 	  for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++)
 	    {
 	      sequence
-                = create_node (sizeof (struct regexp)
-                               + sizeof (regexp_t)
+                = create_node (struct regexp, sizeof (regexp_t)
                                * (REGEXP_SEQUENCE (regexp)->regexps_num - 1));
 	      sequence->mode = rm_sequence;
 	      sequence->pos = regexp->pos;
@@ -4655,8 +4655,7 @@ transform_3 (regexp_t regexp)
 	{
 	  gcc_assert (REGEXP_ONEOF (oneof)->regexps_num > 1
 		      && REGEXP_ALLOF (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-				+ sizeof (regexp_t)
+	  result = create_node (struct regexp, sizeof (regexp_t)
 				* (REGEXP_ONEOF (oneof)->regexps_num - 1));
 	  result->mode = rm_oneof;
 	  result->pos = regexp->pos;
@@ -4665,8 +4664,7 @@ transform_3 (regexp_t regexp)
 	  for (i = 0; i < REGEXP_ONEOF (result)->regexps_num; i++)
 	    {
 	      allof
-		= create_node (sizeof (struct regexp)
-                               + sizeof (regexp_t)
+		= create_node (struct regexp, sizeof (regexp_t)
 			       * (REGEXP_ALLOF (regexp)->regexps_num - 1));
 	      allof->mode = rm_allof;
 	      allof->pos = regexp->pos;
@@ -4710,8 +4708,8 @@ transform_3 (regexp_t regexp)
 	{
 	  gcc_assert (max_seq_length != 1
 		      && REGEXP_ALLOF (regexp)->regexps_num > 1);
-	  result = create_node (sizeof (struct regexp)
-				+ sizeof (regexp_t) * (max_seq_length - 1));
+	  result = create_node (struct regexp,
+				sizeof (regexp_t) * (max_seq_length - 1));
 	  result->mode = rm_sequence;
 	  result->pos = regexp->pos;
 	  REGEXP_SEQUENCE (result)->regexps_num = max_seq_length;
@@ -4748,8 +4746,8 @@ transform_3 (regexp_t regexp)
 		REGEXP_SEQUENCE (result)->regexps [i] = allof_op;
 	      else
 		{
-		  allof = create_node (sizeof (struct regexp)
-				       + sizeof (regexp_t)
+		  allof = create_node (struct regexp,
+				       sizeof (regexp_t)
 				       * (allof_length - 1));
 		  allof->mode = rm_allof;
 		  allof->pos = regexp->pos;
@@ -5665,7 +5663,7 @@ cache_presence (state_t state)
   sz = (description->query_units_num + sizeof (int) * CHAR_BIT - 1)
         / (sizeof (int) * CHAR_BIT);
   
-  state->presence_signature = create_node (sz * sizeof (int));
+  state->presence_signature = create_node (unsigned, sz * sizeof (unsigned));
   for (i = 0; i < description->units_num; i++)
     if (units_array [i]->query_p)
       {
@@ -6393,7 +6391,7 @@ create_ainsns (void)
       decl = description->decls [i];
       if (decl->mode == dm_insn_reserv)
 	{
-	  curr_ainsn = create_node (sizeof (struct ainsn));
+	  curr_ainsn = create_node (struct ainsn, 0);
 	  curr_ainsn->insn_reserv_decl = DECL_INSN_RESERV (decl);
 	  curr_ainsn->important_p = FALSE;
 	  curr_ainsn->next_ainsn = NULL;
@@ -6451,7 +6449,7 @@ create_automata (void)
            curr_automaton_num < automata_num;
            curr_automaton_num++, prev_automaton = curr_automaton)
         {
-	  curr_automaton = create_node (sizeof (struct automaton));
+	  curr_automaton = create_node (struct automaton, 0);
 	  curr_automaton->ainsn_list = create_ainsns ();
 	  curr_automaton->corresponding_automaton_decl = NULL;
 	  curr_automaton->next_automaton = NULL;
@@ -6472,7 +6470,7 @@ create_automata (void)
 	  if (decl->mode == dm_automaton
 	      && DECL_AUTOMATON (decl)->automaton_is_used)
 	    {
-	      curr_automaton = create_node (sizeof (struct automaton));
+	      curr_automaton = create_node (struct automaton, 0);
 	      curr_automaton->ainsn_list = create_ainsns ();
 	      curr_automaton->corresponding_automaton_decl
 		= DECL_AUTOMATON (decl);
@@ -6489,7 +6487,7 @@ create_automata (void)
 	}
       if (curr_automaton_num == 0)
 	{
-	  curr_automaton = create_node (sizeof (struct automaton));
+	  curr_automaton = create_node (struct automaton, 0);
 	  curr_automaton->ainsn_list = create_ainsns ();
 	  curr_automaton->corresponding_automaton_decl = NULL;
 	  curr_automaton->next_automaton = NULL;
@@ -6988,7 +6986,7 @@ create_state_ainsn_table (automaton_t au
   int full_vect_length;
   int i;
 
-  tab = create_node (sizeof (struct state_ainsn_table));
+  tab = create_node (struct state_ainsn_table, 0);
   tab->automaton = automaton;
 
   tab->comb_vect  = VEC_alloc (vect_el_t,heap, 10000);
@@ -7902,8 +7900,8 @@ dfa_insn_code_enlarge (int uid)\n\
 {\n\
   int i = %s;\n\
   %s = 2 * uid;\n\
-  %s = xrealloc (%s,\n\
-                 %s * sizeof(int));\n\
+  %s = XRESIZEVEC (int, %s,\n\
+                 %s);\n\
   for (; i < %s; i++)\n\
     %s[i] = -1;\n}\n\n",
 	   DFA_INSN_CODES_LENGTH_VARIABLE_NAME,
@@ -7948,8 +7946,9 @@ output_trans_func (void)
   fprintf (output_file, "{\n  int %s;\n", INTERNAL_INSN_CODE_NAME);
   output_internal_insn_code_evaluation (INSN_PARAMETER_NAME,
 					INTERNAL_INSN_CODE_NAME, -1);
-  fprintf (output_file, "  return %s (%s, %s);\n}\n\n",
-	   INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME, STATE_NAME);
+  fprintf (output_file, "  return %s (%s, (struct %s *) %s);\n}\n\n",
+	   INTERNAL_TRANSITION_FUNC_NAME, INTERNAL_INSN_CODE_NAME,
+	   CHIP_NAME, STATE_NAME);
 }
 
 /* Output function `min_issue_delay'.  */
@@ -7967,9 +7966,9 @@ output_min_issue_delay_func (void)
 	   INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME);
   fprintf (output_file, "    }\n  else\n    %s = %s;\n",
 	   INTERNAL_INSN_CODE_NAME, ADVANCE_CYCLE_VALUE_NAME);
-  fprintf (output_file, "\n  return %s (%s, %s);\n",
+  fprintf (output_file, "\n  return %s (%s, (struct %s *) %s);\n",
 	   INTERNAL_MIN_ISSUE_DELAY_FUNC_NAME, INTERNAL_INSN_CODE_NAME,
-	   STATE_NAME);
+	   CHIP_NAME, STATE_NAME);
   fprintf (output_file, "}\n\n");
 }
 
@@ -8002,8 +8001,8 @@ output_dead_lock_func (void)
 {
   fprintf (output_file, "int\n%s (%s %s)\n",
 	   DEAD_LOCK_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME);
-  fprintf (output_file, "{\n  return %s (%s);\n}\n\n",
-	   INTERNAL_DEAD_LOCK_FUNC_NAME, STATE_NAME);
+  fprintf (output_file, "{\n  return %s ((struct %s *) %s);\n}\n\n",
+	   INTERNAL_DEAD_LOCK_FUNC_NAME, CHIP_NAME, STATE_NAME);
 }
 
 /* Output function `internal_reset'.  */
@@ -8030,8 +8029,8 @@ output_reset_func (void)
 {
   fprintf (output_file, "void\n%s (%s %s)\n",
 	   RESET_FUNC_NAME, STATE_TYPE_NAME, STATE_NAME);
-  fprintf (output_file, "{\n  %s (%s);\n}\n\n", INTERNAL_RESET_FUNC_NAME,
-	   STATE_NAME);
+  fprintf (output_file, "{\n  %s ((struct %s *) %s);\n}\n\n",
+	   INTERNAL_RESET_FUNC_NAME, CHIP_NAME, STATE_NAME);
 }
 
 /* Output function `min_insn_conflict_delay'.  */
@@ -8278,7 +8277,7 @@ output_get_cpu_unit_code_func (void)
 	   LOW_VARIABLE_NAME, MIDDLE_VARIABLE_NAME, HIGH_VARIABLE_NAME);
   fprintf (output_file, "  static struct %s %s [] =\n    {\n",
 	   NAME_CODE_STRUCT_NAME, NAME_CODE_TABLE_NAME);
-  units = xmalloc (sizeof (unit_decl_t) * description->units_num);
+  units = XNEWVEC (unit_decl_t, description->units_num);
   memcpy (units, units_array, sizeof (unit_decl_t) * description->units_num);
   qsort (units, description->units_num, sizeof (unit_decl_t), units_cmp);
   for (i = 0; i < description->units_num; i++)
@@ -8374,7 +8373,7 @@ output_dfa_start_func (void)
   fprintf (output_file,
 	   "void\n%s (void)\n{\n  %s = get_max_uid ();\n",
 	   DFA_START_FUNC_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME);
-  fprintf (output_file, "  %s = xmalloc (%s * sizeof (int));\n",
+  fprintf (output_file, "  %s = XNEWVEC (int, %s);\n",
 	   DFA_INSN_CODES_VARIABLE_NAME, DFA_INSN_CODES_LENGTH_VARIABLE_NAME);
   fprintf (output_file, "  %s ();\n}\n\n", DFA_CLEAN_INSN_CACHE_FUNC_NAME);
 }
@@ -9057,9 +9056,9 @@ expand_automata (void)
 {
   int i;
 
-  description = create_node (sizeof (struct description)
+  description = create_node (struct description,
 			     /* One entry for cycle advancing insn.  */
-			     + sizeof (decl_t) * VEC_length (decl_t, decls));
+			     sizeof (decl_t) * VEC_length (decl_t, decls));
   description->decls_num = VEC_length (decl_t, decls);
   description->query_units_num = 0;
   for (i = 0; i < description->decls_num; i++)
Index: gcc/genemit.c
===================================================================
--- gcc/genemit.c	(revision 124625)
+++ gcc/genemit.c	(working copy)
@@ -358,16 +358,16 @@ gen_insn (rtx insn, int lineno)
 	      for (j = i + 1; j < XVECLEN (insn, 1); j++)
 		{
 		  rtx old = XEXP (XVECEXP (p->pattern, 1, j), 0);
-		  rtx new = XEXP (XVECEXP (insn, 1, j), 0);
+		  rtx newrtx = XEXP (XVECEXP (insn, 1, j), 0);
 
 		  /* OLD and NEW are the same if both are to be a SCRATCH
 		     of the same mode,
 		     or if both are registers of the same mode and number.  */
-		  if (! (GET_MODE (old) == GET_MODE (new)
+		  if (! (GET_MODE (old) == GET_MODE (newrtx)
 			 && ((GET_CODE (old) == MATCH_SCRATCH
-			      && GET_CODE (new) == MATCH_SCRATCH)
-			     || (REG_P (old) && REG_P (new)
-				 && REGNO (old) == REGNO (new)))))
+			      && GET_CODE (newrtx) == MATCH_SCRATCH)
+			     || (REG_P (old) && REG_P (newrtx)
+				 && REGNO (old) == REGNO (newrtx)))))
 		    break;
 		}
 
Index: gcc/gengtype-lex.l
===================================================================
--- gcc/gengtype-lex.l	(revision 124625)
+++ gcc/gengtype-lex.l	(working copy)
@@ -116,7 +116,7 @@ EOID	[^[:alnum:]_]
 "nested_ptr"/{EOID}		{ return NESTED_PTR; }
 [0-9]+				{ return NUM; }
 "param"[0-9]*"_is"/{EOID}		{
-  *yylval = xmemdup (yytext, yyleng, yyleng+1);
+  *yylval = (char*) xmemdup (yytext, yyleng, yyleng+1);
   return PARAM_IS;
 }
 
@@ -127,28 +127,28 @@ EOID	[^[:alnum:]_]
   for (len = yyleng; ISSPACE (yytext[len-1]); len--)
     ;
 
-  *yylval = xmemdup (yytext, len, len+1);
+  *yylval = (char*) xmemdup (yytext, len, len+1);
   update_lineno (yytext, yyleng);
   return SCALAR;
 }
 
 
 {ID}/{EOID}			{
-  *yylval = xmemdup (yytext, yyleng, yyleng+1);
+  *yylval = (char*) xmemdup (yytext, yyleng, yyleng+1);
   return ID;
 }
 
 \"([^"\\]|\\.)*\"		{
-  *yylval = xmemdup (yytext+1, yyleng-2, yyleng-1);
+  *yylval = (char*) xmemdup (yytext+1, yyleng-2, yyleng-1);
   return STRING;
 }
   /* This "terminal" avoids having to parse integer constant expressions.  */
 "["[^\[\]]*"]"			{
-  *yylval = xmemdup (yytext+1, yyleng-2, yyleng-1);
+  *yylval = (char*) xmemdup (yytext+1, yyleng-2, yyleng-1);
   return ARRAY;
 }
 "'"("\\".|[^\\])"'"		{
-  *yylval = xmemdup (yytext+1, yyleng-2, yyleng);
+  *yylval = (char*) xmemdup (yytext+1, yyleng-2, yyleng);
   return CHAR;
 }
 
Index: gcc/genattrtab.c
===================================================================
--- gcc/genattrtab.c	(revision 124625)
+++ gcc/genattrtab.c	(working copy)
@@ -287,7 +287,10 @@ static rtx one_fn		   (rtx);
 static rtx max_fn		   (rtx);
 static rtx min_fn		   (rtx);
 
-#define oballoc(size) obstack_alloc (hash_obstack, size)
+#define obnew(type)							\
+	((type*) obstack_alloc (hash_obstack, sizeof(type)))
+#define obvec(type,num)							\
+	((type*) obstack_alloc (hash_obstack, (num) * sizeof(type)))
 
 /* Hash table for sharing RTL and strings.  */
 
@@ -327,7 +330,7 @@ attr_hash_add_rtx (int hashcode, rtx rtl
 {
   struct attr_hash *h;
 
-  h = obstack_alloc (hash_obstack, sizeof (struct attr_hash));
+  h = obnew (struct attr_hash);
   h->hashcode = hashcode;
   h->u.rtl = rtl;
   h->next = attr_hash_table[hashcode % RTL_HASH_SIZE];
@@ -341,7 +344,7 @@ attr_hash_add_string (int hashcode, char
 {
   struct attr_hash *h;
 
-  h = obstack_alloc (hash_obstack, sizeof (struct attr_hash));
+  h = obnew (struct attr_hash);
   h->hashcode = -hashcode;
   h->u.str = str;
   h->next = attr_hash_table[hashcode % RTL_HASH_SIZE];
@@ -602,7 +605,7 @@ attr_string (const char *str, int len)
       return h->u.str;			/* <-- return if found.  */
 
   /* Not found; create a permanent copy and add it to the hash table.  */
-  new_str = obstack_alloc (hash_obstack, len + 1);
+  new_str = obvec (char, len + 1);
   memcpy (new_str, str, len);
   new_str[len] = '\0';
   attr_hash_add_string (hashcode, new_str);
@@ -1298,7 +1301,7 @@ get_attr_value (rtx value, struct attr_d
 	    || insn_alternatives[av->first_insn->def->insn_code]))
       return av;
 
-  av = oballoc (sizeof (struct attr_value));
+  av = obnew (struct attr_value);
   av->value = value;
   av->next = attr->first_value;
   attr->first_value = av;
@@ -1441,7 +1444,7 @@ fill_attr (struct attr_desc *attr)
       else
 	av = get_attr_value (value, attr, id->insn_code);
 
-      ie = oballoc (sizeof (struct insn_ent));
+      ie = obnew (struct insn_ent);
       ie->def = id;
       insert_insn_ent (av, ie);
     }
@@ -1572,7 +1575,7 @@ make_length_attrs (void)
 							 no_address_fn[i],
 							 address_fn[i]),
 				     new_attr, ie->def->insn_code);
-	    new_ie = oballoc (sizeof (struct insn_ent));
+	    new_ie = obnew (struct insn_ent);
 	    new_ie->def = ie->def;
 	    insert_insn_ent (new_av, new_ie);
 	  }
@@ -1637,6 +1640,7 @@ write_length_unit_log (void)
       for (length_unit_log = 0; length_or & 1; length_or >>= 1)
 	length_unit_log++;
     }
+  printf ("extern const int length_unit_log;\n");
   printf ("const int length_unit_log = %u;\n", length_unit_log);
 }
 
@@ -1846,11 +1850,11 @@ insert_right_side (enum rtx_code code, r
 
   if (GET_CODE (exp) == code)
     {
-      rtx new = insert_right_side (code, XEXP (exp, 1),
-				   term, insn_code, insn_index);
-      if (new != XEXP (exp, 1))
+      rtx newrtx = insert_right_side (code, XEXP (exp, 1),
+				      term, insn_code, insn_index);
+      if (newrtx != XEXP (exp, 1))
 	/* Make a copy of this expression and call recursively.  */
-	newexp = attr_rtx (code, XEXP (exp, 0), new);
+	newexp = attr_rtx (code, XEXP (exp, 0), newrtx);
       else
 	newexp = exp;
     }
@@ -1980,10 +1984,10 @@ evaluate_eq_attr (rtx exp, rtx value, in
 
       for (i = 0; i < XVECLEN (value, 0); i += 2)
 	{
-	  rtx this = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
-						insn_code, insn_index);
+	  rtx thisrtx = simplify_test_exp_in_temp (XVECEXP (value, 0, i),
+						   insn_code, insn_index);
 
-	  right = insert_right_side (AND, andexp, this,
+	  right = insert_right_side (AND, andexp, thisrtx,
 				     insn_code, insn_index);
 	  right = insert_right_side (AND, right,
 				     evaluate_eq_attr (exp,
@@ -1995,7 +1999,7 @@ evaluate_eq_attr (rtx exp, rtx value, in
 				     insn_code, insn_index);
 
 	  /* Add this condition into the AND expression.  */
-	  newexp = attr_rtx (NOT, this);
+	  newexp = attr_rtx (NOT, thisrtx);
 	  andexp = insert_right_side (AND, andexp, newexp,
 				      insn_code, insn_index);
 	}
@@ -2950,7 +2954,7 @@ gen_attr (rtx exp, int lineno)
       name_ptr = XSTR (exp, 1);
       while ((p = next_comma_elt (&name_ptr)) != NULL)
 	{
-	  av = oballoc (sizeof (struct attr_value));
+	  av = obnew (struct attr_value);
 	  av->value = attr_rtx (CONST_STRING, p);
 	  av->next = attr->first_value;
 	  attr->first_value = av;
@@ -3063,7 +3067,7 @@ gen_insn (rtx exp, int lineno)
 {
   struct insn_def *id;
 
-  id = oballoc (sizeof (struct insn_def));
+  id = obnew (struct insn_def);
   id->next = defs;
   defs = id;
   id->def = exp;
@@ -3127,7 +3131,7 @@ gen_delay (rtx def, int lineno)
 	have_annul_false = 1;
     }
 
-  delay = oballoc (sizeof (struct delay_desc));
+  delay = obnew (struct delay_desc);
   delay->def = def;
   delay->num = ++num_delays;
   delay->next = delays;
@@ -4159,7 +4163,7 @@ find_attr (const char **name_p, int crea
   if (! create)
     return NULL;
 
-  attr = oballoc (sizeof (struct attr_desc));
+  attr = obnew (struct attr_desc);
   attr->name = DEF_ATTR_STRING (name);
   attr->first_value = attr->default_val = NULL;
   attr->is_numeric = attr->is_const = attr->is_special = 0;
@@ -4298,7 +4302,7 @@ static size_t n_insn_reservs;
 static void
 gen_insn_reserv (rtx def)
 {
-  struct insn_reserv *decl = oballoc (sizeof (struct insn_reserv));
+  struct insn_reserv *decl = obnew (struct insn_reserv);
 
   decl->name            = DEF_ATTR_STRING (XSTR (def, 0));
   decl->default_latency = XINT (def, 1);
@@ -4339,7 +4343,7 @@ gen_bypass_1 (const char *s, size_t len)
     if (s == b->insn)
       return;  /* already got that one */
 
-  b = oballoc (sizeof (struct bypass_list));
+  b = obnew (struct bypass_list);
   b->insn = s;
   b->next = all_bypasses;
   all_bypasses = b;
@@ -4545,13 +4549,13 @@ from the machine description file `md'. 
   printf ("#define operands recog_data.operand\n\n");
 
   /* Make `insn_alternatives'.  */
-  insn_alternatives = oballoc (insn_code_number * sizeof (int));
+  insn_alternatives = obvec (int, insn_code_number);
   for (id = defs; id; id = id->next)
     if (id->insn_code >= 0)
       insn_alternatives[id->insn_code] = (1 << id->num_alternatives) - 1;
 
   /* Make `insn_n_alternatives'.  */
-  insn_n_alternatives = oballoc (insn_code_number * sizeof (int));
+  insn_n_alternatives = obvec (int, insn_code_number);
   for (id = defs; id; id = id->next)
     if (id->insn_code >= 0)
       insn_n_alternatives[id->insn_code] = id->num_alternatives;
Index: gcc/optc-gen.awk
===================================================================
--- gcc/optc-gen.awk	(revision 124625)
+++ gcc/optc-gen.awk	(working copy)
@@ -67,37 +67,43 @@ print "int target_flags;"
 print "#endif /* GCC_DRIVER */"
 print ""
 
-for (i = 0; i < n_opts; i++) {
-	name = var_name(flags[i]);
-	if (name == "")
-		continue;
-
-	if (flag_set_p("VarExists", flags[i])) {
-		# Need it for the gcc driver.
-		if (name in var_seen)
+for (pass = 0; pass < 2; pass++) {
+	for (i = 0; i < n_opts; i++) {
+		name = var_name(flags[i]);
+		if (name == "")
 			continue;
-		init = ""
-		gcc_driver = 1
-	}
-	else {
-		init = opt_args("Init", flags[i])
-		if (init != "")
-			init = " = " init;
-		else if (name in var_seen)
-			continue;
-		gcc_driver = 0
-	}
 
-	if (gcc_driver == 1)
-		print "#ifdef GCC_DRIVER"
-	print "/* Set by -" opts[i] "."
-	print "   " help[i] "  */"
-	print var_type(flags[i]) name init ";"
-	if (gcc_driver == 1)
-		print "#endif /* GCC_DRIVER */"
-	print ""
+		if (flag_set_p("VarExists", flags[i])) {
+			if (pass == 0)
+				continue;
+			# Need it for the gcc driver.
+			if (name in var_seen)
+				continue;
+			init = ""
+			gcc_driver = 1
+		}
+		else {
+			if (pass == 1)
+				continue;
+			init = opt_args("Init", flags[i])
+			if (init != "")
+				init = " = " init;
+			else if (name in var_seen)
+				continue;
+			gcc_driver = 0
+		}
 
-	var_seen[name] = 1;
+		if (gcc_driver == 1)
+			print "#ifdef GCC_DRIVER"
+		print "/* Set by -" opts[i] "."
+		print "   " help[i] "  */"
+		print var_type(flags[i]) name init ";"
+		if (gcc_driver == 1)
+			print "#endif /* GCC_DRIVER */"
+		print ""
+
+		var_seen[name] = 1;
+	}
 }
 
 print ""
Index: gcc/genpreds.c
===================================================================
--- gcc/genpreds.c	(revision 124625)
+++ gcc/genpreds.c	(working copy)
@@ -730,7 +730,7 @@ mangle (const char *name)
       }
 
   obstack_1grow (rtl_obstack, '\0');
-  return obstack_finish (rtl_obstack);
+  return (char*) obstack_finish (rtl_obstack);
 }
 
 /* Add one constraint, of any sort, to the tables.  NAME is its name;
@@ -895,7 +895,8 @@ add_constraint (const char *name, const 
     }
 
   
-  c = obstack_alloc (rtl_obstack, sizeof (struct constraint_data));
+  c = (struct constraint_data*) obstack_alloc (
+	rtl_obstack, sizeof (struct constraint_data));
   c->name = name;
   c->c_name = need_mangled_name ? mangle (name) : name;
   c->lineno = lineno;
Index: gcc/genchecksum.c
===================================================================
--- gcc/genchecksum.c	(revision 124625)
+++ gcc/genchecksum.c	(working copy)
@@ -57,6 +57,7 @@ dosum (const char *file)
       exit (1);
     }
 
+  fputs ("extern const unsigned char executable_checksum[16];", stdout);
   fputs ("const unsigned char executable_checksum[16] = { ", stdout);
   for (i = 0; i < 16; i++)
     printf ("%#02x%s", result[i], i == 15 ? " };\n" : ", ");

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