@@ -131,20 +131,23 @@ namespace LIBC_NAMESPACE_DECL {
131131 __arm_wsr (" CPSR_c" , 0x13 ); // SVC
132132#endif
133133
134- #ifdef __ARM_FP
135- // Enable FPU
136- #if __ARM_ARCH_PROFILE == 'M'
134+ #if __ARM_ARCH_PROFILE == 'M' && \
135+ (defined (__ARM_FP) || defined (__ARM_FEATURE_MVE))
136+ // Enable FPU and MVE. They can't be enabled independently: the two are
137+ // governed by the same bits in CPACR.
137138 // Based on
138139 // https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/Floating-Point-Unit/Enabling-the-FPU
139- // Set CPACR cp10 and cp11
140+ // Set CPACR cp10 and cp11.
140141 auto cpacr = (volatile uint32_t *const )0xE000ED88 ;
141142 *cpacr |= (0xF << 20 );
142143 __dsb (0xF );
143144 __isb (0xF );
144- #elif __ARM_ARCH_PROFILE == 'A' || __ARM_ARCH_PROFILE == 'R'
145+ #elif (__ARM_ARCH_PROFILE == 'A' || __ARM_ARCH_PROFILE == 'R') && \
146+ defined (__ARM_FP)
147+ // Enable FPU.
145148 // Based on
146149 // https://developer.arm.com/documentation/dui0472/m/Compiler-Coding-Practices/Enabling-NEON-and-FPU-for-bare-metal
147- // Set CPACR cp10 and cp11
150+ // Set CPACR cp10 and cp11.
148151 uint32_t cpacr = __arm_rsr (" p15:0:c1:c0:2" );
149152 cpacr |= (0xF << 20 );
150153 __arm_wsr (" p15:0:c1:c0:2" , cpacr);
@@ -154,7 +157,6 @@ namespace LIBC_NAMESPACE_DECL {
154157 __asm__ __volatile__ (" vmrs %0, FPEXC" : " =r" (fpexc) : :);
155158 fpexc |= (1 << 30 );
156159 __asm__ __volatile__ (" vmsr FPEXC, %0" : : " r" (fpexc) :);
157- #endif
158160#endif
159161
160162 // Perform the equivalent of scatterloading
0 commit comments