[Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
YunQiang Su
wzssyqa at gmail.com
Thu Feb 27 02:42:40 UTC 2020
This patch is some small.
You can consider this version.
>From de2e4b6f363a1b263f8b62cbf0bac52c130cbf4d Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at debian.org>
Date: Thu, 27 Feb 2020 09:55:23 +0800
Subject: [PATCH] smalllll
---
configure.ac | 74 ++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 55 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1ca3974..3cba653 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,16 +272,12 @@ PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
dnl ===========================================================================
dnl Check for Loongson Multimedia Instructions
-if test "x$LS_CFLAGS" = "x" ; then
- LS_CFLAGS="-march=loongson2f"
-fi
-
-have_loongson_mmi=no
-AC_MSG_CHECKING(whether to use Loongson MMI assembler)
+# check CC default configuration
+CFLAGS=" $CFLAGS $LS_CFLAGS"
+AC_MSG_CHECKING(whether to enable Loongson MMI)
xserver_save_CFLAGS=$CFLAGS
-CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
-AC_LINK_IFELSE([AC_LANG_SOURCE([[
+read -d '' tmp_src << EOF
#ifndef __mips_loongson_vector_rev
#error "Loongson Multimedia Instructions are only available on Loongson"
#endif
@@ -292,35 +288,75 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[
int main () {
union {
__m64 v;
- char c[8];
+ char c[[8]]; // autoconf will strip one pair of [], it is not typo
} a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
int b = 4;
__m64 c = _mm_srli_pi16 (a.v, b);
return 0;
-}]])], have_loongson_mmi=yes)
+}
+EOF
+read -d '' tmp_src_loongson2f << EOF
+#ifndef _MIPS_ARCH_LOONGSON2F
+#error "Loongson 2F support of CC is not enabled, Please use CFLAGS
to enable it"
+#endif
+$tmp_src
+EOF
+read -d '' tmp_src_loongson3a << EOF
+#if !defined(_MIPS_ARCH_LOONGSON2F) && defined(__mips_loongson_mmi)
+#else
+ #error "Loongson 3A/MMI support of CC is not enabled, Please use
CFLAGS to enable it"
+#endif
+$tmp_src
+EOF
+
+CFLAGS="$xserver_save_CFLAGS -march=loongson2f"
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson2f]])],
cc_support_mmi_2f=yes)
+CFLAGS="$xserver_save_CFLAGS -mloongson-mmi"
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson3a]])],
cc_support_mmi_3a=yes)
CFLAGS=$xserver_save_CFLAGS
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson2f]])], cc_enable_mmi_2f=yes)
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson3a]])], cc_enable_mmi_3a=yes)
+# user may disable MMI by --disable-loongson-mmi even compiler
supports it by default
+# or LS_CFLAGS for MMI is given
AC_ARG_ENABLE(loongson-mmi,
[AC_HELP_STRING([--disable-loongson-mmi],
[disable Loongson MMI fast paths])],
[enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto])
-if test $enable_loongson_mmi = no ; then
- have_loongson_mmi=disabled
+if test "x$enable_loongson_mmi" != xauto && \
+ test "x$enable_loongson_mmi" != xyes && \
+ test "x$enable_loongson_mmi" != xno;then
+ AC_MSG_ERROR([--enable-loongson-mmi only support value yes/no/auto])
fi
-if test $have_loongson_mmi = yes ; then
- AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
+if test x"$enable_loongson_mmi" = xyes && \
+ test x"$cc_support_mmi_2f" != x"yes" && \
+ test x"$cc_support_mmi_3a" != x"yes"; then
+ AC_MSG_ERROR([MMI is required while not supported by CC])
+elif (test x"$enable_loongson_mmi" = xyes && test
x"$cc_support_mmi_3a" = x"yes") || \
+ (test x"$enable_loongson_mmi" = xauto && test x"$cc_enable_mmi_3a" =
x"yes") ; then
+ enable_loongson_mmi=3a
+ CFLAGS="$xserver_save_CFLAGS -mloongson-mmi"
+elif (test x"$enable_loongson_mmi" = xyes && test
x"$cc_support_mmi_2f" = x"yes") || \
+ (test x"$enable_loongson_mmi" = xauto && test x"$cc_enable_mmi_2f" =
x"yes") ; then
+ enable_loongson_mmi=2f
+ CFLAGS="$xserver_save_CFLAGS -march=loongson2f"
else
- LS_CFLAGS=
+ enable_loongson_mmi=no
+ if test x"$" = x"-mloongson-mmi";then
+ LS_CFLAGS="$LS_CFLAGS -mno-loongson-mmi"
+ elif test x"$LS_CFLAGS_TMP" = x"-mmarch=loongson2f";then
+ LS_CFLAGS="$LS_CFLAGS -march=mips3"
+ fi
fi
-AC_MSG_RESULT($have_loongson_mmi)
-if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ; then
- AC_MSG_ERROR([Loongson MMI not detected])
+if test x"$enable_loongson_mmi" != xno; then
+ AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
fi
+AC_MSG_RESULT($enable_loongson_mmi)
-AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes)
+AM_CONDITIONAL(USE_LOONGSON_MMI, test x"$enable_loongson_mmi" != xno)
dnl ===========================================================================
dnl Check for MMX
--
2.25.0.rc0
More information about the Pixman
mailing list