[Pixman] [PATCH 05/11] MIPS: MIPS32r2: empty implementation with runtime detection

Nemanja Lukic nemanja.lukic at rt-rk.com
Mon Oct 28 10:04:43 PDT 2013


---
 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            |   26 +++++++++++++++++++-
 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, 275 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 8764f7b..6d425ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -715,6 +715,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 b376d9a..7a7d629 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -112,15 +112,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 0000000..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 software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nemanja.lukic at rt-rk.com)
+ */
+
+#ifndef PIXMAN_MIPS_COMMON_ASM_H
+#define PIXMAN_MIPS_COMMON_ASM_H
+
+#endif /* PIXMAN_MIPS_COMMON_ASM_H */
diff --git a/pixman/pixman-mips-common.h b/pixman/pixman-mips-common.h
new file mode 100644
index 0000000..fc46ed8
--- /dev/null
+++ b/pixman/pixman-mips-common.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 software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nemanja.lukic at rt-rk.com)
+ */
+
+#ifndef PIXMAN_MIPS_COMMON_H
+#define PIXMAN_MIPS_COMMON_H
+
+#endif /* PIXMAN_MIPS_COMMON_H */
diff --git a/pixman/pixman-mips-dspr2-asm.S b/pixman/pixman-mips-dspr2-asm.S
index 9dad163..15e7fa3 100644
--- a/pixman/pixman-mips-dspr2-asm.S
+++ b/pixman/pixman-mips-dspr2-asm.S
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012
+ * Copyright (c) 2012-2013
  *      MIPS Technologies, Inc., California.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/pixman/pixman-mips-dspr2-asm.h b/pixman/pixman-mips-dspr2-asm.h
index c7bcf11..ec46715 100644
--- a/pixman/pixman-mips-dspr2-asm.h
+++ b/pixman/pixman-mips-dspr2-asm.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012
+ * Copyright (c) 2012-2013
  *      MIPS Technologies, Inc., California.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/pixman/pixman-mips-dspr2.c b/pixman/pixman-mips-dspr2.c
index 03ad787..8e90c97 100644
--- a/pixman/pixman-mips-dspr2.c
+++ b/pixman/pixman-mips-dspr2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012
+ * Copyright (c) 2012-2013
  *      MIPS Technologies, Inc., California.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 93fda99..a8f208d 100644
--- a/pixman/pixman-mips.c
+++ b/pixman/pixman-mips.c
@@ -34,6 +34,17 @@ static const char *mips_dspr2_cores[] =
 };
 #endif
 
+#ifdef USE_MIPS32R2
+static const char *mips32r2_cores[] =
+{
+    "MIPS 1004K", "MIPS 74K", "MIPS 34K",
+    "MIPS 24K", "MIPS 4Kc", "MIPS 4Km",
+    "MIPS 4Kp", "MIPS 4KEc", "MIPS 4KEm",
+    "MIPS 4KEp", "MIPS 4KSc", "MIPS 4KSd",
+    NULL
+};
+#endif
+
 #ifdef USE_LOONGSON_MMI
 static const char *mips_loongson_cores[] =
 {
@@ -41,7 +52,8 @@ static const char *mips_loongson_cores[] =
 };
 #endif
 
-#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
+#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI) || \
+    defined(USE_MIPS32R2)
 
 static pixman_bool_t
 have_feature (const char **cores, const char *search_string)
@@ -120,6 +132,18 @@ _pixman_mips_get_implementations (pixman_implementation_t *imp)
         imp = _pixman_implementation_create_mmx (imp);
 #endif
 
+#ifdef USE_MIPS32R2
+    if (!_pixman_disabled ("mips32r2"))
+    {
+        int already_compiling_everything_for_mips32r2 = 0;
+#if defined(__mips__) && (__mips_isa_rev >= 2)
+        already_compiling_everything_for_mips32r2 = 1;
+#endif
+        if (already_compiling_everything_for_mips32r2 ||
+            have_feature (mips32r2_cores, "mips32r2")
+            imp = _pixman_implementation_create_mips32r2 (imp);
+#endif
+
 #ifdef USE_MIPS_DSPR2
     if (!_pixman_disabled ("mips-dspr2"))
     {
diff --git a/pixman/pixman-mips32r2-asm.S b/pixman/pixman-mips32r2-asm.S
new file mode 100644
index 0000000..468937c
--- /dev/null
+++ b/pixman/pixman-mips32r2-asm.S
@@ -0,0 +1,30 @@
+/*
+ * 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 software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "pixman-mips32r2-asm.h"
diff --git a/pixman/pixman-mips32r2-asm.h b/pixman/pixman-mips32r2-asm.h
new file mode 100644
index 0000000..b8f1773
--- /dev/null
+++ b/pixman/pixman-mips32r2-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 software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nemanja.lukic at rt-rk.com)
+ */
+
+#ifndef PIXMAN_MIPS32R2_ASM_H
+#define PIXMAN_MIPS32R2_ASM_H
+
+#endif /* PIXMAN_MIPS32R2_ASM_H */
diff --git a/pixman/pixman-mips32r2.c b/pixman/pixman-mips32r2.c
new file mode 100644
index 0000000..f3500bc
--- /dev/null
+++ b/pixman/pixman-mips32r2.c
@@ -0,0 +1,51 @@
+/*
+ * 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 software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Author:  Nemanja Lukic (nemanja.lukic at rt-rk.com)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pixman-private.h"
+#include "pixman-mips-common.h"
+
+static const pixman_fast_path_t mips32r2_fast_paths[] =
+{
+    { PIXMAN_OP_NONE },
+};
+
+pixman_implementation_t *
+_pixman_implementation_create_mips32r2 (pixman_implementation_t *fallback)
+{
+    pixman_implementation_t *imp =
+        _pixman_implementation_create (fallback, mips32r2_fast_paths);
+
+    return imp;
+}
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 6ca13b2..32726e5 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -613,6 +613,11 @@ pixman_implementation_t *
 _pixman_implementation_create_mips_dspr2 (pixman_implementation_t *fallback);
 #endif
 
+#ifdef USE_MIPS32R2
+pixman_implementation_t *
+_pixman_implementation_create_mips32r2 (pixman_implementation_t *fallback);
+#endif
+
 #ifdef USE_VMX
 pixman_implementation_t *
 _pixman_implementation_create_vmx (pixman_implementation_t *fallback);
-- 
1.7.3



More information about the Pixman mailing list