os/ossrv/genericopenlibs/liboil/src/mmx/splat_mmx.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/mmx/splat_mmx.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,160 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005
     1.6 + *	Eric Anholt.  All rights reserved.
     1.7 + *
     1.8 + * Redistribution and use in source and binary forms, with or without
     1.9 + * modification, are permitted provided that the following conditions
    1.10 + * are met:
    1.11 + * 1. Redistributions of source code must retain the above copyright
    1.12 + *    notice, this list of conditions and the following disclaimer.
    1.13 + * 2. Redistributions in binary form must reproduce the above copyright
    1.14 + *    notice, this list of conditions and the following disclaimer in the
    1.15 + *    documentation and/or other materials provided with the distribution.
    1.16 + *
    1.17 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
    1.18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.20 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
    1.21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.27 + * SUCH DAMAGE.
    1.28 + */
    1.29 +//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.30 +
    1.31 +#ifdef HAVE_CONFIG_H
    1.32 +#include "config.h"
    1.33 +#endif
    1.34 +#include <liboil/liboilclasses.h>
    1.35 +#include <liboil/liboilfunction.h>
    1.36 +
    1.37 +#ifdef HAVE_GCC_ASM      
    1.38 +#include <mmintrin.h>
    1.39 +#endif
    1.40 +
    1.41 +static void
    1.42 +splat_u32_ns_mmx (uint32_t *dest, const uint32_t *param, int n)
    1.43 +{
    1.44 +#ifdef HAVE_GCC_ASM      
    1.45 +  __m64 v;
    1.46 +
    1.47 +  v = _mm_set1_pi32(*param);
    1.48 +
    1.49 +  for (; n >= 2; n -= 2) {
    1.50 +    *(__m64 *)dest = v;
    1.51 +    dest += 2;
    1.52 +  }
    1.53 +  for (; n > 0; n--) {
    1.54 +    *dest++ = *param;
    1.55 +  }
    1.56 +  _mm_empty();
    1.57 +#endif  
    1.58 +}
    1.59 +OIL_DEFINE_IMPL_FULL (splat_u32_ns_mmx, splat_u32_ns, OIL_IMPL_FLAG_MMX);
    1.60 +
    1.61 +static void
    1.62 +splat_u32_ns_mmx_unroll4 (uint32_t *dest, const uint32_t *param, int n)
    1.63 +{
    1.64 +#ifdef HAVE_GCC_ASM      
    1.65 +  __m64 v;
    1.66 +
    1.67 +  v = _mm_set1_pi32(*param);
    1.68 +
    1.69 +  for (; n >= 8; n -= 8) {
    1.70 +    ((__m64 *)dest)[0] = v;
    1.71 +    ((__m64 *)dest)[1] = v;
    1.72 +    ((__m64 *)dest)[2] = v;
    1.73 +    ((__m64 *)dest)[3] = v;
    1.74 +    dest += 8;
    1.75 +  }
    1.76 +  for (; n >= 2; n -= 2) {
    1.77 +    *(__m64 *)dest = v;
    1.78 +    dest += 2;
    1.79 +  }
    1.80 +  for (; n > 0; n--) {
    1.81 +    *dest++ = *param;
    1.82 +  }
    1.83 +  _mm_empty();
    1.84 +#endif  
    1.85 +}
    1.86 +OIL_DEFINE_IMPL_FULL (splat_u32_ns_mmx_unroll4, splat_u32_ns, OIL_IMPL_FLAG_MMX);
    1.87 +
    1.88 +static void
    1.89 +splat_u8_ns_mmx (uint8_t *dest, const uint8_t *param, int n)
    1.90 +{
    1.91 +#ifdef HAVE_GCC_ASM      
    1.92 +  __m64 v;
    1.93 +
    1.94 +  v = _mm_set1_pi8(*param);
    1.95 +
    1.96 +  for (; n >= 8; n -= 8) {
    1.97 +    *(__m64 *)dest = v;
    1.98 +    dest += 8;
    1.99 +  }
   1.100 +  for (; n > 0; n--) {
   1.101 +    *dest++ = *param;
   1.102 +  }
   1.103 +  _mm_empty();
   1.104 +#endif
   1.105 +}
   1.106 +OIL_DEFINE_IMPL_FULL (splat_u8_ns_mmx, splat_u8_ns, OIL_IMPL_FLAG_MMX);
   1.107 +
   1.108 +static void
   1.109 +splat_u8_ns_mmx_unroll4 (uint8_t *dest, const uint8_t *param, int n)
   1.110 +{
   1.111 +#ifdef HAVE_GCC_ASM          
   1.112 +  __m64 v;
   1.113 +
   1.114 +  v = _mm_set1_pi8(*param);
   1.115 +
   1.116 +  for (; n >= 32; n -= 32) {
   1.117 +    ((__m64 *)dest)[0] = v;
   1.118 +    ((__m64 *)dest)[1] = v;
   1.119 +    ((__m64 *)dest)[2] = v;
   1.120 +    ((__m64 *)dest)[3] = v;
   1.121 +    dest += 32;
   1.122 +  }
   1.123 +  for (; n >= 8; n -= 8) {
   1.124 +    *(__m64 *)dest = v;
   1.125 +    dest += 8;
   1.126 +  }
   1.127 +  for (; n > 0; n--) {
   1.128 +    *dest++ = *param;
   1.129 +  }
   1.130 +  _mm_empty();
   1.131 +#endif
   1.132 +}
   1.133 +OIL_DEFINE_IMPL_FULL (splat_u8_ns_mmx_unroll4, splat_u8_ns, OIL_IMPL_FLAG_MMX);
   1.134 +
   1.135 +
   1.136 +#ifdef	__SYMBIAN32__
   1.137 + 
   1.138 +OilFunctionImpl* __oil_function_impl_splat_u32_ns_mmx() {
   1.139 +		return &_oil_function_impl_splat_u32_ns_mmx;
   1.140 +}
   1.141 +#endif
   1.142 +
   1.143 +#ifdef	__SYMBIAN32__
   1.144 + 
   1.145 +OilFunctionImpl* __oil_function_impl_splat_u32_ns_mmx_unroll4() {
   1.146 +		return &_oil_function_impl_splat_u32_ns_mmx_unroll4;
   1.147 +}
   1.148 +#endif
   1.149 +
   1.150 +#ifdef	__SYMBIAN32__
   1.151 + 
   1.152 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_mmx() {
   1.153 +		return &_oil_function_impl_splat_u8_ns_mmx;
   1.154 +}
   1.155 +#endif
   1.156 +
   1.157 +#ifdef	__SYMBIAN32__
   1.158 + 
   1.159 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_mmx_unroll4() {
   1.160 +		return &_oil_function_impl_splat_u8_ns_mmx_unroll4;
   1.161 +}
   1.162 +#endif
   1.163 +