Skip to content

Instantly share code, notes, and snippets.

@mshabunin
Created June 10, 2015 19:53
Show Gist options
  • Save mshabunin/9ea66aa1dcde1d200783 to your computer and use it in GitHub Desktop.
Save mshabunin/9ea66aa1dcde1d200783 to your computer and use it in GitHub Desktop.
#define CV_VFP 1
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__)
// #define CV_VFP 1
#endif
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
// #define CV_VFP 1
#endif
#ifdef CV_VFP
// 1. general scheme
#define ARM_ROUND(_value, _asm_string) \
int res; \
float temp; \
asm(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
return res
// 2. version for double
#ifdef __clang__
#define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %[value] \n vmov %[res], %[temp]")
#else
#define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %P[value] \n vmov %[res], %[temp]")
#endif
// 3. version for float
#define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
int cvRound( double value );
int cvRound( double value )
{
ARM_ROUND_DBL(value);
}
#warning Experimental round is enabled
#endif
#!/bin/bash
RED=`tput setaf 1; tput bold`
GREEN=`tput setaf 2; tput bold`
NC=`tput sgr0`
ndks=("./android-ndk-r10d" "./android-ndk-r8d")
# "-mfloat-abi=softfp"
options=("-mfloat-abi=soft" "-mfloat-abi=softfp -mfpu=neon" "-mfloat-abi=hard -mfpu=neon")
common="-fexceptions -fpic -funwind-tables -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -fdata-sections -ffunction-sections -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -fomit-frame-pointer -mfpu=neon -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG -DNDEBUG"
for ndk in ${ndks[@]} ; do
chains=$(ls -1 $ndk/toolchains | grep arm-linux | grep -v clang)
for chain in ${chains[@]} ; do
for option in "${options[@]}" ; do
tool=$(find $ndk/toolchains/$chain -name 'arm*g++')
echo
echo " ||| NDK: $ndk"
echo " ||| Toolchain: $chain"
echo " ||| Option: $option"
$tool $common $option -dM -E - < /dev/null | egrep -i "arm|vfp|neon|soft"
$tool $common $option -S test.cpp
if [ $? == 0 ] ; then
echo "${GREEN}====== Compilation successful!!! =========${NC}"
# cat test.s
else
echo "${RED}========= Compilation FAILED =========${NC}"
fi
done
done
done
targets=("arm-none-linux-gnueabi" "arm-none-linux-android")
for target in ${targets[@]} ; do
for option in "${options[@]}" ; do
echo
echo " ||| Tool: clang"
echo " ||| Target: $target"
echo " ||| Option: $option"
clang++ -target $target $common $option -dM -E - < /dev/null | egrep -i "arm|vfp|neon|soft"
clang++ -target $target $common $option -S test.cpp
if [ $? == 0 ] ; then
echo "${GREEN}====== Compilation successful!!! =========${NC}"
# cat test.s
else
echo "${RED}========= Compilation FAILED =========${NC}"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment