From patchwork Fri Jul 21 23:38:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 124149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp525032vqg; Fri, 21 Jul 2023 16:39:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFTiDmqCsjYr2QWFCQF5kMwlGVaD+a60BpHMnSsb/b7TfhaBC9Dm3ARU+fUgx9jAe58QpDi X-Received: by 2002:a17:907:2bc4:b0:997:e7d0:e26d with SMTP id gv4-20020a1709072bc400b00997e7d0e26dmr3372509ejc.4.1689982771692; Fri, 21 Jul 2023 16:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689982771; cv=none; d=google.com; s=arc-20160816; b=a73YhIM28BxbVaG22/eANuGo7AmVLIPAOJVpqwxe9OBBa3vUJ5jo31WG1yLwixVl5d g/J7aKNRy4SKkQynYIn/nguDOxE27e3M+8n2lUNi2UntTG1smMwv+df2VXmvG6CTyHU+ qJX1aD5hLEth0gfrmnz/V5Uquk4pPXt4ymBtAcC5mkZxYJjbL21t7n8WPSBCy8vYU2nv ZqLFdj5J/fGCs5SR2rZzLXu808Zg+78GkNKu3q5Os+O7sY8cmjozhMAEoBCSNDPId8Aa 0xPqnMOMlNRtKm5wVqF0EzshUOjtc3AQGf2NfplPKSxsXUvMtnpKb05mGJ74Wi204X5W 1vfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to:date :cc:to:subject:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=fWp7s5E7d2qH7RyXPryTHCi03wc668MAfSxZYNRouks=; fh=XJAhQtWb2vdlZ1dWbjSf/N4wW/OlQVz5FmpAPVNDEt8=; b=i6WAheiQJ6LPtZTkODfFC5skRPDyHDsjPLHdLS54IohKtQ3KU/J9BAM+U+Pp6V3vUt O14B3KyQVLEFZFwpspZmjopSDNwt38V7HgSNm60AYhuW57F18GyGlM89ftIeBm+NIoMi y8vsR2LSx4/6SLEY/d4qg/pqH7mQxv/mxGTFzjKKfWkHLtT5VOH423MNinWo2+ihOFb/ 0JNngJu2tXDV9UlyIqMKjFzU6iWikt6u5HDiOdVQ9Seo4QRUDk3qbItlAY2MU7swdHjL /rv1+1qGBTFHp+rbOgzUsnL9lVSWCAdfWT+vaLIDCoJQqnhl47Gto5Q7Ib8qFpT6As6V BCKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="r19j/Ejp"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lf16-20020a170906ae5000b00993a68a3af9si2888445ejb.535.2023.07.21.16.39.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 16:39:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="r19j/Ejp"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B5BE3851AB7 for ; Fri, 21 Jul 2023 23:39:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B5BE3851AB7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689982740; bh=fWp7s5E7d2qH7RyXPryTHCi03wc668MAfSxZYNRouks=; h=Subject:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=r19j/EjpXX9thDF5q4DKGPqq1Wk3/EYFDIaOahKy6xAQ27U5mGRrIOzD2K63vtMTR RJOgH0sjXzEpaW6fdBBMfG6doMh6au7eXCS5eTO4g7MAdnJP4IC6MMHxsD9oWZOqTR b3roHudJ7o/wGY3VaksdarCnIpCG6xOZArd93Ew8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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 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> X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 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 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: Carl Love via Gcc-patches From: Carl Love Reply-To: Carl Love Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772075374688383743 X-GMAIL-MSGID: 1772075374688383743 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;