[Liboil] [PATCH] don't use AltiVec/Floating point if it is not available

Sebastian Andrzej Siewior sebastian at breakpoint.cc
Tue Aug 17 13:08:03 PDT 2010


From: Sebastian Andrzej Siewior <bigeasy at linutronix.de>

on powerpc-linux-gnuspe there is no support for AlitVec at all. In fact
AltiVec opcodes share the same opcode range as some Embedded Floating
Point (EFP). Floating point is available in hardware however it uses the
earlier mentioned EFP instead of the "classic FPU".
On this target, gcc can't produce AltiVec code. Classic floating is also
unavailable.
gcc defines __SPE__ on targets where the EFP extension is used for
floating point.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
---
 liboil/Makefile.am                                |    8 ++++++--
 liboil/liboilcpu-powerpc.c                        |    4 ++++
 liboil/powerpc/abs.c                              |    5 +++--
 liboil/powerpc/copy.c                             |    4 ++--
 liboil/powerpc/mix.c                              |    4 ++--
 liboil/powerpc/multsum.c                          |    6 ++----
 liboil/powerpc/resample.c                         |    5 ++---
 liboil/powerpc/sad8x8.c                           |    5 ++---
 liboil/powerpc/splat.c                            |    3 ++-
 liboil/powerpc/zigzag8x8.c                        |    5 ++---
 liboil/powerpc_asm_blocks/fdct8x8theora_altivec.c |    2 ++
 liboil/powerpc_asm_blocks/recon8x8_altivec.c      |    2 ++
 12 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/liboil/Makefile.am b/liboil/Makefile.am
index 84a61ae..046c746 100644
--- a/liboil/Makefile.am
+++ b/liboil/Makefile.am
@@ -37,8 +37,12 @@ endif
 
 if HAVE_POWERPC
 if HAVE_GCC_ASM
-SUBDIRS += powerpc motovec
-libs += powerpc/libpowerpc.la motovec/libmotovec.la
+SUBDIRS += powerpc
+libs += powerpc/libpowerpc.la
+if HAVE_ALTIVEC_INTRINSICS
+SUBDIRS += motovec
+libs += motovec/libmotovec.la
+endif
 
 # motovec doesn't compile on snow leopard, and isn't useful elsewhere
 #SUBDIRS += motovec
diff --git a/liboil/liboilcpu-powerpc.c b/liboil/liboilcpu-powerpc.c
index 8bbc72d..e9f3a28 100644
--- a/liboil/liboilcpu-powerpc.c
+++ b/liboil/liboilcpu-powerpc.c
@@ -132,6 +132,7 @@ oil_check_altivec_sysctl_darwin (void)
 #endif
 
 #if defined(__linux__)
+#ifndef defined(__SPE__)
 static void
 oil_check_altivec_proc_auxv (void)
 {
@@ -180,6 +181,7 @@ out:
   }
 }
 #endif
+#endif
 
 #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__linux__)
 static void
@@ -204,7 +206,9 @@ oil_cpu_detect_arch(void)
 #elif defined(__APPLE__)
   oil_check_altivec_sysctl_darwin();
 #elif defined(__linux__)
+#ifndef defined(__SPE__)
   oil_check_altivec_proc_auxv();
+#endif
 #else
   oil_check_altivec_fault();
 #endif
diff --git a/liboil/powerpc/abs.c b/liboil/powerpc/abs.c
index 67b2ef8..83b20e6 100644
--- a/liboil/powerpc/abs.c
+++ b/liboil/powerpc/abs.c
@@ -32,8 +32,9 @@
 #include <liboil/liboilfunction.h>
 #include <liboil/simdpack/simdpack.h>
 
-#define ABS(x) ((x)>0 ? (x) : -(x))
+#ifndef __SPE__
 
