From patchwork Thu Jun 17 15:19:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1493622 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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=xdg6+8eV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4G5R8W2rcZz9sSs for ; Fri, 18 Jun 2021 01:40:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 684A63959E52 for ; Thu, 17 Jun 2021 15:40:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 684A63959E52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623944424; bh=IHhFGhQQrORP/0umpEEgqoioSf3seO5FkYDICPUh8YE=; 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=xdg6+8eVOw+nkZnFRhVTLCnZgw594G+s+Fa4XxkK2y1KAEIB1c/8bKrS/+FfnVMcK r0U9/VUGQUsfoH2u0lEPwiG4+yGVx5X4+uM/WaJUNIlBIF9J5jHli1ay6/K3lgEN1u /GanqxKQcdPf7f9194MyegXUZgqymoLbVRkqJMhk= 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 0C3D2395C80C for ; Thu, 17 Jun 2021 15:21:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C3D2395C80C Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15HF3nPt164932; Thu, 17 Jun 2021 11:21:42 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 39873s4qtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Jun 2021 11:21:42 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15HFCK51001785; Thu, 17 Jun 2021 15:21:41 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 3980b9cve0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Jun 2021 15:21:41 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15HFLenQ29425976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jun 2021 15:21:40 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C8EF6E04C; Thu, 17 Jun 2021 15:21:40 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0F7B6E050; Thu, 17 Jun 2021 15:21:39 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 17 Jun 2021 15:21:39 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 18/55] rs6000: Write output to the builtins init file, part 1 of 3 Date: Thu, 17 Jun 2021 10:19:02 -0500 Message-Id: <9b7092a69c5849d5b4911c01054481fdc7a0e099.1623941441.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-ORIG-GUID: cMwq59dLoHhXc-787EUiJdCf09xRVJsl X-Proofpoint-GUID: cMwq59dLoHhXc-787EUiJdCf09xRVJsl X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-17_13:2021-06-15, 2021-06-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106170096 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: segher@kernel.crashing.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 2021-06-07 Bill Schmidt gcc/ * config/rs6000/rs6000-gen-builtins.c (write_fntype): New callback function. (write_fntype_init): New stub function. (write_init_bif_table): Likewise. (write_init_ovld_table): New function. (write_init_file): Implement. --- gcc/config/rs6000/rs6000-gen-builtins.c | 163 ++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index 6f393ee46d3..2240dfc030f 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -2202,6 +2202,18 @@ write_extern_fntype (char *str) fprintf (header_file, "extern GTY(()) 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 (void) @@ -2222,10 +2234,161 @@ write_header_file (void) return 1; } +/* Write code to initialize the built-in function table. */ +static void +write_init_bif_table (void) +{ +} + +/* Write code to initialize the overload table. */ +static void +write_init_ovld_table (void) +{ + fprintf (init_file, " int base = RS6000_OVLD_NONE;\n\n"); + + for (int i = 0; i <= curr_ovld; i++) + { + fprintf (init_file, + " rs6000_instance_info[RS6000_INST_%s].fntype" + "\n = %s;\n", + ovlds[i].ovld_id_name, ovlds[i].fndecl); + + if (i == 0 || ovlds[i].stanza != ovlds[i-1].stanza) + { + ovld_stanza *stanza = &ovld_stanzas[ovlds[i].stanza]; + fprintf (init_file, "\n"); + + /* Check whether we have a "tf" token in this string, representing + a float128_type_node. It's possible that float128_type_node is + undefined (occurs for -maltivec -mno-vsx, for example), so we + must guard against that. */ + int tf_found = strstr (ovlds[i].fndecl, "tf") != NULL; + + /* Similarly, look for decimal float tokens. */ + int dfp_found = (strstr (ovlds[i].fndecl, "dd") != NULL + || strstr (ovlds[i].fndecl, "td") != NULL + || strstr (ovlds[i].fndecl, "sd") != NULL); + + /* The fndecl for an overload is arbitrarily the first one + for the overload. We sort out the real types when + processing the overload in the gcc front end. */ + fprintf (init_file, + " if (new_builtins_are_live)\n"); + fprintf (init_file, " {\n"); + + if (tf_found) + { + fprintf (init_file, " if (float128_type_node)\n"); + fprintf (init_file, " {\n"); + } + else if (dfp_found) + { + fprintf (init_file, " if (dfloat64_type_node)\n"); + fprintf (init_file, " {\n"); + } + + fprintf (init_file, + " rs6000_builtin_decls_x[(int)RS6000_OVLD_%s] = t\n", + stanza->stanza_id); + fprintf (init_file, + " = add_builtin_function (\"%s\",\n", + stanza->intern_name); + fprintf (init_file, + " %s,\n", + ovlds[i].fndecl); + fprintf (init_file, + " (int)RS6000_OVLD_%s," + " BUILT_IN_MD,\n", + stanza->stanza_id); + fprintf (init_file, + " NULL, NULL_TREE);\n"); + + if (tf_found || dfp_found) + fprintf (init_file, " }\n"); + + fprintf (init_file, " }\n\n"); + + fprintf (init_file, + " rs6000_overload_info[RS6000_OVLD_%s - base]" + ".first_instance\n", + stanza->stanza_id); + fprintf (init_file, + " = &rs6000_instance_info[RS6000_INST_%s];\n\n", + ovlds[i].ovld_id_name); + } + } +} + /* Write everything to the initialization file (rs6000-builtins.c). */ static int write_init_file (void) { + 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"); + + fprintf (init_file, "int new_builtins_are_live = 0;\n\n"); + + fprintf (init_file, "tree rs6000_builtin_decls_x[RS6000_OVLD_MAX];\n\n"); + + rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype); + fprintf (init_file, "\n"); + + fprintf (init_file, "void\n"); + fprintf (init_file, "rs6000_autoinit_builtins ()\n"); + fprintf (init_file, "{\n"); + fprintf (init_file, " tree t;\n"); + rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype_init); + fprintf (init_file, "\n"); + + fprintf (init_file, + " rs6000_builtin_decls_x[RS6000_BIF_NONE] = NULL_TREE;\n"); + fprintf (init_file, + " rs6000_builtin_decls_x[RS6000_BIF_MAX] = NULL_TREE;\n"); + fprintf (init_file, + " rs6000_builtin_decls_x[RS6000_OVLD_NONE] = NULL_TREE;\n\n"); + + write_init_bif_table (); + write_init_ovld_table (); + + fprintf (init_file, "}\n\n"); + + fprintf (init_file, + "void gt_ggc_mx (bifdata *bd)\n"); + fprintf (init_file, + "{\n gt_ggc_mx (bd->fntype);\n}\n\n"); + fprintf (init_file, + "void gt_pch_nx (bifdata *bd)\n"); + fprintf (init_file, + "{\n gt_pch_nx (bd->fntype);\n}\n\n"); + fprintf (init_file, + "void gt_pch_nx (bifdata *bd, gt_pointer_operator op, " + "void *cookie)\n"); + fprintf (init_file, + "{\n op(&(bd->fntype), cookie);\n}\n\n"); + fprintf (init_file, + "void gt_ggc_mx (ovlddata *od)\n"); + fprintf (init_file, + "{\n gt_ggc_mx (od->fntype);\n}\n\n"); + fprintf (init_file, + "void gt_pch_nx (ovlddata *od)\n"); + fprintf (init_file, + "{\n gt_pch_nx (od->fntype);\n}\n\n"); + fprintf (init_file, + "void gt_pch_nx (ovlddata *od, gt_pointer_operator op, " + "void *cookie)\n"); + fprintf (init_file, + "{\n op(&(od->fntype), cookie);\n}\n"); + return 1; }