x86: use template for AVX512 integer comparison insns
[deliverable/binutils-gdb.git] / opcodes / opc2c.c
index bec361f32cb3edb270ee6cdf3261e999a82e5f76..494dd860a49be2507433f2cdfc7f79333ef81dae 100644 (file)
@@ -1,6 +1,6 @@
 /* opc2c.c --- generate C opcode decoder code from from .opc file
 
-   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc.
 
    This file is part of the GNU opcode library.
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <errno.h>
+#include "libiberty.h"
 
 static char * line_buf = NULL;
 static int line_buf_size = 0;
@@ -119,7 +121,7 @@ int n_varies = 0;
 
 unsigned char cur_bits[MAX_BYTES + 1];
 
-char * orig_filename;
+const char * orig_filename;
 
 FILE * sim_log = NULL;
 #define lprintf if (sim_log) fprintf
@@ -288,7 +290,7 @@ dump_lines (opcode * op, int level, Indirect * ind)
            }
          *np = 0;
          varnames[vn++] = strdup (name);
-         printf ("#line %d \"%s\"\n", op->lineno, orig_filename);
+         printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename);
          if (mask & ~0xff)
            {
              fprintf (stderr, "Error: variable %s spans bytes: %s\n",
@@ -337,7 +339,10 @@ dump_lines (opcode * op, int level, Indirect * ind)
   printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename);
 
   for (i = 0; i < op->nlines; i++)
-    printf ("%*s%s", level, "", op->lines[i]);
+    if (op->lines[i][0] == '\n')
+      printf ("%s", op->lines[i]);
+    else
+      printf ("%*s%s", level, "", op->lines[i]);
 
   if (op->comment)
     printf ("%*s}\n", level, "");
@@ -572,33 +577,25 @@ main (int argc, char ** argv)
   VaryRef * vlist;
   int skipping_section = 0;
 
-  if (argc > 2 && strcmp (argv[1], "-l") == 0)
-    {
-      sim_log = fopen (argv[2], "w");
-      fprintf (stderr, "sim_log: %s\n", argv[2]);
-      argc -= 2;
-      argv += 2;
-    }
-
   if (argc < 2)
     {
       fprintf (stderr, "usage: opc2c infile.opc > outfile.opc\n");
       exit (1);
     }
 
-  orig_filename = argv[1];
+  orig_filename = lbasename (argv[1]);
   in = fopen (argv[1], "r");
   if (!in)
     {
-      fprintf (stderr, "Unable to open file %s for reading\n", argv[1]);
-      perror ("The error was");
+      fprintf (stderr, "Unable to open file %s for reading: %s\n", argv[1],
+              xstrerror (errno));
       exit (1);
     }
 
   n_opcodes = 0;
   opcodes = (opcode **) malloc (sizeof (opcode *));
   op = &prefix_text;
-  op->lineno = 1;
+  op->lineno = 0;
   while ((line = safe_fgets (in)) != 0)
     {
       lineno++;
@@ -797,6 +794,8 @@ main (int argc, char ** argv)
       store_opcode_bits (opcodes[i], 0, indirect);
     }
 
+  printf ("/* DO NOT EDIT!  -*- buffer-read-only: t -*- vi:set ro:  */\n");
+
   dump_lines (&prefix_text, 0, 0);
 
   emit_indirect (indirect, 0);
This page took 0.026642 seconds and 4 git commands to generate.