From patchwork Thu Feb 4 20:40:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1436298 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; 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=JOd6eqtQ; dkim-atps=neutral Received: from sourceware.org (unknown [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 4DWr6D2HdXz9sWk for ; Fri, 5 Feb 2021 07:40:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F2C7C396AC2D; Thu, 4 Feb 2021 20:40:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2C7C396AC2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1612471227; bh=ZG4zxoyG9UGYwK9yJ7IUKzger29gsBgEADzttrmhMjQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JOd6eqtQKty9W+35yeb2B4PDipeOclBKTlkp4zfkO89aD4atCPgQqvFPbXD4Q89Ym yA5jiqnW10VN79VfjZsvwuVMWiLQsWF1Mtl4jZ1ehYPtMwYmsdqeJp/C1N1WzijFA5 Qc7ZDuPOl2OA2BwfppLHOqU2nHFrvA+njHnwhtY4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 43988396AC0C for ; Thu, 4 Feb 2021 20:40:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43988396AC0C Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 114KW7LT108419; Thu, 4 Feb 2021 15:40:22 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 36gr1c07dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 15:40:22 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 114KcAnb031379; Thu, 4 Feb 2021 20:40:22 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 36f3kvsgds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 20:40:22 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 114KeL2Y30343666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Feb 2021 20:40:21 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76055124054; Thu, 4 Feb 2021 20:40:21 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00BB5124052; Thu, 4 Feb 2021 20:40:20 +0000 (GMT) Received: from [9.160.87.37] (unknown [9.160.87.37]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 4 Feb 2021 20:40:20 +0000 (GMT) To: Segher Boessenkool Subject: [PATCH] rs6000: Fix MMA API - Add support for compatibility built-ins Message-ID: <12ebce7f-29c0-3d98-c2f2-e6d3135ff043@linux.ibm.com> Date: Thu, 4 Feb 2021 14:40:20 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.737 definitions=2021-02-04_10:2021-02-04, 2021-02-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040122 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Cc: GCC Patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The LLVM and GCC teams agreed to rename the __builtin_mma_assemble_pair and __builtin_mma_disassemble_pair built-ins to __builtin_vsx_assemble_pair and __builtin_vsx_disassemble_pair respectively. It's too late to remove the old names, so this patch adds support for creating compatibility built-ins (ie, multiple built-in functions generate the same code) and then creates compatibility built-ins using the new names. This passed bootstrap and regtesting on powerpc64le-linux with no regressions. Ok for mainline? This will need backporting to GCC 10. Ok there too once it's baked on trunk for a little while? Peter gcc/ * gcc/config/rs6000/rs6000-builtin.def (BU_COMPAT): Add support macro for defining compatibility built-ins. (vsx_assemble_pair): Add compatibility built-in. * gcc/config/rs6000/rs6000-call.c (struct builtin_compatibility): New. (bdesc_compat): New. (RS6000_BUILTIN_COMPAT): Define. (rs6000_init_builtins): Register compatibility built-ins. * gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c: Add tests for __builtin_vsx_assemble_pair and __builtin_vsx_disassemble_pair. Update expected instruction counts. diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 058a32abf4c..268f5d5b52b 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -43,6 +43,10 @@ ATTR builtin attribute information. ICODE Insn code of the function that implements the builtin. */ +#ifndef RS6000_BUILTIN_COMPAT + #undef BU_COMPAT + #define BU_COMPAT(ENUM, COMPAT_NAME) + #ifndef RS6000_BUILTIN_0 #error "RS6000_BUILTIN_0 is not defined." #endif @@ -87,6 +91,36 @@ #error "RS6000_BUILTIN_X is not defined." #endif +#else + /* Compatibility builtins. These builtins are simply mapped into + their compatible builtin function identified by ENUM. */ + #undef BU_COMPAT + #define BU_COMPAT(ENUM, COMPAT_NAME) { ENUM, "__builtin_" COMPAT_NAME }, + + #undef RS6000_BUILTIN_0 + #undef RS6000_BUILTIN_1 + #undef RS6000_BUILTIN_2 + #undef RS6000_BUILTIN_3 + #undef RS6000_BUILTIN_4 + #undef RS6000_BUILTIN_A + #undef RS6000_BUILTIN_D + #undef RS6000_BUILTIN_H + #undef RS6000_BUILTIN_M + #undef RS6000_BUILTIN_P + #undef RS6000_BUILTIN_X + #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_4(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_M(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) + #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) +#endif + #ifndef BU_AV_1 /* Define convenience macros using token pasting to allow fitting everything in one line. */ @@ -3137,8 +3171,10 @@ BU_MMA_1 (XXSETACCZ, "xxsetaccz", MISC, mma_xxsetaccz) BU_MMA_2 (DISASSEMBLE_ACC, "disassemble_acc", QUAD, mma_disassemble_acc) BU_MMA_2 (DISASSEMBLE_PAIR,"disassemble_pair", PAIR, mma_disassemble_pair) +BU_COMPAT (MMA_BUILTIN_DISASSEMBLE_PAIR, "vsx_disassemble_pair") BU_MMA_3 (ASSEMBLE_PAIR, "assemble_pair", MISC, mma_assemble_pair) +BU_COMPAT (MMA_BUILTIN_ASSEMBLE_PAIR, "vsx_assemble_pair") BU_MMA_3 (XVBF16GER2, "xvbf16ger2", MISC, mma_xvbf16ger2) BU_MMA_3 (XVF16GER2, "xvf16ger2", MISC, mma_xvf16ger2) BU_MMA_3 (XVF32GER, "xvf32ger", MISC, mma_xvf32ger) diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index ae0c761f0a4..240533dec55 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -89,6 +89,12 @@ #define TARGET_NO_PROTOTYPE 0 #endif +struct builtin_compatibility +{ + const enum rs6000_builtins code; + const char *const name; +}; + struct builtin_description { const HOST_WIDE_INT mask; @@ -8839,6 +8845,13 @@ def_builtin (const char *name, tree type, enum rs6000_builtins code) (int)code, name, attr_string); } +static const struct builtin_compatibility bdesc_compat[] = +{ +#define RS6000_BUILTIN_COMPAT +#include "rs6000-builtin.def" +}; +#undef RS6000_BUILTIN_COMPAT + /* Simple ternary operations: VECd = foo (VECa, VECb, VECc). */ #undef RS6000_BUILTIN_0 @@ -13445,6 +13458,18 @@ rs6000_init_builtins (void) #ifdef SUBTARGET_INIT_BUILTINS SUBTARGET_INIT_BUILTINS; #endif + + /* Register the compatibility builtins after all of the normal + builtins have been defined. */ + const struct builtin_compatibility *d = bdesc_compat; + unsigned i; + for (i = 0; i < ARRAY_SIZE (bdesc_compat); i++, d++) + { + tree decl = rs6000_builtin_decls[(int)d->code]; + gcc_assert (decl != NULL); + add_builtin_function (d->name, TREE_TYPE (decl), (int)d->code, + BUILT_IN_MD, NULL, NULL_TREE); + } } /* Returns the rs6000 builtin decl for CODE. */ diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c index f3a857bb8c1..4b1ba3148e2 100644 --- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c @@ -12,6 +12,14 @@ foo (__vector_pair *dst, vec_t *src) *dst = pair; } +void +foo2 (__vector_pair *dst, vec_t *src) +{ + __vector_pair pair; + __builtin_vsx_assemble_pair (&pair, src[0], src[4]); + *dst = pair; +} + void bar (vec_t *dst, __vector_pair *src) { @@ -21,8 +29,17 @@ bar (vec_t *dst, __vector_pair *src) dst[4] = res[1]; } -/* { dg-final { scan-assembler-times {\mlxv\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mlxvp\M} 1 } } */ -/* { dg-final { scan-assembler-times {\mstxv\M} 2 } } */ -/* { dg-final { scan-assembler-times {\mstxvp\M} 1 } } */ +void +bar2 (vec_t *dst, __vector_pair *src) +{ + vec_t res[2]; + __builtin_vsx_disassemble_pair (res, src); + dst[0] = res[0]; + dst[4] = res[1]; +} + +/* { dg-final { scan-assembler-times {\mlxv\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */ +/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */ +/* { dg-final { scan-assembler-times {\mstxvp\M} 2 } } */