From patchwork Wed Jun 17 19:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1311457 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=HGgk3Wse; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49nFx61T8Gz9sR4 for ; Thu, 18 Jun 2020 05:48:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F240399783C; Wed, 17 Jun 2020 19:47:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F240399783C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592423272; bh=YfBWWbcFvV5RXAl2+5U7Gjjgx/Km9gtSwZUIZjf+t4k=; h=To:Subject:Date:In-Reply-To:References:In-Reply-To:References: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=HGgk3WseWDPxFWXEVZMseMaNAnxaX7Dd/Kw32bhBM1YGH+R7jJzVUvxZIKt5Uh7+O MEcwQ5WaSLqUS8Lil4GTu4wH14p8LEhelnXdUDlQsWmSOCRuQrakOtMaJMf4+T4GmE 9giCC4FP4ETT8bn8nJioH/+/2zhnz9FWEP9cBUOY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id F357A3997824 for ; Wed, 17 Jun 2020 19:47:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F357A3997824 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05HJaufL075754; Wed, 17 Jun 2020 15:47:48 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q8p4qvvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 15:47:48 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05HJdj4w085944; Wed, 17 Jun 2020 15:47:47 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q8p4qvvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 15:47:47 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05HJiHZa024217; Wed, 17 Jun 2020 19:47:46 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma01dal.us.ibm.com with ESMTP id 31q9v65w70-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2020 19:47:46 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05HJlkYN45023706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jun 2020 19:47:46 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E773828059; Wed, 17 Jun 2020 19:47:45 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE13228058; Wed, 17 Jun 2020 19:47:45 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 17 Jun 2020 19:47:45 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 16/28] rs6000: Write output to the builtins header file Date: Wed, 17 Jun 2020 14:46:39 -0500 Message-Id: <5b41f079194a0cd6318f1072d12d3b8b1af7fa92.1592419212.git.wschmidt@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-17_10:2020-06-17, 2020-06-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=1 bulkscore=0 priorityscore=1501 cotscore=-2147483648 adultscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006170149 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bill Schmidt via Gcc-patches From: Bill Schmidt Reply-To: Bill Schmidt Cc: dje.gcc@gmail.com, segher@kernel.crashing.org, willschm@linux.ibm.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 2020-06-17 Bill Schmidt * config/rs6000/rs6000-gen-builtins.c (write_autogenerated_header): New function. (write_bif_enum): Likewise. (write_ovld_enum): Likewise. (write_decls): Likewise. (write_extern_fntype): Likewise. (write_header_file): Implement. --- gcc/config/rs6000/rs6000-gen-builtins.c | 169 ++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index a54b522a6b3..f80cd61d6ec 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -1812,10 +1812,179 @@ 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_VAR_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, " HOST_WIDE_INT mask;\n"); + fprintf (header_file, " tree fntype;\n"); + fprintf (header_file, " insn_code icode;\n"); + fprintf (header_file, " int nargs;\n"); + fprintf (header_file, " int bifattrs;\n"); + fprintf (header_file, " int restr_opnd[2];\n"); + fprintf (header_file, " restriction restr[2];\n"); + fprintf (header_file, " int restr_val1[2];\n"); + fprintf (header_file, " int restr_val2[2];\n"); + fprintf (header_file, "};\n\n"); + + fprintf (header_file, "#define bif_init_bit\t\t(0x00000001)\n"); + fprintf (header_file, "#define bif_set_bit\t\t(0x00000002)\n"); + fprintf (header_file, "#define bif_extract_bit\t\t(0x00000004)\n"); + fprintf (header_file, "#define bif_nosoft_bit\t\t(0x00000008)\n"); + fprintf (header_file, "#define bif_ldvec_bit\t\t(0x00000010)\n"); + fprintf (header_file, "#define bif_stvec_bit\t\t(0x00000020)\n"); + fprintf (header_file, "#define bif_reve_bit\t\t(0x00000040)\n"); + fprintf (header_file, "#define bif_pred_bit\t\t(0x00000080)\n"); + fprintf (header_file, "#define bif_htm_bit\t\t(0x00000100)\n"); + fprintf (header_file, "#define bif_htmspr_bit\t\t(0x00000200)\n"); + fprintf (header_file, "#define bif_htmcr_bit\t\t(0x00000400)\n"); + fprintf (header_file, "#define bif_no32bit_bit\t\t(0x00000800)\n"); + fprintf (header_file, "#define bif_cpu_bit\t\t(0x00001000)\n"); + fprintf (header_file, "#define bif_ldstmask_bit\t(0x00002000)\n"); + fprintf (header_file, "\n"); + fprintf (header_file, + "#define bif_is_init(x)\t\t((x).bifattrs & bif_init_bit)\n"); + fprintf (header_file, + "#define bif_is_set(x)\t\t((x).bifattrs & bif_set_bit)\n"); + fprintf (header_file, + "#define bif_is_extract(x)\t((x).bifattrs & bif_extract_bit)\n"); + fprintf (header_file, + "#define bif_is_nosoft(x)\t((x).bifattrs & bif_nosoft_bit)\n"); + fprintf (header_file, + "#define bif_is_ldvec(x)\t\t((x).bifattrs & bif_ldvec_bit)\n"); + fprintf (header_file, + "#define bif_is_stvec(x)\t\t((x).bifattrs & bif_stvec_bit)\n"); + fprintf (header_file, + "#define bif_is_reve(x)\t\t((x).bifattrs & bif_reve_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, + "#define bif_is_htmspr(x)\t((x).bifattrs & bif_htmspr_bit)\n"); + fprintf (header_file, + "#define bif_is_htmcr(x)\t\t((x).bifattrs & bif_htmcr_bit)\n"); + fprintf (header_file, + "#define bif_is_no32bit(x)\t((x).bifattrs & bif_no32bit_bit)\n"); + fprintf (header_file, + "#define bif_is_cpu(x)\t\t((x).bifattrs & bif_cpu_bit)\n"); + fprintf (header_file, + "#define bif_is_ldstmask(x)\t((x).bifattrs " + "& bif_ldstmask_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-builtins.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, "extern int 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; }