Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/aarch64/sme-abi-init.c
35292 views
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.1// See https://llvm.org/LICENSE.txt for license information.2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception34__attribute__((visibility("hidden"), nocommon))5_Bool __aarch64_has_sme_and_tpidr2_el0;67// We have multiple ways to check that the function has SME, depending on our8// target.9// * For Linux we can use __getauxval().10// * For newlib we can use __aarch64_sme_accessible().1112#if defined(__linux__)1314#ifndef AT_HWCAP215#define AT_HWCAP2 2616#endif1718#ifndef HWCAP2_SME19#define HWCAP2_SME (1 << 23)20#endif2122extern unsigned long int __getauxval (unsigned long int);2324static _Bool has_sme(void) {25return __getauxval(AT_HWCAP2) & HWCAP2_SME;26}2728#else // defined(__linux__)2930#if defined(COMPILER_RT_SHARED_LIB)31__attribute__((weak))32#endif33extern _Bool __aarch64_sme_accessible(void);3435static _Bool has_sme(void) {36#if defined(COMPILER_RT_SHARED_LIB)37if (!__aarch64_sme_accessible)38return 0;39#endif40return __aarch64_sme_accessible();41}4243#endif // defined(__linux__)4445#if __GNUC__ >= 946#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"47#endif48__attribute__((constructor(90)))49static void init_aarch64_has_sme(void) {50__aarch64_has_sme_and_tpidr2_el0 = has_sme();51}525354