+#define ABS(x) ((x)>0 ? (x) : -(x))
 #ifdef ENABLE_BROKEN_IMPLS
 static void
 abs_u16_s16_a16_altivec (uint16_t * dest, int dstr, int16_t * src, int sstr,
@@ -62,4 +63,4 @@ abs_u16_s16_a16_altivec (uint16_t * dest, int dstr, int16_t * src, int sstr,
 
 OIL_DEFINE_IMPL_FULL (abs_u16_s16_a16_altivec, abs_u16_s16, OIL_IMPL_FLAG_ALTIVEC);
 #endif
-
+#endif
diff --git a/liboil/powerpc/copy.c b/liboil/powerpc/copy.c
index ba9d9ce..795ec6b 100644
--- a/liboil/powerpc/copy.c
+++ b/liboil/powerpc/copy.c
@@ -32,6 +32,7 @@
 #include <liboil/liboilfunction.h>
 #include <liboil/liboilfunction.h>
 
+#ifndef __SPE__
 OIL_DECLARE_CLASS(copy_u8);
 
 static void
@@ -141,5 +142,4 @@ copy_u8_altivec2 (uint8_t *dest, uint8_t *src, int n)
   }
 }
 OIL_DEFINE_IMPL_FULL (copy_u8_altivec2, copy_u8, OIL_IMPL_FLAG_ALTIVEC);
-
-
+#endif
diff --git a/liboil/powerpc/mix.c b/liboil/powerpc/mix.c
index 4c5b55b..52c4f5c 100644
--- a/liboil/powerpc/mix.c
+++ b/liboil/powerpc/mix.c
@@ -33,7 +33,7 @@
 #include <liboil/simdpack/simdpack.h>
 #include <math.h>
 
-
+#ifndef __SPE__
 #ifdef ENABLE_BROKEN_IMPLS
 static void mix_u8_a16_altivec(uint8_t *dest, uint8_t *src1, uint8_t *src2, uint8_t *scale, int n)
 {
@@ -81,4 +81,4 @@ static void mix_u8_a16_altivec(uint8_t *dest, uint8_t *src1, uint8_t *src2, uint
 }
 OIL_DEFINE_IMPL_FULL (mix_u8_a16_altivec, mix_u8, OIL_IMPL_FLAG_ALTIVEC);
 #endif
-
+#endif
diff --git a/liboil/powerpc/multsum.c b/liboil/powerpc/multsum.c
index b649209..1598be6 100644
--- a/liboil/powerpc/multsum.c
+++ b/liboil/powerpc/multsum.c
@@ -33,7 +33,7 @@
 #include <liboil/simdpack/simdpack.h>
 #include <math.h>
 
-
+#ifdef HAVE_GCC_ASM_POWERPC_FPU
 #ifdef ENABLE_BROKEN_IMPLS
 /* This could probably be improved by unrolling */
 static void multsum_f32_ppcasm(float *dest, float *src1, int sstr1,
@@ -56,6 +56,4 @@ static void multsum_f32_ppcasm(float *dest, float *src1, int sstr1,
 }
 OIL_DEFINE_IMPL_ASM (multsum_f32_ppcasm, multsum_f32);
 #endif
-
-
-
+#endif
diff --git a/liboil/powerpc/resample.c b/liboil/powerpc/resample.c
index eef688a..f3caaa6 100644
--- a/liboil/powerpc/resample.c
+++ b/liboil/powerpc/resample.c
@@ -33,7 +33,7 @@
 #include <liboil/liboilfunction.h>
 #include <liboil/liboiltest.h>
 
-
+#ifndef __SPE__
 OIL_DECLARE_CLASS (merge_linear_argb);
 
 #define ALIGN_UP(ptr,boundary) ((void *)(((unsigned long)ptr + boundary-1) & (~(boundary-1))))
@@ -94,5 +94,4 @@ merge_linear_argb_powerpc (uint32_t *dest, uint32_t *src1, uint32_t *src2,
   }
 }
 OIL_DEFINE_IMPL_FULL (merge_linear_argb_powerpc, merge_linear_argb, OIL_IMPL_FLAG_ALTIVEC);
-
-
+#endif
diff --git a/liboil/powerpc/sad8x8.c b/liboil/powerpc/sad8x8.c
index 8bde530..60038ec 100644
--- a/liboil/powerpc/sad8x8.c
+++ b/liboil/powerpc/sad8x8.c
@@ -33,7 +33,7 @@
 #include <liboil/simdpack/simdpack.h>
 #include <math.h>
 
-
+#ifndef __SPE__
 #if 0
 static void
 sad8x8_s16_a16_altivec (uint32_t *dest, int16_t *src1, int16_t *src2, int s1str, int s2str)
@@ -183,5 +183,4 @@ sad8x8_s16_l15_a16_altivec(uint32_t *dest, int16_t *src1, int16_t *src2, int s1s
 	*dest = x[3];
 }
 #endif
-
-
+#endif
diff --git a/liboil/powerpc/splat.c b/liboil/powerpc/splat.c
index e33b928..0772ec4 100644
--- a/liboil/powerpc/splat.c
+++ b/liboil/powerpc/splat.c
@@ -32,6 +32,7 @@
 #include <liboil/liboilfunction.h>
 #include <liboil/liboilfunction.h>
 
+#ifndef __SPE__
 OIL_DECLARE_CLASS(splat_u8_ns);
 OIL_DECLARE_CLASS(splat_u32_ns);
 
@@ -141,4 +142,4 @@ splat_u32_ns_altivec (uint32_t *dest, uint32_t *src, int n)
   }
 }
 OIL_DEFINE_IMPL_FULL (splat_u32_ns_altivec, splat_u32_ns, OIL_IMPL_FLAG_ALTIVEC);
