From 662f75e048bc3080b49f2bf285bcc62209272d29 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 15 Sep 2012 22:55:09 -0400 Subject: [PATCH] build: Support building Loongson code for 2e, 2f, 3a Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51451 --- configure.ac | 86 +++++++++++++++++++++++++++++++++++++++++++---- pixman/Makefile.am | 39 ++++++++++++++++++--- pixman/pixman-mips.c | 16 ++++++++- pixman/pixman-mmx.c | 8 ++++ pixman/pixman-private.h | 13 +++++++ 5 files changed, 148 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 515e312..3c5ba07 100644 --- a/configure.ac +++ b/configure.ac @@ -270,21 +270,27 @@ 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 + LS2E_CFLAGS="-march=loongson2e" +fi +if test "x$LS2F_CFLAGS" = "x" ; then + LS2F_CFLAGS="-march=loongson2f" +fi +if test "x$LS3A_CFLAGS" = "x" ; then + LS3A_CFLAGS="-march=loongson3a" fi have_loongson_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 () { @@ -296,29 +302,95 @@ int main () { __m64 c = _mm_srli_pi16 (a.v, b); return 0; }]])], have_loongson_mmi=yes) +have_loongson2e_mmi=$have_loongson_mmi +have_loongson2f_mmi=$have_loongson_mmi +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=auto]) +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=auto]) +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 + loongson_msg="yes:" AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia Instructions]) + if test $have_loongson2e_mmi = yes ; then + loongson_msg="$loongson_msg 2e" + AC_DEFINE(HAVE_LOONGSON2E_MMI, 1, [use Loongson 2e Multimedia Instructions]) + fi + if test $have_loongson2f_mmi = yes ; then + loongson_msg="$loongson_msg 2f" + AC_DEFINE(HAVE_LOONGSON2F_MMI, 1, [use Loongson 2f Multimedia Instructions]) + fi + if test $have_loongson3a_mmi = yes ; then + loongson_msg="$loongson_msg 3a" + AC_DEFINE(HAVE_LOONGSON3A_MMI, 1, [use Loongson 3a Multimedia Instructions]) + 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 +AC_SUBST([LS2E_CFLAGS]) +AC_SUBST([LS2F_CFLAGS]) +AC_SUBST([LS3A_CFLAGS]) 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 cbed085..de668ac 100644 --- a/pixman/Makefile.am +++ b/pixman/Makefile.am @@ -114,11 +114,40 @@ 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 = $(LS_CFLAGS) -libpixman_1_la_LDFLAGS += $(LS_LDFLAGS) -libpixman_1_la_LIBADD += libpixman-loongson-mmi.la +if HAVE_LOONGSON2E +lib_LTLIBRARIES += libpixman-loongson2e-mmi.la +libpixman_loongson2e_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson2e_mmi_la_CPPFLAGS = -DUSE_LOONGSON2E_MMI +libpixman_loongson2e_mmi_la_LDFLAGS = -avoid-version +libpixman_1_la_LIBADD += libpixman-loongson2e-mmi.la + +LS2E_LO = libpixman_loongson2e_mmi_la-pixman-mmx.lo +$(LS2E_LO): pixman-mmx.c loongson-mmintrin.h + @$(MAKE) libpixman_loongson2e_mmi_la-pixman-mmx.lo CFLAGS="$(CFLAGS) $(LS2E_CFLAGS)" LS2E_LO=dummy-libpixman_loongson2e_mmi_la-pixman-mmx.lo +endif +if HAVE_LOONGSON2F +lib_LTLIBRARIES += libpixman-loongson2f-mmi.la +libpixman_loongson2f_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson2f_mmi_la_CPPFLAGS = -DUSE_LOONGSON2F_MMI +libpixman_loongson2f_mmi_la_LDFLAGS = -avoid-version +libpixman_1_la_LIBADD += libpixman-loongson2f-mmi.la + +LS2F_LO = libpixman_loongson2f_mmi_la-pixman-mmx.lo +$(LS2F_LO): pixman-mmx.c loongson-mmintrin.h + @$(MAKE) libpixman_loongson2f_mmi_la-pixman-mmx.lo CFLAGS="$(CFLAGS) $(LS2F_CFLAGS)" LS2F_LO=dummy-libpixman_loongson2f_mmi_la-pixman-mmx.lo +endif +if HAVE_LOONGSON3A +lib_LTLIBRARIES += libpixman-loongson3a-mmi.la +libpixman_loongson3a_mmi_la_SOURCES = pixman-mmx.c loongson-mmintrin.h +libpixman_loongson3a_mmi_la_CPPFLAGS = -DUSE_LOONGSON3A_MMI +libpixman_loongson3a_mmi_la_LDFLAGS = -avoid-version +libpixman_1_la_LIBADD += libpixman-loongson3a-mmi.la + +LS3A_LO = libpixman_loongson3a_mmi_la-pixman-mmx.lo +$(LS3A_LO): pixman-mmx.c loongson-mmintrin.h + @$(MAKE) libpixman_loongson3a_mmi_la-pixman-mmx.lo CFLAGS="$(CFLAGS) $(LS3A_CFLAGS)" LS3A_LO=dummy-libpixman_loongson3a_mmi_la-pixman-mmx.lo +endif + endif .c.s : $(libpixmaninclude_HEADERS) diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c index 3048813..53b7547 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_MMI + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson") + && have_feature ("-2e")) + imp = _pixman_implementation_create_mmx_2e (imp); +#endif +#ifdef HAVE_LOONGSON2F_MMI + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson") + && have_feature ("-2f")) + imp = _pixman_implementation_create_mmx_2f (imp); +#endif +#ifdef HAVE_LOONGSON3A_MMI + 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 ca2ac83..7dbb53d 100644 --- a/pixman/pixman-mmx.c +++ b/pixman/pixman-mmx.c @@ -4045,7 +4045,15 @@ static const pixman_fast_path_t mmx_fast_paths[] = }; pixman_implementation_t * +#ifdef USE_LOONGSON2E_MMI +_pixman_implementation_create_mmx_2e (pixman_implementation_t *fallback) +#elif defined USE_LOONGSON2F_MMI +_pixman_implementation_create_mmx_2f (pixman_implementation_t *fallback) +#elif defined USE_LOONGSON3A_MMI +_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 e5ab873..f871aef 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -578,6 +578,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_MMI +pixman_implementation_t * +_pixman_implementation_create_mmx_2e (pixman_implementation_t *fallback); +#endif +#ifdef HAVE_LOONGSON2F_MMI +pixman_implementation_t * +_pixman_implementation_create_mmx_2f (pixman_implementation_t *fallback); +#endif +#ifdef HAVE_LOONGSON3A_MMI +pixman_implementation_t * +_pixman_implementation_create_mmx_3a (pixman_implementation_t *fallback); +#endif #endif #ifdef USE_SSE2 -- 1.7.8.5