diff gcc/genopinit.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/genopinit.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/genopinit.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Generate code to initialize optabs from machine description.
-   Copyright (C) 1993-2017 Free Software Foundation, Inc.
+   Copyright (C) 1993-2018 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -104,6 +104,63 @@
   return f;
 }
 
+/* Declare the maybe_code_for_* function for ONAME, and provide
+   an inline definition of the assserting code_for_* wrapper.  */
+
+static void
+handle_overloaded_code_for (FILE *file, overloaded_name *oname)
+{
+  fprintf (file, "\nextern insn_code maybe_code_for_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
+  fprintf (file, ");\n");
+
+  fprintf (file, "inline insn_code\ncode_for_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
+  fprintf (file, ")\n{\n  insn_code code = maybe_code_for_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
+  fprintf (file,
+	   ");\n"
+	   "  gcc_assert (code != CODE_FOR_nothing);\n"
+	   "  return code;\n"
+	   "}\n");
+}
+
+/* Declare the maybe_gen_* function for ONAME, and provide
+   an inline definition of the assserting gen_* wrapper.  */
+
+static void
+handle_overloaded_gen (FILE *file, overloaded_name *oname)
+{
+  pattern_stats stats;
+  get_pattern_stats (&stats, XVEC (oname->first_instance->insn, 1));
+
+  fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
+  for (int i = 0; i < stats.num_generator_args; ++i)
+    fprintf (file, ", rtx");
+  fprintf (file, ");\n");
+
+  fprintf (file, "inline rtx\ngen_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
+  for (int i = 0; i < stats.num_generator_args; ++i)
+    fprintf (file, ", rtx x%d", i);
+  fprintf (file, ")\n{\n  rtx res = maybe_gen_%s (", oname->name);
+  for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+    fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
+  for (int i = 0; i < stats.num_generator_args; ++i)
+    fprintf (file, ", x%d", i);
+  fprintf (file,
+	   ");\n"
+	   "  gcc_assert (res);\n"
+	   "  return res;\n"
+	   "}\n");
+}
+
 int
 main (int argc, const char **argv)
 {
@@ -220,7 +277,16 @@
 	   "optab_to_code (optab op)\n"
 	   "{\n"
 	   "  return optab_to_code_[op];\n"
-	   "}\n"
+	   "}\n");
+
+  for (overloaded_name *oname = rtx_reader_ptr->get_overloads ();
+       oname; oname = oname->next)
+    {
+      handle_overloaded_code_for (h_file, oname);
+      handle_overloaded_gen (h_file, oname);
+    }
+
+  fprintf (h_file,
 	   "#endif\n"
 	   "\n"
 	   "extern const struct convert_optab_libcall_d convlib_def[NUM_CONVLIB_OPTABS];\n"
@@ -234,6 +300,13 @@
 	   "struct target_optabs {\n"
 	   "  /* Patterns that are used by optabs that are enabled for this target.  */\n"
 	   "  bool pat_enable[NUM_OPTAB_PATTERNS];\n"
+	   "\n"
+	   "  /* Cache if the target supports vec_gather_load for at least one vector\n"
+	   "     mode.  */\n"
+	   "  bool supports_vec_gather_load;\n"
+	   "  bool supports_vec_gather_load_cached;\n"
+	   "  bool supports_vec_scatter_store;\n"
+	   "  bool supports_vec_scatter_store_cached;\n"
 	   "};\n"
 	   "extern void init_all_optabs (struct target_optabs *);\n"
 	   "\n"
@@ -246,6 +319,7 @@
 	   "#endif\n");
 
   fprintf (s_file,
+	   "#define IN_TARGET_CODE 1\n"
 	   "#include \"config.h\"\n"
 	   "#include \"system.h\"\n"
 	   "#include \"coretypes.h\"\n"