OSDN Git Service

* rtl.h (copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
[pf3gnuchains/gcc-fork.git] / gcc / genrecog.c
index f3c052c..7e1d879 100644 (file)
@@ -226,6 +226,9 @@ static int error_count;
 #define TRISTATE_NOT(a)                                \
   ((a) == I ? I : !(a))
 
+/* 0 means no warning about that code yet, 1 means warned.  */
+static char did_you_mean_codes[NUM_RTX_CODE];
+
 /* Recursively calculate the set of rtx codes accepted by the
    predicate expression EXP, writing the result to CODES.  */
 static void
@@ -254,7 +257,7 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
     case NOT:
       compute_predicate_codes (XEXP (exp, 0), op0_codes);
       for (i = 0; i < NUM_RTX_CODE; i++)
-       codes[i] = TRISTATE_NOT (codes[i]);
+       codes[i] = TRISTATE_NOT (op0_codes[i]);
       break;
 
     case IF_THEN_ELSE:
@@ -285,14 +288,31 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
        while ((code = scan_comma_elt (&next_code)) != 0)
          {
            size_t n = next_code - code;
+           int found_it = 0;
            
            for (i = 0; i < NUM_RTX_CODE; i++)
              if (!strncmp (code, GET_RTX_NAME (i), n)
                  && GET_RTX_NAME (i)[n] == '\0')
                {
                  codes[i] = Y;
+                 found_it = 1;
                  break;
                }
+           if (!found_it)
+             {
+               message_with_line (pattern_lineno, "match_code \"%.*s\" matches nothing",
+                                  (int) n, code);
+               error_count ++;
+               for (i = 0; i < NUM_RTX_CODE; i++)
+                 if (!strncasecmp (code, GET_RTX_NAME (i), n)
+                     && GET_RTX_NAME (i)[n] == '\0'
+                     && !did_you_mean_codes[i])
+                   {
+                     did_you_mean_codes[i] = 1;
+                     message_with_line (pattern_lineno, "(did you mean \"%s\"?)", GET_RTX_NAME (i));
+                   }
+             }
+
          }
       }
       break;
@@ -547,7 +567,7 @@ find_operand (rtx pattern, int n, rtx stop)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 
@@ -598,7 +618,7 @@ find_matching_operand (rtx pattern, int n)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 
@@ -851,7 +871,7 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 }
@@ -974,15 +994,25 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position,
              {
                test->u.pred.data = pred;
                allows_const_int = pred->codes[CONST_INT];
-               code = pred->singleton;
+               if (was_code == MATCH_PARALLEL
+                   && pred->singleton != PARALLEL)
+                 message_with_line (pattern_lineno,
+                       "predicate '%s' used in match_parallel "
+                       "does not allow only PARALLEL", pred->name);
+               else
+                 code = pred->singleton;
              }
+           else
+             message_with_line (pattern_lineno,
+                       "warning: unknown predicate '%s' in '%s' expression",
+                       pred_name, GET_RTX_NAME (was_code));
          }
 
        /* Can't enforce a mode if we allow const_int.  */
        if (allows_const_int)
          mode = VOIDmode;
 
-       /* Accept the operand, ie. record it in `operands'.  */
+       /* Accept the operand, i.e. record it in `operands'.  */
        test = new_decision_test (DT_accept_op, &place);
        test->u.opno = XINT (pattern, 0);
 
