[libc-commits] [libc] [libc] Enable the FPU in Arm startup code (PR #166349)

Simon Tatham via libc-commits libc-commits at lists.llvm.org
Wed Nov 5 07:02:57 PST 2025


================
@@ -131,6 +131,28 @@ namespace LIBC_NAMESPACE_DECL {
   __arm_wsr("CPSR_c", 0x13); // SVC
 #endif
 
+#ifdef __ARM_FP
+// Enable FPU
+#if __ARM_ARCH_PROFILE == 'M'
+  // Set CPACR cp10 and cp11
+  auto cpacr = (volatile uint32_t *const)0xE000ED88;
+  *cpacr |= (0xF << 20);
+  __dsb(0xF);
----------------
statham-arm wrote:

Thanks for the references. I notice that the middle one of your links puts the ISB _before_ attempting to mess with FPEXC, rather than after, which makes sense to me since the VMSR/VMRS pair are themselves (modelled as) MRC/MCR to coprocessor 10 which you've only just enabled. That seems like a reasonable precaution if we're going to include it at all.

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


More information about the libc-commits mailing list