GNU Linux-libre 5.4.274-gnu1
[releases.git] / arch / arm / include / asm / vfpmacros.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * arch/arm/include/asm/vfpmacros.h
4  *
5  * Assembler-only file containing VFP macros and register definitions.
6  */
7 #include <asm/hwcap.h>
8
9 #include <asm/vfp.h>
10
11 @ Macros to allow building with old toolkits (with no VFP support)
12         .macro  VFPFMRX, rd, sysreg, cond
13         MRC\cond        p10, 7, \rd, \sysreg, cr0, 0    @ FMRX  \rd, \sysreg
14         .endm
15
16         .macro  VFPFMXR, sysreg, rd, cond
17         MCR\cond        p10, 7, \rd, \sysreg, cr0, 0    @ FMXR  \sysreg, \rd
18         .endm
19
20         @ read all the working registers back into the VFP
21         .macro  VFPFLDMIA, base, tmp
22         .fpu    vfpv2
23 #if __LINUX_ARM_ARCH__ < 6
24         fldmiax \base!, {d0-d15}
25 #else
26         vldmia  \base!, {d0-d15}
27 #endif
28 #ifdef CONFIG_VFPv3
29         .fpu    vfpv3
30 #if __LINUX_ARM_ARCH__ <= 6
31         ldr     \tmp, =elf_hwcap                    @ may not have MVFR regs
32         ldr     \tmp, [\tmp, #0]
33         tst     \tmp, #HWCAP_VFPD32
34         vldmiane \base!, {d16-d31}
35         addeq   \base, \base, #32*4                 @ step over unused register space
36 #else
37         VFPFMRX \tmp, MVFR0                         @ Media and VFP Feature Register 0
38         and     \tmp, \tmp, #MVFR0_A_SIMD_MASK      @ A_SIMD field
39         cmp     \tmp, #2                            @ 32 x 64bit registers?
40         vldmiaeq \base!, {d16-d31}
41         addne   \base, \base, #32*4                 @ step over unused register space
42 #endif
43 #endif
44         .endm
45
46         @ write all the working registers out of the VFP
47         .macro  VFPFSTMIA, base, tmp
48 #if __LINUX_ARM_ARCH__ < 6
49         fstmiax \base!, {d0-d15}
50 #else
51         vstmia  \base!, {d0-d15}
52 #endif
53 #ifdef CONFIG_VFPv3
54         .fpu    vfpv3
55 #if __LINUX_ARM_ARCH__ <= 6
56         ldr     \tmp, =elf_hwcap                    @ may not have MVFR regs
57         ldr     \tmp, [\tmp, #0]
58         tst     \tmp, #HWCAP_VFPD32
59         vstmiane \base!, {d16-d31}
60         addeq   \base, \base, #32*4                 @ step over unused register space
61 #else
62         VFPFMRX \tmp, MVFR0                         @ Media and VFP Feature Register 0
63         and     \tmp, \tmp, #MVFR0_A_SIMD_MASK      @ A_SIMD field
64         cmp     \tmp, #2                            @ 32 x 64bit registers?
65         vstmiaeq \base!, {d16-d31}
66         addne   \base, \base, #32*4                 @ step over unused register space
67 #endif
68 #endif
69         .endm