OSDN Git Service

* varasm.c (default_assemble_visibility): Remove extra ().
[pf3gnuchains/gcc-fork.git] / gcc / recog.c
index d39bb84..d81ae5b 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used by or related to instruction recognition.
    Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
-   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -107,22 +107,6 @@ init_recog (void)
   volatile_ok = 1;
 }
 
-/* Try recognizing the instruction INSN,
-   and return the code number that results.
-   Remember the code so that repeated calls do not
-   need to spend the time for actual rerecognition.
-
-   This function is the normal interface to instruction recognition.
-   The automatically-generated function `recog' is normally called
-   through this one.  (The only exception is in combine.c.)  */
-
-int
-recog_memoized_1 (rtx insn)
-{
-  if (INSN_CODE (insn) < 0)
-    INSN_CODE (insn) = recog (PATTERN (insn), insn, 0);
-  return INSN_CODE (insn);
-}
 \f
 /* Check that X is an insn-body for an `asm' with operands
    and that the operands mentioned in it are legitimate.  */
@@ -310,11 +294,11 @@ num_changes_pending (void)
   return num_changes;
 }
 
-/* Apply a group of changes previously issued with `validate_change'.
+/* Tentatively apply the changes numbered NUM and up.
    Return 1 if all changes are valid, zero otherwise.  */
 
-int
-apply_change_group (void)
+static int
+verify_changes (int num)
 {
   int i;
   rtx last_validated = NULL_RTX;
@@ -328,7 +312,7 @@ apply_change_group (void)
      we also require that the operands meet the constraints for
      the insn.  */
 
-  for (i = 0; i < num_changes; i++)
+  for (i = num; i < num_changes; i++)
     {
       rtx object = changes[i].object;
 
@@ -392,17 +376,38 @@ apply_change_group (void)
       last_validated = object;
     }
 
-  if (i == num_changes)
-    {
-      basic_block bb;
+  return (i == num_changes);
+}
+
+/* A group of changes has previously been issued with validate_change and
+   verified with verify_changes.  Update the BB_DIRTY flags of the affected
+   blocks, and clear num_changes.  */
 
-      for (i = 0; i < num_changes; i++)
-       if (changes[i].object
-           && INSN_P (changes[i].object)
-           && (bb = BLOCK_FOR_INSN (changes[i].object)))
-         bb->flags |= BB_DIRTY;
+void
+confirm_change_group (void)
+{
+  int i;
+  basic_block bb;
 
-      num_changes = 0;
+  for (i = 0; i < num_changes; i++)
+    if (changes[i].object
+       && INSN_P (changes[i].object)
+       && (bb = BLOCK_FOR_INSN (changes[i].object)))
+      bb->flags |= BB_DIRTY;
+
+  num_changes = 0;
+}
+
+/* Apply a group of changes previously issued with `validate_change'.
+   If all changes are valid, call confirm_change_group and return 1,
+   otherwise, call cancel_changes and return 0.  */
+
+int
+apply_change_group (void)
+{
+  if (verify_changes (0))
+    {
+      confirm_change_group ();
       return 1;
     }
   else
@@ -412,6 +417,7 @@ apply_change_group (void)
     }
 }
 
+
 /* Return the number of changes so far in the current group.  */
 
 int
@@ -2249,6 +2255,7 @@ constrain_operands (int strict)
 
   do
     {
+      int seen_earlyclobber_at = -1;
       int opno;
       int lose = 0;
       funny_match_index = 0;
@@ -2311,6 +2318,8 @@ constrain_operands (int strict)
 
              case '&':
                earlyclobber[opno] = 1;
+               if (seen_earlyclobber_at < 0)
+                 seen_earlyclobber_at = opno;
                break;
 
              case '0':  case '1':  case '2':  case '3':  case '4':
@@ -2559,8 +2568,10 @@ constrain_operands (int strict)
          /* See if any earlyclobber operand conflicts with some other
             operand.  */
 
-         if (strict > 0)
-           for (eopno = 0; eopno < recog_data.n_operands; eopno++)
+         if (strict > 0  && seen_earlyclobber_at >= 0)
+           for (eopno = seen_earlyclobber_at;
+                eopno < recog_data.n_operands;
+                eopno++)
              /* Ignore earlyclobber operands now in memory,
                 because we would often report failure when we have
                 two memory operands, one of which was formerly a REG.  */
@@ -2984,12 +2995,13 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   bool changed;
 #endif
   bool do_cleanup_cfg = false;
+  bool do_global_life_update = false;
   bool do_rebuild_jump_labels = false;
 
   /* Initialize the regsets we're going to use.  */
   for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)
-    peep2_insn_data[i].live_before = OBSTACK_ALLOC_REG_SET (&reg_obstack);
-  live = OBSTACK_ALLOC_REG_SET (&reg_obstack);
+    peep2_insn_data[i].live_before = ALLOC_REG_SET (&reg_obstack);
+  live = ALLOC_REG_SET (&reg_obstack);
 
 #ifdef HAVE_conditional_execution
   blocks = sbitmap_alloc (last_basic_block);
@@ -3002,6 +3014,8 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   FOR_EACH_BB_REVERSE (bb)
     {
       struct propagate_block_info *pbi;
+      reg_set_iterator rsi;
+      unsigned int j;
 
       /* Indicate that all slots except the last holds invalid data.  */
       for (i = 0; i < MAX_INSNS_PER_PEEP2; ++i)
@@ -3078,7 +3092,6 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
                          {
                          case REG_NORETURN:
                          case REG_SETJMP:
-                         case REG_ALWAYS_RETURN:
                            REG_NOTES (new_insn)
                              = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note),
                                                   XEXP (note, 0),
@@ -3223,6 +3236,15 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
            break;
        }
 
+      /* Some peepholes can decide the don't need one or more of their
+        inputs.  If this happens, local life update is not enough.  */
+      EXECUTE_IF_AND_COMPL_IN_BITMAP (bb->global_live_at_start, live,
+                                     0, j, rsi)
+       {
+         do_global_life_update = true;
+         break;
+       }
+
       free_propagate_block_info (pbi);
     }
 
@@ -3239,8 +3261,10 @@ peephole2_optimize (FILE *dump_file ATTRIBUTE_UNUSED)
   if (do_cleanup_cfg)
     {
       cleanup_cfg (0);
-      update_life_info (0, UPDATE_LIFE_GLOBAL_RM_NOTES, PROP_DEATH_NOTES);
+      do_global_life_update = true;
     }
+  if (do_global_life_update)
+    update_life_info (0, UPDATE_LIFE_GLOBAL_RM_NOTES, PROP_DEATH_NOTES);
 #ifdef HAVE_conditional_execution
   else
     {