OSDN Git Service

IA64 uses // instead of # for comments in its assembly file.
[pf3gnuchains/gcc-fork.git] / gcc / genautomata.c
index 0f5a408..88d358c 100644 (file)
@@ -2314,8 +2314,7 @@ add_presence_absence (unit_set_el_t dest_list,
                          no_error_flag = 0;
                        }
                      else
-                       warning
-                         (0, "unit `%s' excludes and requires presence of `%s'",
+                       warning ("unit `%s' excludes and requires presence of `%s'",
                           dst->unit_decl->name, unit->name);
                    }
                }
@@ -2328,15 +2327,13 @@ add_presence_absence (unit_set_el_t dest_list,
                  {
                    if (!w_flag)
                      {
-                       error
-                         ("unit `%s' requires absence and presence of `%s'",
-                          dst->unit_decl->name, unit->name);
+                       error ("unit `%s' requires absence and presence of `%s'",
+                              dst->unit_decl->name, unit->name);
                        no_error_flag = 0;
                      }
                    else
-                     warning
-                       (0, "unit `%s' requires absence and presence of `%s'",
-                        dst->unit_decl->name, unit->name);
+                     warning ("unit `%s' requires absence and presence of `%s'",
+                              dst->unit_decl->name, unit->name);
                  }
            if (no_error_flag)
              {
@@ -2385,7 +2382,7 @@ insert_bypass (struct bypass_decl *bypass)
   struct bypass_decl *curr, *last;
   struct insn_reserv_decl *out_insn_reserv = bypass->out_insn_reserv;
   struct insn_reserv_decl *in_insn_reserv = bypass->in_insn_reserv;
-  
+
   for (curr = out_insn_reserv->bypass_list, last = NULL;
        curr != NULL;
        last = curr, curr = curr->next)
@@ -2402,7 +2399,7 @@ insert_bypass (struct bypass_decl *bypass)
                  error ("the same bypass `%s - %s' is already defined",
                         bypass->out_insn_name, bypass->in_insn_name);
                else
-                 warning (0, "the same bypass `%s - %s' is already defined",
+                 warning ("the same bypass `%s - %s' is already defined",
                           bypass->out_insn_name, bypass->in_insn_name);
              }
            else if (!w_flag)
@@ -2411,7 +2408,7 @@ insert_bypass (struct bypass_decl *bypass)
                     bypass->bypass_guard_name);
            else
              warning
-               (0, "the same bypass `%s - %s' (guard %s) is already defined",
+               ("the same bypass `%s - %s' (guard %s) is already defined",
                 bypass->out_insn_name, bypass->in_insn_name,
                 bypass->bypass_guard_name);
            return;
@@ -2423,7 +2420,7 @@ insert_bypass (struct bypass_decl *bypass)
            last = curr;
            break;
          }
-         
+
       }
   if (last == NULL)
     {
@@ -2465,7 +2462,7 @@ process_decls (void)
                error ("repeated declaration of automaton `%s'",
                       DECL_AUTOMATON (decl)->name);
              else
-               warning (0, "repeated declaration of automaton `%s'",
+               warning ("repeated declaration of automaton `%s'",
                         DECL_AUTOMATON (decl)->name);
            }
        }
@@ -2664,7 +2661,7 @@ check_automaton_usage (void)
          if (!w_flag)
            error ("automaton `%s' is not used", DECL_AUTOMATON (decl)->name);
          else
-           warning (0, "automaton `%s' is not used",
+           warning ("automaton `%s' is not used",
                     DECL_AUTOMATON (decl)->name);
        }
     }
@@ -2778,14 +2775,14 @@ check_usage (void)
          if (!w_flag)
            error ("unit `%s' is not used", DECL_UNIT (decl)->name);
          else
-           warning (0, "unit `%s' is not used", DECL_UNIT (decl)->name);
+           warning ("unit `%s' is not used", DECL_UNIT (decl)->name);
        }
       else if (decl->mode == dm_reserv && !DECL_RESERV (decl)->reserv_is_used)
        {
          if (!w_flag)
            error ("reservation `%s' is not used", DECL_RESERV (decl)->name);
          else
-           warning (0, "reservation `%s' is not used", DECL_RESERV (decl)->name);
+           warning ("reservation `%s' is not used", DECL_RESERV (decl)->name);
        }
     }
 }
