[Pixman] [PATCH] build: Support building Loongson code for 2e, 2f, 3a
Matt Turner
mattst88 at gmail.com
Sat Sep 15 23:59:12 PDT 2012
pixman/Makefile.am contains a hack that allows pixman-mmx.c to
be compiled with different overriding CFLAGS, since automake
seriously doesn't have a way to do this. Seriously stupid.
It works by defining a new rule and recursively calling make
with modified CFLAGS set.
Note the difference between the USE_LOONGSON* and HAVE_LOONGSON*
preprocessor macros.
Cc: Cyril Brulebois <kibi at debian.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51451
---
This patch applies on top of the previous.
Although the build system works, linking unfortunately doesn't. gcc
refuses to link object files that have been compiled with different
-march=loongson* options together. This sucks.
I'm not sure what to do. I guess I could make them separate shared
objects or even dlopen them, but that really sucks, especially when
I don't see a reason why gcc shouldn't be able to link this code
together.
Anyone have any other ideas? It's really obnoxious that there's not
just a simple -mloongson-mmi flag irrespective of -march=...
configure.ac | 87 ++++++++++++++++++++++++++++++++++++++++++----
pixman/Makefile.am | 36 +++++++++++++++++---
pixman/pixman-mips.c | 16 +++++++-
pixman/pixman-mmx.c | 10 +++++-
pixman/pixman-private.h | 13 +++++++
5 files changed, 146 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5fda547..f3804ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,21 +273,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 () {
@@ -299,29 +305,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
@@ -468,7 +540,6 @@ case $host_os in
;;
esac
-AC_SUBST(LS_CFLAGS)
AC_SUBST(IWMMXT_CFLAGS)
AC_SUBST(MMX_CFLAGS)
AC_SUBST(MMX_LDFLAGS)
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 270d65e..6a23545 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -120,11 +120,37 @@ 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
+noinst_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_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
+noinst_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_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
+noinst_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_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) $(BUILT_SOURCES)
diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 2b280c6..0e070ad 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 b3a4c5f..91cc665 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -2055,7 +2055,7 @@ mmx_composite_over_n_8_8888 (pixman_implementation_t *imp,
_mm_empty ();
}
-pixman_bool_t
+static pixman_bool_t
pixman_fill_mmx (uint32_t *bits,
int stride,
int bpp,
@@ -4092,7 +4092,15 @@ mmx_fill (pixman_implementation_t *imp,
}
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 dbfa829..57602e7 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_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.6
More information about the Pixman
mailing list