Re: [Pixman] Use of bitwise operators on vectors with Boolean results

2014-06-27 Thread Michael Tautschnig
[...]
  as, at least on the platforms that I tried, comparisons on vectors yield
  (unsigned)-1 as representation of true.
 
 Yes, this behaves exactly as documented at:
 
 https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
 
 Vectors are compared element-wise producing 0 when comparison is false
 and -1 (constant of the appropriate type where all bits are set)
 otherwise.
 

Thank you very much for the elaboration!

Sorry for the noise,
Michael

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 03/13] MIPS: dspr2: Removed build restrictions and repair compiler's check

2014-06-27 Thread Nemanja Lukic
Build restriction wasn't good since it demands '-mips32r2'
in CFLAGS during configuration to enable DSPr2 optimizations.
Additional CFLAGS are not needed now and pixman could build
targeting the lowest common denominator.
Architecture and ISA are set in inline assembler
to allow compiler to build test code.
---
 configure.ac |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0339494..7d62373 100644
--- a/configure.ac
+++ b/configure.ac
@@ -720,25 +720,21 @@ dnl Check if assembler is gas compatible and supports 
MIPS DSPr2 instructions
 
 have_mips_dspr2=no
 AC_MSG_CHECKING(whether to use MIPS DSPr2 assembler)
-xserver_save_CFLAGS=$CFLAGS
-CFLAGS=-mdspr2 $CFLAGS
 
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-#if !(defined(__mips__)   __mips_isa_rev = 2)
-#error MIPS DSPr2 is currently only available on MIPS32r2 platforms.
-#endif
 int
 main ()
 {
 int c = 0, a = 0, b = 0;
 __asm__ __volatile__ (
+.setarch=mips32r2 \n\t
+.setdspr2 \n\t
 precr.qb.ph %[c], %[a], %[b]  \n\t
 : [c] =r (c)
 : [a] r (a), [b] r (b)
 );
 return c;
 }]])], have_mips_dspr2=yes)