@@ -1040,18 +1070,18 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position,
     {
       if (fmt[i] == 'i')
        {
-         if (i == 0)
+         gcc_assert (i < 2);
+         
+         if (!i)
            {
              test = new_decision_test (DT_elt_zero_int, &place);
              test->u.intval = XINT (pattern, i);
            }
-         else if (i == 1)
+         else
            {
              test = new_decision_test (DT_elt_one_int, &place);
              test->u.intval = XINT (pattern, i);
            }
-         else
-           abort ();
        }
       else if (fmt[i] == 'w')
        {
@@ -1061,16 +1091,14 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position,
            = ((int) XWINT (pattern, i) == XWINT (pattern, i))
              ? DT_elt_zero_wide_safe : DT_elt_zero_wide;
 
-         if (i != 0)
-           abort ();
+         gcc_assert (!i);
 
          test = new_decision_test (type, &place);
          test->u.intval = XWINT (pattern, i);
        }
       else if (fmt[i] == 'E')
        {
-         if (i != 0)
-           abort ();
+         gcc_assert (!i);
 
          test = new_decision_test (DT_veclen, &place);
          test->u.veclen = XVECLEN (pattern, i);
@@ -1107,7 +1135,7 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position,
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 
@@ -1129,8 +1157,7 @@ add_to_sequence (rtx pattern, struct decision_head *last, const char *position,
     }
 
   /* If we didn't insert any tests or accept nodes, hork.  */
-  if (this->tests == NULL)
-    abort ();
+  gcc_assert (this->tests);
 
  ret:
   free (subpos);
@@ -1301,8 +1328,7 @@ maybe_both_true (struct decision *d1, struct decision *d2,
   cmp = strcmp (d1->position, d2->position);
   if (cmp != 0)
     {
-      if (toplevel)
-       abort ();
+      gcc_assert (!toplevel);
 
       /* If the d2->position was lexically lower, swap.  */
       if (cmp > 0)
@@ -1380,7 +1406,7 @@ nodes_identical_1 (struct decision_test *d1, struct decision_test *d2)
       return 1;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -1482,8 +1508,7 @@ merge_trees (struct decision_head *oldh, struct decision_head *addh)
     }
 
   /* Trying to merge bits at different positions isn't possible.  */
-  if (strcmp (oldh->first->position, addh->first->position))
-    abort ();
+  gcc_assert (!strcmp (oldh->first->position, addh->first->position));
 
   for (add = addh->first; add ; add = next)
     {
@@ -1979,7 +2004,7 @@ write_switch (struct decision *start, int depth)
          printf ("(int) XWINT (x%d, 0)", depth);
          break;
        default:
-         abort ();
+         gcc_unreachable ();
        }
       printf (")\n%s    {\n", indent);
 
@@ -2012,7 +2037,7 @@ write_switch (struct decision *start, int depth)
              print_host_wide_int (p->tests->u.intval);
              break;
            default:
-             abort ();
+             gcc_unreachable ();
            }
          printf (":\n%s      goto L%d;\n", indent, p->success.first->number);
          p->success.first->need_label = 1;
@@ -2088,25 +2113,17 @@ write_cond (struct decision_test *p, int depth,
       break;
 
     case DT_c_test:
-      printf ("(%s)", p->u.c_test);
+      print_c_condition (p->u.c_test);
       break;
 
     case DT_accept_insn:
-      switch (subroutine_type)
-       {
-       case RECOG:
-         if (p->u.insn.num_clobbers_to_add == 0)
-           abort ();
-         printf ("pnum_clobbers != NULL");
-         break;
-
-       default:
-         abort ();
-       }
+      gcc_assert (subroutine_type == RECOG);
+      gcc_assert (p->u.insn.num_clobbers_to_add);
+      printf ("pnum_clobbers != NULL");
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -2141,14 +2158,12 @@ write_action (struct decision *p, struct decision_test *test,
       if (test->next)
        {
          test = test->next;
-         if (test->type != DT_accept_insn)
-           abort ();
+         gcc_assert (test->type == DT_accept_insn);
        }
     }
 
   /* Sanity check that we're now at the end of the list of tests.  */
-  if (test->next)
-    abort ();
+  gcc_assert (!test->next);
 
   if (test->type == DT_accept_insn)
     {
@@ -2158,7 +2173,9 @@ write_action (struct decision *p, struct decision_test *test,
          if (test->u.insn.num_clobbers_to_add != 0)
            printf ("%s*pnum_clobbers = %d;\n",
                    indent, test->u.insn.num_clobbers_to_add);
-         printf ("%sreturn %d;\n", indent, test->u.insn.code_number);
+         printf ("%sreturn %d;  /* %s */\n", indent,
+                 test->u.insn.code_number,
+                 insn_name_ptr[test->u.insn.code_number]);
          break;
 
        case SPLIT:
@@ -2184,7 +2201,7 @@ write_action (struct decision *p, struct decision_test *test,
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
   else
@@ -2219,7 +2236,7 @@ is_unconditional (struct decision_test *t, enum routine_type subroutine_type)
        case PEEPHOLE2:
          return -1;
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 
@@ -2515,8 +2532,7 @@ make_insn_sequence (rtx insn, enum routine_type type)
   char c_test_pos[2];
 
   /* We should never see an insn whose C test is false at compile time.  */
-  if (truth == 0)
-    abort ();
+  gcc_assert (truth);
 
   record_insn_name (next_insn_code, (type == RECOG ? XSTR (insn, 0) : NULL));
 
@@ -2862,7 +2878,7 @@ debug_decision_2 (struct decision_test *test)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }