[Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
YunQiang Su
wzssyqa at gmail.com
Thu Feb 27 01:53:53 UTC 2020
I have a sample version if you really need make so complicated.
In fact I don't think that we need make it like this.
Do *not* use it directly.
diff --git a/configure.ac b/configure.ac
index 1ca3974..f8c1b18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,16 +272,32 @@ PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
dnl ===========================================================================
dnl Check for Loongson Multimedia Instructions
-if test "x$LS_CFLAGS" = "x" ; then
- LS_CFLAGS="-march=loongson2f"
+# check CC default configuration
+xserver_save_CFLAGS=$CFLAGS
+CFLAGS=" $LS_CFLAGS $CFLAGS"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ int main () {
+ /* No -mloongson-mmi,-march=loongson3a and -march=loongson2f */
+ #ifndef __mips_loongson_mmi
+ # error "No Loongson MMI support"
+ #else
+ /* Has Loongson MMI support */
+ #endif
+ }]])], LS_CFLAGS_TMP="-mloongson-mmi", LS_CFLAGS_TMP="")
+if test x"$LS_CFLAGS_TMP" = x"-mloongson-mmi";then
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ int main () {
+ #ifdef _MIPS_ARCH_LOONGSON2F
+ /* Loongson 2F */
+ #else
+ #error "Loongson 3A"
+ #endif
+ }]])], LS_CFLAGS_TMP="-march=loongson2f", LS_CFLAGS_TMP="-mloongson-mmi")
fi
-have_loongson_mmi=no
-AC_MSG_CHECKING(whether to use Loongson MMI assembler)
+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 +308,90 @@ 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
+CFLAGS="$xserver_save_CFLAGS -I$srcdir -march=loongson2f"
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src]])], cc_support_mmi_2f=yes)
+CFLAGS="$xserver_save_CFLAGS -I$srcdir -mloongson-mmi"
+AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src]])], cc_support_mmi_3a=yes)
CFLAGS=$xserver_save_CFLAGS
+# 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 && \
+ test "x$enable_loongson_mmi" != x2f && \
+ test "x$enable_loongson_mmi" != x3a;then
+ AC_MSG_ERROR([--enable-loongson-mmi only support value yes/no/auto/2f/3a])
fi
-if test $have_loongson_mmi = yes ; then
- AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions])
+if test "x$enable_loongson_mmi" = x2f && test x"$cc_support_mmi_2f"
!= x"yes"; then
+ AC_MSG_ERROR([MMI 2F mode is requested while not supported by CC])
+elif test x"$enable_loongson_mmi" = x2f && test x"$cc_support_mmi_2f"
= x"yes"; then
+ LS_CFLAGS="$LS_CFLAGS -march=loongson2f"
+elif test x"$enable_loongson_mmi" = x3a && test x"$cc_support_mmi_3a"
!= x"yes"; then
+ AC_MSG_ERROR([MMI 3A mode is requested while not supported by CC])
+elif test x"$enable_loongson_mmi" = x3a && test x"$cc_support_mmi_3a"
= x"yes"; then
+ LS_CFLAGS="$LS_CFLAGS -mloongson-mmi"
+elif test x"$enable_loongson_mmi" = xno ; then
+ if test x"$LS_CFLAGS_TMP" = 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
+elif 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"$LS_CFLAGS_TMP" =
x"" && test x"$cc_support_mmi_3a" = x"yes"; then
+ # we prefer 3A if gcc is not configured to support MMI by
default, while --enable-loongson-mmi is given
+ enable_loongson_mmi=3a
+ LS_CFLAGS="$LS_CFLAGS -mloongson-mmi"
+elif test x"$enable_loongson_mmi" = xyes && test x"$LS_CFLAGS_TMP" =
x"" && test x"$cc_support_mmi_2f" = x"yes"; then
+ enable_loongson_mmi=2f
+ LS_CFLAGS="$LS_CFLAGS -march=loongson2f"
+elif test x"$enable_loongson_mmi" = xyes && test x"$LS_CFLAGS_TMP" =
x"-mloongson-mmi" && test x"$cc_support_mmi_3a" = x"yes"; then
+ enable_loongson_mmi=3a
+ LS_CFLAGS="$LS_CFLAGS -mloongson-mmi"
+elif test x"$enable_loongson_mmi" = xyes && test x"$LS_CFLAGS_TMP" =
x"-mloongson-mmi" && test x"$cc_support_mmi_3a" != x"yes"; then
+ AC_MSG_ERROR([CC error: it claims support 3A MMI, while in fact not])
+elif test x"$enable_loongson_mmi" = xyes && test x"$LS_CFLAGS_TMP" =
x"-march=loongson2f" && test x"$cc_support_mmi_2f" = x"yes"; then
+ enable_loongson_mmi=2f
+ LS_CFLAGS="$LS_CFLAGS -march=loongson2f"
+elif test x"$enable_loongson_mmi" = xyes && test x"$LS_CFLAGS_TMP" =
x"-march=loongson2f" && test x"$cc_support_mmi_2f" != x"yes"; then
+ AC_MSG_ERROR([CC error: it claims support 2F MMI, while in fact not])
+elif test x"$enable_loongson_mmi" = xauto && test x"$LS_CFLAGS_TMP" =
x"-mloongson-mmi" && test x"$cc_support_mmi_3a" = x"yes"; then
+ enable_loongson_mmi=3a
+ LS_CFLAGS="$LS_CFLAGS -mloongson-mmi"
+elif test x"$enable_loongson_mmi" = xauto && test x"$LS_CFLAGS_TMP" =
x"-mloongson-mmi" && test x"$cc_support_mmi_3a" != x"yes"; then
+ AC_MSG_ERROR([CC error: it claims support 3A MMI, while in fact not])
+elif test x"$enable_loongson_mmi" = xauto && test x"$LS_CFLAGS_TMP" =
x"-march=loongson2f" && test x"$cc_support_mmi_2f" = x"yes"; then
+ enable_loongson_mmi=2f
+ LS_CFLAGS="$LS_CFLAGS -march=loongson2f"
+elif test x"$enable_loongson_mmi" = xauto && test x"$LS_CFLAGS_TMP" =
x"-march=loongson2f" && test x"$cc_support_mmi_2f" != x"yes"; then
+ AC_MSG_ERROR([CC error: it claims support 2F MMI, while in fact not])
+elif test x"$enable_loongson_mmi" = xauto; then
+ # no LS_CFLAGS_TMP set: gcc is configured not use MMI by default
and CFLAGS doesn't have options about MMI
+ enable_loongson_mmi=no
else
- LS_CFLAGS=
+ enable_loongson_mmi=no
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
More information about the Pixman
mailing list