genericopenlibs/liboil/src/mmx/splat_mmx.c
changeset 18 47c74d1534e1
equal deleted inserted replaced
0:e4d67989cc36 18:47c74d1534e1
       
     1 /*
       
     2  * Copyright (c) 2005
       
     3  *	Eric Anholt.  All rights reserved.
       
     4  *
       
     5  * Redistribution and use in source and binary forms, with or without
       
     6  * modification, are permitted provided that the following conditions
       
     7  * are met:
       
     8  * 1. Redistributions of source code must retain the above copyright
       
     9  *    notice, this list of conditions and the following disclaimer.
       
    10  * 2. Redistributions in binary form must reproduce the above copyright
       
    11  *    notice, this list of conditions and the following disclaimer in the
       
    12  *    documentation and/or other materials provided with the distribution.
       
    13  *
       
    14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
       
    15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
       
    18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
       
    20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
       
    22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
       
    23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    24  * SUCH DAMAGE.
       
    25  */
       
    26 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
       
    27 
       
    28 #ifdef HAVE_CONFIG_H
       
    29 #include "config.h"
       
    30 #endif
       
    31 #include <liboil/liboilclasses.h>
       
    32 #include <liboil/liboilfunction.h>
       
    33 
       
    34 #ifdef HAVE_GCC_ASM      
       
    35 #include <mmintrin.h>
       
    36 #endif
       
    37 
       
    38 static void
       
    39 splat_u32_ns_mmx (uint32_t *dest, const uint32_t *param, int n)
       
    40 {
       
    41 #ifdef HAVE_GCC_ASM      
       
    42   __m64 v;
       
    43 
       
    44   v = _mm_set1_pi32(*param);
       
    45 
       
    46   for (; n >= 2; n -= 2) {
       
    47     *(__m64 *)dest = v;
       
    48     dest += 2;
       
    49   }
       
    50   for (; n > 0; n--) {
       
    51     *dest++ = *param;
       
    52   }
       
    53   _mm_empty();
       
    54 #endif  
       
    55 }
       
    56 OIL_DEFINE_IMPL_FULL (splat_u32_ns_mmx, splat_u32_ns, OIL_IMPL_FLAG_MMX);
       
    57 
       
    58 static void
       
    59 splat_u32_ns_mmx_unroll4 (uint32_t *dest, const uint32_t *param, int n)
       
    60 {
       
    61 #ifdef HAVE_GCC_ASM      
       
    62   __m64 v;
       
    63 
       
    64   v = _mm_set1_pi32(*param);
       
    65 
       
    66   for (; n >= 8; n -= 8) {
       
    67     ((__m64 *)dest)[0] = v;
       
    68     ((__m64 *)dest)[1] = v;
       
    69     ((__m64 *)dest)[2] = v;
       
    70     ((__m64 *)dest)[3] = v;
       
    71     dest += 8;
       
    72   }
       
    73   for (; n >= 2; n -= 2) {
       
    74     *(__m64 *)dest = v;
       
    75     dest += 2;
       
    76   }
       
    77   for (; n > 0; n--) {
       
    78     *dest++ = *param;
       
    79   }
       
    80   _mm_empty();
       
    81 #endif  
       
    82 }
       
    83 OIL_DEFINE_IMPL_FULL (splat_u32_ns_mmx_unroll4, splat_u32_ns, OIL_IMPL_FLAG_MMX);
       
    84 
       
    85 static void
       
    86 splat_u8_ns_mmx (uint8_t *dest, const uint8_t *param, int n)
       
    87 {
       
    88 #ifdef HAVE_GCC_ASM      
       
    89   __m64 v;
       
    90 
       
    91   v = _mm_set1_pi8(*param);
       
    92 
       
    93   for (; n >= 8; n -= 8) {
       
    94     *(__m64 *)dest = v;
       
    95     dest += 8;
       
    96   }
       
    97   for (; n > 0; n--) {
       
    98     *dest++ = *param;
       
    99   }
       
   100   _mm_empty();
       
   101 #endif
       
   102 }
       
   103 OIL_DEFINE_IMPL_FULL (splat_u8_ns_mmx, splat_u8_ns, OIL_IMPL_FLAG_MMX);
       
   104 
       
   105 static void
       
   106 splat_u8_ns_mmx_unroll4 (uint8_t *dest, const uint8_t *param, int n)
       
   107 {
       
   108 #ifdef HAVE_GCC_ASM          
       
   109   __m64 v;
       
   110 
       
   111   v = _mm_set1_pi8(*param);
       
   112 
       
   113   for (; n >= 32; n -= 32) {
       
   114     ((__m64 *)dest)[0] = v;
       
   115     ((__m64 *)dest)[1] = v;
       
   116     ((__m64 *)dest)[2] = v;
       
   117     ((__m64 *)dest)[3] = v;
       
   118     dest += 32;
       
   119   }
       
   120   for (; n >= 8; n -= 8) {
       
   121     *(__m64 *)dest = v;
       
   122     dest += 8;
       
   123   }
       
   124   for (; n > 0; n--) {
       
   125     *dest++ = *param;
       
   126   }
       
   127   _mm_empty();
       
   128 #endif
       
   129 }
       
   130 OIL_DEFINE_IMPL_FULL (splat_u8_ns_mmx_unroll4, splat_u8_ns, OIL_IMPL_FLAG_MMX);
       
   131 
       
   132 
       
   133 #ifdef	__SYMBIAN32__
       
   134  
       
   135 OilFunctionImpl* __oil_function_impl_splat_u32_ns_mmx() {
       
   136 		return &_oil_function_impl_splat_u32_ns_mmx;
       
   137 }
       
   138 #endif
       
   139 
       
   140 #ifdef	__SYMBIAN32__
       
   141  
       
   142 OilFunctionImpl* __oil_function_impl_splat_u32_ns_mmx_unroll4() {
       
   143 		return &_oil_function_impl_splat_u32_ns_mmx_unroll4;
       
   144 }
       
   145 #endif
       
   146 
       
   147 #ifdef	__SYMBIAN32__
       
   148  
       
   149 OilFunctionImpl* __oil_function_impl_splat_u8_ns_mmx() {
       
   150 		return &_oil_function_impl_splat_u8_ns_mmx;
       
   151 }
       
   152 #endif
       
   153 
       
   154 #ifdef	__SYMBIAN32__
       
   155  
       
   156 OilFunctionImpl* __oil_function_impl_splat_u8_ns_mmx_unroll4() {
       
   157 		return &_oil_function_impl_splat_u8_ns_mmx_unroll4;
       
   158 }
       
   159 #endif
       
   160