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

Victor Campos via libc-commits libc-commits at lists.llvm.org
Wed Nov 5 06:50:22 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);
----------------
vhscampos wrote:

For the M-profile I've based it on this example: https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Floating-Point-Unit/Enabling-the-FPU

For A/R profiles I couldn't find an example as normative.

The best I could find was from this: https://developer.arm.com/documentation/dui0472/m/Compiler-Coding-Practices/Enabling-NEON-and-FPU-for-bare-metal

Although this one doesn't have any sort of barrier: https://developer.arm.com/documentation/ddi0408/g/Programmers-Model/Register-summary/Accessing-the-FPU-registers

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


More information about the libc-commits mailing list