1/*
2 * Copyright (c) 2014 Travis Geiselbrecht
3 *
4 * Use of this source code is governed by a MIT-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/MIT
7 */
8#include <lk/asm.h>
9
10#if ARM_WITH_VFP
11
12.fpu neon
13.syntax unified
14
15.macro disable, scratchreg
16    vmrs  \scratchreg, fpexc
17    bic   \scratchreg, #(1<<30)
18    vmsr  fpexc, \scratchreg
19.endm
20
21.macro vfp_instructions
22    disable r12
23    vadd.f32 s0, s0, s0
24
25    disable r12
26    vadd.f64 d0, d0, d0
27
28    disable r12
29    ldr     r0, =float_test_scratch
30    vldr    s0, [r0]
31.endm
32
33.macro neon_instructions
34    disable r12
35    vadd.f32 q0, q0, q0
36
37    disable r12
38    ldr     r0, =float_test_scratch
39    vld1.f32 { q0 }, [r0]
40
41    disable r12
42    vmov    s0, r0
43.endm
44
45#if !ARM_ONLY_THUMB
46.arm
47
48FUNCTION(float_vfp_arm_instruction_test)
49    vfp_instructions
50    bx  lr
51
52FUNCTION(float_neon_arm_instruction_test)
53    neon_instructions
54    bx  lr
55#endif
56
57.thumb
58
59FUNCTION(float_vfp_thumb_instruction_test)
60    vfp_instructions
61    bx  lr
62
63FUNCTION(float_neon_thumb_instruction_test)
64    neon_instructions
65    bx  lr
66
67.data
68LOCAL_DATA(float_test_scratch)
69    .word 0
70    .word 0
71
72#endif // ARM_WITH_VFP
73