[Mlir-commits] [compiler-rt] [llvm] [mlir] [compiler-rt] Don't provide `__arm_sme_state` for baremetal targets (PR #191434)

Daniel Kiss llvmlistbot at llvm.org
Mon Apr 13 07:37:02 PDT 2026


================
@@ -1,19 +1,19 @@
-// For baremetal platforms, we don't really initialise '__aarch64_cpu_features',
-// with exception of FEAT_SME that we can get from '__aarch64_sme_accessible'.
+#include <stdint.h>
 
-#if defined(COMPILER_RT_SHARED_LIB)
-__attribute__((weak))
-#endif
-extern _Bool
-__aarch64_sme_accessible(void);
+// The libc/runtime for baremetal targets should provide an implementation of
+// __arm_sme_state. LLVM's compiler-rt does not provide this function for
+// baremetal as checking CPU features is implementation defined.
+//
+// See:
+// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#811__arm_sme_state
+extern struct {
+  uint64_t x0;
+  uint64_t x1;
+} __arm_sme_state(void);
----------------
DanielKristofKiss wrote:

I mean if __arm_sme_state is defined as `weak` you can check the presence of an actual implementation and call it only when present.

`_Bool has_sme = __arm_sme_state && (__arm_sme_state().x0 & SME_STATE_HAS_SME_BIT_X0) != 0;`

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


More information about the Mlir-commits mailing list