Home | History | Annotate | Line # | Download | only in scripts
      1 #!/bin/sh
      2 
      3 # check_simd <srcdir> <builddir> <CXXFLAGS>
      4 # Read config from $CHECK_SIMD_CONFIG file or $target_list
      5 
      6 scriptdir="$(cd "${0%/*}" && pwd)"
      7 srcdir="$1"
      8 builddir="$2"
      9 shift 2
     10 testdir="$builddir/testsuite"
     11 
     12 CXX="$("$builddir/scripts/testsuite_flags" --build-cxx)"
     13 CXXFLAGS="$("$builddir/scripts/testsuite_flags" --cxxflags) $1 -Wno-psabi"
     14 shift
     15 INCLUDES="$("$builddir/scripts/testsuite_flags" --build-includes)"
     16 
     17 target_triplet=$($CXX -dumpmachine)
     18 
     19 define_target() {
     20   name="$1"
     21   flags="$2"
     22   sim="$3"
     23   eval "$name=\"flags=\\\"$flags\\\"
     24 sim=\\\"$sim\\\"\""
     25 }
     26 
     27 if [ -f "$CHECK_SIMD_CONFIG" ]; then
     28   . "$CHECK_SIMD_CONFIG"
     29 elif [ -z "$CHECK_SIMD_CONFIG" ]; then
     30   if [ -z "$target_list" ]; then
     31     target_list="unix"
     32     case "$target_triplet" in
     33       x86_64-*)      target_list="unix/-march=native" ;;
     34       i?86-*)        target_list="unix/-march=native" ;;
     35       powerpc64le-*) target_list="unix/-mcpu=power8" ;;
     36       aarch64-*)     target_list="unix/-mcpu=cortex-a53" ;;
     37       arm-*)         target_list="unix/-mcpu=cortex-a7" ;;
     38     esac
     39   fi
     40 else
     41   echo "Error: File not found: \$CHECK_SIMD_CONFIG='$CHECK_SIMD_CONFIG'" 1>&2
     42   exit 1
     43 fi
     44 
     45 # define unix with no flags and no simulator:
     46 define_target unix
     47 
     48 list="$target_list"
     49 
     50 # expand a{b,c} to a/b a/c
     51 while [ "${list#*\{}" != "${list}" ]; do
     52   list="$(echo "$list" | \
     53     sed -e 's#\([^ ]\+\){\([^{},]*\),\([^{}]*\)}\(/[^ ]*\)\?#\1/\2\4 \1{\3}\4#g' \
     54         -e 's#{\([^{},]*\)}#/\1#g' \
     55         -e 's#/ # #g' -e 's#/$##')"
     56 done
     57 
     58 # per a/b/c block extract flags and simulator, then make check-simd
     59 while [ ${#list} -gt 0 ]; do
     60   a="${list%% *}"
     61   if [ "$a" = "$list" ]; then
     62     list=""
     63   else
     64     list="${list#${a} }"
     65   fi
     66   b="${a%%/*}"
     67   eval "eval \"\$$b\""
     68   flags="${flags}$(echo "${a#${b}}"|sed 's#/# #g')"
     69   subdir="simd/$(echo "$flags" | sed 's#[= /-]##g')"
     70   rm -f "${subdir}/Makefile"
     71   $srcdir/testsuite/experimental/simd/generate_makefile.sh \
     72     --destination="$testdir/$subdir" --sim="$sim" --testflags="$flags" \
     73     $CXX $INCLUDES $CXXFLAGS -static-libgcc -static-libstdc++
     74   echo "$subdir"
     75 done
     76