1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/copy/splat_ref.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,225 @@
1.4 +/*
1.5 + * LIBOIL - Library of Optimized Inner Loops
1.6 + * Copyright (c) 2001,2003,2004 David A. Schleef <ds@schleef.org>
1.7 + * All rights reserved.
1.8 + *
1.9 + * Redistribution and use in source and binary forms, with or without
1.10 + * modification, are permitted provided that the following conditions
1.11 + * are met:
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + * 2. Redistributions in binary form must reproduce the above copyright
1.15 + * notice, this list of conditions and the following disclaimer in the
1.16 + * documentation and/or other materials provided with the distribution.
1.17 + *
1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.21 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1.28 + * POSSIBILITY OF SUCH DAMAGE.
1.29 + */
1.30 +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.31 +
1.32 +#ifdef HAVE_CONFIG_H
1.33 +#include "config.h"
1.34 +#endif
1.35 +#include <liboil/liboilfunction.h>
1.36 +#include <string.h>
1.37 +
1.38 +OIL_DECLARE_CLASS(splat_u8);
1.39 +OIL_DECLARE_CLASS(splat_u32);
1.40 +OIL_DECLARE_CLASS(splat_u8_ns);
1.41 +OIL_DECLARE_CLASS(splat_u32_ns);
1.42 +
1.43 +
1.44 +
1.45 +
1.46 +static void splat_u32_unroll2 (uint32_t *dest, int dstr, const uint32_t *param, int n)
1.47 +{
1.48 + int i;
1.49 + if (n&1) {
1.50 + *dest = *param;
1.51 + OIL_INCREMENT(dest,dstr);
1.52 + }
1.53 + n >>= 1;
1.54 + for(i=0;i<n;i++){
1.55 + *dest = *param;
1.56 + OIL_INCREMENT(dest,dstr);
1.57 + *dest = *param;
1.58 + OIL_INCREMENT(dest,dstr);
1.59 + }
1.60 +}
1.61 +OIL_DEFINE_IMPL(splat_u32_unroll2, splat_u32);
1.62 +
1.63 +static void splat_u32_ns_unroll2 (uint32_t *dest, const uint32_t *param, int n)
1.64 +{
1.65 + int i;
1.66 + if (n&1) {
1.67 + *dest = *param;
1.68 + dest++;
1.69 + }
1.70 + n >>= 1;
1.71 + for(i=0;i<n;i++){
1.72 + *dest = *param;
1.73 + dest++;
1.74 + *dest = *param;
1.75 + dest++;
1.76 + }
1.77 +}
1.78 +OIL_DEFINE_IMPL(splat_u32_ns_unroll2, splat_u32_ns);
1.79 +
1.80 +static void splat_u32_ns_unroll4 (uint32_t *dest, const uint32_t *param, int n)
1.81 +{
1.82 + int i;
1.83 + while (n&3) {
1.84 + *dest = *param;
1.85 + dest++;
1.86 + n--;
1.87 + }
1.88 + n >>= 2;
1.89 + for(i=0;i<n;i++){
1.90 + dest[0] = *param;
1.91 + dest[1] = *param;
1.92 + dest[2] = *param;
1.93 + dest[3] = *param;
1.94 + dest+=4;
1.95 + }
1.96 +}
1.97 +OIL_DEFINE_IMPL(splat_u32_ns_unroll4, splat_u32_ns);
1.98 +
1.99 +static void splat_u8_ns_memset (uint8_t *dest, const uint8_t *param, int n)
1.100 +{
1.101 + memset (dest, *param, n);
1.102 +}
1.103 +OIL_DEFINE_IMPL(splat_u8_ns_memset, splat_u8_ns);
1.104 +
1.105 +#ifdef HAVE_UNALIGNED_ACCESS
1.106 +static void splat_u8_ns_int (uint8_t *dest, const uint8_t *param, int n)
1.107 +{
1.108 + int p;
1.109 + while(n&3) {
1.110 + *dest = *param;
1.111 + dest++;
1.112 + n--;
1.113 + }
1.114 + n >>= 2;
1.115 + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
1.116 + while(n>0){
1.117 + *(uint32_t *)dest = p;
1.118 + dest+=4;
1.119 + n--;
1.120 + }
1.121 +}
1.122 +OIL_DEFINE_IMPL(splat_u8_ns_int, splat_u8_ns);
1.123 +#endif
1.124 +
1.125 +#ifdef HAVE_UNALIGNED_ACCESS
1.126 +static void splat_u8_ns_int2 (uint8_t *dest, const uint8_t *param, int n)
1.127 +{
1.128 + uint32_t p;
1.129 + while(n&7) {
1.130 + *dest = *param;
1.131 + dest++;
1.132 + n--;
1.133 + }
1.134 + n >>= 3;
1.135 + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
1.136 + while(n>0){
1.137 + ((uint32_t *)dest)[0] = p;
1.138 + ((uint32_t *)dest)[1] = p;
1.139 + dest+=8;
1.140 + n--;
1.141 + }
1.142 +}
1.143 +OIL_DEFINE_IMPL(splat_u8_ns_int2, splat_u8_ns);
1.144 +#endif
1.145 +
1.146 +#ifdef HAVE_UNALIGNED_ACCESS
1.147 +static void splat_u8_ns_int4 (uint8_t *dest, const uint8_t *param, int n)
1.148 +{
1.149 + uint32_t p;
1.150 + while(n&15) {
1.151 + *dest = *param;
1.152 + dest++;
1.153 + n--;
1.154 + }
1.155 + n >>= 4;
1.156 + p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
1.157 + while(n>0){
1.158 + ((uint32_t *)dest)[0] = p;
1.159 + ((uint32_t *)dest)[1] = p;
1.160 + ((uint32_t *)dest)[2] = p;
1.161 + ((uint32_t *)dest)[3] = p;
1.162 + dest+=16;
1.163 + n--;
1.164 + }
1.165 +}
1.166 +OIL_DEFINE_IMPL(splat_u8_ns_int4, splat_u8_ns);
1.167 +#endif
1.168 +
1.169 +
1.170 +
1.171 +
1.172 +
1.173 +
1.174 +#ifdef __SYMBIAN32__
1.175 +
1.176 +OilFunctionImpl* __oil_function_impl_splat_u32_unroll2() {
1.177 + return &_oil_function_impl_splat_u32_unroll2;
1.178 +}
1.179 +#endif
1.180 +
1.181 +#ifdef __SYMBIAN32__
1.182 +
1.183 +OilFunctionImpl* __oil_function_impl_splat_u32_ns_unroll2() {
1.184 + return &_oil_function_impl_splat_u32_ns_unroll2;
1.185 +}
1.186 +#endif
1.187 +
1.188 +#ifdef __SYMBIAN32__
1.189 +
1.190 +OilFunctionImpl* __oil_function_impl_splat_u32_ns_unroll4() {
1.191 + return &_oil_function_impl_splat_u32_ns_unroll4;
1.192 +}
1.193 +#endif
1.194 +
1.195 +#ifdef __SYMBIAN32__
1.196 +
1.197 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_memset() {
1.198 + return &_oil_function_impl_splat_u8_ns_memset;
1.199 +}
1.200 +#endif
1.201 +
1.202 +#ifdef HAVE_UNALIGNED_ACCESS
1.203 +#ifdef __SYMBIAN32__
1.204 +
1.205 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_int() {
1.206 + return &_oil_function_impl_splat_u8_ns_int;
1.207 +}
1.208 +#endif
1.209 +#endif
1.210 +
1.211 +#ifdef HAVE_UNALIGNED_ACCESS
1.212 +#ifdef __SYMBIAN32__
1.213 +
1.214 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_int2() {
1.215 + return &_oil_function_impl_splat_u8_ns_int2;
1.216 +}
1.217 +#endif
1.218 +#endif
1.219 +
1.220 +#ifdef HAVE_UNALIGNED_ACCESS
1.221 +#ifdef __SYMBIAN32__
1.222 +
1.223 +OilFunctionImpl* __oil_function_impl_splat_u8_ns_int4() {
1.224 + return &_oil_function_impl_splat_u8_ns_int4;
1.225 +}
1.226 +#endif
1.227 +#endif
1.228 +