From patchwork Tue Apr 18 13:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 84850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2864534vqo; Tue, 18 Apr 2023 06:48:09 -0700 (PDT) X-Google-Smtp-Source: AKy350b2dU2UQYGoeOO3pKchecAPKlJ1CZRHzsq0RGI3RIJa8KL8nhc6iZwX0T3a49VZ8h5SLil6 X-Received: by 2002:a17:906:564e:b0:94e:ec0f:455 with SMTP id v14-20020a170906564e00b0094eec0f0455mr10630547ejr.54.1681825689035; Tue, 18 Apr 2023 06:48:09 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ev3-20020a17090729c300b0094f78ca58d6si4133070ejc.1016.2023.04.18.06.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 06:48:09 -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="G+4fHBJ/"; arc=fail (signature failed); 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 197C23856976 for ; Tue, 18 Apr 2023 13:47:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 197C23856976 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681825672; bh=gPdk7QTKQhX37dTQXICxCq5ijvxH1uce/uVqST1foNg=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=G+4fHBJ/GaQwO8ztfR7sfDLylbvldB248zcVCvBrOD6tDU+KHyLhQ3nHCsd6y2LtB CwU5Xof5Rbj1C8ZffqTQawqo+QOhMOIxJCMutDM2fRGTEUu5xQLQ3vRSxUB29Ju/BD tXtRltuVn8aRpvjWNK/s7fE5k80L5CkH4IxrRLdU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2083.outbound.protection.outlook.com [40.107.8.83]) by sourceware.org (Postfix) with ESMTPS id BF60B3857706 for ; Tue, 18 Apr 2023 13:47:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF60B3857706 Received: from AS9PR06CA0025.eurprd06.prod.outlook.com (2603:10a6:20b:462::30) by AS8PR08MB7910.eurprd08.prod.outlook.com (2603:10a6:20b:50b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Tue, 18 Apr 2023 13:46:58 +0000 Received: from AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:462:cafe::7d) by AS9PR06CA0025.outlook.office365.com (2603:10a6:20b:462::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 13:46:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT027.mail.protection.outlook.com (100.127.140.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 13:46:57 +0000 Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Tue, 18 Apr 2023 13:46:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5f9b59d12e6ebe24 X-CR-MTA-TID: 64aa7808 Received: from 166005639cd1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9FBA5E15-FAEB-4B95-BCB9-CAFFB15A67AA.1; Tue, 18 Apr 2023 13:46:46 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 166005639cd1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 Apr 2023 13:46:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XSEbJGr+EEahB2AviV3LWZU4jnfxzQPPvil37wNwSXoJ83lBF6abG7RiX0ozJPTJFummA4pmIwWy1ltOyZKycfCGWQxLKSm4ENL3CHWQ3EFYT+sGJfHYMmd/ER4X8wC+je3aIALi80DHZs14vOe6AVUyyztJ0Jeb355vpFMDKIKOubVd+iisJwQYT7SsP1/sEKqFjnqeqr4rqmR2HhruJQPJmkkEfNH5U2EJINloFr67f7huSZshh7CA/ubjvzAozK3LU1SYa0i3wVqimIL/o1I57It59ZVDha5L0E5lWAz5qHfluJ2fjeDWdMWArY6VPtqqG6h8yXajGcuSytK/Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gPdk7QTKQhX37dTQXICxCq5ijvxH1uce/uVqST1foNg=; b=DAa6Va6YWRBbLdHAedJL9UueHVIAE4uMWgDpLkSpklNearDurAwHYnpyA5X7X6DaLRz/hkV5+kVp2MkjrHAzv8zGhKs+auSPl7mgag1MDtKaPJ19V7BouW0GKTNuvX4nZ7Xfyip0RTnd+NaRWtIKy4dSK04Vf6divpUtl+ngjZQJye2wzrWvT7VE+cDmzkBZ77jctfivpAPdy6ufyIi6S1sDaG8K1P/gXuKa3Xa2p/paBkv+UAz5hKMoXOJIOWyZ5B9N13xXDSfyckCQJfT7ZVPVPRq2mkpMcusw12FkFPN6v1934xnKICCFTxNkJU9XyY4iakWZUzN1CJvTt6Rg9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from AS8P251CA0008.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::26) by AM0PR08MB5521.eurprd08.prod.outlook.com (2603:10a6:208:18a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20; Tue, 18 Apr 2023 13:46:43 +0000 Received: from AM7EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::83) by AS8P251CA0008.outlook.office365.com (2603:10a6:20b:2f2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.47 via Frontend Transport; Tue, 18 Apr 2023 13:46:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT028.mail.protection.outlook.com (100.127.140.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 13:46:43 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 18 Apr 2023 13:46:43 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 18 Apr 2023 13:46:42 +0000 Received: from e129018.arm.com (10.57.54.117) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Tue, 18 Apr 2023 13:46:42 +0000 To: , , , CC: Christophe Lyon Subject: [PATCH 01/22] arm: move builtin function codes into general numberspace Date: Tue, 18 Apr 2023 15:45:47 +0200 Message-ID: <20230418134608.244751-2-christophe.lyon@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418134608.244751-1-christophe.lyon@arm.com> References: <20230418134608.244751-1-christophe.lyon@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT028:EE_|AM0PR08MB5521:EE_|AM7EUR03FT027:EE_|AS8PR08MB7910:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fd75661-785b-4e8b-30cd-08db4013610b x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 5Y0ccmyOiLvSOXLRdS2x5U9TNRyHcxwH/XEb+hj9jTACC9s2yazVyKgjFq8GVJqOrLBXZNtxgsM6jR5qVDTzB9WFr37gH0IxKbismCiXpBYgqSymFoMW3ITRXq5Sd4UsPOg2DcIaz7iYD3rN65QW1KfBM9z0jgM3AwYHTpvLbpCmbMJTH3BkTdSjstnT7GVXRc8dxdZcDADp05e+1xRN9eDJEA9Em3jkRGVphC4ewN3S3rHzyzT3wEK4F95XVxOsrQQtPkqFMoiPxzMdEgp1bwknoqev7H6P0AyNeCnhtwyjbPPV65U23PjduCbOSXFzF63P8m4lg2qP/wh+EdNHBbc6C0lcx/kfFCrCxFSw9QHTD6qYFVPQ1eesL1uT1bzHVr9h0IOlEpSzgPozWPqFO12yq6oKexySEC38H1jyRHZBHKPAmzsCFCWSLWrEw4X6PaJoNfurI7khjMiQDebA2b1xQOAadC2TeBqz148YtCXr9B3WqyUuSn6C8wyzUi5x3y9+Nxzn0mXN3Y10n+p+Jy1oyrAG2sB0am4SkGS/JKJJwH/FggpZHX7gIx9Ce7P5mmAMNf63yQGt7Bad/ahmk7rJgQ1PqxxWH0xfFvzB5hkq3utbJ2fBwlVkMsE10eI3LGP7JAshpz6+8ZEJcWMnRdayo9FEmF7OrhNXjeQauQ0Sn0g53nbQPX+xLlmy8veT316NnjhU80nM7DTOy9oFcg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199021)(46966006)(36840700001)(6636002)(110136005)(4326008)(316002)(70586007)(70206006)(478600001)(7696005)(40480700001)(82310400005)(8936002)(8676002)(5660300002)(41300700001)(30864003)(2906002)(44832011)(81166007)(356005)(82740400003)(86362001)(36756003)(426003)(336012)(2616005)(1076003)(26005)(186003)(36860700001)(83380400001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5521 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f410450b-5785-4c69-3ae0-08db40135893 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uSvn993ujoBOXKs8u3b16QM1+iRvzJ3HT6bDrgEt+WtvULubK/08nyj1iJdpdSssacbLusY5ZVyUrLr54i8UHmextfMQYCOHyVhbiodMbFjsU6dtOFPrhQPCUb01CKGXCKGgL88TMLvXZSSEuY1lWVn2iU8h6SAPK7+rWS6K3mlKzBbngIz7pUeB2gxnxSWhyQKFG83Ku9bB7L6RwEKlztaUBcFq4PfXFq4mGU39gcuCSeYJP3bMWBjSpZPGbXw1fo5vzd+53PRN3SFtzFJ1itj5RruxI953JV/JnbQ4OajL3AYpJuiE5oXgWT1reoHawKR+Ci9H4M1rvBx4zLSsxZHhYGQ+Gqf/CIW5aN3NLCXiz5E4ldvNU0FJ7/mm6dBBhfmD2QXyQDoGVZGwrh2mu04sQk1YbKyzFkpXtiMTTru+gHDoSuFno+lxYsFPmvohBzo1IxPt0QlIAf3UeJDJYXJJiZmb6R8RhW/OkQJj/z9QRIZ/zRfPi9EB78R6DMK4fYjEhhreFPhh3MpyWoxQvyUBVPK5XZtFwTwavosP3VHmfIGkScwiS6oCnYQRK+ATTOzK9sLlEBEwTjCmva4/lXarBjAPaF717VS/ZpPq2BHZv9B4iWISg/aw2ep2+N75r7rs2DOaPe21yJlZyaJdTA4Y3h5w/tKLkT2IwoKWFIUeXXuElksxWMFFs7kTZpuq6H2gnly6iHTw+ZdUZsCM2w== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(36756003)(6636002)(4326008)(110136005)(316002)(70586007)(70206006)(7696005)(478600001)(41300700001)(5660300002)(82310400005)(8676002)(8936002)(40480700001)(30864003)(2906002)(44832011)(82740400003)(86362001)(81166007)(426003)(2616005)(336012)(40460700003)(1076003)(26005)(186003)(36860700001)(47076005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 13:46:57.8955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fd75661-785b-4e8b-30cd-08db4013610b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7910 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: Christophe Lyon via Gcc-patches From: Christophe Lyon Reply-To: Christophe Lyon Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763522053588907531?= X-GMAIL-MSGID: =?utf-8?q?1763522053588907531?= This patch introduces a separate numberspace for general arm builtin function codes. The intent of this patch is to separate the space of function codes that may be assigned to general builtins and future MVE intrinsic functions by using the first bit of each function code to differentiate them. This is identical to how SVE intrinsic functions are currently differentiated from general aarch64 builtins. Future intrinsics implementations may also make use of numberspacing by changing the values of ARM_BUILTIN_SHIFT and ARM_BUILTIN_CLASS, and adding themselves to the arm_builtin_class enum. 2022-09-08 Murray Steele Christophe Lyon gcc/ChangeLog: * config/arm/arm-builtins.cc (arm_general_add_builtin_function): New function. (arm_init_builtin): Use arm_general_add_builtin_function instead of arm_add_builtin_function. (arm_init_acle_builtins): Likewise. (arm_init_mve_builtins): Likewise. (arm_init_crypto_builtins): Likewise. (arm_init_builtins): Likewise. (arm_general_builtin_decl): New function. (arm_builtin_decl): Defer to numberspace-specialized functions. (arm_expand_builtin_args): Rename into arm_general_expand_builtin_args. (arm_expand_builtin_1): Rename into arm_general_expand_builtin_1 and ... (arm_general_expand_builtin_1): ... specialize for general builtins. (arm_expand_acle_builtin): Use arm_general_expand_builtin instead of arm_expand_builtin. (arm_expand_mve_builtin): Likewise. (arm_expand_neon_builtin): Likewise. (arm_expand_vfp_builtin): Likewise. (arm_general_expand_builtin): New function. (arm_expand_builtin): Specialize for general builtins. (arm_general_check_builtin_call): New function. (arm_check_builtin_call): Specialize for general builtins. (arm_describe_resolver): Validate numberspace. (arm_cde_end_args): Likewise. * config/arm/arm-protos.h (enum arm_builtin_class): New enum. (ARM_BUILTIN_SHIFT, ARM_BUILTIN_CLASS): New constants. Co-authored-by: Christophe Lyon --- gcc/config/arm/arm-builtins.cc | 226 ++++++++++++++++++++++----------- gcc/config/arm/arm-protos.h | 16 +++ 2 files changed, 165 insertions(+), 77 deletions(-) diff --git a/gcc/config/arm/arm-builtins.cc b/gcc/config/arm/arm-builtins.cc index 9f5c568cbc3..adcb50d2185 100644 --- a/gcc/config/arm/arm-builtins.cc +++ b/gcc/config/arm/arm-builtins.cc @@ -1405,6 +1405,18 @@ static tree arm_simd_polyHI_type_node = NULL_TREE; static tree arm_simd_polyDI_type_node = NULL_TREE; static tree arm_simd_polyTI_type_node = NULL_TREE; +/* Wrapper around add_builtin_function. NAME is the name of the built-in + function, TYPE is the function type, CODE is the function subcode + (relative to ARM_BUILTIN_GENERAL), and ATTRS is the function + attributes. */ +static tree +arm_general_add_builtin_function (const char* name, tree type, + unsigned int code, tree attrs = NULL_TREE) +{ + code = (code << ARM_BUILTIN_SHIFT) | ARM_BUILTIN_GENERAL; + return add_builtin_function (name, type, code, BUILT_IN_MD, NULL, attrs); +} + static const char * arm_mangle_builtin_scalar_type (const_tree type) { @@ -1811,8 +1823,7 @@ arm_init_builtin (unsigned int fcode, arm_builtin_datum *d, snprintf (namebuf, sizeof (namebuf), "%s_%s", prefix, d->name); - fndecl = add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD, - NULL, NULL_TREE); + fndecl = arm_general_add_builtin_function (namebuf, ftype, fcode); arm_builtin_decls[fcode] = fndecl; } @@ -1832,7 +1843,7 @@ arm_init_bf16_types (void) /* Set up ACLE builtins, even builtins for instructions that are not in the current target ISA to allow the user to compile particular modules with different target specific options that differ from the command line - options. Such builtins will be rejected in arm_expand_builtin. */ + options. Such builtins will be rejected in arm_general_expand_builtin. */ static void arm_init_acle_builtins (void) @@ -1845,9 +1856,9 @@ arm_init_acle_builtins (void) intSI_type_node, NULL); arm_builtin_decls[ARM_BUILTIN_SAT_IMM_CHECK] - = add_builtin_function ("__builtin_sat_imm_check", sat_check_fpr, - ARM_BUILTIN_SAT_IMM_CHECK, BUILT_IN_MD, - NULL, NULL_TREE); + = arm_general_add_builtin_function ("__builtin_sat_imm_check", + sat_check_fpr, + ARM_BUILTIN_SAT_IMM_CHECK); for (i = 0; i < ARRAY_SIZE (acle_builtin_data); i++, fcode++) { @@ -1894,13 +1905,13 @@ arm_init_mve_builtins (void) intSI_type_node, NULL); arm_builtin_decls[ARM_BUILTIN_GET_FPSCR_NZCVQC] - = add_builtin_function ("__builtin_arm_get_fpscr_nzcvqc", get_fpscr_nzcvqc, - ARM_BUILTIN_GET_FPSCR_NZCVQC, BUILT_IN_MD, NULL, - NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_get_fpscr_nzcvqc", + get_fpscr_nzcvqc, + ARM_BUILTIN_GET_FPSCR_NZCVQC); arm_builtin_decls[ARM_BUILTIN_SET_FPSCR_NZCVQC] - = add_builtin_function ("__builtin_arm_set_fpscr_nzcvqc", set_fpscr_nzcvqc, - ARM_BUILTIN_SET_FPSCR_NZCVQC, BUILT_IN_MD, NULL, - NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_set_fpscr_nzcvqc", + set_fpscr_nzcvqc, + ARM_BUILTIN_SET_FPSCR_NZCVQC); for (i = 0; i < ARRAY_SIZE (mve_builtin_data); i++, fcode++) { @@ -1912,7 +1923,7 @@ arm_init_mve_builtins (void) /* Set up all the NEON builtins, even builtins for instructions that are not in the current target ISA to allow the user to compile particular modules with different target specific options that differ from the command line - options. Such builtins will be rejected in arm_expand_builtin. */ + options. Such builtins will be rejected in arm_general_expand_builtin. */ static void arm_init_neon_builtins (void) @@ -2006,17 +2017,14 @@ arm_init_crypto_builtins (void) R##_ftype_##A1##_##A2##_##A3 #define CRYPTO1(L, U, R, A) \ arm_builtin_decls[C (U)] \ - = add_builtin_function (N (L), FT1 (R, A), \ - C (U), BUILT_IN_MD, NULL, NULL_TREE); + = arm_general_add_builtin_function (N (L), FT1 (R, A), C (U)); #define CRYPTO2(L, U, R, A1, A2) \ arm_builtin_decls[C (U)] \ - = add_builtin_function (N (L), FT2 (R, A1, A2), \ - C (U), BUILT_IN_MD, NULL, NULL_TREE); + = arm_general_add_builtin_function (N (L), FT2 (R, A1, A2), C (U)); #define CRYPTO3(L, U, R, A1, A2, A3) \ arm_builtin_decls[C (U)] \ - = add_builtin_function (N (L), FT3 (R, A1, A2, A3), \ - C (U), BUILT_IN_MD, NULL, NULL_TREE); + = arm_general_add_builtin_function (N (L), FT3 (R, A1, A2, A3), C (U)); #include "crypto.def" #undef CRYPTO1 @@ -2039,8 +2047,8 @@ arm_init_crypto_builtins (void) || bitmap_bit_p (arm_active_target.isa, FLAG)) \ { \ tree bdecl; \ - bdecl = add_builtin_function ((NAME), (TYPE), (CODE), \ - BUILT_IN_MD, NULL, NULL_TREE); \ + bdecl = arm_general_add_builtin_function ((NAME), (TYPE), \ + (CODE)); \ arm_builtin_decls[CODE] = bdecl; \ } \ } \ @@ -2650,9 +2658,9 @@ arm_init_builtins (void) intSI_type_node, NULL); arm_builtin_decls[ARM_BUILTIN_SIMD_LANE_CHECK] - = add_builtin_function ("__builtin_arm_lane_check", lane_check_fpr, - ARM_BUILTIN_SIMD_LANE_CHECK, BUILT_IN_MD, - NULL, NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_lane_check", + lane_check_fpr, + ARM_BUILTIN_SIMD_LANE_CHECK); if (TARGET_HAVE_MVE) arm_init_mve_builtins (); else @@ -2674,11 +2682,13 @@ arm_init_builtins (void) = build_function_type_list (unsigned_type_node, NULL); arm_builtin_decls[ARM_BUILTIN_GET_FPSCR] - = add_builtin_function ("__builtin_arm_get_fpscr", ftype_get_fpscr, - ARM_BUILTIN_GET_FPSCR, BUILT_IN_MD, NULL, NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_get_fpscr", + ftype_get_fpscr, + ARM_BUILTIN_GET_FPSCR); arm_builtin_decls[ARM_BUILTIN_SET_FPSCR] - = add_builtin_function ("__builtin_arm_set_fpscr", ftype_set_fpscr, - ARM_BUILTIN_SET_FPSCR, BUILT_IN_MD, NULL, NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_set_fpscr", + ftype_set_fpscr, + ARM_BUILTIN_SET_FPSCR); } if (use_cmse) @@ -2686,17 +2696,15 @@ arm_init_builtins (void) tree ftype_cmse_nonsecure_caller = build_function_type_list (unsigned_type_node, NULL); arm_builtin_decls[ARM_BUILTIN_CMSE_NONSECURE_CALLER] - = add_builtin_function ("__builtin_arm_cmse_nonsecure_caller", - ftype_cmse_nonsecure_caller, - ARM_BUILTIN_CMSE_NONSECURE_CALLER, BUILT_IN_MD, - NULL, NULL_TREE); + = arm_general_add_builtin_function ("__builtin_arm_cmse_nonsecure_caller", + ftype_cmse_nonsecure_caller, + ARM_BUILTIN_CMSE_NONSECURE_CALLER); } } -/* Return the ARM builtin for CODE. */ - +/* Implement TARGET_BUILTIN_DECL for general builtins. */ tree -arm_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED) +arm_general_builtin_decl (unsigned code) { if (code >= ARM_BUILTIN_MAX) return error_mark_node; @@ -2704,6 +2712,20 @@ arm_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED) return arm_builtin_decls[code]; } +/* Return the ARM builtin for CODE. */ +tree +arm_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED) +{ + unsigned subcode = code >> ARM_BUILTIN_SHIFT; + switch (code & ARM_BUILTIN_CLASS) + { + case ARM_BUILTIN_GENERAL: + return arm_general_builtin_decl (subcode); + default: + gcc_unreachable (); + } +} + /* Errors in the source file can cause expand_expr to return const0_rtx where we expect a vector. To avoid crashing, use one of the vector clear instructions. */ @@ -2769,7 +2791,7 @@ arm_expand_ternop_builtin (enum insn_code icode, return target; } -/* Subroutine of arm_expand_builtin to take care of binop insns. */ +/* Subroutine of arm_general_expand_builtin to take care of binop insns. */ static rtx arm_expand_binop_builtin (enum insn_code icode, @@ -2809,7 +2831,7 @@ arm_expand_binop_builtin (enum insn_code icode, return target; } -/* Subroutine of arm_expand_builtin to take care of unop insns. */ +/* Subroutine of arm_general_expand_builtin to take care of unop insns. */ static rtx arm_expand_unop_builtin (enum insn_code icode, @@ -2946,11 +2968,11 @@ mve_dereference_pointer (tree exp, tree type, machine_mode reg_mode, build_int_cst (build_pointer_type (array_type), 0)); } -/* Expand a builtin. */ +/* Implement TARGET_EXPAND_BUILTIN for general builtins. */ static rtx -arm_expand_builtin_args (rtx target, machine_mode map_mode, int fcode, - int icode, int have_retval, tree exp, - builtin_arg *args) +arm_general_expand_builtin_args (rtx target, machine_mode map_mode, int fcode, + int icode, int have_retval, tree exp, + builtin_arg *args) { rtx pat; tree arg[SIMD_MAX_BUILTIN_ARGS]; @@ -3234,13 +3256,13 @@ constant_arg: return target; } -/* Expand a builtin. These builtins are "special" because they don't have - symbolic constants defined per-instruction or per instruction-variant. +/* Expand a general builtin. These builtins are "special" because they don't + have symbolic constants defined per-instruction or per instruction-variant. Instead, the required info is looked up in the ARM_BUILTIN_DATA record that is passed into the function. */ static rtx -arm_expand_builtin_1 (int fcode, tree exp, rtx target, +arm_general_expand_builtin_1 (int fcode, tree exp, rtx target, arm_builtin_datum *d) { enum insn_code icode = d->code; @@ -3308,16 +3330,16 @@ arm_expand_builtin_1 (int fcode, tree exp, rtx target, } args[k] = ARG_BUILTIN_STOP; - /* The interface to arm_expand_builtin_args expects a 0 if + /* The interface to arm_general_expand_builtin_args expects a 0 if the function is void, and a 1 if it is not. */ - return arm_expand_builtin_args + return arm_general_expand_builtin_args (target, d->mode, fcode, icode, !is_void, exp, &args[1]); } /* Expand an ACLE builtin, i.e. those registered only if their respective target constraints are met. This check happens within - arm_expand_builtin_args. */ + arm_general_expand_builtin_args. */ static rtx arm_expand_acle_builtin (int fcode, tree exp, rtx target) @@ -3351,11 +3373,12 @@ arm_expand_acle_builtin (int fcode, tree exp, rtx target) ? &acle_builtin_data[fcode - ARM_BUILTIN_ACLE_PATTERN_START] : &cde_builtin_data[fcode - ARM_BUILTIN_CDE_PATTERN_START].base; - return arm_expand_builtin_1 (fcode, exp, target, d); + return arm_general_expand_builtin_1 (fcode, exp, target, d); } -/* Expand an MVE builtin, i.e. those registered only if their respective target - constraints are met. This check happens within arm_expand_builtin. */ +/* Expand an MVE builtin, i.e. those registered only if their respective + target constraints are met. This check happens within + arm_general_expand_builtin. */ static rtx arm_expand_mve_builtin (int fcode, tree exp, rtx target) @@ -3371,7 +3394,7 @@ arm_expand_mve_builtin (int fcode, tree exp, rtx target) arm_builtin_datum *d = &mve_builtin_data[fcode - ARM_BUILTIN_MVE_PATTERN_START]; - return arm_expand_builtin_1 (fcode, exp, target, d); + return arm_general_expand_builtin_1 (fcode, exp, target, d); } /* Expand a Neon builtin, i.e. those registered only if TARGET_NEON holds. @@ -3394,7 +3417,7 @@ arm_expand_neon_builtin (int fcode, tree exp, rtx target) arm_builtin_datum *d = &neon_builtin_data[fcode - ARM_BUILTIN_NEON_PATTERN_START]; - return arm_expand_builtin_1 (fcode, exp, target, d); + return arm_general_expand_builtin_1 (fcode, exp, target, d); } /* Expand a VFP builtin. These builtins are treated like @@ -3415,25 +3438,18 @@ arm_expand_vfp_builtin (int fcode, tree exp, rtx target) arm_builtin_datum *d = &vfp_builtin_data[fcode - ARM_BUILTIN_VFP_PATTERN_START]; - return arm_expand_builtin_1 (fcode, exp, target, d); + return arm_general_expand_builtin_1 (fcode, exp, target, d); } -/* Expand an expression EXP that calls a built-in function, - with result going to TARGET if that's convenient - (and in mode MODE if that's convenient). - SUBTARGET may be used as the target for computing one of EXP's operands. - IGNORE is nonzero if the value is to be ignored. */ - +/* Implement TARGET_EXPAND_BUILTIN for general builtins. */ rtx -arm_expand_builtin (tree exp, +arm_general_expand_builtin (unsigned int fcode, + tree exp, rtx target, - rtx subtarget ATTRIBUTE_UNUSED, - machine_mode mode ATTRIBUTE_UNUSED, int ignore ATTRIBUTE_UNUSED) { const struct builtin_description * d; enum insn_code icode; - tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); tree arg0; tree arg1; tree arg2; @@ -3441,7 +3457,6 @@ arm_expand_builtin (tree exp, rtx op1; rtx op2; rtx pat; - unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl); size_t i; machine_mode tmode; machine_mode mode0; @@ -4052,6 +4067,31 @@ arm_expand_builtin (tree exp, return NULL_RTX; } +/* Expand an expression EXP that calls a built-in function, + with result going to TARGET if that's convenient + (and in mode MODE if that's convenient). + SUBTARGET may be used as the target for computing one of EXP's operands. + IGNORE is nonzero if the value is to be ignored. */ + +rtx +arm_expand_builtin (tree exp, + rtx target, + rtx subtarget ATTRIBUTE_UNUSED, + machine_mode mode ATTRIBUTE_UNUSED, + int ignore ATTRIBUTE_UNUSED) +{ + tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); + unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); + unsigned int subcode = code >> ARM_BUILTIN_SHIFT; + switch (code & ARM_BUILTIN_CLASS) + { + case ARM_BUILTIN_GENERAL: + return arm_general_expand_builtin (subcode, exp, target, ignore); + default: + gcc_unreachable (); + } +} + void arm_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) { @@ -4122,22 +4162,21 @@ arm_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) reload_fenv, restore_fnenv), update_call); } -/* Implement TARGET_CHECK_BUILTIN_CALL. Record a read of the Q bit through - intrinsics in the machine function. */ +/* Implement TARGET_CHECK_BUILTIN_CALL for general builtins. Record a read of + the Q bit through intrinsics in the machine function for general built-in + functions. */ bool -arm_check_builtin_call (location_t , vec , tree fndecl, - tree, unsigned int, tree *) +arm_general_check_builtin_call (unsigned int code) { - int fcode = DECL_MD_FUNCTION_CODE (fndecl); - if (fcode == ARM_BUILTIN_saturation_occurred - || fcode == ARM_BUILTIN_set_saturation) + if (code == ARM_BUILTIN_saturation_occurred + || code == ARM_BUILTIN_set_saturation) { if (cfun && cfun->decl) DECL_ATTRIBUTES (cfun->decl) = tree_cons (get_identifier ("acle qbit"), NULL_TREE, DECL_ATTRIBUTES (cfun->decl)); } - if (fcode == ARM_BUILTIN_sel) + else if (code == ARM_BUILTIN_sel) { if (cfun && cfun->decl) DECL_ATTRIBUTES (cfun->decl) @@ -4147,19 +4186,52 @@ arm_check_builtin_call (location_t , vec , tree fndecl, return true; } +/* Implement TARGET_CHECK_BUILTIN_CALL. */ +bool +arm_check_builtin_call (location_t, vec, tree fndecl, tree, + unsigned int, tree *) +{ + unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); + unsigned int subcode = code >> ARM_BUILTIN_SHIFT; + switch (code & ARM_BUILTIN_CLASS) + { + case ARM_BUILTIN_GENERAL: + return arm_general_check_builtin_call (subcode); + default: + gcc_unreachable (); + } + +} + enum resolver_ident arm_describe_resolver (tree fndecl) { - if (DECL_MD_FUNCTION_CODE (fndecl) >= ARM_BUILTIN_vcx1qv16qi - && DECL_MD_FUNCTION_CODE (fndecl) < ARM_BUILTIN_MVE_BASE) - return arm_cde_resolver; - return arm_no_resolver; + unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); + unsigned int subcode = code >> ARM_BUILTIN_SHIFT; + switch (code & ARM_BUILTIN_CLASS) + { + case ARM_BUILTIN_GENERAL: + if (subcode >= ARM_BUILTIN_vcx1qv16qi + && subcode < ARM_BUILTIN_MVE_BASE) + return arm_cde_resolver; + return arm_no_resolver; + default: + gcc_unreachable (); + } } unsigned arm_cde_end_args (tree fndecl) { - return DECL_MD_FUNCTION_CODE (fndecl) >= ARM_BUILTIN_vcx1q_p_v16qi ? 2 : 1; + unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); + unsigned int subcode = code >> ARM_BUILTIN_SHIFT; + switch (code & ARM_BUILTIN_CLASS) + { + case ARM_BUILTIN_GENERAL: + return subcode >= ARM_BUILTIN_vcx1q_p_v16qi ? 2 : 1; + default: + gcc_unreachable (); + } } #include "gt-arm-builtins.h" diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index c8ae5e1e9c1..1bdbd3b8ab3 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -210,6 +210,22 @@ extern opt_machine_mode arm_get_mask_mode (machine_mode mode); #endif /* RTX_CODE */ +/* It's convenient to divide the built-in function codes into groups, + rather than having everything in a single enum. This type enumerates + those groups. */ +enum arm_builtin_class +{ + ARM_BUILTIN_GENERAL +}; + +/* Built-in function codes are structured so that the low + ARM_BUILTIN_SHIFT bits contain the arm_builtin_class + and the upper bits contain a group-specific subcode. */ +const unsigned int ARM_BUILTIN_SHIFT = 1; + +/* Mask that selects the arm part of a function code. */ +const unsigned int ARM_BUILTIN_CLASS = (1 << ARM_BUILTIN_SHIFT) - 1; + /* MVE functions. */ namespace arm_mve { void handle_arm_mve_types_h ();