os/ossrv/genericopenlibs/liboil/src/copy/splat_ref.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2  * LIBOIL - Library of Optimized Inner Loops
     3  * Copyright (c) 2001,2003,2004 David A. Schleef <ds@schleef.org>
     4  * All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     9  * 1. Redistributions of source code must retain the above copyright
    10  *    notice, this list of conditions and the following disclaimer.
    11  * 2. Redistributions in binary form must reproduce the above copyright
    12  *    notice, this list of conditions and the following disclaimer in the
    13  *    documentation and/or other materials provided with the distribution.
    14  * 
    15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  * POSSIBILITY OF SUCH DAMAGE.
    26  */
    27 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    28 
    29 #ifdef HAVE_CONFIG_H
    30 #include "config.h"
    31 #endif
    32 #include <liboil/liboilfunction.h>
    33 #include <string.h>
    34 
    35 OIL_DECLARE_CLASS(splat_u8);
    36 OIL_DECLARE_CLASS(splat_u32);
    37 OIL_DECLARE_CLASS(splat_u8_ns);
    38 OIL_DECLARE_CLASS(splat_u32_ns);
    39 
    40 
    41 
    42 
    43 static void splat_u32_unroll2 (uint32_t *dest, int dstr, const uint32_t *param, int n)
    44 {
    45   int i;
    46   if (n&1) {
    47     *dest = *param;
    48     OIL_INCREMENT(dest,dstr);
    49   }
    50   n >>= 1;
    51   for(i=0;i<n;i++){
    52     *dest = *param;
    53     OIL_INCREMENT(dest,dstr);
    54     *dest = *param;
    55     OIL_INCREMENT(dest,dstr);
    56   }
    57 }
    58 OIL_DEFINE_IMPL(splat_u32_unroll2, splat_u32);
    59 
    60 static void splat_u32_ns_unroll2 (uint32_t *dest, const uint32_t *param, int n)
    61 {
    62   int i;
    63   if (n&1) {
    64     *dest = *param;
    65     dest++;
    66   }
    67   n >>= 1;
    68   for(i=0;i<n;i++){
    69     *dest = *param;
    70     dest++;
    71     *dest = *param;
    72     dest++;
    73   }
    74 }
    75 OIL_DEFINE_IMPL(splat_u32_ns_unroll2, splat_u32_ns);
    76 
    77 static void splat_u32_ns_unroll4 (uint32_t *dest, const uint32_t *param, int n)
    78 {
    79   int i;
    80   while (n&3) {
    81     *dest = *param;
    82     dest++;
    83     n--;
    84   }
    85   n >>= 2;
    86   for(i=0;i<n;i++){
    87     dest[0] = *param;
    88     dest[1] = *param;
    89     dest[2] = *param;
    90     dest[3] = *param;
    91     dest+=4;
    92   }
    93 }
    94 OIL_DEFINE_IMPL(splat_u32_ns_unroll4, splat_u32_ns);
    95 
    96 static void splat_u8_ns_memset (uint8_t *dest, const uint8_t *param, int n)
    97 {
    98   memset (dest, *param, n);
    99 }
   100 OIL_DEFINE_IMPL(splat_u8_ns_memset, splat_u8_ns);
   101 
   102 #ifdef HAVE_UNALIGNED_ACCESS
   103 static void splat_u8_ns_int (uint8_t *dest, const uint8_t *param, int n)
   104 {
   105   int p;
   106   while(n&3) {
   107     *dest = *param;
   108     dest++;
   109     n--;
   110   }
   111   n >>= 2;
   112   p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
   113   while(n>0){
   114     *(uint32_t *)dest = p;
   115     dest+=4;
   116     n--;
   117   }
   118 }
   119 OIL_DEFINE_IMPL(splat_u8_ns_int, splat_u8_ns);
   120 #endif
   121 
   122 #ifdef HAVE_UNALIGNED_ACCESS
   123 static void splat_u8_ns_int2 (uint8_t *dest, const uint8_t *param, int n)
   124 {
   125   uint32_t p;
   126   while(n&7) {
   127     *dest = *param;
   128     dest++;
   129     n--;
   130   }
   131   n >>= 3;
   132   p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
   133   while(n>0){
   134     ((uint32_t *)dest)[0] = p;
   135     ((uint32_t *)dest)[1] = p;
   136     dest+=8;
   137     n--;
   138   }
   139 }
   140 OIL_DEFINE_IMPL(splat_u8_ns_int2, splat_u8_ns);
   141 #endif
   142 
   143 #ifdef HAVE_UNALIGNED_ACCESS
   144 static void splat_u8_ns_int4 (uint8_t *dest, const uint8_t *param, int n)
   145 {
   146   uint32_t p;
   147   while(n&15) {
   148     *dest = *param;
   149     dest++;
   150     n--;
   151   }
   152   n >>= 4;
   153   p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
   154   while(n>0){
   155     ((uint32_t *)dest)[0] = p;
   156     ((uint32_t *)dest)[1] = p;
   157     ((uint32_t *)dest)[2] = p;
   158     ((uint32_t *)dest)[3] = p;
   159     dest+=16;
   160     n--;
   161   }
   162 }
   163 OIL_DEFINE_IMPL(splat_u8_ns_int4, splat_u8_ns);
   164 #endif
   165 
   166 
   167 
   168 
   169 
   170 
   171 #ifdef	__SYMBIAN32__
   172  
   173 OilFunctionImpl* __oil_function_impl_splat_u32_unroll2() {
   174 		return &_oil_function_impl_splat_u32_unroll2;
   175 }
   176 #endif
   177 
   178 #ifdef	__SYMBIAN32__
   179  
   180 OilFunctionImpl* __oil_function_impl_splat_u32_ns_unroll2() {
   181 		return &_oil_function_impl_splat_u32_ns_unroll2;
   182 }
   183 #endif
   184 
   185 #ifdef	__SYMBIAN32__
   186  
   187 OilFunctionImpl* __oil_function_impl_splat_u32_ns_unroll4() {
   188 		return &_oil_function_impl_splat_u32_ns_unroll4;
   189 }
   190 #endif
   191 
   192 #ifdef	__SYMBIAN32__
   193  
   194 OilFunctionImpl* __oil_function_impl_splat_u8_ns_memset() {
   195 		return &_oil_function_impl_splat_u8_ns_memset;
   196 }
   197 #endif
   198 
   199 #ifdef HAVE_UNALIGNED_ACCESS
   200 #ifdef	__SYMBIAN32__
   201  
   202 OilFunctionImpl* __oil_function_impl_splat_u8_ns_int() {
   203 		return &_oil_function_impl_splat_u8_ns_int;
   204 }
   205 #endif
   206 #endif
   207 
   208 #ifdef HAVE_UNALIGNED_ACCESS
   209 #ifdef	__SYMBIAN32__
   210  
   211 OilFunctionImpl* __oil_function_impl_splat_u8_ns_int2() {
   212 		return &_oil_function_impl_splat_u8_ns_int2;
   213 }
   214 #endif
   215 #endif
   216 
   217 #ifdef HAVE_UNALIGNED_ACCESS
   218 #ifdef	__SYMBIAN32__
   219  
   220 OilFunctionImpl* __oil_function_impl_splat_u8_ns_int4() {
   221 		return &_oil_function_impl_splat_u8_ns_int4;
   222 }
   223 #endif
   224 #endif
   225