public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: William Schmidt <wschmidt@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/wschmidt/heads/builtins4)] rs6000: Statically initialize overload data Date: Tue, 24 Nov 2020 16:45:29 +0000 (GMT) [thread overview] Message-ID: <20201124164529.CD1AB39494B3@sourceware.org> (raw) https://gcc.gnu.org/g:1f08fcc58344c22f5e6a2286a944c679641b685f commit 1f08fcc58344c22f5e6a2286a944c679641b685f Author: Bill Schmidt <wschmidt@linux.ibm.com> Date: Mon Nov 9 10:08:46 2020 -0500 rs6000: Statically initialize overload data Note that we need alphabetic order to support the chaining from one overload to the next in the same group. 2020-11-09 Bill Schmidt <wschmidt@linux.ibm.com> * config/rs6000/rs6000-gen-builtins.c (write_ovld_enum): Remove. (write_decls): Change overloads from alphabetic order to encounter order. (write_ovld_static_init): New function. (write_init_ovld_table): Move some initialization from here to write_ovld_static_init; separate table numbering for bifs and overloads. (write_init_file): Call write_ovld_static_init; remove decl of rs6000_overload_info. Diff: --- gcc/config/rs6000/rs6000-gen-builtins.c | 84 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index 3062d10531a..b44abf37e15 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -2101,17 +2101,12 @@ write_autogenerated_header (FILE *file) bif_path, ovld_path); } -/* Callback functions used in creating enumerations. */ +/* Callback function used in creating the built-in function enumeration. */ void write_bif_enum (char *str) { fprintf (header_file, " RS6000_BIF_%s,\n", str); } -void write_ovld_enum (char *str) -{ - fprintf (header_file, " RS6000_OVLD_%s,\n", str); -} - /* Write declarations into the header file. */ static void write_decls () @@ -2241,14 +2236,10 @@ write_decls () fprintf (header_file, "extern hash_table<rs6000_bif_hasher> bif_hash;\n\n"); - /* Right now we use nonoverlapping numbers for rs6000_gen_builtins - and rs6000_gen_overloads. In the old design, these were all in the - same enum, and I can't yet prove there isn't a dependency on these - numbers being distinct. Once this is more clear, I may change - this to start at zero. */ fprintf (header_file, "enum rs6000_gen_overloads\n{\n"); - fprintf (header_file, " RS6000_OVLD_NONE = RS6000_BIF_MAX + 1,\n"); - rbt_inorder_callback (&ovld_rbt, ovld_rbt.rbt_root, write_ovld_enum); + fprintf (header_file, " RS6000_OVLD_NONE,\n"); + for (int i = 0; i < num_ovlds; i++) + fprintf (header_file, " RS6000_OVLD_%s,\n", ovlds[i].ovld_id_name); fprintf (header_file, " RS6000_OVLD_MAX\n};\n\n"); fprintf (header_file, "struct ovlddata\n"); @@ -2471,6 +2462,38 @@ write_bif_static_init () fprintf (init_file, " };\n\n"); } +/* Write the decl and initializer for rs6000_overload_info[]. */ +static void +write_ovld_static_init () +{ + fprintf (init_file, "ovlddata rs6000_overload_info[RS6000_OVLD_MAX] =\n"); + fprintf (init_file, " {\n"); + fprintf (init_file, " { /* RS6000_OVLD_NONE: */\n"); + fprintf (init_file, " \"\", RS6000_BIF_NONE, NULL_TREE, NULL\n"); + fprintf (init_file, " },\n"); + for (int i = 0; i <= curr_ovld; i++) + { + fprintf (init_file, " { /* RS6000_OVLD_%s: */\n", + ovlds[i].ovld_id_name); + fprintf (init_file, " /* bifname */\t\"%s\",\n", + ovlds[i].proto.bifname); + fprintf (init_file, " /* bifid */\tRS6000_BIF_%s,\n", + ovlds[i].bif_id_name); + /* Type must be instantiated at run time. */ + fprintf (init_file, " /* fntype */\t0,\n"); + fprintf (init_file, " /* next */\t"); + if (i < curr_ovld + && !strcmp (ovlds[i+1].proto.bifname, ovlds[i].proto.bifname)) + fprintf (init_file, + "&rs6000_overload_info[RS6000_OVLD_%s]\n", + ovlds[i+1].ovld_id_name); + else + fprintf (init_file, "NULL\n"); + fprintf (init_file, " },\n"); + } + fprintf (init_file, " };\n\n"); +} + /* Write code to initialize the built-in function table. */ static void write_init_bif_table () @@ -2541,40 +2564,19 @@ write_init_bif_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].ovld_id_name, ovlds[i].proto.bifname); - fprintf (init_file, - " rs6000_overload_info[RS6000_OVLD_%s - base].bifid" - "\n = RS6000_BIF_%s;\n", - ovlds[i].ovld_id_name, ovlds[i].bif_id_name); - fprintf (init_file, - " rs6000_overload_info[RS6000_OVLD_%s - base].fntype" + " rs6000_overload_info[RS6000_OVLD_%s].fntype" "\n = %s;\n", ovlds[i].ovld_id_name, ovlds[i].fndecl); - fprintf (init_file, - " rs6000_overload_info[RS6000_OVLD_%s - base].next" - "\n = ", ovlds[i].ovld_id_name); - 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].ovld_id_name); - 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", + "[RS6000_OVLD_%s];\n", ovlds[i].ovld_id_name); fprintf (init_file, " hash = rs6000_ovld_hasher::hash (ovldaddr);\n"); @@ -2586,11 +2588,8 @@ write_init_ovld_table () fprintf (init_file, " );\n"); fprintf (init_file, - " *oslot = ovldaddr;\n"); + " *oslot = ovldaddr;\n\n"); } - - if (i < curr_ovld) - fprintf (init_file, "\n"); } } @@ -2619,10 +2618,7 @@ write_init_file () #endif write_bif_static_init (); - - fprintf (init_file, - "ovlddata rs6000_overload_info[RS6000_OVLD_MAX" - " - RS6000_BIF_MAX];\n\n"); + write_ovld_static_init (); rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype); fprintf (init_file, "\n");
next reply other threads:[~2020-11-24 16:45 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-24 16:45 William Schmidt [this message] -- strict thread matches above, loose matches on Subject: below -- 2021-02-07 18:14 William Schmidt 2020-12-16 18:08 William Schmidt 2020-11-09 15:09 William Schmidt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201124164529.CD1AB39494B3@sourceware.org \ --to=wschmidt@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).