diff --git a/configure.ac b/configure.ac index e3a5ff9..c14138c 100644 --- a/configure.ac +++ b/configure.ac @@ -273,21 +273,30 @@ PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl dnl =========================================================================== dnl Check for Loongson Multimedia Instructions -if test "x$LS_CFLAGS" = "x" ; then - LS_CFLAGS="-march=loongson2f" +if test "x$LS2E_CFLAGS" = "x" ; then + LS2F_CFLAGS="-march=loongson2e" +fi +if test "x$LS2F_CFLAGS" = "x" ; then + LS2F_CFLAGS="-march=loongson2f" +fi +if test "x$LS3A_CFLAGS" = "x" ; then + LS2F_CFLAGS="-march=loongson3a" fi have_loongson_mmi=no +have_loongson2e_mmi=no +have_loongson2f_mmi=no +have_loongson3a_mmi=no AC_MSG_CHECKING(whether to use Loongson MMI assembler) xserver_save_CFLAGS=$CFLAGS -CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir" +CFLAGS=" $LS2F_CFLAGS $CFLAGS -I$srcdir" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef __mips_loongson_vector_rev #error "Loongson Multimedia Instructions are only available on Loongson" #endif #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4)) -#error "Need GCC >= 4.4 for Loongson MMI compilation" +#error "Need GCC >= 4.4 for Loongson 2e/f MMI compilation" #endif #include "pixman/loongson-mmintrin.h" int main () { @@ -301,27 +310,79 @@ int main () { }]])], have_loongson_mmi=yes) CFLAGS=$xserver_save_CFLAGS +xserver_save_CFLAGS=$CFLAGS +CFLAGS=" $LS3A_CFLAGS $CFLAGS -I$srcdir" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#ifndef __mips_loongson_vector_rev +#error "Loongson Multimedia Instructions are only available on Loongson" +#endif +#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) +#error "Need GCC >= 4.6 for Loongson 3A MMI compilation" +#endif +#include "pixman/loongson-mmintrin.h" +int main () { + union { + __m64 v; + char c[8]; + } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} }; + int b = 4; + __m64 c = _mm_srli_pi16 (a.v, b); + return 0; +}]])], have_loongson3a_mmi=yes) +CFLAGS=$xserver_save_CFLAGS + AC_ARG_ENABLE(loongson-mmi, [AC_HELP_STRING([--disable-loongson-mmi], [disable Loongson MMI fast paths])], [enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto]) +AC_ARG_ENABLE(loongson2e-mmi, + [AC_HELP_STRING([--disable-loongson2e-mmi], + [do not build Loongson MMI fast paths for 2e])], + [enable_loongson2e_mmi=$enableval], [enable_loongson2e_mmi=yes]) +AC_ARG_ENABLE(loongson2f-mmi, + [AC_HELP_STRING([--disable-loongson2f-mmi], + [do not build Loongson MMI fast paths for 2f])], + [enable_loongson2f_mmi=$enableval], [enable_loongson2f_mmi=yes]) +AC_ARG_ENABLE(loongson3a-mmi, + [AC_HELP_STRING([--disable-loongson3a-mmi], + [do not build Loongson MMI fast paths for 3a])], + [enable_loongson3a_mmi=$enableval], [enable_loongson3a_mmi=auto]) if test $enable_loongson_mmi = no ; then have_loongson_mmi=disabled fi +if test $enable_loongson2e_mmi = no ; then + have_loongson2e_mmi=disabled +fi +if test $enable_loongson2f_mmi = no ; then + have_loongson2f_mmi=disabled +fi +if test $enable_loongson3a_mmi = no ; then + have_loongson3a_mmi=disabled +fi if test $have_loongson_mmi = yes ; then AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions]) + loongson_msg="$have_loongson_mmi: 2e, 2f" + if test $have_loongson3a_mmi = yes ; then + loongson_msg="$loongson_msg, 3a" + fi else - LS_CFLAGS= + loongson_msg="no" fi -AC_MSG_RESULT($have_loongson_mmi) -if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ; then +AC_MSG_RESULT($loongson_msg) +if test $enable_loongson_mmi = yes -a $have_loongson_mmi = no ; then AC_MSG_ERROR([Loongson MMI not detected]) fi +if test $enable_loongson3a_mmi = yes -a $have_loongson3a_mmi = no ; then + AC_MSG_ERROR([Cannot build Loongson MMI for 3a]) +fi AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes) +AM_CONDITIONAL(HAVE_LOONGSON2E, test $have_loongson2e_mmi = yes) +AM_CONDITIONAL(HAVE_LOONGSON2F, test $have_loongson2f_mmi = yes) +AM_CONDITIONAL(HAVE_LOONGSON3A, test $have_loongson3a_mmi = yes) dnl =========================================================================== dnl Check for MMX diff --git a/pixman/Makefile.am b/pixman/Makefile.am index 843711a..8326d51 100644 --- a/pixman/Makefile.am +++ b/pixman/Makefile.am @@ -130,14 +130,27 @@ endif # loongson code if USE_LOONGSON_MMI -noinst_LTLIBRARIES += libpixman-loongson-mmi.la -libpixman_loongson_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h -libpixman_loongson_mmi_la_CFLAGS = $(DEP_CFLAGS) $(LS_CFLAGS) -libpixman_loongson_mmi_la_LIBADD = $(DEP_LIBS) -libpixman_1_la_LDFLAGS += $(LS_LDFLAGS) -libpixman_1_la_LIBADD += libpixman-loongson-mmi.la - -ASM_CFLAGS_ls=$(LS_CFLAGS) +if HAVE_LOONGSON2E +noinst_LTLIBRARIES += libpixman-loongson2e-mmi.la +libpixman_loongson2e_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson2e_mmi_la_CFLAGS = $(DEP_CFLAGS) $(LS2E_CFLAGS) +libpixman_loongson2e_mmi_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-loongson2e-mmi.la +endif +if HAVE_LOONGSON2F +noinst_LTLIBRARIES += libpixman-loongson2f-mmi.la +libpixman_loongson2f_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson2f_mmi_la_CFLAGS = $(DEP_CFLAGS) $(LS2F_CFLAGS) +libpixman_loongson2f_mmi_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-loongson2f-mmi.la +endif +if HAVE_LOONGSON3A +noinst_LTLIBRARIES += libpixman-loongson3a-mmi.la +libpixman_loongson3a_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson3a_mmi_la_CFLAGS = $(DEP_CFLAGS) $(LS3A_CFLAGS) +libpixman_loongson3a_mmi_la_LIBADD = $(DEP_LIBS) +libpixman_1_la_LIBADD += libpixman-loongson3a-mmi.la +endif endif .c.s : $(libpixmaninclude_HEADERS) $(BUILT_SOURCES) diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c index 2b280c6..f091a67 100644 --- a/pixman/pixman-mips.c +++ b/pixman/pixman-mips.c @@ -70,8 +70,20 @@ _pixman_mips_get_implementations (pixman_implementation_t *imp) { #ifdef USE_LOONGSON_MMI /* I really don't know if some Loongson CPUs don't have MMI. */ - if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson")) - imp = _pixman_implementation_create_mmx (imp); +#ifdef HAVE_LOONGSON2E + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson") + && have_feature ("-2e")) + imp = _pixman_implementation_create_mmx_2e (imp); +#endif +#ifdef HAVE_LOONGSON2F + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson") + && have_feature ("-2f")) + imp = _pixman_implementation_create_mmx_2f (imp); +#endif +#ifdef HAVE_LOONGSON3A + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson-3A")) + imp = _pixman_implementation_create_mmx_3a (imp); +#endif #endif #ifdef USE_MIPS_DSPR2 diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c index 74a5e87..6628987 100644 --- a/pixman/pixman-mmx.c +++ b/pixman/pixman-mmx.c @@ -4091,7 +4091,15 @@ mmx_fill (pixman_implementation_t *imp, } pixman_implementation_t * +#ifdef HAVE_LOONGSON2E +_pixman_implementation_create_mmx_2e (pixman_implementation_t *fallback) +#elif defined HAVE_LOONGSON2F +_pixman_implementation_create_mmx_2f (pixman_implementation_t *fallback) +#elif defined HAVE_LOONGSON3A +_pixman_implementation_create_mmx_3a (pixman_implementation_t *fallback) +#else _pixman_implementation_create_mmx (pixman_implementation_t *fallback) +#endif { pixman_implementation_t *imp = _pixman_implementation_create (fallback, mmx_fast_paths); diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index d5e6a72..7965cf9 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -558,6 +558,19 @@ _pixman_implementation_create_noop (pixman_implementation_t *fallback); #if defined USE_X86_MMX || defined USE_ARM_IWMMXT || defined USE_LOONGSON_MMI pixman_implementation_t * _pixman_implementation_create_mmx (pixman_implementation_t *fallback); + +#ifdef HAVE_LOONGSON2E +pixman_implementation_t * +_pixman_implementation_create_mmx_2e (pixman_implementation_t *fallback); +#endif +#ifdef HAVE_LOONGSON2F +pixman_implementation_t * +_pixman_implementation_create_mmx_2f (pixman_implementation_t *fallback); +#endif +#ifdef HAVE_LOONGSON3A +pixman_implementation_t * +_pixman_implementation_create_mmx_3a (pixman_implementation_t *fallback); +#endif #endif #ifdef USE_SSE2