From patchwork Fri Nov 8 14:47:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 2008495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XlMKN1t8Yz1xy0 for ; Sat, 9 Nov 2024 01:49:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 808F0385780C for ; Fri, 8 Nov 2024 14:49:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 9CBC53858283; Fri, 8 Nov 2024 14:48:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CBC53858283 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9CBC53858283 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731077342; cv=none; b=QDh8rXkLz/zUtZp5G5KJOtSawuVFw5OJzaAWeVxGH3xIvjdL+HctNpty1Ypd1L3N860bN77VFQ/KV+/3RVA7+YodHkvWP9veQ3RagFY0k6r9C/M8DqDSN4c3SHH4QpKxw8nRqRmTmFjKKxnEPeErfZt4mXOLYxalxHe9QtSO76w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731077342; c=relaxed/simple; bh=cCN/X27bNSfS1Ooj8qvLHN7mrv6+/sxZZNl/uTbIIa4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=rKXB5IWQIigVm4Mvo8BnZ0jdmJB6PBZ3v7Ogu2eQqrpv8YdydTqN4Bz8Rk18M+oUQcTWEtW7xajfovXTNnDw/1Ev+v7B4LHHdi6je8r4QaLljPseM1Zii2+ZRs5f053YExrYT+8nNm6VS09Q9I2AZw8GnrLbiPheymsdAvnQqZA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42994339; Fri, 8 Nov 2024 06:49:24 -0800 (PST) Received: from udebian.localdomain (unknown [10.57.26.225]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 26A633F528; Fri, 8 Nov 2024 06:48:53 -0800 (PST) From: Yury Khrustalev To: gcc-patches@gcc.gnu.org Cc: nsz@gcc.gnu.org, richard.earnshaw@arm.com, matthieu.longo@arm.com, richard.ball@arm.com, richard.sandiford@arm.com, ktkachov@nvidia.com, john.brawn@arm.com Subject: [PATCH v3 04/23] aarch64: Add __builtin_aarch64_chkfeat Date: Fri, 8 Nov 2024 14:47:57 +0000 Message-Id: <20241108144816.2681175-5-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241108144816.2681175-1-yury.khrustalev@arm.com> References: <20241108144816.2681175-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Szabolcs Nagy Builtin for chkfeat: the input argument is used to initialize x16 then execute chkfeat and return the updated x16. Note: the ACLE __chkfeat(x) will flip the bits to be more intuitive (xor the input to output), but for the builtin that seems unnecessary complication. gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (enum aarch64_builtins): Define AARCH64_BUILTIN_CHKFEAT. (aarch64_general_init_builtins): Handle chkfeat. (aarch64_general_expand_builtin): Handle chkfeat. Co-authored-by: Richard Sandiford --- gcc/config/aarch64/aarch64-builtins.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc index 97bde7c15d3..e693a14f4f3 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc @@ -876,6 +876,8 @@ enum aarch64_builtins AARCH64_PLDX, AARCH64_PLI, AARCH64_PLIX, + /* Armv8.9-A / Armv9.4-A builtins. */ + AARCH64_BUILTIN_CHKFEAT, AARCH64_BUILTIN_MAX }; @@ -2279,6 +2281,12 @@ aarch64_general_init_builtins (void) if (!TARGET_ILP32) aarch64_init_pauth_hint_builtins (); + tree ftype_chkfeat + = build_function_type_list (uint64_type_node, uint64_type_node, NULL); + aarch64_builtin_decls[AARCH64_BUILTIN_CHKFEAT] + = aarch64_general_add_builtin ("__builtin_aarch64_chkfeat", ftype_chkfeat, + AARCH64_BUILTIN_CHKFEAT); + if (in_lto_p) handle_arm_acle_h (); } @@ -3498,6 +3506,15 @@ aarch64_general_expand_builtin (unsigned int fcode, tree exp, rtx target, case AARCH64_PLIX: aarch64_expand_prefetch_builtin (exp, fcode); return target; + + case AARCH64_BUILTIN_CHKFEAT: + { + rtx x16_reg = gen_rtx_REG (DImode, R16_REGNUM); + op0 = expand_normal (CALL_EXPR_ARG (exp, 0)); + emit_move_insn (x16_reg, op0); + expand_insn (CODE_FOR_aarch64_chkfeat, 0, 0); + return copy_to_reg (x16_reg); + } } if (fcode >= AARCH64_SIMD_BUILTIN_BASE && fcode <= AARCH64_SIMD_BUILTIN_MAX)