From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id A3CB6395B462; Tue, 27 Oct 2020 16:28:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3CB6395B462 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: William Schmidt To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/wschmidt/heads/builtins3)] rs6000: Write output to the builtins init file, part 1 of 3 X-Act-Checkin: gcc X-Git-Author: Bill Schmidt X-Git-Refname: refs/users/wschmidt/heads/builtins3 X-Git-Oldrev: e22361b69953b43ea44af74a0544745a9c5eaf25 X-Git-Newrev: e193000f8c6ee6fb99c834be5b0af3479b2a7082 Message-Id: <20201027162822.A3CB6395B462@sourceware.org> Date: Tue, 27 Oct 2020 16:28:22 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 16:28:22 -0000 https://gcc.gnu.org/g:e193000f8c6ee6fb99c834be5b0af3479b2a7082 commit e193000f8c6ee6fb99c834be5b0af3479b2a7082 Author: Bill Schmidt Date: Wed Jun 17 11:13:01 2020 -0500 rs6000: Write output to the builtins init file, part 1 of 3 2020-07-26 Bill Schmidt * config/rs6000/rs6000-gen-builtins.c (write_fntype): New function. (write_fntype_init): New stub function. (write_init_bif_table): Likewise. (write_init_ovld_table): New function. (write_init_file): Implement. Diff: --- gcc/config/rs6000/rs6000-gen-builtins.c | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index 67c7b22aad6..3ac199ff2e5 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -2055,6 +2055,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 () @@ -2078,10 +2090,147 @@ 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 DEBUG_NEW_BUILTINS + 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 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 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, " 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; }