• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021 Loongson Technology Corporation Limited
3# Contributed by Xiwei Gu <guxiwei-hf@loongson.cn>
4# Contributed by Lu Wang  <wanglu@loongson.cn>
5#
6#***************************************************************************************
7#    This script is used in build/arch.mk for loongarch to detect the simd instructions:
8#    lsx, lasx (maybe more in the future).
9#
10#   --usage:
11#             ./loongarch-simd-check.sh $(CC) lsx
12#         or  ./loongarch-simd-check.sh $(CC) lasx
13#
14# date:  11/23/2021 Created
15#***************************************************************************************
16
17TMPC=$(mktemp tmp.XXXXXX.c)
18TMPO=$(mktemp tmp.XXXXXX.o)
19if [ $2 == "lsx" ]
20then
21   echo "void main(void){ __asm__ volatile(\"vadd.b \$vr0, \$vr1, \$vr1\"); }" > $TMPC
22   $1 -mlsx $TMPC -o $TMPO &> /dev/null
23   if test -s $TMPO
24   then
25      echo "Yes"
26   fi
27elif [ $2 == "lasx" ]
28then
29   echo "void main(void){ __asm__ volatile(\"xvadd.b \$xr0, \$xr1, \$xr1\"); }" > $TMPC
30   $1 -mlasx $TMPC -o $TMPO &> /dev/null
31   if test -s $TMPO
32   then
33      echo "Yes"
34   fi
35fi
36rm -f $TMPC $TMPO
37