[clang] [Clang][AArch64] Add missing SME functions to header file. (PR #75791)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 19 03:00:40 PST 2023


================
@@ -1600,6 +1600,25 @@ void SVEEmitter::createSMEHeader(raw_ostream &OS) {
   OS << "extern \"C\" {\n";
   OS << "#endif\n\n";
 
+  OS << "void __arm_za_disable(void) __arm_streaming_compatible;\n\n";
+
+  OS << "__ai bool __arm_has_sme(void) __arm_streaming_compatible {\n";
+  OS << "  uint64_t x0, x1;\n";
+  OS << "  __builtin_arm_get_sme_state(&x0, &x1);\n";
+  OS << "  return x0 & (1ULL << 63);\n";
+  OS << "}\n\n";
+
+  OS << "__ai bool __arm_in_streaming_mode(void) __arm_streaming_compatible "
+        "{\n";
+  OS << "  uint64_t x0, x1;\n";
+  OS << "  __builtin_arm_get_sme_state(&x0, &x1);\n";
+  OS << "  return x0 & 1;\n";
+  OS << "}\n\n";
+
+  OS << "__ai __attribute__((target(\"sme\"))) void svundef_za(void) "
----------------
sdesmalen-arm wrote:

`__arm_shared_za` is only available when `+sme` is enabled. By adding the target attribute here, this allows including the header file even when none of the bulitins are used. One such case could be when someone wants to include the header for the declarations of the streaming-compatible memcpy intrinsics, without particularly wanting to use any SME instructions.

https://github.com/llvm/llvm-project/pull/75791


More information about the cfe-commits mailing list