@@ -2939,7 +2936,7 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle,
       {
        int max_cycle = 0;
        int min_cycle = 0;
-       
+
        for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
          {
            process_regexp_cycles (REGEXP_ALLOF (regexp)->regexps [i],
@@ -2959,7 +2956,7 @@ process_regexp_cycles (regexp_t regexp, int max_start_cycle,
       {
        int max_cycle = 0;
        int min_cycle = 0;
-       
+
        for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
          {
            process_regexp_cycles (REGEXP_ONEOF (regexp)->regexps [i],
@@ -3317,15 +3314,18 @@ finish_alt_states (void)
 /* Set bit number bitno in the bit string.  The macro is not side
    effect proof.  */
 #define SET_BIT(bitstring, bitno)                                        \
-  (((char *) (bitstring)) [(bitno) / CHAR_BIT] |= 1 << (bitno) % CHAR_BIT)
+  ((bitstring)[(bitno) / (sizeof (*(bitstring)) * CHAR_BIT)] |=                  \
+       (HOST_WIDE_INT)1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT))
 
 #define CLEAR_BIT(bitstring, bitno)                                      \
-  (((char *) (bitstring)) [(bitno) / CHAR_BIT] &= ~(1 << (bitno) % CHAR_BIT))
+  ((bitstring)[(bitno) / (sizeof (*(bitstring)) * CHAR_BIT)] &=                  \
+       ~((HOST_WIDE_INT)1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT)))
 
 /* Test if bit number bitno in the bitstring is set.  The macro is not
    side effect proof.  */
-#define TEST_BIT(bitstring, bitno)                                        \
-  (((char *) (bitstring)) [(bitno) / CHAR_BIT] >> (bitno) % CHAR_BIT & 1)
+#define TEST_BIT(bitstring, bitno)                                       \
+  ((bitstring)[(bitno) / (sizeof (*(bitstring)) * CHAR_BIT)] >>                  \
+       (bitno) % (sizeof (*(bitstring)) * CHAR_BIT) & 1)
 
 \f
 
@@ -4177,20 +4177,18 @@ initiate_excl_sets (void)
 static reserv_sets_t
 get_excl_set (reserv_sets_t in_set)
 {
-  int excl_char_num;
-  int chars_num;
-  int i;
+  int el;
+  unsigned int i;
   int start_unit_num;
   int unit_num;
 
-  chars_num = els_in_cycle_reserv * sizeof (set_el_t);
-  memset (excl_set, 0, chars_num);
-  for (excl_char_num = 0; excl_char_num < chars_num; excl_char_num++)
-    if (((unsigned char *) in_set) [excl_char_num])
-      for (i = CHAR_BIT - 1; i >= 0; i--)
-       if ((((unsigned char *) in_set) [excl_char_num] >> i) & 1)
+  memset (excl_set, 0, els_in_cycle_reserv * sizeof (set_el_t));
+  for (el = 0; el < els_in_cycle_reserv; el++)
+    if (in_set[el])
+      for (i = 0; i < CHAR_BIT * sizeof (set_el_t); i++)
+       if ((in_set[el] >> i) & 1)
          {
-           start_unit_num = excl_char_num * CHAR_BIT + i;
+           start_unit_num = el * CHAR_BIT * sizeof (set_el_t) + i;
            if (start_unit_num >= description->units_num)
              return excl_set;
            for (unit_num = 0; unit_num < els_in_cycle_reserv; unit_num++)
@@ -4289,21 +4287,19 @@ check_presence_pattern_sets (reserv_sets_t checked_set,
                             reserv_sets_t original_set,
                             int final_p)
 {
-  int char_num;
-  int chars_num;
-  int i;
+  int el;
+  unsigned int i;
   int start_unit_num;
   int unit_num;
   int presence_p;
   pattern_reserv_t pat_reserv;
 
-  chars_num = els_in_cycle_reserv * sizeof (set_el_t);
-  for (char_num = 0; char_num < chars_num; char_num++)
-    if (((unsigned char *) original_set) [char_num])
-      for (i = CHAR_BIT - 1; i >= 0; i--)
-       if ((((unsigned char *) original_set) [char_num] >> i) & 1)
+  for (el = 0; el < els_in_cycle_reserv; el++)
+    if (original_set[el])
+      for (i = 0; i < CHAR_BIT * sizeof (set_el_t); i++)
+       if ((original_set[el] >> i) & 1)
          {
-           start_unit_num = char_num * CHAR_BIT + i;
+           start_unit_num = el * CHAR_BIT * sizeof (set_el_t) + i;
            if (start_unit_num >= description->units_num)
              break;
            if ((final_p
@@ -4338,20 +4334,18 @@ check_absence_pattern_sets (reserv_sets_t checked_set,
                            reserv_sets_t original_set,
                            int final_p)
 {
-  int char_num;
-  int chars_num;
-  int i;
+  int el;
+  unsigned int i;
   int start_unit_num;
   int unit_num;
   pattern_reserv_t pat_reserv;
 
-  chars_num = els_in_cycle_reserv * sizeof (set_el_t);
-  for (char_num = 0; char_num < chars_num; char_num++)
-    if (((unsigned char *) original_set) [char_num])
-      for (i = CHAR_BIT - 1; i >= 0; i--)
-       if ((((unsigned char *) original_set) [char_num] >> i) & 1)
+  for (el = 0; el < els_in_cycle_reserv; el++)
+    if (original_set[el])
+      for (i = 0; i < CHAR_BIT * sizeof (set_el_t); i++)
+       if ((original_set[el] >> i) & 1)
          {
-           start_unit_num = char_num * CHAR_BIT + i;
+           start_unit_num = el * CHAR_BIT * sizeof (set_el_t) + i;
            if (start_unit_num >= description->units_num)
              break;
            for (pat_reserv = (final_p
@@ -4782,7 +4776,7 @@ transform_3 (regexp_t regexp)
                  default:
                    break;
                  }
-             
+
              if (allof_length == 1)
                REGEXP_SEQUENCE (result)->regexps [i] = allof_op;
              else
@@ -4966,7 +4960,7 @@ store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle,
   length = (cycle + 1) * REGEXP_ONEOF (regexp)->regexps_num;
   while (VEC_length (unit_usage_t, cycle_alt_unit_usages) < length)
     VEC_safe_push (unit_usage_t, heap, cycle_alt_unit_usages, 0);
-  
+
   index = cycle * REGEXP_ONEOF (regexp)->regexps_num + alt_num;
   prev = NULL;
   for (curr = VEC_index (unit_usage_t, cycle_alt_unit_usages, index);
@@ -5048,7 +5042,7 @@ static void
 check_regexp_units_distribution (const char *insn_reserv_name,
                                 regexp_t regexp)
 {
-  int i, j, k, cycle, cycle2, start, n_alts, alt, alt2;
+  int i, j, k, cycle, start, n_alts, alt, alt2;
   bool annotation_reservation_message_reported_p;
   regexp_t seq, allof, unit;
   struct unit_usage *unit_usage_ptr;
@@ -5081,14 +5075,14 @@ check_regexp_units_distribution (const char *insn_reserv_name,
                        gcc_assert (unit->mode == rm_nothing);
                    }
                  break;
-                 
+
                case rm_unit:
                  store_alt_unit_usage (regexp, allof, j, i);
                  break;
-                 
+
                case rm_nothing:
                  break;
-                 
+
                default:
                  gcc_unreachable ();
                }
@@ -5104,10 +5098,10 @@ check_regexp_units_distribution (const char *insn_reserv_name,
                case rm_unit:
                  store_alt_unit_usage (regexp, unit, 0, i);
                  break;
-                 
+
                case rm_nothing:
                  break;
-                 
+
                default:
                  gcc_unreachable ();
                }
@@ -5167,7 +5161,6 @@ check_regexp_units_distribution (const char *insn_reserv_name,
                   j < (int) VEC_length (unit_usage_t, cycle_alt_unit_usages);
                   j++)
                {
-                 cycle2 = j / n_alts;
                  alt2 = j % n_alts;
                  if (! unit_present_on_list_p
                        (VEC_index (unit_usage_t, cycle_alt_unit_usages,
@@ -5275,7 +5268,7 @@ process_seq_for_forming_states (regexp_t regexp, automaton_t automaton,
         set_state_reserv (state_being_formed, curr_cycle,
                           REGEXP_UNIT (regexp)->unit_decl->unit_num);
       return curr_cycle;
-      
+
     case rm_sequence:
       for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++)
        curr_cycle
@@ -5287,7 +5280,7 @@ process_seq_for_forming_states (regexp_t regexp, automaton_t automaton,
       {
        int finish_cycle = 0;
        int cycle;
-       
+
        for (i = 0; i < REGEXP_ALLOF (regexp)->regexps_num; i++)
          {
            cycle = process_seq_for_forming_states (REGEXP_ALLOF (regexp)
@@ -5823,7 +5816,7 @@ cache_presence (state_t state)
   unsigned int sz;
   sz = (description->query_units_num + sizeof (int) * CHAR_BIT - 1)
         / (sizeof (int) * CHAR_BIT);
-  
+
   state->presence_signature = XCREATENODEVEC (unsigned int, sz);
   for (i = 0; i < description->units_num; i++)
     if (units_array [i]->query_p)
@@ -5969,7 +5962,7 @@ partition_equiv_class (state_t first_state, int odd_iteration_flag,
               curr_state = next_state)
            {
              next_state = curr_state->next_equiv_class_state;
-             if (state_is_differed (curr_state, first_state, 
+             if (state_is_differed (curr_state, first_state,
                                     odd_iteration_flag))
                {
                  /* Remove curr state from the class equivalence.  */
@@ -6709,11 +6702,11 @@ form_regexp (regexp_t regexp)
        const char *name = (regexp->mode == rm_unit
                            ? REGEXP_UNIT (regexp)->name
                            : REGEXP_RESERV (regexp)->name);
-       
+
        obstack_grow (&irp, name, strlen (name));
        break;
       }
-      
+
     case rm_sequence:
       for (i = 0; i < REGEXP_SEQUENCE (regexp)->regexps_num; i++)
        {
@@ -6739,7 +6732,7 @@ form_regexp (regexp_t regexp)
         }
       obstack_1grow (&irp, ')');
       break;
-      
+
     case rm_oneof:
       for (i = 0; i < REGEXP_ONEOF (regexp)->regexps_num; i++)
        {
@@ -6752,11 +6745,11 @@ form_regexp (regexp_t regexp)
           obstack_1grow (&irp, ')');
        }
       break;
-      
+
     case rm_repeat:
       {
        char digits [30];
-       
+
        if (REGEXP_REPEAT (regexp)->regexp->mode == rm_sequence
            || REGEXP_REPEAT (regexp)->regexp->mode == rm_allof
            || REGEXP_REPEAT (regexp)->regexp->mode == rm_oneof)
@@ -7492,72 +7485,6 @@ output_trans_table (automaton_t automaton)
   VEC_free (vect_el_t, heap, transition_vect);
 }
 
-/* The current number of passing states to find minimal issue delay
-   value for an ainsn and state.  */
-static int curr_state_pass_num;
-
-/* This recursive function passes states to find minimal issue delay
-   value for AINSN.  The state being visited is STATE.  The function
-   returns minimal issue delay value for AINSN in STATE or -1 if we
-   enter into a loop.  */
-static int
-min_issue_delay_pass_states (state_t state, ainsn_t ainsn)
-{
-  arc_t arc;
-  int min_insn_issue_delay, insn_issue_delay;
-
-  if (state->state_pass_num == curr_state_pass_num
-      || state->min_insn_issue_delay != -1)
-    /* We've entered into a loop or already have the correct value for
-       given state and ainsn.  */
-    return state->min_insn_issue_delay;
-  state->state_pass_num = curr_state_pass_num;
-  min_insn_issue_delay = -1;
-  for (arc = first_out_arc (state); arc != NULL; arc = next_out_arc (arc))
-    if (arc->insn == ainsn)
-      {
-       min_insn_issue_delay = 0;
-       break;
-      }
-    else
-      {
-        insn_issue_delay = min_issue_delay_pass_states (arc->to_state, ainsn);
-       if (insn_issue_delay != -1)
-         {
-           if (arc->insn->insn_reserv_decl
-               == DECL_INSN_RESERV (advance_cycle_insn_decl))
-             insn_issue_delay++;
-           if (min_insn_issue_delay == -1
-               || min_insn_issue_delay > insn_issue_delay)
-             {
-               min_insn_issue_delay = insn_issue_delay;
-               if (insn_issue_delay == 0)
-                 break;
-             }
-         }
-      }
-  return min_insn_issue_delay;
-}
-
-/* The function searches minimal issue delay value for AINSN in STATE.
-   The function can return negative value if we can not issue AINSN.  We
-   will report about it later.  */
-static int
-min_issue_delay (state_t state, ainsn_t ainsn)
-{
-  curr_state_pass_num++;
-  state->min_insn_issue_delay = min_issue_delay_pass_states (state, ainsn);
-  return state->min_insn_issue_delay;
-}
-
-/* The function initiates code for finding minimal issue delay values.
-   It should be called only once.  */
-static void
-initiate_min_issue_delay_pass_states (void)
-{
-  curr_state_pass_num = 0;
-}
-
 /* Form and output vectors representing minimal issue delay table of
    AUTOMATON.  The table is state x ainsn -> minimal issue delay of
    the ainsn.  */
@@ -7566,11 +7493,11 @@ output_min_issue_delay_table (automaton_t automaton)
 {
   vla_hwint_t min_issue_delay_vect;
   vla_hwint_t compressed_min_issue_delay_vect;
-  vect_el_t min_delay;
   ainsn_t ainsn;
-  size_t i, min_issue_delay_len;
-  size_t compressed_min_issue_delay_len;
+  size_t i;
+  size_t min_issue_delay_len, compressed_min_issue_delay_len;
   size_t cfactor;
+  int changed;
 
   /* Create vect of pointers to states ordered by num of transitions
      from the state (state with the maximum num is the first).  */
@@ -7581,27 +7508,86 @@ output_min_issue_delay_table (automaton_t automaton)
                         * automaton->insn_equiv_classes_num);
   min_issue_delay_vect = VEC_alloc (vect_el_t, heap, min_issue_delay_len);
   for (i = 0; i < min_issue_delay_len; i++)
-    VEC_quick_push (vect_el_t, min_issue_delay_vect, 0);
+    VEC_quick_push (vect_el_t, min_issue_delay_vect, -1);
 
   automaton->max_min_delay = 0;
-  for (ainsn = automaton->ainsn_list; ainsn != NULL; ainsn = ainsn->next_ainsn)
+
+  do
+    {
+      size_t state_no;
+
+      changed = 0;
+
+      for (state_no = 0; state_no < VEC_length (state_t, output_states_vect);
+           state_no++)
+       {
+         state_t s = VEC_index (state_t, output_states_vect, state_no);
+         arc_t arc;
+
+         for (arc = first_out_arc (s); arc; arc = next_out_arc (arc))
+           {
+             int k;
+
+             size_t asn = s->order_state_num
+                          * automaton->insn_equiv_classes_num
+                          + arc->insn->insn_equiv_class_num;
+
+             if (VEC_index (vect_el_t, min_issue_delay_vect, asn))
+               {
+                 VEC_replace (vect_el_t, min_issue_delay_vect, asn, 0);
+                 changed = 1;
+               }
+
+             for (k = 0; k < automaton->insn_equiv_classes_num; k++)
+               {
+                 size_t n0, n1;
+                 vect_el_t delay0, delay1;
+
+                 n0 = s->order_state_num
+                      * automaton->insn_equiv_classes_num
+                      + k;
+                 n1 = arc->to_state->order_state_num
+                      * automaton->insn_equiv_classes_num
+                      + k;
+                 delay0 = VEC_index (vect_el_t, min_issue_delay_vect, n0);
+                 delay1 = VEC_index (vect_el_t, min_issue_delay_vect, n1);
+                 if (delay1 != -1)
+                   {
+                     if (arc->insn->insn_reserv_decl
+                         == DECL_INSN_RESERV (advance_cycle_insn_decl))
+                       delay1++;
+                     if (delay1 < delay0 || delay0 == -1)
+                       {
+                         VEC_replace (vect_el_t, min_issue_delay_vect, n0, delay1);
+                         changed = 1;
+                       }
+                   }
+               }
+           }
+       }
+    }
+  while (changed);
+
+  automaton->max_min_delay = 0;
+
+  for (ainsn = automaton->ainsn_list; ainsn; ainsn = ainsn->next_ainsn)
     if (ainsn->first_ainsn_with_given_equivalence_num)
       {
        for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
-         VEC_index (state_t, output_states_vect, i)->min_insn_issue_delay = -1;
-       for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
          {
            state_t s = VEC_index (state_t, output_states_vect, i);
-            min_delay = min_issue_delay (s, ainsn);
-           if (automaton->max_min_delay < min_delay)
-             automaton->max_min_delay = min_delay;
-           VEC_replace (vect_el_t, min_issue_delay_vect,
-                        s->order_state_num
-                        * automaton->insn_equiv_classes_num
-                        + ainsn->insn_equiv_class_num,
-                        min_delay);
+           size_t np = s->order_state_num
+                       * automaton->insn_equiv_classes_num
+                       + ainsn->insn_equiv_class_num;
+           vect_el_t x = VEC_index (vect_el_t, min_issue_delay_vect, np);
+
+           if (automaton->max_min_delay < x)
+             automaton->max_min_delay = x;
+           if (x == -1)
+             VEC_replace (vect_el_t, min_issue_delay_vect, np, 0);
          }
       }
+
   fprintf (output_file, "/* Vector of min issue delay of insns.  */\n");
   fprintf (output_file, "static const ");
   output_range_type (output_file, 0, automaton->max_min_delay);
@@ -7658,7 +7644,7 @@ output_dead_lock_vect (automaton_t automaton)
   output_states_vect = 0;
   pass_states (automaton, add_states_vect_el);
 
-  VEC_safe_grow (vect_el_t, heap, dead_lock_vect, 
+  VEC_safe_grow (vect_el_t, heap, dead_lock_vect,
                 VEC_length (state_t, output_states_vect));
   for (i = 0; i < VEC_length (state_t, output_states_vect); i++)
     {
@@ -7713,7 +7699,7 @@ output_reserved_units_table (automaton_t automaton)
                         * state_byte_size);
 
   reserved_units_table = VEC_alloc (vect_el_t, heap, reserved_units_size);
-                
+
   for (i = 0; i < reserved_units_size; i++)
     VEC_quick_push (vect_el_t, reserved_units_table, 0);
   for (n = 0; n < VEC_length (state_t, output_states_vect); n++)
@@ -7753,7 +7739,6 @@ output_tables (void)
 {
   automaton_t automaton;
 
-  initiate_min_issue_delay_pass_states ();
   for (automaton = description->first_automaton;
        automaton != NULL;
        automaton = automaton->next_automaton)
@@ -7869,12 +7854,15 @@ output_automata_list_min_issue_delay_code (automata_list_el_t automata_list)
        {
          fprintf (output_file, ") / %d];\n",
                   automaton->min_issue_delay_table_compression_factor);
-         fprintf (output_file, "      %s = (%s >> (8 - (",
+         fprintf (output_file, "      %s = (%s >> (8 - ((",
                   TEMPORARY_VARIABLE_NAME, TEMPORARY_VARIABLE_NAME);
          output_translate_vect_name (output_file, automaton);
+         fprintf (output_file, " [%s] + ", INTERNAL_INSN_CODE_NAME);
+         fprintf (output_file, "%s->", CHIP_PARAMETER_NAME);
+         output_chip_member_name (output_file, automaton);
+         fprintf (output_file, " * %d)", automaton->insn_equiv_classes_num);
          fprintf
-           (output_file, " [%s] %% %d + 1) * %d)) & %d;\n",
-            INTERNAL_INSN_CODE_NAME,
+           (output_file, " %% %d + 1) * %d)) & %d;\n",
             automaton->min_issue_delay_table_compression_factor,
             8 / automaton->min_issue_delay_table_compression_factor,
             (1 << (8 / automaton->min_issue_delay_table_compression_factor))
@@ -8222,7 +8210,7 @@ output_min_insn_conflict_delay_func (void)
   fprintf (output_file, "}\n\n");
 }
 
-/* Output the array holding default latency values.  These are used in 
+/* Output the array holding default latency values.  These are used in
    insn_latency and maximal_insn_latency function implementations.  */
 static void
 output_default_latencies (void)
@@ -8446,7 +8434,7 @@ output_print_reservation_func (void)
        {
          gcc_assert (j == DECL_INSN_RESERV (decl)->insn_num);
          j++;
-         
+
          fprintf (output_file, "\n      \"%s\",",
                   regexp_representation (DECL_INSN_RESERV (decl)->regexp));
          finish_regexp_representation ();
@@ -9234,10 +9222,9 @@ check_automata_insn_issues (void)
                           automaton->corresponding_automaton_decl->name,
                           reserv_ainsn->insn_reserv_decl->name);
                  else
-                   warning
-                     (0, "Automaton `%s': Insn `%s' will never be issued",
-                      automaton->corresponding_automaton_decl->name,
-                      reserv_ainsn->insn_reserv_decl->name);
+                   warning ("Automaton `%s': Insn `%s' will never be issued",
+                            automaton->corresponding_automaton_decl->name,
+                            reserv_ainsn->insn_reserv_decl->name);
                }
              else
                {
@@ -9245,7 +9232,7 @@ check_automata_insn_issues (void)
                    error ("Insn `%s' will never be issued",
                           reserv_ainsn->insn_reserv_decl->name);
                  else
-                   warning (0, "Insn `%s' will never be issued",
+                   warning ("Insn `%s' will never be issued",
                             reserv_ainsn->insn_reserv_decl->name);
                }
          }
@@ -9483,7 +9470,7 @@ main (int argc, char **argv)
 
   progname = "genautomata";
 
-  if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
+  if (!init_rtx_reader_args (argc, argv))
     return (FATAL_EXIT_CODE);
 
   initiate_automaton_gen (argc, argv);
@@ -9570,16 +9557,27 @@ main (int argc, char **argv)
                "#include \"insn-config.h\"\n"
                "#include \"recog.h\"\n"
                "#include \"regs.h\"\n"
-               "#include \"real.h\"\n"
                "#include \"output.h\"\n"
                "#include \"insn-attr.h\"\n"
-               "#include \"toplev.h\"\n"
+                "#include \"diagnostic-core.h\"\n"
                "#include \"flags.h\"\n"
-               "#include \"function.h\"\n");
+               "#include \"function.h\"\n"
+               "#include \"emit-rtl.h\"\n");
+                /* FIXME: emit-rtl.h can go away once crtl is in rtl.h.  */
 
          write_automata ();
        }
     }
+  else
+    {
+      puts ("/* Generated automatically by the program `genautomata'\n"
+           "   from the machine description file `md'.  */\n\n"
+           "/* There is no automaton, but ISO C forbids empty\n"
+           "   translation units, so include a header file with some\n"
+           "   declarations, and its pre-requisite header file.  */\n"
+           "#include \"config.h\"\n"
+           "#include \"system.h\"\n");
+    }
 
   fflush (stdout);
   return (ferror (stdout) != 0 || have_error