>From 542d4003a60320ac0446b156681c59cbc19dd6a1 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 21 Jul 2015 20:00:03 +0000 Subject: [PATCH] fix armhf asm to use .fpu vfp and UAL mnemonics (1) Some armhf gcc toolchains (built with --with-float=hard but without --with-fpu=vfp*) do not pass -mfpu=vfp to the assembler and then binutils rejects the UAL mnemonics for VFP unless there is an .fpu vfp directive in the asm source. (2) binutils <= 2.17 does not support UAL VFP syntax, and vmrs/vmsr insns are only recognised in binutils >= 2.21. (3) clang builtin assembler does not support the old mnemonics (except a few with warnings). Added .fpu vfp directive to all armhf asm which use VFP instructions to solve (1) (only backward compatible VFPv1 instructions are used), dropped support for binutils < 2.21 and replaced mcr/mrc with vmsr/vmrs. The generated code should not be changed by this commit. --- src/fenv/armhf/fenv.s | 22 ++++++++++++---------- src/math/armhf/fabs.s | 1 + src/math/armhf/fabsf.s | 1 + src/math/armhf/sqrt.s | 1 + src/math/armhf/sqrtf.s | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/fenv/armhf/fenv.s b/src/fenv/armhf/fenv.s index 387234b..2621422 100644 --- a/src/fenv/armhf/fenv.s +++ b/src/fenv/armhf/fenv.s @@ -1,17 +1,19 @@ +.fpu vfp + .global fegetround .type fegetround,%function fegetround: - mrc p10, 7, r0, cr1, cr0, 0 + vmrs r0, fpscr and r0, r0, #0xc00000 bx lr .global __fesetround .type __fesetround,%function __fesetround: - mrc p10, 7, r3, cr1, cr0, 0 + vmrs r3, fpscr bic r3, r3, #0xc00000 orr r3, r3, r0 - mcr p10, 7, r3, cr1, cr0, 0 + vmsr fpscr, r3 mov r0, #0 bx lr @@ -19,7 +21,7 @@ __fesetround: .type fetestexcept,%function fetestexcept: and r0, r0, #0x1f - mrc p10, 7, r3, cr1, cr0, 0 + vmrs r3, fpscr and r0, r0, r3 bx lr @@ -27,9 +29,9 @@ fetestexcept: .type feclearexcept,%function feclearexcept: and r0, r0, #0x1f - mrc p10, 7, r3, cr1, cr0, 0 + vmrs r3, fpscr bic r3, r3, r0 - mcr p10, 7, r3, cr1, cr0, 0 + vmsr fpscr, r3 mov r0, #0 bx lr @@ -37,16 +39,16 @@ feclearexcept: .type feraiseexcept,%function feraiseexcept: and r0, r0, #0x1f - mrc p10, 7, r3, cr1, cr0, 0 + vmrs r3, fpscr orr r3, r3, r0 - mcr p10, 7, r3, cr1, cr0, 0 + vmsr fpscr, r3 mov r0, #0 bx lr .global fegetenv .type fegetenv,%function fegetenv: - mrc p10, 7, r3, cr1, cr0, 0 + vmrs r3, fpscr str r3, [r0] mov r0, #0 bx lr @@ -57,6 +59,6 @@ fesetenv: cmn r0, #1 moveq r3, #0 ldrne r3, [r0] - mcr p10, 7, r3, cr1, cr0, 0 + vmsr fpscr, r3 mov r0, #0 bx lr diff --git a/src/math/armhf/fabs.s b/src/math/armhf/fabs.s index 2bdebff..8a705e1 100644 --- a/src/math/armhf/fabs.s +++ b/src/math/armhf/fabs.s @@ -1,3 +1,4 @@ +.fpu vfp .text .global fabs .type fabs,%function diff --git a/src/math/armhf/fabsf.s b/src/math/armhf/fabsf.s index 35c720f..2c7beb6 100644 --- a/src/math/armhf/fabsf.s +++ b/src/math/armhf/fabsf.s @@ -1,3 +1,4 @@ +.fpu vfp .text .global fabsf .type fabsf,%function diff --git a/src/math/armhf/sqrt.s b/src/math/armhf/sqrt.s index 99fe64b..90f74a9 100644 --- a/src/math/armhf/sqrt.s +++ b/src/math/armhf/sqrt.s @@ -1,3 +1,4 @@ +.fpu vfp .text .global sqrt .type sqrt,%function diff --git a/src/math/armhf/sqrtf.s b/src/math/armhf/sqrtf.s index 9ea519f..91d8ad6 100644 --- a/src/math/armhf/sqrtf.s +++ b/src/math/armhf/sqrtf.s @@ -1,3 +1,4 @@ +.fpu vfp .text .global sqrtf .type sqrtf,%function -- 2.4.1