-
+#endif
diff --git a/liboil/powerpc/zigzag8x8.c b/liboil/powerpc/zigzag8x8.c
index 4b5c058..cf303af 100644
--- a/liboil/powerpc/zigzag8x8.c
+++ b/liboil/powerpc/zigzag8x8.c
@@ -31,7 +31,7 @@
 
 #include <liboil/liboil.h>
 
-
+#ifndef __SPE__
 /* Derivation:
  * zigzag_order in zigzag8z8_c.c is defined in terms of where the
  * elements are moving from.  We rewrite the matrix in terms of
@@ -191,5 +191,4 @@ zigzag8x8_s16_a16_altivec(int16_t *dest, int dstr, int16_t *src, int sstr)
 }
 OIL_DEFINE_IMPL_FULL (zigzag8x8_s16_altivec, zigzag8x8_s16, OIL_FLAG_ALTIVEC);
 #endif
-
-
+#endif
diff --git a/liboil/powerpc_asm_blocks/fdct8x8theora_altivec.c b/liboil/powerpc_asm_blocks/fdct8x8theora_altivec.c
index e02f85f..9d5e07b 100644
--- a/liboil/powerpc_asm_blocks/fdct8x8theora_altivec.c
+++ b/liboil/powerpc_asm_blocks/fdct8x8theora_altivec.c
@@ -51,6 +51,7 @@
 #include <liboil/dct/dct.h>
 #include <math.h>
 
+#ifndef __SPE__
 extern vector signed short idctConst;
 extern vector unsigned char vPerm1;
 extern vector unsigned char vPerm2;
@@ -520,3 +521,4 @@ fdct8x8theora_altivec(int16_t *src, int16_t *dest)
     
 }
 OIL_DEFINE_IMPL_REF (fdct8x8theora_altivec, fdct8x8theora, OIL_IMPL_FLAG_ALTIVEC);
+#endif
diff --git a/liboil/powerpc_asm_blocks/recon8x8_altivec.c b/liboil/powerpc_asm_blocks/recon8x8_altivec.c
index 1d85b2a..5c501de 100644
--- a/liboil/powerpc_asm_blocks/recon8x8_altivec.c
+++ b/liboil/powerpc_asm_blocks/recon8x8_altivec.c
@@ -36,6 +36,7 @@
 #include <liboil/liboilfunction.h>
 #include <liboil/simdpack/simdpack.h>
 
+#ifndef __SPE__
 OIL_DECLARE_CLASS (recon8x8_intra);
 OIL_DECLARE_CLASS (recon8x8_inter);
 OIL_DECLARE_CLASS (recon8x8_inter2);
@@ -714,3 +715,4 @@ recon8x8_inter2_altivec (uint8_t *dest, uint8_t *s1, uint8_t *s2, int16_t *chang
 }
 
 OIL_DEFINE_IMPL_FULL (recon8x8_inter2_altivec, recon8x8_inter2, OIL_IMPL_FLAG_ALTIVEC);
+#endif
-- 
1.5.6.5



More information about the Liboil mailing list