From patchwork Tue Feb 4 02:26:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1233114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518841-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=xvb9h8SV; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48BTCz6vkvz9sX3 for ; Tue, 4 Feb 2020 13:29:19 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=RJS0FawpS/sZLuof3Aw q00g0irDDPHZ/D5HGN9vIlOiPtM65/Jb2nSHNDSbfeu03xb5rTKK+bGse8TLjsrJ rcJncbDGtozgG1Qk8rYJHeeHTKq3K1xsLP7ZhHE/xPKJcfsKDoeXPDWMast6pLsK tXuROcb72Io/vTGCi+4Ox03U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=6TEwcgA7oVDs7UF+eO21IF7VY FI=; b=xvb9h8SVDLrP1XlNo3qPWbG+Cre/pY+NhTvOB6rgp0mzNL8MpLUIkg+pu 059ZXVI8+UTUPtmekKwj5R8xxXX57/yKoDvRvumuOC+klUB+4u+PJdlqslMgdG4D T79n8Uc7RBv8k4Yk/AGFvEK3lTosG1G5cUBFP6ApKE2j9VnBPM= Received: (qmail 68997 invoked by alias); 4 Feb 2020 02:27:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 68924 invoked by uid 89); 4 Feb 2020 02:27:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Feb 2020 02:27:37 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0142OFxd026633; Mon, 3 Feb 2020 21:27:36 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxp0f372g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 21:27:35 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0142KpMc020906; Tue, 4 Feb 2020 02:27:34 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma04wdc.us.ibm.com with ESMTP id 2xw0y6dspw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 02:27:34 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0142RXQ245744392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Feb 2020 02:27:33 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 93245C6055; Tue, 4 Feb 2020 02:27:33 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AF9FC6057; Tue, 4 Feb 2020 02:27:33 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 4 Feb 2020 02:27:33 +0000 (GMT) From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org Subject: [PATCH 12/14] Write code to rs6000-bif.h. Date: Mon, 3 Feb 2020 20:26:13 -0600 Message-Id: In-Reply-To: References: In-Reply-To: References: 2020-02-03 Bill Schmidt * config/rs6000/rs6000-genbif.c (write_autogenerated_header): New function. (write_bif_enum): New callback function. (write_ovld_enum): New callback function. (write_decls): New function. (write_extern_fntype): New callback function. (write_header_file): Implement. --- gcc/config/rs6000/rs6000-genbif.c | 160 ++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c index 0bcd035060d..c84df1aa30f 100644 --- a/gcc/config/rs6000/rs6000-genbif.c +++ b/gcc/config/rs6000/rs6000-genbif.c @@ -1617,10 +1617,170 @@ parse_ovld () return result; } +/* Write a comment at the top of FILE about how the code was generated. */ +static void +write_autogenerated_header (FILE *file) +{ + fprintf (file, "/* Automatically generated by the program '%s'\n", + pgm_path); + fprintf (file, " from the files '%s' and '%s'. */\n\n", + bif_path, ovld_path); +} + +/* Callback functions used in creating enumerations. */ +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 () +{ + fprintf (header_file, "enum rs6000_gen_builtins\n{\n RS6000_BIF_NONE,\n"); + rbt_inorder_callback (&bif_rbt, bif_rbt.rbt_root, write_bif_enum); + fprintf (header_file, " RS6000_BIF_MAX\n};\n\n"); + + fprintf (header_file, "enum restriction {\n"); + fprintf (header_file, " RES_NONE,\n"); + fprintf (header_file, " RES_BITS,\n"); + fprintf (header_file, " RES_RANGE,\n"); + fprintf (header_file, " RES_VALUES\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, "struct bifdata\n"); + fprintf (header_file, "{\n"); + fprintf (header_file, " const char *bifname;\n"); + fprintf (header_file, " tree fntype;\n"); + fprintf (header_file, " insn_code icode;\n"); + fprintf (header_file, " int bifattrs;\n"); + fprintf (header_file, " int restr_opnd;\n"); + fprintf (header_file, " restriction restr;\n"); + fprintf (header_file, " int restr_val1;\n"); + fprintf (header_file, " int restr_val2;\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, "#define bif_const_bit\t(0x0000001)\n"); + fprintf (header_file, "#define bif_pure_bit\t(0x0000002)\n"); + fprintf (header_file, "#define bif_round_bit\t(0x0000004)\n"); + fprintf (header_file, "#define bif_init_bit\t(0x0000008)\n"); + fprintf (header_file, "#define bif_set_bit\t(0x0000010)\n"); + fprintf (header_file, "#define bif_ext_bit\t(0x0000020)\n"); + fprintf (header_file, "#define bif_nosoft_bit\t(0x0000040)\n"); + fprintf (header_file, "#define bif_ldv_bit\t(0x0000080)\n"); + fprintf (header_file, "#define bif_stv_bit\t(0x0000100)\n"); + fprintf (header_file, "#define bif_reve_bit\t(0x0000200)\n"); + fprintf (header_file, "#define bif_abs_bit\t(0x0000400)\n"); + fprintf (header_file, "#define bif_pred_bit\t(0x0000800)\n"); + fprintf (header_file, "#define bif_htm_bit\t(0x0001000)\n"); + fprintf (header_file, "\n"); + fprintf (header_file, + "#define bif_is_const(x)\t\t((x).bifattrs & bif_const_bit)\n"); + fprintf (header_file, + "#define bif_is_pure(x)\t\t((x).bifattrs & bif_pure_bit)\n"); + fprintf (header_file, + "#define bif_has_rounding(x)\t((x).bifattrs & bif_round_bit)\n"); + fprintf (header_file, + "#define bif_is_init(x)\t\t((x).bifattrs & bif_init_bit)\n"); + fprintf (header_file, + "#define bif_is_extract(x)\t((x).bifattrs & bif_ext_bit)\n"); + fprintf (header_file, + "#define bif_is_nosoft(x)\t((x).bifattrs & bif_nosoft_bit)\n"); + fprintf (header_file, + "#define bif_is_ldv(x)\t\t((x).bifattrs & bif_ldv_bit)\n"); + fprintf (header_file, + "#define bif_is_stv(x)\t\t((x).bifattrs & bif_stv_bit)\n"); + fprintf (header_file, + "#define bif_is_reve(x)\t\t((x).bifattrs & bif_reve_bit)\n"); + fprintf (header_file, + "#define bif_is_abs(x)\t\t((x).bifattrs & bif_abs_bit)\n"); + fprintf (header_file, + "#define bif_is_predicate(x)\t((x).bifattrs & bif_pred_bit)\n"); + fprintf (header_file, + "#define bif_is_htm(x)\t\t((x).bifattrs & bif_htm_bit)\n"); + fprintf (header_file, "\n"); + + /* #### Note that the _x is added for now to avoid conflict with + the existing rs6000_builtin_info[] file while testing. It will + be removed as we progress. */ + fprintf (header_file, "extern bifdata rs6000_builtin_info_x[];\n\n"); + + fprintf (header_file, + "struct rs6000_bif_hasher : nofree_ptr_hash\n"); + fprintf (header_file, "{\n"); + fprintf (header_file, " typedef const char *compare_type;\n\n"); + fprintf (header_file, " static hashval_t hash (bifdata *);\n"); + fprintf (header_file, " static bool equal (bifdata *, const char *);\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, "extern hash_table 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_MAX\n};\n\n"); + + fprintf (header_file, "struct ovlddata\n"); + fprintf (header_file, "{\n"); + fprintf (header_file, " const char *bifname;\n"); + fprintf (header_file, " rs6000_gen_builtins bifid;\n"); + fprintf (header_file, " tree fntype;\n"); + fprintf (header_file, " ovlddata *next;\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, "extern ovlddata rs6000_overload_info[];\n\n"); + + fprintf (header_file, + "struct rs6000_ovld_hasher : nofree_ptr_hash\n"); + fprintf (header_file, "{\n"); + fprintf (header_file, " typedef const char *compare_type;\n\n"); + fprintf (header_file, " static hashval_t hash (ovlddata *);\n"); + fprintf (header_file, " static bool equal (ovlddata *, const char *);\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, + "extern hash_table ovld_hash;\n\n"); + + fprintf (header_file, "extern void rs6000_autoinit_builtins ();\n\n"); +} + +/* Callback functions used for generating trees for function types. */ +void +write_extern_fntype (char *str) +{ + fprintf (header_file, "extern tree %s;\n", str); +} + /* Write everything to the header file (rs6000-bif.h). */ static int write_header_file () { + write_autogenerated_header (header_file); + fprintf (header_file, "#include \"config.h\"\n"); + fprintf (header_file, "#include \"system.h\"\n"); + fprintf (header_file, "#include \"coretypes.h\"\n"); + fprintf (header_file, "#include \"backend.h\"\n"); + fprintf (header_file, "#include \"rtl.h\"\n"); + fprintf (header_file, "#include \"tree.h\"\n"); + fprintf (header_file, "\n"); + fprintf (header_file, "#undef NEW_BUILTINS_ARE_LIVE\n\n"); + + write_decls (); + + /* Write function type list declarators to the header file. */ + rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_extern_fntype); + fprintf (header_file, "\n"); + return 1; }