Skip to content

Commit

Permalink
add hard float support for Linux/Andriod
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhang committed Dec 9, 2013
1 parent bb58860 commit b933473
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 42 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ option(NE10_BUILD_SHARED "Build NE10 shared libraries" OFF)
option(NE10_BUILD_STATIC "Build NE10 static libraries" ON)
option(NE10_BUILD_EXAMPLES "Build NE10 examples" ON)

#hard float abi
option(NE10_ARM_HARD_FLOAT "Build NE10 for hard float abi" OFF)

#unit test options
option(NE10_BUILD_UNIT_TEST "Build NE10 unit test" OFF)
if (NE10_BUILD_UNIT_TEST)
Expand All @@ -57,8 +60,13 @@ set(NE10_VERSION 10)

# set complile flags for ARM.
if(ANDROID_PLATFORM)
set(CMAKE_C_FLAGS "-O2 -mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=vfp3 --sysroot=${NDK_SYSROOT_PATH}")
set(CMAKE_ASM_FLAGS "-mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon --sysroot=${NDK_SYSROOT_PATH}")
if(NE10_ARM_HARD_FLOAT)
set(CMAKE_C_FLAGS "-O2 -mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=hard -Wl,--no-warn-mismatch -mfpu=vfp3 --sysroot=${NDK_SYSROOT_PATH}")
set(CMAKE_ASM_FLAGS "-mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=hard -Wl,--no-warn-mismatch -mfpu=neon --sysroot=${NDK_SYSROOT_PATH}")
else(NE10_ARM_HARD_FLOAT)
set(CMAKE_C_FLAGS "-O2 -mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=vfp3 --sysroot=${NDK_SYSROOT_PATH}")
set(CMAKE_ASM_FLAGS "-mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon --sysroot=${NDK_SYSROOT_PATH}")
endif(NE10_ARM_HARD_FLOAT)
message("loaded toolchain:
${ANDROID_TOOLCHAIN_PATH}/arm-linux-androideabi-gcc
${ANDROID_TOOLCHAIN_PATH}/arm-linux-androideabi-g++
Expand All @@ -69,8 +77,8 @@ if(ANDROID_PLATFORM)
add_subdirectory(android/NE10Demo/jni)
endif()
elseif(GNULINUX_PLATFORM)
set(CMAKE_C_FLAGS "-O2 -mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=vfp3")
set(CMAKE_ASM_FLAGS "-mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon")
set(CMAKE_C_FLAGS "-O2 -mthumb-interwork -mthumb -march=armv7-a -mfpu=vfp3")
set(CMAKE_ASM_FLAGS "-mthumb-interwork -mthumb -march=armv7-a -mfpu=neon")
elseif(IOS_PLATFORM)
set(CMAKE_C_FLAGS "-O2 -arch armv7 -arch armv7s -mfpu=vfp3")
set(CMAKE_ASM_FLAGS "-arch armv7 -arch armv7s -mfpu=neon")
Expand Down
3 changes: 3 additions & 0 deletions android/NE10Demo/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ set(NE10_TEST_DSP_SRCS
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fir_lattice.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fir_sparse.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_iir.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_float32.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_int16.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_int32.c
)

add_library(NE10_test_demo SHARED
Expand Down
3 changes: 3 additions & 0 deletions ios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ set(NE10_TEST_DSP_SRCS
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fir_lattice.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fir_sparse.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_iir.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_float32.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_int16.c
${PROJECT_SOURCE_DIR}/modules/dsp/test/test_suite_fft_int32.c
)

add_library(NE10_test_demo STATIC ${NE10_TEST_MATH_SRCS} ${NE10_TEST_COMMON_SRCS} ${NE10_TEST_DSP_SRCS})
Expand Down
5 changes: 4 additions & 1 deletion modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

if(NE10_ARM_HARD_FLOAT)
add_definitions(-DNE10_ENABLE_HF)
endif()
# Define files.
set(NE10_INIT_SRCS ${PROJECT_SOURCE_DIR}/modules/NE10_init.c)
set(NE10_C_SRCS )
Expand All @@ -34,7 +37,7 @@ set(NE10_NEON_SRCS )
#Tell CMake these files need to go to the C compiler
function(set_file_to_c files)
set(FLAGS
"-mfpu=neon -Wa,-I${PROJECT_SOURCE_DIR}/inc -Wa,-I${PROJECT_SOURCE_DIR}/common -Wa,-I${PROJECT_SOURCE_DIR}/modules/math" )
"-x assembler-with-cpp -mfpu=neon -Wa,-I${PROJECT_SOURCE_DIR}/inc -Wa,-I${PROJECT_SOURCE_DIR}/common -Wa,-I${PROJECT_SOURCE_DIR}/modules/math" )
foreach(file ${${files}})
set_property (SOURCE ${file} PROPERTY LANGUAGE C)
set_source_files_properties(
Expand Down
11 changes: 10 additions & 1 deletion modules/dsp/NE10_cfft.neon.s
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ ne10_radix4_butterfly_inverse_float_neon:

PUSH {r4-r12,lr} @push r12: to keep stack 8 bytes aligned
VPUSH {d8-d15}

#if defined (NE10_ENABLE_HF)
VPUSH {s0,s1}
#endif
qInp1 .qn Q0.F32
qInp2 .qn Q1.F32
qInp3 .qn Q2.F32
Expand Down Expand Up @@ -658,7 +660,11 @@ ifftLastStageSetLoop:
VSUB qInp8,qIm2,qRe4

@/* multiply onebyN */
#if defined (NE10_ENABLE_HF)
LDR grpCount,[sp,#0] @revert the original value
#else
LDR grpCount,[sp,#104] @revert the original value
#endif
VDUP.f32 q8,grpCount

VMUL qInp1,qInp1,qRe1
Expand Down Expand Up @@ -721,6 +727,9 @@ ifftCopyLoop:

ifftEnd:
@/* Retureq From Function*/
#if defined (NE10_ENABLE_HF)
VPOP {s0,s1}
#endif
VPOP {d8-d15}
POP {r4-r12,pc}

Expand Down
Loading

0 comments on commit b933473

Please sign in to comment.