-CFLAGS=$xserver_save_CFLAGS
 
 AC_ARG_ENABLE(mips-dspr2,
[AC_HELP_STRING([--disable-mips-dspr2],
-- 
1.7.3

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 02/13] MIPS: update author's e-mail address

2014-06-27 Thread Nemanja Lukic
---
 pixman/pixman-mips-dspr2-asm.S |2 +-
 pixman/pixman-mips-dspr2-asm.h |2 +-
 pixman/pixman-mips-dspr2.c |2 +-
 pixman/pixman-mips-dspr2.h |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pixman/pixman-mips-dspr2-asm.S b/pixman/pixman-mips-dspr2-asm.S
index 866e93e..9dad163 100644
--- a/pixman/pixman-mips-dspr2-asm.S
+++ b/pixman/pixman-mips-dspr2-asm.S
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Author:  Nemanja Lukic (nlu...@mips.com)
+ * Author:  Nemanja Lukic (nemanja.lu...@rt-rk.com)
  */
 
 #include pixman-private.h
diff --git a/pixman/pixman-mips-dspr2-asm.h b/pixman/pixman-mips-dspr2-asm.h
index 11849bd..482ad15 100644
--- a/pixman/pixman-mips-dspr2-asm.h
+++ b/pixman/pixman-mips-dspr2-asm.h
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Author:  Nemanja Lukic (nlu...@mips.com)
+ * Author:  Nemanja Lukic (nemanja.lu...@rt-rk.com)
  */
 
 #ifndef PIXMAN_MIPS_DSPR2_ASM_H
diff --git a/pixman/pixman-mips-dspr2.c b/pixman/pixman-mips-dspr2.c
index e10c9df..03ad787 100644
--- a/pixman/pixman-mips-dspr2.c
+++ b/pixman/pixman-mips-dspr2.c
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Author:  Nemanja Lukic (nlu...@mips.com)
+ * Author:  Nemanja Lukic (nemanja.lu...@rt-rk.com)
  */
 
 #ifdef HAVE_CONFIG_H
diff --git a/pixman/pixman-mips-dspr2.h b/pixman/pixman-mips-dspr2.h
index 955ed70..7a7fd39 100644
--- a/pixman/pixman-mips-dspr2.h
+++ b/pixman/pixman-mips-dspr2.h
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Author:  Nemanja Lukic (nlu...@mips.com)
+ * Author:  Nemanja Lukic (nemanja.lu...@rt-rk.com)
  */
 
 #ifndef PIXMAN_MIPS_DSPR2_H
-- 
1.7.3

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 07/13] MIPS: mips32r2: empty implementation with runtime detection

2014-06-27 Thread Nemanja Lukic
configure.ac - added compiler's check for mips32r2
Makefile.am - added files for mips32r2 support
pixman-mips.c - runtime detection extended to
support mips32r2 (searches mips32r2 cores
or 'mips32r2' in ASEs implemented (for
kernels = 3.7))
pixman-mips32r2.c - added empty mips32r2 implementation
added mips32r2 files with headers only
---
 configure.ac|   39 +
 pixman/Makefile.am  |   20 +--
 pixman/pixman-mips-common-asm.h |   35 ++
 pixman/pixman-mips-common.h |   35 ++
 pixman/pixman-mips-dspr2-asm.S  |2 +-
 pixman/pixman-mips-dspr2-asm.h  |2 +-
 pixman/pixman-mips-dspr2.c  |2 +-
 pixman/pixman-mips.c|   29 +-
 pixman/pixman-mips32r2-asm.S|   30 +++
 pixman/pixman-mips32r2-asm.h|   35 ++
 pixman/pixman-mips32r2.c|   51 +++
 pixman/pixman-private.h |5 
 12 files changed, 278 insertions(+), 7 deletions(-)
 create mode 100644 pixman/pixman-mips-common-asm.h
 create mode 100644 pixman/pixman-mips-common.h
 create mode 100644 pixman/pixman-mips32r2-asm.S
 create mode 100644 pixman/pixman-mips32r2-asm.h
 create mode 100644 pixman/pixman-mips32r2.c

diff --git a/configure.ac b/configure.ac
index 7d62373..b320072 100644
--- a/configure.ac
+++ b/configure.ac
@@ -716,6 +716,45 @@ fi
 AM_CONDITIONAL(USE_ARM_IWMMXT, test $have_iwmmxt_intrinsics = yes)
 
 dnl ==
+dnl Check if assembler is gas compatible and supports MIPS32r2 instructions
+
+have_mips32r2=no
+AC_MSG_CHECKING(whether to use MIPS32r2 assembler)
+
+AC_COMPILE_IFELSE([[
+int
+main () {
+int a = 0, b = 0;
+__asm__ __volatile__ (
+.set arch=mips32r2\n\t
+ins  %[b], %[a], 14, 14   \n\t
+: [b] =r (b)
+: [a] r (a)
+);
+return b;
+}]], have_mips32r2=yes)
+
+AC_ARG_ENABLE(mips32r2,
+   [AC_HELP_STRING([--disable-mips32r2],
+   [disable MIPS32r2 fast paths])],
+   [enable_mips32r2=$enableval], [enable_mips32r2=auto])
+
+if test $enable_mips32r2 = no ; then
+   have_mips32r2=disabled
+fi
+
+if test $have_mips32r2 = yes ; then
+   AC_DEFINE(USE_MIPS32R2, 1, [use MIPS32r2 assembly optimizations])
+fi
+
+AM_CONDITIONAL(USE_MIPS32R2, test $have_mips32r2 = yes)
+
+AC_MSG_RESULT($have_mips32r2)
+if test $enable_mips32r2 = yes  test $have_mips32r2 = no ; then
+   AC_MSG_ERROR([MIPS32r2 instructions not detected])
+fi
+
+dnl ==
 dnl Check if assembler is gas compatible and supports MIPS DSPr2 instructions
 
 have_mips_dspr2=no
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 581b6f6..0a6f585 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -114,15 +114,29 @@ libpixman-iwmmxt.la: libpixman_iwmmxt_la-pixman-mmx.lo 
$(libpixman_iwmmxt_la_DEP
$(AM_V_CCLD)$(libpixman_iwmmxt_la_LINK) 
libpixman_iwmmxt_la-pixman-mmx.lo $(libpixman_iwmmxt_la_LIBADD) $(LIBS)
 endif
 
+# mips32r2 code
+if USE_MIPS32R2
+noinst_LTLIBRARIES += libpixman-mips32r2.la
+libpixman_mips32r2_la_SOURCES = \
+pixman-mips32r2.c \
+pixman-mips-common.h \
+pixman-mips-common-asm.h \
+pixman-mips32r2-asm.S \
+pixman-mips32r2-asm.h
+libpixman_1_la_LIBADD += libpixman-mips32r2.la
+
+ASM_CFLAGS_mips32r2=
+endif
+
 # mips dspr2 code
 if USE_MIPS_DSPR2
 noinst_LTLIBRARIES += libpixman-mips-dspr2.la
 libpixman_mips_dspr2_la_SOURCES = \
 pixman-mips-dspr2.c \
-pixman-mips-dspr2.h \
+pixman-mips-common.h \
+pixman-mips-common-asm.h \
 pixman-mips-dspr2-asm.S \
-pixman-mips-dspr2-asm.h \
-pixman-mips-memcpy-asm.S
+pixman-mips-dspr2-asm.h
 libpixman_1_la_LIBADD += libpixman-mips-dspr2.la
 
 ASM_CFLAGS_mips_dspr2=
diff --git a/pixman/pixman-mips-common-asm.h b/pixman/pixman-mips-common-asm.h
new file mode 100644
index 000..1e97cc7
--- /dev/null
+++ b/pixman/pixman-mips-common-asm.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012-2013
+ *  MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
+ *contributors may be used to endorse or promote products derived from
+ *this 

[Pixman] [PATCH 06/13] MIPS: dspr2: runtime detection extended

2014-06-27 Thread Nemanja Lukic
isa filed (mips32r2) is available from kernel version 3.9
ASEs implemented field (dsp, dsp2) is available from 3.7
In older kernel versions dsp represents both DSPr1 and DSPr2

if kernel version is 3.7 and above runtime detection tries
to find 'dsp2' in /proc/cpuinfo. If it fails or if kernel
version is  3.7 it tries to find core strings in
/proc/cpuinfo

old runtime detection searches only for core strings
---
 pixman/pixman-mips.c |   87 ++---
 1 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 3048813..f347bb9 100644
--- a/pixman/pixman-mips.c
+++ b/pixman/pixman-mips.c
@@ -24,14 +24,27 @@
 #endif
 
 #include pixman-private.h
-
-#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
-
 #include string.h
 #include stdlib.h
 
+#ifdef USE_MIPS_DSPR2
+static const char *mips_dspr2_cores[] =
+{
+MIPS 74K, NULL
+};
+#endif
+
+#ifdef USE_LOONGSON_MMI
+static const char *mips_loongson_cores[] =
+{
+Loongson, NULL
+};
+#endif
+
+#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
+
 static pixman_bool_t
-have_feature (const char *search_string)
+have_feature (const char **cores, const char *search_string)
 {
 #if defined (__linux__) /* linux ELF */
 /* Simple detection of MIPS features at runtime for Linux.
@@ -40,20 +53,52 @@ have_feature (const char *search_string)
  * facility is universally available on the MIPS architectures, so it's up
  * to individual OSes to provide such.
  */
-const char *file_name = /proc/cpuinfo;
-char cpuinfo_line[256];
+const char *file_name = /proc/version;
+char line[512];
+int v0 = 0, v1 = 0;
 FILE *f = NULL;
+char **temp = (char **)cores;
+
+if ((f = fopen (file_name, r)) != NULL)
+{
+if (fgets (line, sizeof (line), f) != NULL)
+sscanf (line, %*s%*s%d%*c%d, v0, v1);
+fclose (f);
+}
+
+file_name = /proc/cpuinfo;
 
 if ((f = fopen (file_name, r)) == NULL)
 return FALSE;
 
-while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
+if (((v0 = 3)  (v1 = 7)) || (v0 = 4))
 {
-if (strstr (cpuinfo_line, search_string) != NULL)
+/* isa filed (mips32r2) is available from kernel version 3.9
+ * ASEs implemented field (dsp, dsp2) is available from 3.7
+ * In older kernel versions dsp represents both DSPr1 and DSPr2
+ */
+while (fgets (line, sizeof (line), f) != NULL)
 {
-fclose (f);
-return TRUE;
+if (strstr (line, search_string) != NULL)
+{
+fclose (f);
+return TRUE;
+}
 }
+rewind(f);
+}
+
+while (fgets (line, sizeof (line), f) != NULL)
+{
+while (*temp)
+{
+if (strstr (line, *temp++) != NULL)
+{
+fclose (f);
+return TRUE;
+}
+}
+temp = (char **)cores;
 }
 
 fclose (f);
@@ -70,23 +115,25 @@ _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);
+if (!_pixman_disabled (loongson-mmi) 
+have_feature (mips_loongson_cores, Loongson))
+{
+imp = _pixman_implementation_create_mmx (imp);
+}
 #endif
 
 #ifdef USE_MIPS_DSPR2
 if (!_pixman_disabled (mips-dspr2))
 {
-   int already_compiling_everything_for_dspr2 = 0;
+int already_compiling_everything_for_dspr2 = 0;
 #if defined(__mips_dsp)  (__mips_dsp_rev = 2)
-   already_compiling_everything_for_dspr2 = 1;
+already_compiling_everything_for_dspr2 = 1;
 #endif
-   if (already_compiling_everything_for_dspr2 ||
-   /* Only currently available MIPS core that supports DSPr2 is 74K. */
-   have_feature (MIPS 74K))
-   {
-   imp = _pixman_implementation_create_mips_dspr2 (imp);
-   }
+if (already_compiling_everything_for_dspr2 ||
+have_feature (mips_dspr2_cores, dsp2))
+{
+imp = _pixman_implementation_create_mips_dspr2 (imp);
+}
 }
 #endif
 
-- 
1.7.3

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 12/13] MIPS: disabled non 32-bit platforms

2014-06-27 Thread Nemanja Lukic
There are important differences in the ABI, since saved
registers or passed values can take twice as much stack space.
This patch add mechanism which allows optimizations to be run only
on 32-bit platforms since all optimizations are done in assembly.
---
 pixman/pixman-mips.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 5a23a67..4c31a80 100644
--- a/pixman/pixman-mips.c
+++ b/pixman/pixman-mips.c
@@ -142,6 +142,10 @@ _pixman_mips_get_implementations (pixman_implementation_t 
*imp)
 }
 #endif
 
