Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use environment for mips feature detection #3630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build/arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ ASM_ARCH = mips
ASMFLAGS += -I$(SRC_PATH)codec/common/mips/
#mmi
ifeq ($(ENABLE_MMI), Yes)
ENABLE_MMI = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) mmi)
ENABLE_MMI = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/mips-simd-check.sh mmi)
ifeq ($(ENABLE_MMI), Yes)
CFLAGS += -DHAVE_MMI -march=loongson3a
endif
endif
#msa
ifeq ($(ENABLE_MSA), Yes)
ENABLE_MSA = $(shell $(SRC_PATH)build/mips-simd-check.sh $(CC) msa)
ENABLE_MSA = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/mips-simd-check.sh msa)
ifeq ($(ENABLE_MSA), Yes)
CFLAGS += -DHAVE_MSA -mmsa
endif
Expand All @@ -63,14 +63,14 @@ ASM_ARCH = loongarch
ASMFLAGS += -I$(SRC_PATH)codec/common/loongarch/
#lsx
ifeq ($(ENABLE_LSX), Yes)
ENABLE_LSX = $(shell $(SRC_PATH)build/loongarch-simd-check.sh $(CC) lsx)
ENABLE_LSX = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/loongarch-simd-check.sh lsx)
ifeq ($(ENABLE_LSX), Yes)
CFLAGS += -DHAVE_LSX -mlsx
endif
endif
#lasx
ifeq ($(ENABLE_LASX), Yes)
ENABLE_LASX = $(shell $(SRC_PATH)build/loongarch-simd-check.sh $(CC) lasx)
ENABLE_LASX = $(shell CC="$(CC)" CFLAGS="$(CFLAGS)" $(SRC_PATH)build/loongarch-simd-check.sh lasx)
ifeq ($(ENABLE_LASX), Yes)
CFLAGS += -DHAVE_LASX -mlasx
endif
Expand Down
17 changes: 7 additions & 10 deletions build/loongarch-simd-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,26 @@
# lsx, lasx (maybe more in the future).
#
# --usage:
# ./loongarch-simd-check.sh $(CC) lsx
# or ./loongarch-simd-check.sh $(CC) lasx
# ./loongarch-simd-check.sh lsx
# or ./loongarch-simd-check.sh lasx
#
# date: 11/23/2021 Created
#***************************************************************************************

TMPC=$(mktemp tmp.XXXXXX.c)
TMPO=$(mktemp tmp.XXXXXX.o)
if [ $2 == "lsx" ]
if [ $1 == "lsx" ]
then
echo "void main(void){ __asm__ volatile(\"vadd.b \$vr0, \$vr1, \$vr1\"); }" > $TMPC
$1 -mlsx $TMPC -o $TMPO &> /dev/null
if test -s $TMPO
if make -f /dev/null "${TMPC/.c/.o}"
then
echo "Yes"
fi
elif [ $2 == "lasx" ]
elif [ $1 == "lasx" ]
then
echo "void main(void){ __asm__ volatile(\"xvadd.b \$xr0, \$xr1, \$xr1\"); }" > $TMPC
$1 -mlasx $TMPC -o $TMPO &> /dev/null
if test -s $TMPO
if make -f /dev/null "${TMPC/.c/.o}"
then
echo "Yes"
fi
fi
rm -f $TMPC $TMPO
rm -f $TMPC
17 changes: 7 additions & 10 deletions build/mips-simd-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@
# mmi, msa (maybe more in the future).
#
# --usage:
# ./mips-simd-check.sh $(CC) mmi
# or ./mips-simd-check.sh $(CC) msa
# ./mips-simd-check.sh mmi
# or ./mips-simd-check.sh msa
#
# date: 10/17/2019 Created
#**********************************************************************************

TMPC=$(mktemp tmp.XXXXXX.c)
TMPO=$(mktemp tmp.XXXXXX.o)
if [ $2 == "mmi" ]
if [ $1 == "mmi" ]
then
echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > $TMPC
$1 -march=loongson3a $TMPC -o $TMPO &> /dev/null
if test -s $TMPO
if make -f /dev/null "${TMPC/.c/.o}" &> /dev/null
then
echo "Yes"
fi
elif [ $2 == "msa" ]
elif [ $1 == "msa" ]
then
echo "void main(void){ __asm__ volatile(\"addvi.b \$w0, \$w1, 1\"); }" > $TMPC
$1 -mmsa $TMPC -o $TMPO &> /dev/null
if test -s $TMPO
if make -f /dev/null "${TMPC/.c/.o}" &> /dev/null
then
echo "Yes"
fi
fi
rm -f $TMPC $TMPO
rm -f $TMPC