OSDN Git Service

Cast pointer operands to bzero, bcopy, and bcmp to (char *).
[pf3gnuchains/gcc-fork.git] / gcc / genrecog.c
index b9583fe..c0d31d2 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate code from machine description to recognize rtl as insns.
-   Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -46,7 +46,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    it returns the split rtl in a SEQUENCE.  */
 
 #include <stdio.h>
-#include "config.h"
+#include "hconfig.h"
 #include "rtl.h"
 #include "obstack.h"
 
@@ -158,32 +158,43 @@ static struct pred_table
      {"push_operand", {MEM}},
      {"memory_operand", {SUBREG, MEM}},
      {"indirect_operand", {SUBREG, MEM}},
-     {"comparison_operation", {EQ, NE, LE, LT, GE, LT, LEU, LTU, GEU, GTU}},
+     {"comparison_operator", {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, GTU}},
      {"mode_independent_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
                                   LABEL_REF, SUBREG, REG, MEM}}};
 
 #define NUM_KNOWN_PREDS (sizeof preds / sizeof preds[0])
 
-static int try_merge_1 ();
-static int no_same_mode ();
-static int same_codes ();
-static int same_modes ();
-char *xmalloc ();
-static struct decision *add_to_sequence ();
-static struct decision_head merge_trees ();
-static struct decision *try_merge_2 ();
-static void write_subroutine ();
-static void print_code ();
-static void clear_codes ();
-static void clear_modes ();
-static void change_state ();
-static void write_tree ();
-static char *copystr ();
-static char *concat ();
-static void fatal ();
-void fancy_abort ();
-static void mybzero ();
-static void mybcopy ();
+static struct decision_head make_insn_sequence PROTO((rtx, enum routine_type));
+static struct decision *add_to_sequence PROTO((rtx, struct decision_head *,
+                                              char *));
+static int not_both_true       PROTO((struct decision *, struct decision *,
+                                      int));
+static int position_merit      PROTO((struct decision *, enum machine_mode,
+                                      enum rtx_code));
+static struct decision_head merge_trees PROTO((struct decision_head,
+                                              struct decision_head));
+static int break_out_subroutines PROTO((struct decision_head,
+                                       enum routine_type, int));
+static void write_subroutine   PROTO((struct decision *, enum routine_type));
+static void write_tree_1       PROTO((struct decision *, char *,
+                                      struct decision *, enum routine_type));
+static void print_code         PROTO((enum rtx_code));
+static int same_codes          PROTO((struct decision *, enum rtx_code));
+static void clear_codes                PROTO((struct decision *));
+static int same_modes          PROTO((struct decision *, enum machine_mode));
+static void clear_modes                PROTO((struct decision *));
+static void write_tree         PROTO((struct decision *, char *,
+                                      struct decision *, int,
+                                      enum routine_type));
+static void change_state       PROTO((char *, char *, int));
+static char *copystr           PROTO((char *));
+static void mybzero            PROTO((char *, unsigned));
+static void mybcopy            PROTO((char *, char *, unsigned));
+static char *concat            PROTO((char *, char *));
+static void fatal              PROTO((char *));
+char *xrealloc                 PROTO((char *, unsigned));
+char *xmalloc                  PROTO((unsigned));
+void fancy_abort               PROTO((void));
 \f
 /* Construct and return a sequence of decisions
    that will recognize INSN.
@@ -367,30 +378,40 @@ add_to_sequence (pattern, last, position)
         considerably simplify the generated code.  */
 
       if (new->tests)
