@@ -1965,6 +1965,18 @@ write_extern_fntype (char *str)
fprintf (header_file, "extern tree %s;\n", str);
}
+void
+write_fntype (char *str)
+{
+ fprintf (init_file, "tree %s;\n", str);
+}
+
+/* Write an initializer for a function type identified by STR. */
+void
+write_fntype_init (char *str)
+{
+}
+
/* Write everything to the header file (rs6000-builtins.h). */
static int
write_header_file ()
@@ -1988,10 +2000,149 @@ write_header_file ()
return 1;
}
+/* Write code to initialize the built-in function table. */
+static void
+write_init_bif_table ()
+{
+}
+
+/* Write code to initialize the overload table. */
+static void
+write_init_ovld_table ()
+{
+ fprintf (init_file, " int base = RS6000_BIF_MAX;\n\n");
+
+ for (int i = 0; i <= curr_ovld; i++)
+ {
+ fprintf (init_file,
+ " rs6000_overload_info[RS6000_OVLD_%s - base].bifname"
+ "\n = \"%s\";\n",
+ ovlds[i].idname, ovlds[i].proto.bifname);
+ fprintf (init_file,
+ " rs6000_overload_info[RS6000_OVLD_%s - base].bifid"
+ "\n = RS6000_BIF_%s;\n",
+ ovlds[i].idname, ovlds[i].idname);
+ fprintf (init_file,
+ " rs6000_overload_info[RS6000_OVLD_%s - base].fntype"
+ "\n = %s;\n",
+ ovlds[i].idname, ovlds[i].fndecl);
+ fprintf (init_file,
+ " rs6000_overload_info[RS6000_OVLD_%s - base].next"
+ "\n = ", ovlds[i].idname);
+ if (i < curr_ovld
+ && !strcmp (ovlds[i+1].proto.bifname, ovlds[i].proto.bifname))
+ fprintf (init_file,
+ "&rs6000_overload_info[RS6000_OVLD_%s - base];\n",
+ ovlds[i+1].idname);
+ else
+ fprintf (init_file, "NULL;\n");
+
+ if (i == 0 || ovlds[i].stanza != ovlds[i-1].stanza)
+ {
+ fprintf (init_file, "\n");
+
+ fprintf (init_file,
+ " ovldaddr = &rs6000_overload_info"
+ "[RS6000_OVLD_%s - base];\n",
+ ovlds[i].idname);
+ fprintf (init_file,
+ " hash = rs6000_ovld_hasher::hash (ovldaddr);\n");
+ fprintf (init_file,
+ " oslot = ovld_hash.find_slot_with_hash (\n");
+ fprintf (init_file,
+ " \"%s\", hash, INSERT\n",
+ ovlds[i].proto.bifname);
+ fprintf (init_file,
+ " );\n");
+ fprintf (init_file,
+ " *oslot = ovldaddr;\n");
+ }
+
+ if (i < curr_ovld)
+ fprintf (init_file, "\n");
+ }
+}
+
/* Write everything to the initialization file (rs6000-builtins.c). */
static int
write_init_file ()
{
+ write_autogenerated_header (init_file);
+
+ fprintf (init_file, "#include \"config.h\"\n");
+ fprintf (init_file, "#include \"system.h\"\n");
+ fprintf (init_file, "#include \"coretypes.h\"\n");
+ fprintf (init_file, "#include \"backend.h\"\n");
+ fprintf (init_file, "#include \"rtl.h\"\n");
+ fprintf (init_file, "#include \"tree.h\"\n");
+ fprintf (init_file, "#include \"langhooks.h\"\n");
+ fprintf (init_file, "#include \"insn-codes.h\"\n");
+ fprintf (init_file, "#include \"rs6000-builtins.h\"\n");
+ fprintf (init_file, "\n");
+
+#ifdef BILLDEBUG
+ fprintf (init_file, "int new_builtins_are_live = 1;\n\n");
+#else
+ fprintf (init_file, "int new_builtins_are_live = 0;\n\n");
+#endif
+
+ fprintf (init_file,
+ "bifdata rs6000_builtin_info_x[RS6000_BIF_MAX];\n\n");
+ fprintf (init_file,
+ "ovlddata rs6000_overload_info[RS6000_OVLD_MAX"
+ " - RS6000_BIF_MAX];\n\n");
+
+ rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype);
+ fprintf (init_file, "\n");
+
+ fprintf (init_file, "hashval_t\n");
+ fprintf (init_file, "rs6000_bif_hasher::hash (bifdata *bd)\n");
+ fprintf (init_file, "{\n");
+ fprintf (init_file, " return htab_hash_string (bd->bifname);\n");
+ fprintf (init_file, "}\n\n");
+
+ fprintf (init_file, "bool\n");
+ fprintf (init_file,
+ "rs6000_bif_hasher::equal (bifdata *bd, const char *name)\n");
+ fprintf (init_file, "{\n");
+ fprintf (init_file, " return bd && name && !strcmp (bd->bifname, name);\n");
+ fprintf (init_file, "}\n\n");
+
+ fprintf (init_file, "hash_table<rs6000_bif_hasher> bif_hash (1024);\n\n");
+
+ fprintf (init_file, "hashval_t\n");
+ fprintf (init_file, "rs6000_ovld_hasher::hash (ovlddata *od)\n");
+ fprintf (init_file, "{\n");
+ fprintf (init_file, " return htab_hash_string (od->bifname);\n");
+ fprintf (init_file, "}\n\n");
+
+ fprintf (init_file, "bool\n");
+ fprintf (init_file,
+ "rs6000_ovld_hasher::equal (ovlddata *od, const char *name)\n");
+ fprintf (init_file, "{\n");
+ fprintf (init_file, " return od && name && !strcmp (od->bifname, name);\n");
+ fprintf (init_file, "}\n\n");
+
+ fprintf (init_file, "hash_table<rs6000_ovld_hasher> ovld_hash (512);\n\n");
+
+ fprintf (init_file, "void\n");
+ fprintf (init_file, "rs6000_autoinit_builtins ()\n");
+ fprintf (init_file, "{\n");
+ fprintf (init_file, " tree t;\n");
+ fprintf (init_file,
+ " HOST_WIDE_INT builtin_mask = rs6000_builtin_mask;\n");
+ fprintf (init_file, " bifdata **slot;\n");
+ fprintf (init_file, " bifdata *bifaddr;\n");
+ fprintf (init_file, " hashval_t hash;\n");
+ fprintf (init_file, " ovlddata **oslot;\n");
+ fprintf (init_file, " ovlddata *ovldaddr;\n\n");
+ rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype_init);
+ fprintf (init_file, "\n");
+
+ write_init_bif_table ();
+ write_init_ovld_table ();
+
+ fprintf (init_file, "}\n");
return 1;
}