From patchwork Wed Mar 28 08:19:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Phillips X-Patchwork-Id: 26499 X-Patchwork-Delegate: tuliom@linux.vnet.ibm.com Received: (qmail 16593 invoked by alias); 28 Mar 2018 08:20:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16559 invoked by uid 89); 28 Mar 2018 08:20:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*R:D*protonmail.com, H*RU:sk:mail4.p, H*r:sk:mail4.p, Hx-spam-relays-external:sk:mail4.p X-HELO: mail4.protonmail.ch Date: Wed, 28 Mar 2018 04:19:57 -0400 To: "libc-alpha@sourceware.org" From: Nathan Phillips Reply-To: Nathan Phillips Subject: [PATCH] powerpc: Expose VSX feature test Message-ID: Feedback-ID: pIMM7SjgsBkoh1VHiFjtO1aCnt3hdIguBtsk5guUZVvO7OljEshi__TzlKj4CrF76xqm0sJcB-O9Syj4wMI1Lg==:Ext:ProtonMail MIME-Version: 1.0 Hope it's OK to submit a small change like this. Trying to familiarize myself with the patch process. My copyright assignment is underway. --- Read the HWCAP auxval key to test for VSX support. Expose result through the cpu_features interface. Preliminary change to prepare for PowerPC optimized libmvec implementations [BZ #20123]. Enables selecting optimized version at load time in ifunc resolver. * sysdeps/powerpc/cpu-features.h (cpu_features): Add vsx field. * sysdeps/powerpc/cpu-features.c (init_cpu_features): Feature test VSX availability. --- diff --git a/sysdeps/powerpc/cpu-features.c b/sysdeps/powerpc/cpu-features.c index 955d4778a6..477c7504b9 100644 --- a/sysdeps/powerpc/cpu-features.c +++ b/sysdeps/powerpc/cpu-features.c @@ -16,6 +16,8 @@ License along with the GNU C Library; if not, see . */ +#include +#include #include #include @@ -26,6 +28,9 @@ static inline void init_cpu_features (struct cpu_features *cpu_features) { + errno = 0; + unsigned long int hwcap = getauxval (AT_HWCAP); + /* Default is to use aligned memory access on optimized function unless tunables is enable, since for this case user can explicit disable unaligned optimizations. */ @@ -36,4 +41,13 @@ init_cpu_features (struct cpu_features *cpu_features) #else cpu_features->use_cached_memopt = false; #endif + + if (errno == ENOENT) + { + cpu_features->vsx = false; + } + else + { + cpu_features->vsx = ((hwcap & PPC_FEATURE_HAS_VSX) != 0); + } } diff --git a/sysdeps/powerpc/cpu-features.h b/sysdeps/powerpc/cpu-features.h index e596385b4b..0248862b8a 100644 --- a/sysdeps/powerpc/cpu-features.h +++ b/sysdeps/powerpc/cpu-features.h @@ -23,6 +23,7 @@ struct cpu_features { bool use_cached_memopt; + bool vsx; }; #endif /* __CPU_FEATURES_H */