From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 221293855587 for ; Fri, 21 Jul 2023 23:38:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 221293855587 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=us.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36LN8jcO025793; Fri, 21 Jul 2023 23:38:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=fWp7s5E7d2qH7RyXPryTHCi03wc668MAfSxZYNRouks=; b=Zhf1NnKa6VtWJB8jZLJ4oNqkAyVxnO1nBTxdrRs2B0ClR84w+4/mvBdix0nVAVWH/0pV Dzark0NrHHH5+XUTPpcnAQB9ShMDVjLHYLE9T1Z8JDnvg38PmKzd59cO26ex77oIw6VY UralCMaoMqr2x2PXGMsVcZDUB/iOlF8TNjGLAPJX5qyAO8ZOli3MIANnuadC+Flyzu86 7P5whKcE4mYCHk2AHCRCd4ZYAVSrkknLi9AZAP7hFc+1x8feY8FBYBgX0RQvgmYQjqWk omYuAIEQXnAZwJg6zMhVQjuI5tSWQ/lFm/i/dMvS8NgAAbtFNYp30gaWAJGKa5B8V1kr 0g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s036bgfvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 23:38:08 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36LNc0gT028123; Fri, 21 Jul 2023 23:38:07 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s036bgfuw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 23:38:07 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36LMk4mX016914; Fri, 21 Jul 2023 23:38:07 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3rv5ssbfq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 23:38:07 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36LNc5Q81770182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 23:38:05 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C79D358059; Fri, 21 Jul 2023 23:38:05 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1201458043; Fri, 21 Jul 2023 23:38:05 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.61.185.149]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jul 2023 23:38:04 +0000 (GMT) Message-ID: Subject: [PATCH 1/2 ver 2] rs6000, add argument to function find_instance From: Carl Love To: "Kewen.Lin" , Segher Boessenkool , David Edelsohn , gcc-patches@gcc.gnu.org Cc: Peter Bergner , cel@us.ibm.com Date: Fri, 21 Jul 2023 16:38:04 -0700 In-Reply-To: <03669543c8fc64dfb6a7f5324606bf9209f25ad7.camel@us.ibm.com> References: <03669543c8fc64dfb6a7f5324606bf9209f25ad7.camel@us.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: X4P9gNTd4r9iUvlIPxbC5r1dAzy-c9aL X-Proofpoint-ORIG-GUID: pjTcb-lx767PurHo7TFkQ03SSRrW92k5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-21_12,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 suspectscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210209 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: GCC maintainers: Version 2: Updated a number of formatting and spacing issues. Added the NARGS description to the header comment for function find_instance. This patch was tested on Power 8 LE/BE, Power 9 LE/BE and Power 10 LE with no regressions. The rs6000 function find_instance assumes that it is called for built- ins with only two arguments. There is no checking for the actual number of aruguments used in the built-in. This patch adds an additional parameter to the function call containing the number of aruguments in the built-in. The function will now do the needed checks for all of the arguments. This fix is needed for the next patch in the series that fixes the vec_replace_unaligned built-in.c test. Please let me know if this patch is acceptable for mainline. Thanks. Carl ------------------------------------- rs6000, add argument to function find_instance The function find_instance assumes it is called to check a built-in with only two arguments. This patch extends the function by adding a parameter specifying the number of built-in arguments to check. gcc/ChangeLog: * config/rs6000/rs6000-c.cc (find_instance): Add new parameter that specifies the number of built-in arguments to check. (altivec_resolve_overloaded_builtin): Update calls to find_instance to pass the number of built-in arguments to be checked. --- gcc/config/rs6000/rs6000-c.cc | 40 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index a353bca19ef..de35490de42 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -1668,18 +1668,20 @@ resolve_vec_step (resolution *res, vec *arglist, unsigned nargs) /* Look for a matching instance in a chain of instances. INSTANCE points to the chain of instances; INSTANCE_CODE is the code identifying the specific built-in being searched for; FCODE is the overloaded function code; TYPES - contains an array of two types that must match the types of the instance's - parameters; and ARGS contains an array of two arguments to be passed to - the instance. If found, resolve the built-in and return it, unless the - built-in is not supported in context. In that case, set - UNSUPPORTED_BUILTIN to true. If we don't match, return error_mark_node - and leave UNSUPPORTED_BUILTIN alone. */ + contains an array of NARGS types that must match the types of the + instance's parameters; ARGS contains an array of NARGS arguments to be + passed to the instance; and NARGS is the number of built-in arguments to + check. If found, resolve the built-in and return it, unless the built-in + is not supported in context. In that case, set UNSUPPORTED_BUILTIN to + true. If we don't match, return error_mark_node and leave + UNSUPPORTED_BUILTIN alone. +*/ tree find_instance (bool *unsupported_builtin, ovlddata **instance, rs6000_gen_builtins instance_code, rs6000_gen_builtins fcode, - tree *types, tree *args) + tree *types, tree *args, int nargs) { while (*instance && (*instance)->bifid != instance_code) *instance = (*instance)->next; @@ -1691,17 +1693,27 @@ find_instance (bool *unsupported_builtin, ovlddata **instance, if (!inst->fntype) return error_mark_node; tree fntype = rs6000_builtin_info[inst->bifid].fntype; - tree parmtype0 = TREE_VALUE (TYPE_ARG_TYPES (fntype)); - tree parmtype1 = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (fntype))); + tree argtype = TYPE_ARG_TYPES (fntype); + bool args_compatible = true; - if (rs6000_builtin_type_compatible (types[0], parmtype0) - && rs6000_builtin_type_compatible (types[1], parmtype1)) + for (int i = 0; i < nargs; i++) + { + tree parmtype = TREE_VALUE (argtype); + if (!rs6000_builtin_type_compatible (types[i], parmtype)) + { + args_compatible = false; + break; + } + argtype = TREE_CHAIN (argtype); + } + + if (args_compatible) { if (rs6000_builtin_decl (inst->bifid, false) != error_mark_node && rs6000_builtin_is_supported (inst->bifid)) { tree ret_type = TREE_TYPE (inst->fntype); - return altivec_build_resolved_builtin (args, 2, fntype, ret_type, + return altivec_build_resolved_builtin (args, nargs, fntype, ret_type, inst->bifid, fcode); } else @@ -1921,7 +1933,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, instance_code = RS6000_BIF_CMPB_32; tree call = find_instance (&unsupported_builtin, &instance, - instance_code, fcode, types, args); + instance_code, fcode, types, args, nargs); if (call != error_mark_node) return call; break; @@ -1958,7 +1970,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, } tree call = find_instance (&unsupported_builtin, &instance, - instance_code, fcode, types, args); + instance_code, fcode, types, args, nargs); if (call != error_mark_node) return call; break; -- 2.37.2