From c8dc7f57d402282524faea4190ea1a8bd9468641 Mon Sep 17 00:00:00 2001 From: George Steed Date: Mon, 20 May 2024 18:41:31 +0100 Subject: [PATCH] [AArch64] Print the SVE and SME vector lengths in cpu_id This file is not compiled with SVE or SME features enabled so use `.inst` to specify the instructions to read the vector length in hex instead. Change-Id: I2673b6f79a4a6ea0753f8b3de31244457fc08e76 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5616030 Reviewed-by: Frank Barchard --- util/cpuid.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/util/cpuid.c b/util/cpuid.c index 50ab9ffbc..0f1f806a8 100644 --- a/util/cpuid.c +++ b/util/cpuid.c @@ -107,6 +107,22 @@ int main(int argc, const char* argv[]) { printf("Has SVE 0x%x\n", has_sve); printf("Has SVE2 0x%x\n", has_sve2); printf("Has SME 0x%x\n", has_sme); + +#if __aarch64__ + // Read and print the SVE and SME vector lengths. + if (has_sve) { + int sve_vl; + // rdvl x0, #1 + asm(".inst 0x04bf5020; mov %w0, w0" : "=r"(sve_vl)::"x0"); + printf("SVE vector length: %d bytes\n", sve_vl); + } + if (has_sme) { + int sme_vl; + // rdsvl x0, #1 + asm(".inst 0x04bf5820; mov %w0, w0" : "=r"(sme_vl)::"x0"); + printf("SME vector length: %d bytes\n", sme_vl); + } +#endif } if (has_riscv) { int has_rvv = TestCpuFlag(kCpuHasRVV);