From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 92BBE3858C27; Sun, 21 Mar 2021 17:01:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92BBE3858C27 From: "evan@coeus-group.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99698] New: [aarch64] Impossible to accurately detect extensions using preprocessor Date: Sun, 21 Mar 2021 17:01:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: evan@coeus-group.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2021 17:01:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99698 Bug ID: 99698 Summary: [aarch64] Impossible to accurately detect extensions using preprocessor Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: evan@coeus-group.com Target Milestone: --- Using SHA3 as an example, but this problem exists for other extensions as w= ell. If you pass something like -march=3Darmv8-a+sha3, GCC will define __ARM_FEATURE_SHA3. According to the ACLE documentation: __ARM_FEATURE_SHA3 is defined to 1 if the SHA1 & SHA2 Crypto instructions from Armv8-A and the SHA2 and SHA3 instructions from Armv8.2-A and newer are supported and intrinsics targeting them are available. These instructions include AES{E, D}, SHA1{C, P, M}, RAX, and others. So, I should be able to use the preprocessor to call a function like vbcaxq= _u32 if __ARM_FEATURE_SHA3 is defined to 1. However, if I call vbcaxq_u32 I get an error about a target specific option mismatch. It turns out that you need -march=3Darmv8.2-a+sha3 to convince G= CC to accept the function call. AFAICT there is no way to reliably detect armv8.2-a. The only difference in the preprocessor macros defined for armv8-a and armv8.2-a are a few extra __ARM_FEATURE_* macros. There is *no* difference in pre-defined macros bet= ween armv8.1-a and armv8.2-a. FWIW, clang accepts -march=3Darmv8-a+sha3, defines __ARM_FEATURE_SHA3 to 1,= and allows you to call the SHA3 functions, which seems pretty reasonable to me.=