-       for (i = 0; i < NUM_KNOWN_PREDS; i++)
-         if (! strcmp (preds[i].name, new->tests))
-           {
-             int j;
-             int allows_const_int = 0;
+       {
+         for (i = 0; i < NUM_KNOWN_PREDS; i++)
+           if (! strcmp (preds[i].name, new->tests))
+             {
+               int j;
+               int allows_const_int = 0;
 
-             new->pred = i;
+               new->pred = i;
 
-             if (preds[i].codes[1] == 0 && new->code == UNKNOWN)
-               {
-                 new->code = preds[i].codes[0];
-                 if (! strcmp ("const_int_operand", new->tests))
-                   new->tests = 0, new->pred = -1;
-               }
+               if (preds[i].codes[1] == 0 && new->code == UNKNOWN)
+                 {
+                   new->code = preds[i].codes[0];
+                   if (! strcmp ("const_int_operand", new->tests))
+                     new->tests = 0, new->pred = -1;
+                 }
 
-             for (j = 0; j < NUM_RTX_CODE && preds[i].codes[j] != 0; j++)
-               if (preds[i].codes[j] == CONST_INT)
-                 allows_const_int = 1;
+               for (j = 0; j < NUM_RTX_CODE && preds[i].codes[j] != 0; j++)
+                 if (preds[i].codes[j] == CONST_INT)
+                   allows_const_int = 1;
 
-             if (! allows_const_int)
-               new->enforce_mode = new->ignore_mode= 1;
+               if (! allows_const_int)
+                 new->enforce_mode = new->ignore_mode= 1;
 
-             break;
-           }
+               break;
+             }
+
+#ifdef PREDICATE_CODES
+         /* If the port has a list of the predicates it uses but omits
+            one, warn.  */
+         if (i == NUM_KNOWN_PREDS)
+           fprintf (stderr, "Warning: `%s' not in PREDICATE_CODES\n",
+                    new->tests);
+#endif
+       }
 
       if (code == MATCH_OPERATOR || code == MATCH_PARALLEL)
        {
@@ -653,7 +674,7 @@ static int
 position_merit (p, mode, code)
      struct decision *p;
      enum machine_mode mode;
-     RTX_CODE code;
+     enum rtx_code code;
 {
   enum machine_mode p_mode;
 
@@ -793,7 +814,8 @@ merge_trees (oldh, addh)
                      struct decision *split
                        = (struct decision *) xmalloc (sizeof (struct decision));
 
-                     mybcopy (old, split, sizeof (struct decision));
+                     mybcopy ((char *) old, (char *) split,
+                              sizeof (struct decision));
 
                      old->success.first = old->success.last = split;
                      old->c_test = 0;
@@ -819,7 +841,8 @@ merge_trees (oldh, addh)
                      struct decision *split
                        = (struct decision *) xmalloc (sizeof (struct decision));
 
-                     mybcopy (add, split, sizeof (struct decision));
+                     mybcopy ((char *) add, (char *) split,
+                              sizeof (struct decision));
 
                      add->success.first = add->success.last = split;
                      add->c_test = 0;
@@ -932,7 +955,7 @@ break_out_subroutines (head, type, initial)
      int initial;
 {
   int size = 0;
-  struct decision *node, *sub;
+  struct decision *sub;
 
   for (sub = head.first; sub; sub = sub->next)
     size += 1 + break_out_subroutines (sub->success, type, 0);
@@ -1018,7 +1041,7 @@ static char *indents[]
    resulting function.   We do check for when every test is the same mode
    or code.  */
 
-void
+static void
 write_tree_1 (tree, prevpos, afterward, type)
      struct decision *tree;
      char *prevpos;
@@ -1441,7 +1464,7 @@ write_tree_1 (tree, prevpos, afterward, type)
 
 static void
 print_code (code)
-     RTX_CODE code;
+     enum rtx_code code;
 {
   register char *p1;
   for (p1 = GET_RTX_NAME (code); *p1; p1++)
@@ -1456,7 +1479,7 @@ print_code (code)
 static int
 same_codes (p, code)
      register struct decision *p;
-     register RTX_CODE code;
+     register enum rtx_code code;
 {
   for (; p; p = p->next)
     if (p->code != code)
@@ -1521,7 +1544,10 @@ write_tree (tree, prevpos, afterward, initial, type)
        {
          printf ("  tem = %s_%d (x0, insn%s);\n",
                  name_prefix, tree->subroutine_number, call_suffix);
-         printf ("  if (tem >= 0) return tem;\n");
+         if (type == SPLIT)
+           printf ("  if (tem != 0) return tem;\n");
+         else
+           printf ("  if (tem >= 0) return tem;\n");
          change_state (tree->position, afterward->position, 2);
          printf ("  goto L%d;\n", afterward->number);
        }
@@ -1649,11 +1675,11 @@ xmalloc (size)
 }
 
 static void
-fatal (s, a1, a2)
+fatal (s)
      char *s;
 {
   fprintf (stderr, "genrecog: ");
-  fprintf (stderr, s, a1, a2);
+  fprintf (stderr, s);
   fprintf (stderr, "\n");
   fprintf (stderr, "after %d definitions\n", next_index);
   exit (FATAL_EXIT_CODE);