• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#**********************************************************************************
3#    This script is using in build/arch.mk for mips to detect the simd instructions:
4#    mmi, msa (maybe more in the future).
5#
6#   --usage:
7#             ./mips-simd-check.sh $(CC) mmi
8#         or  ./mips-simd-check.sh $(CC) msa
9#
10# date:  10/17/2019 Created
11#**********************************************************************************
12
13TMPC=$(mktemp tmp.XXXXXX.c)
14TMPO=$(mktemp tmp.XXXXXX.o)
15if [ $2 == "mmi" ]
16then
17   echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > $TMPC
18   $1 -march=loongson3a $TMPC -o $TMPO &> /dev/null
19   if test -s $TMPO
20   then
21      echo "Yes"
22   fi
23elif [ $2 == "msa" ]
24then
25   echo "void main(void){ __asm__ volatile(\"addvi.b \$w0, \$w1, 1\"); }" > $TMPC
26   $1 -mmsa $TMPC -o $TMPO &> /dev/null
27   if test -s $TMPO
28   then
29      echo "Yes"
30   fi
31fi
32rm -f $TMPC $TMPO
33