-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
[AArch64][compiler-rt] Add a function returning the current vector length #92921
Conversation
…ngth get_runtime_vl emits a cntd instruction if SVE is available at runtime, otherwise it will return 0.
✅ With the latest revision this PR passed the C/C++ code formatter. |
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.
This function should be in the ABI document before we merge it, I think.
__init_cpu_features(); | ||
} | ||
|
||
__attribute__((target("sve"))) long emit_cntd(void) { |
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.
static
?
return vl; | ||
} | ||
|
||
long get_runtime_vl(void) { |
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.
This probably should be prefixed with __aarch64
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.
Hi @efriedma-quic, I've added this routine to the ABI document in ARM-software/abi-aa#263 and renamed it to __arm_get_current_vg
.
@@ -2,6 +2,8 @@ | |||
// See https://llvm.org/LICENSE.txt for license information. | |||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||
|
|||
#include "../cpu_model/aarch64.c" |
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.
cpu_model/aarch64.c
isn't a header; including it seem wrong.
ARM-software/abi-aa#263 - Renamed get_runtime_vl to __arm_get_current_vg - Also return VG if currently in streaming-mode - Added static to get_aarch64_cpu_features - Added aarch64.h and included in sme-abi-init.c
…me_state, to check if currently in streaming mode.
FEAT_INIT // Used as flag of features initialization completion | ||
}; | ||
|
||
long long get_features(void); |
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.
This exports a function named get_features from compiler-rt... probably you want to hide it somehow (__
prefix, or make it static).
|
||
long long __get_aarch64_features(void); | ||
|
||
void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void); |
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.
You shouldn't need CONSTRUCTOR_ATTRIBUTE on the declaration here, I think.
extern struct SME_STATE __arm_sme_state(void) __arm_streaming_compatible; | ||
|
||
__attribute__((target("sve"))) long | ||
__arm_get_current_vg(void) __arm_streaming_compatible { |
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 split this into a separate file, so code using the other stuff defined in this file doesn't pull in the constructor? I assume __arm_get_current_vg won't be used in most configurations.
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.
I've split this into a separate file and replaced the use of has_sme()
with __aarch64_has_sme_and_tpidr2_el0
.
FEAT_INIT // Used as flag of features initialization completion | ||
}; | ||
|
||
long long __get_aarch64_features(void); |
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.
Looking again... maybe we should just poke at __aarch64_cpu_features directly, instead of adding this function? __aarch64_cpu_features is already part of the ABI (clang codegen knows about it).
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.
Thanks, I've removed __get_aarch64_features
. I'd missed that clang was also using __aarch64_cpu_features
.
- Removed __get_aarch64_features. - Split out changes for __arm_get_current_vg into a new file (sme-abi-vg.c) and removed from sme-abi-init.c.
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.
LGTM
This change results in
The new C file, |
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`.
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`.
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`.
…features. (#119414) When #92921 added the `__arm_get_current_vg` functionality, it used the FMV feature bits mechanism rather than the mechanism that was previously added for SME which called `getauxval` on Linux platforms or `__aarch64_sme_accessible` required for baremetal libraries. It is better to always use `__aarch64_cpu_features`. For baremetal we still need to rely on `__arm_sme_accessible` to initialise the struct.
get_runtime_vl emits a cntd instruction if SVE is available at runtime,
otherwise it will return 0.