forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler-rt][AArch64] Rewrite SME routines to all use FMV feature bits.
When llvm#92921 added the `__arm_get_current_vg` functionality, it used the FMV feature bits mechanism rather than the existing mechanism that was previously added for SME that called `getauxval` (on Linux platforms) or `__aarch64_sme_accessible` (required for baremetal libraries). It seems simpler to always use the FMV feature bits mechanism, but for baremetal targets we still need to rely on `__arm_sme_accessible`.
- Loading branch information
1 parent
5a0d73b
commit 8db75c0
Showing
6 changed files
with
61 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
// We rely on the FMV __aarch64_cpu_features mechanism to determine | ||
// which features are set at runtime. | ||
|
||
#include "../cpu_model/AArch64CPUFeatures.inc" | ||
_Static_assert(FEAT_SVE== 30, "sme-abi.S assumes FEAT_SVE = 30"); | ||
_Static_assert(FEAT_SME== 42, "sme-abi.S assumes FEAT_SME = 42"); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
compiler-rt/lib/builtins/cpu_model/aarch64/fmv/baremetal_sme.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// For baremetal platforms, we don't really initialise '__aarch64_cpu_features', | ||
// with exception of FEAT_SME that we can get from '__aarch64_sme_accessible'. | ||
|
||
#if defined(COMPILER_RT_SHARED_LIB) | ||
__attribute__((weak)) | ||
#endif | ||
extern _Bool __aarch64_sme_accessible(void); | ||
|
||
static _Bool has_sme(void) { | ||
#if defined(COMPILER_RT_SHARED_LIB) | ||
if (!__aarch64_sme_accessible) | ||
return 0; | ||
#endif | ||
return __aarch64_sme_accessible(); | ||
} | ||
|
||
void __init_cpu_features_resolver(unsigned long hwcap, | ||
const __ifunc_arg_t *arg) { } | ||
|
||
void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) { | ||
// CPU features already initialized. | ||
if (__atomic_load_n(&__aarch64_cpu_features.features, __ATOMIC_RELAXED)) | ||
return; | ||
|
||
unsigned long long feat = 0; | ||
if (has_sme()) | ||
feat |= 1ULL << FEAT_SME; | ||
|
||
__atomic_store_n(&__aarch64_cpu_features.features, feat, __ATOMIC_RELAXED); | ||
} |