[clang] [Clang][AArch64] Use 'uint64_t*' for _arm_get_sme_state builtin. (PR #95982)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 01:29:42 PDT 2024


https://github.com/sdesmalen-arm updated https://github.com/llvm/llvm-project/pull/95982

>From a41a740d5e77303febbd4e0cb4d8def2010e32ed Mon Sep 17 00:00:00 2001
From: Sander de Smalen <sander.desmalen at arm.com>
Date: Tue, 18 Jun 2024 16:04:08 +0000
Subject: [PATCH 1/2] [Clang][AArch64] Use 'uint64_t*' for _arm_get_sme_state
 builtin.

Depending on the platform, the parameter for __arm_get_sme_state
requires a `unsigned long long*` instead of a `unsigned long*`.

>From ASTContext.cpp:

  case 'W':
    // This modifier represents int64 type.
---
 clang/include/clang/Basic/BuiltinsAArch64.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def b/clang/include/clang/Basic/BuiltinsAArch64.def
index 5f53c98167dfb..5fb199b1b2b03 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -72,7 +72,7 @@ TARGET_BUILTIN(__builtin_arm_stg, "vv*", "t", "mte")
 TARGET_BUILTIN(__builtin_arm_subp, "Uiv*v*", "t", "mte")
 
 // SME state function
-BUILTIN(__builtin_arm_get_sme_state, "vULi*ULi*", "n")
+BUILTIN(__builtin_arm_get_sme_state, "vWUi*WUi*", "n")
 
 // Memory Operations
 TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")

>From 025b780dc05634a99e3a45d54472ae01484c4498 Mon Sep 17 00:00:00 2001
From: Sander de Smalen <sander.desmalen at arm.com>
Date: Wed, 19 Jun 2024 07:46:17 +0000
Subject: [PATCH 2/2] Add test-case.

---
 .../acle_sme_state_builtin.c                       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_builtin.c

diff --git a/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_builtin.c b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_builtin.c
new file mode 100644
index 0000000000000..f2ef0b3c1a3b5
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_state_builtin.c
@@ -0,0 +1,14 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-linux -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-windows -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-darwin -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include <stdint.h>
+
+// Ensure that the builtin is defined to take a uint64_t * rather than relying
+// on the size of 'unsigned long' which may have different meanings on different
+// targets depending on LP64/LLP64.
+void test_sme_state_builtin(uint64_t *a,
+                            uint64_t *b) __arm_streaming_compatible {
+  __builtin_arm_get_sme_state(a, b);
+}



More information about the cfe-commits mailing list