OSDN Git Service

* config/linux.h (ASM_COMMENT_START): Remove from here,
[pf3gnuchains/gcc-fork.git] / gcc / genoutput.c
index 24b6c9f..490ecb4 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate code from to output assembler insns as recognized from rtl.
-   Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -15,7 +15,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 /* This program reads the machine description for the compiler target machine
@@ -89,8 +90,8 @@ insn_template[24] to be "clrd %0", and insn_n_operands[24] to be 1.
 It would not make an case in output_insn_hairy because the template
 given in the entry is a constant (it does not start with `*').  */
 \f
-#include <stdio.h>
-#include "config.h"
+#include "hconfig.h"
+#include "system.h"
 #include "rtl.h"
 #include "obstack.h"
 
@@ -106,15 +107,16 @@ struct obstack *rtl_obstack = &obstack;
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-extern void free ();
-
-char *xmalloc ();
+char *xmalloc PROTO((unsigned));
 static void fatal ();
-void fancy_abort ();
+void fancy_abort PROTO((void));
 static void error ();
 static void mybcopy ();
 static void mybzero ();
-static int n_occurrences ();
+static int n_occurrences PROTO((int, char *));
+
+/* Define this so we can link with print-rtl.o to get debug_rtx function.  */
+char **insn_name_ptr = 0;
 
 /* insns in the machine description are assigned sequential code numbers
    that are used by insn-recog.c (produced by genrecog) to communicate
@@ -164,15 +166,32 @@ struct data *end_of_insn_data;
    for this machine description.  */
 
 int have_constraints;
+
+/* Nonzero if some error has occurred.  We will make all errors fatal, but
+   might as well continue until we see all of them.  */
+
+static int have_error;
+\f
+static void output_prologue PROTO((void));
+static void output_epilogue PROTO((void));
+static void scan_operands PROTO((rtx, int, int));
+static void process_template PROTO((struct data *, char *));
+static void validate_insn_alternatives PROTO((struct data *));
+static void gen_insn PROTO((rtx));
+static void gen_peephole PROTO((rtx));
+static void gen_expand PROTO((rtx));
+static void gen_split PROTO((rtx));
+static int n_occurrences PROTO((int, char *));
 \f
 static void
 output_prologue ()
 {
-
   printf ("/* Generated automatically by the program `genoutput'\n\
 from the machine description file `md'.  */\n\n");
 
   printf ("#include \"config.h\"\n");
+  printf ("#include \"system.h\"\n");
+  printf ("#include \"flags.h\"\n");
   printf ("#include \"rtl.h\"\n");
   printf ("#include \"regs.h\"\n");
   printf ("#include \"hard-reg-set.h\"\n");
@@ -184,7 +203,6 @@ from the machine description file `md'.  */\n\n");
   printf ("#include \"insn-codes.h\"\n\n");
   printf ("#include \"recog.h\"\n\n");
 
-  printf ("#include <stdio.h>\n");
   printf ("#include \"output.h\"\n");
 }
 
@@ -216,7 +234,7 @@ output_epilogue ()
   printf ("\nrtx (*const insn_gen_function[]) () =\n  {\n");
   for (d = insn_data; d; d = d->next)
     {
-      if (d->name)
+      if (d->name && d->name[0] != '*')
        printf ("    gen_%s,\n", d->name);
       else
        printf ("    0,\n");
@@ -228,10 +246,10 @@ output_epilogue ()
     int offset = 0;
     int next;
     char * last_name = 0;
-    char * next_name;
+    char * next_name = 0;
     register struct data *n;
 
-    for (n = insn_data, next = 0; n; n = n->next, next++)
+    for (n = insn_data, next = 1; n; n = n->next, next++)
       if (n->name)
        {
          next_name = n->name;
@@ -496,6 +514,7 @@ scan_operands (part, this_address_p, this_strict_low)
 
     case MATCH_DUP:
     case MATCH_OP_DUP:
+    case MATCH_PAR_DUP:
       ++num_dups;
       return;
 
@@ -506,6 +525,9 @@ scan_operands (part, this_address_p, this_strict_low)
     case STRICT_LOW_PART:
       scan_operands (XEXP (part, 0), 0, 1);
       return;
+      
+    default:
+      break;
     }
 
   format_ptr = GET_RTX_FORMAT (GET_CODE (part));
@@ -514,6 +536,7 @@ scan_operands (part, this_address_p, this_strict_low)
     switch (*format_ptr++)
       {
       case 'e':
+      case 'u':
        scan_operands (XEXP (part, i), 0, 0);
        break;
       case 'E':
@@ -552,8 +575,8 @@ process_template (d, template)
 
   printf ("\nstatic char *\n");
   printf ("output_%d (operands, insn)\n", d->code_number);
-  printf ("     rtx *operands;\n");
-  printf ("     rtx insn;\n");
+  printf ("     rtx *operands ATTRIBUTE_UNUSED;\n");
+  printf ("     rtx insn ATTRIBUTE_UNUSED;\n");
   printf ("{\n");
 
   /* If the assembler code template starts with a @ it is a newline-separated
@@ -573,7 +596,10 @@ process_template (d, template)
 
          printf ("    \"");
          while (*cp != '\n' && *cp != '\0')
-           putchar (*cp++);
+           {
+             putchar (*cp);
+             cp++;
+           }
 
          printf ("\",\n");
          i++;
@@ -593,7 +619,11 @@ process_template (d, template)
          VAX-11 "C" on VMS.  It is the equivalent of:
                printf ("%s\n", &template[1])); */
       cp = &template[1];
-      while (*cp) putchar (*cp++);
+      while (*cp)
+       {
+         putchar (*cp);
+         cp++;
+       }
       putchar ('\n');
     }
 
@@ -845,6 +875,7 @@ gen_split (split)
   mybzero (d->strict_low, sizeof strict_low);
 
   d->n_dups = 0;
+  d->n_alternatives = 0;
   d->template = 0;
   d->outfun = 0;
 }
@@ -916,6 +947,8 @@ error (s, a1, a2)
   fprintf (stderr, "genoutput: ");
   fprintf (stderr, s, a1, a2);
   fprintf (stderr, "\n");
+
+  have_error = 1;
 }
 \f
 int
@@ -925,7 +958,6 @@ main (argc, argv)
 {
   rtx desc;
   FILE *infile;
-  extern rtx read_rtx ();
   register int c;
 
   obstack_init (rtl_obstack);
@@ -971,14 +1003,16 @@ main (argc, argv)
   output_epilogue ();
 
   fflush (stdout);
-  exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+  exit (ferror (stdout) != 0 || have_error
+       ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+
   /* NOTREACHED */
   return 0;
 }
 
 static int
 n_occurrences (c, s)
-     char c;
+     int c;
      char *s;
 {
   int n = 0;