-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
mesa: detect SVE/SVE2 support on ARM64 #24769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,59 @@ | ||
| https://github.com/llvm/llvm-project/issues/114987 | ||
| https://github.com/termux/termux-packages/issues/24544 | ||
|
|
||
| --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | ||
| +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | ||
| @@ -88,6 +88,23 @@ | ||
| #include "lp_bld_misc.h" | ||
| #include "lp_bld_debug.h" | ||
|
|
||
| +#if __has_include(<sys/auxv.h>) | ||
| +#include <sys/auxv.h> | ||
| +#define HAVE_SYS_AUXV 1 | ||
| +#ifndef AT_HWCAP | ||
| +#define AT_HWCAP 16 | ||
| +#endif | ||
| +#ifndef AT_HWCAP2 | ||
| +#define AT_HWCAP2 26 | ||
| +#endif | ||
| +#ifndef HWCAP_SVE | ||
| +#define HWCAP_SVE (1 << 22) | ||
| +#endif | ||
| +#ifndef HWCAP2_SVE2 | ||
| +#define HWCAP2_SVE2 (1 << 1) | ||
| +#endif | ||
| +#endif | ||
| + | ||
| static void lp_run_atexit_for_destructors(void); | ||
|
|
||
| namespace { | ||
| @@ -446,6 +463,29 @@ | ||
| MAttrs.push_back("-lasx"); | ||
| #endif | ||
| #endif | ||
| + | ||
| +#if DETECT_ARCH_AARCH64 && defined(HAVE_SYS_AUXV) | ||
| + // Guess SVE/SVE2 support on ARM64 | ||
| + bool has_sve = getauxval(AT_HWCAP) & HWCAP_SVE; | ||
| + bool has_sve2 = getauxval(AT_HWCAP2) & HWCAP2_SVE2; | ||
| + MAttrs.push_back(has_sve ? "+sve" : "-sve"); | ||
| + MAttrs.push_back(has_sve2 ? "+sve2" : "-sve2"); | ||
| +#endif | ||
| + | ||
| + // Allow adding extra MAttrs through envs | ||
| + char *env_extra_mattrs = getenv("GALLIVM_EXTRA_MATTRS"); | ||
| + if (env_extra_mattrs != NULL) { | ||
| + char *dup = strdup(env_extra_mattrs); | ||
| + if (dup != NULL) { | ||
| + char *state; | ||
| + char *token = strtok_r(dup, ",", &state); | ||
| + while (token) { | ||
| + MAttrs.push_back(token); | ||
| + token = strtok_r(NULL, ",", &state); | ||
| + } | ||
| + free(dup); | ||
| + } | ||
| + } | ||
| } | ||
|
|
||
| void | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe set pointer to NULL after free pointer
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I don't think it is necessary.
dupis declared as a local variable and only can be used inside theif (env_extra_mattrs != NULL) {scope.