+/* disable runtime detection for non 32-bit platforms */
+if (sizeof (uintptr_t) != 4)
+return imp;
+
 #ifdef USE_MIPS32R2
 if (!_pixman_disabled (mips32r2))
 {
-- 
1.7.3

___
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [PATCH 05/13] Implementing memcpy through pointer

2014-06-27 Thread Nemanja Lukic
pointer to function (memcpy) added to pixman_implementation_t
and it points to C version of memcpy (linked in
pixman-general.c). Function to call is pixman_memcpy and
every call of memcpy is replaced with pixman_memcpy.
If there is optimized version of memcpy it should
be linked with imp-memcpy.
---
 pixman/pixman-combine32.c  |2 +-
 pixman/pixman-fast-path.c  |2 +-
 pixman/pixman-filter.c |4 ++--
 pixman/pixman-general.c|2 ++
 pixman/pixman-image.c  |8 
 pixman/pixman-implementation.c |   20 
 pixman/pixman-private.h|   10 ++
 pixman/pixman-region.c |4 ++--
 pixman/pixman-x86.c|6 +++---
 pixman/pixman.c|9 +
 pixman/pixman.h|3 +++
 test/lowlevel-blt-bench.c  |   36 ++--
 test/tolerance-test.c  |2 +-
 test/utils-prng.c  |2 +-
 14 files changed, 77 insertions(+), 33 deletions(-)

diff --git a/pixman/pixman-combine32.c b/pixman/pixman-combine32.c
index 4c484d3..68c4427 100644
--- a/pixman/pixman-combine32.c
+++ b/pixman/pixman-combine32.c
@@ -173,7 +173,7 @@ combine_src_u (pixman_implementation_t *imp,
 
 if (!mask)
 {
-   memcpy (dest, src, width * sizeof (uint32_t));
+   pixman_memcpy (dest, src, width * sizeof (uint32_t));
 }
 else
 {
diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c
index c6e43de..9eb1ed8 100644
--- a/pixman/pixman-fast-path.c
+++ b/pixman/pixman-fast-path.c
@@ -1175,7 +1175,7 @@ fast_composite_src_memcpy (pixman_implementation_t *imp,
 
 while (height--)
 {
-   memcpy (dst, src, n_bytes);
+   pixman_memcpy (dst, src, n_bytes);
 
dst += dst_stride;
src += src_stride;
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index b2bf53f..52db5f3 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -337,9 +337,9 @@ pixman_filter_create_separable_convolution (int 
*n_values,
 params[2] = pixman_int_to_fixed (subsample_bits_x);
 params[3] = pixman_int_to_fixed (subsample_bits_y);
 
-memcpy (params + 4, horz,
+pixman_memcpy (params + 4, horz,
width * subsample_x * sizeof (pixman_fixed_t));
-memcpy (params + 4 + width * subsample_x, vert,
+pixman_memcpy (params + 4 + width * subsample_x, vert,
height * subsample_y * sizeof (pixman_fixed_t));
 
 out:
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 7cdea29..8ecbe30 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -249,6 +249,8 @@ _pixman_implementation_create_general (void)
 {
 pixman_implementation_t *imp = _pixman_implementation_create (NULL, 
general_fast_path);
 
+imp-memcpy = (void*)memcpy;
+
 _pixman_setup_combiner_functions_32 (imp);
 _pixman_setup_combiner_functions_float (imp);
 
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 1ff1a49..4896399 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -98,7 +98,7 @@ _pixman_init_gradient (gradient_t *  gradient,
return FALSE;
 
 gradient-stops += 1;
-memcpy (gradient-stops, stops, n_stops * sizeof (pixman_gradient_stop_t));
+pixman_memcpy (gradient-stops, stops, n_stops * sizeof 
(pixman_gradient_stop_t));
 gradient-n_stops = n_stops;
 
 gradient-common.property_changed = gradient_property_changed;
@@ -652,7 +652,7 @@ pixman_image_set_transform (pixman_image_t *  image,
goto out;
 }
 
-memcpy (common-transform, transform, sizeof(pixman_transform_t));
+pixman_memcpy (common-transform, transform, sizeof(pixman_transform_t));
 
 result = TRUE;
 
@@ -706,8 +706,8 @@ pixman_image_set_filter (pixman_image_t *  image,
if (!new_params)
return FALSE;
 
-   memcpy (new_params,
-   params, n_params * sizeof (pixman_fixed_t));
+   pixman_memcpy (new_params,
+  params, n_params * sizeof (pixman_fixed_t));
 }
 
 common-filter = filter;
diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c
index 5884054..d4ca0b2 100644
--- a/pixman/pixman-implementation.c
+++ b/pixman/pixman-implementation.c
@@ -285,6 +285,26 @@ _pixman_implementation_fill (pixman_implementation_t *imp,
 return FALSE;
 }
 
+pixman_bool_t
+_pixman_implementation_memcpy (pixman_implementation_t *imp,
+   void*dest,
+   const void  *src,
+   uint32_tn)
+{
+while (imp)
+{
+   if (imp-memcpy 
+   ((*imp-memcpy) (dest, src, n)))
+   {
+   return TRUE;
+   }
+
+   imp = imp-fallback;
+}
+
+return FALSE;
+}
+
 static uint32_t *
 get_scanline_null (pixman_iter_t *iter, const uint32_t *mask)
 {
diff --git a/pixman/pixman-private.h 

[Pixman] [PATCH 09/13] MIPS: dspr1: empty implementation with runtime detection

2014-06-27 Thread Nemanja Lukic
configure.ac - added compiler's check for dspr1
Makefile.am - added files for dspr1 support
pixman-mips.c - runtime detection extended to
support dspr1 (searches dspr1 cores
or 'dsp' in ASEs implemented (for
kernels = 3.7))
pixman-mips-dspr1.c - added empty dspr1 implementation
added dspr1 files with headers only
---
 configure.ac|   40 ++
 pixman/Makefile.am  |   14 ++
 pixman/pixman-mips-common-asm.h |   13 ++
 pixman/pixman-mips-dspr1-asm.S  |   33 +
 pixman/pixman-mips-dspr1-asm.h  |   37 
 pixman/pixman-mips-dspr1.c  |   51 +++
 pixman/pixman-mips-dspr2-asm.h  |2 +-
 pixman/pixman-mips.c|   25 ++-
 pixman/pixman-private.h |5 
 9 files changed, 218 insertions(+), 2 deletions(-)
 create mode 100644 pixman/pixman-mips-dspr1-asm.S
 create mode 100644 pixman/pixman-mips-dspr1-asm.h
 create mode 100644 pixman/pixman-mips-dspr1.c

diff --git a/configure.ac b/configure.ac
index b320072..031c1cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -755,6 +755,46 @@ if test $enable_mips32r2 = yes  test $have_mips32r2 = no 
; then
 fi
 
 dnl ==
+dnl Check if assembler is gas compatible and supports MIPS DSPr1 instructions
+
+have_mips_dspr1=no
+AC_MSG_CHECKING(whether to use MIPS DSPr1 assembler)
+
+AC_COMPILE_IFELSE([[
+int
+main () {
+int c = 0, a = 0, b = 0;
+__asm__ __volatile__ (
+.set  arch=mips32r2 \n\t
+.set  dsp   \n\t
+packrl.ph %[c], %[a], %[b]  \n\t
+: [c] =r (c)
+: [a] r (a), [b] r (b)
+  );
+  return c;
+}]], have_mips_dspr1=yes)
+
+AC_ARG_ENABLE(mips-dspr1,
+   [AC_HELP_STRING([--disable-mips-dspr1],
+   [disable MIPS DSPr1 fast paths])],
+   [enable_mips_dspr1=$enableval], [enable_mips_dspr1=auto])
+
+if test $enable_mips_dspr1 = no ; then
+   have_mips_dspr1=disabled
+fi
+
+if test $have_mips_dspr1 = yes ; then
+   AC_DEFINE(USE_MIPS_DSPR1, 1, [use MIPS DSPr1 assembly optimizations])
+fi
+
+AM_CONDITIONAL(USE_MIPS_DSPR1, test $have_mips_dspr1 = yes)
+
+AC_MSG_RESULT($have_mips_dspr1)
+if test $enable_mips_dspr1 = yes  test $have_mips_dspr1 = no ; then
+   AC_MSG_ERROR([MIPS DSPr1 instructions not detected])
+fi
+
+dnl ==
 dnl Check if assembler is gas compatible and supports MIPS DSPr2 instructions
 
 have_mips_dspr2=no
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 0a6f585..d7e32e5 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -128,6 +128,20 @@ libpixman_1_la_LIBADD += libpixman-mips32r2.la
 ASM_CFLAGS_mips32r2=
 endif
 
+# mips dspr1 code
+if USE_MIPS_DSPR1
+noinst_LTLIBRARIES += libpixman-mips-dspr1.la
+libpixman_mips_dspr1_la_SOURCES = \
+pixman-mips-dspr1.c \
+pixman-mips-common.h \
+pixman-mips-common-asm.h \
+pixman-mips-dspr1-asm.S \
+pixman-mips-dspr1-asm.h
+libpixman_1_la_LIBADD += libpixman-mips-dspr1.la
+
+ASM_CFLAGS_mips_dspr1=
+endif
+
 # mips dspr2 code
 if USE_MIPS_DSPR2
 noinst_LTLIBRARIES += libpixman-mips-dspr2.la
diff --git a/pixman/pixman-mips-common-asm.h b/pixman/pixman-mips-common-asm.h
index 186f17a..096ccf4 100644
--- a/pixman/pixman-mips-common-asm.h
+++ b/pixman/pixman-mips-common-asm.h
@@ -88,6 +88,13 @@ symbol##suffix: .frame  sp, 0, ra;  \
 LEAF_MIPS(symbol, _mips32r2)
 
 /*
+ * LEAF_MIPS_DSPR1 - declare leaf routine for MIPS DSPr1
+ */
+#define LEAF_MIPS_DSPR1(symbol) \
+LEAF_MIPS(symbol, _mips_dspr1)  \
+.setdsp;
+
+/*
  * LEAF_MIPS_DSPR2 - declare leaf routine for MIPS DSPr2
  */
 #define LEAF_MIPS_DSPR2(symbol) \
@@ -109,6 +116,12 @@ LEAF_MIPS(symbol, _mips_dspr2)  \
 END(function, _mips32r2)
 
 /*
+ * END_MIPS_DSPR1 - mark end of mips_dspr1 function
+ */
+#define END_MIPS_DSPR1(function)\
+END(function, _mips_dspr1)
+
+/*
  * END_MIPS_DSPR2 - mark end of mips_dspr2 function
  */
 #define END_MIPS_DSPR2(function)\
diff --git a/pixman/pixman-mips-dspr1-asm.S b/pixman/pixman-mips-dspr1-asm.S
new file mode 100644
index 000..c6b4e98
--- /dev/null
+++ b/pixman/pixman-mips-dspr1-asm.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012-2013
+ *  MIPS Technologies, Inc., California.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must