diff gcc/genflags.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
line wrap: on
line diff
--- a/gcc/genflags.c	Sun Aug 21 07:07:55 2011 +0900
+++ b/gcc/genflags.c	Fri Oct 27 22:46:09 2017 +0900
@@ -1,8 +1,7 @@
 /* Generate from machine description:
    - some flags HAVE_... saying which simple standard instructions are
    available for this machine.
-   Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2003, 2004, 2007, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 1987-2017 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -43,8 +42,6 @@
 static void max_operand_1 (rtx);
 static int num_operands (rtx);
 static void gen_proto (rtx);
-static void gen_macro (const char *, int, int);
-static void gen_insn (int, rtx);
 
 /* Count the number of match_operand's found.  */
 
@@ -94,32 +91,6 @@
   return max_opno + 1;
 }
 
-/* Print out a wrapper macro for a function which corrects the number
-   of arguments it takes.  Any missing arguments are assumed to be at
-   the end.  */
-static void
-gen_macro (const char *name, int real, int expect)
-{
-  int i;
-
-  gcc_assert (real <= expect);
-  gcc_assert (real);
-
-  /* #define GEN_CALL(A, B, C, D) gen_call((A), (B)) */
-  fputs ("#define GEN_", stdout);
-  for (i = 0; name[i]; i++)
-    putchar (TOUPPER (name[i]));
-
-  putchar('(');
-  for (i = 0; i < expect - 1; i++)
-    printf ("%c, ", i + 'A');
-  printf ("%c) gen_%s (", i + 'A', name);
-
-  for (i = 0; i < real - 1; i++)
-    printf ("(%c), ", i + 'A');
-  printf ("(%c))\n", i + 'A');
-}
-
 /* Print out prototype information for a generator function.  If the
    insn pattern has been elided, print out a dummy generator that
    does nothing.  */
@@ -132,25 +103,6 @@
   const char *name = XSTR (insn, 0);
   int truth = maybe_eval_c_test (XSTR (insn, 2));
 
-  /* Many md files don't refer to the last two operands passed to the
-     call patterns.  This means their generator functions will be two
-     arguments too short.  Instead of changing every md file to touch
-     those operands, we wrap the prototypes in macros that take the
-     correct number of arguments.  */
-  if (name[0] == 'c' || name[0] == 's')
-    {
-      if (!strcmp (name, "call")
-	  || !strcmp (name, "call_pop")
-	  || !strcmp (name, "sibcall")
-	  || !strcmp (name, "sibcall_pop"))
-	gen_macro (name, num, 4);
-      else if (!strcmp (name, "call_value")
-	       || !strcmp (name, "call_value_pop")
-	       || !strcmp (name, "sibcall_value")
-	       || !strcmp (name, "sibcall_value_pop"))
-	gen_macro (name, num, 5);
-    }
-
   if (truth != 0)
     printf ("extern rtx        gen_%-*s (", max_id_len, name);
   else
@@ -188,8 +140,9 @@
 }
 
 static void
-gen_insn (int line_no, rtx insn)
+gen_insn (md_rtx_info *info)
 {
+  rtx insn = info->def;
   const char *name = XSTR (insn, 0);
   const char *p;
   const char *lt, *gt;
@@ -199,18 +152,15 @@
   lt = strchr (name, '<');
   if (lt && strchr (lt + 1, '>'))
     {
-      message_with_line (line_no, "unresolved iterator");
-      have_error = 1;
+      error_at (info->loc, "unresolved iterator");
       return;
     }
 
   gt = strchr (name, '>');
   if (lt || gt)
     {
-      message_with_line (line_no,
-			 "unmatched angle brackets, likely "
-			 "an error in iterator syntax");
-      have_error = 1;
+      error_at (info->loc, "unmatched angle brackets, likely "
+		"an error in iterator syntax");
       return;
     }
 
@@ -248,9 +198,8 @@
 }
 
 int
-main (int argc, char **argv)
+main (int argc, const char **argv)
 {
-  rtx desc;
   rtx dummy;
   rtx *insns;
   rtx *insn_ptr;
@@ -272,16 +221,18 @@
 
   /* Read the machine description.  */
 
-  while (1)
-    {
-      int line_no, insn_code_number = 0;
+  md_rtx_info info;
+  while (read_md_rtx (&info))
+    switch (GET_CODE (info.def))
+      {
+      case DEFINE_INSN:
+      case DEFINE_EXPAND:
+	gen_insn (&info);
+	break;
 
-      desc = read_md_rtx (&line_no, &insn_code_number);
-      if (desc == NULL)
+      default:
 	break;
-      if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
-	gen_insn (line_no, desc);
-    }
+      }
 
   /* Print out the prototypes now.  */
   dummy = (rtx) 0;
@@ -291,7 +242,7 @@
   for (insn_ptr = insns; *insn_ptr; insn_ptr++)
     gen_proto (*insn_ptr);
 
-  puts("\n#endif /* GCC_INSN_FLAGS_H */");
+  puts ("\n#endif /* GCC_INSN_FLAGS_H */");
 
   if (have_error || ferror (stdout) || fflush (stdout) || fclose (stdout))
     return FATAL_EXIT_CODE;