os/ossrv/genericopenlibs/liboil/src/copy_sse.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/copy_sse.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,92 @@
     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 +#include <emmintrin.h>
    1.37 +
    1.38 +#define SSE_FUNCTION __attribute__((force_align_arg_pointer))
    1.39 +
    1.40 +SSE_FUNCTION static void
    1.41 +copy_u8_sse (uint8_t *dest, const uint8_t *src, int n)
    1.42 +{
    1.43 +  for (; ((long)dest & 15) && (n > 0); n--) {
    1.44 +    *dest++ = *src++;
    1.45 +  }
    1.46 +  for (; n >= 16; n -= 16) {
    1.47 +    _mm_store_si128((__m128i *)dest, _mm_loadu_si128((__m128i *)src));
    1.48 +    src += 16;
    1.49 +    dest += 16;
    1.50 +  }
    1.51 +  for (; n > 0; n--) {
    1.52 +    *dest++ = *src++;
    1.53 +  }
    1.54 +}
    1.55 +OIL_DEFINE_IMPL_FULL (copy_u8_sse, copy_u8, OIL_IMPL_FLAG_SSE2);
    1.56 +
    1.57 +SSE_FUNCTION static void
    1.58 +copy_u8_sse_unroll2 (uint8_t *dest, const uint8_t *src, int n)
    1.59 +{
    1.60 +  for (; ((long)dest & 15) && (n > 0); n--) {
    1.61 +    *dest++ = *src++;
    1.62 +  }
    1.63 +  for (; n >= 32; n -= 32) {
    1.64 +    _mm_store_si128((__m128i *)dest, _mm_loadu_si128((__m128i *)src));
    1.65 +    _mm_store_si128((__m128i *)(dest + 16), _mm_loadu_si128((__m128i *)(src + 16)));
    1.66 +    src += 32;
    1.67 +    dest += 32;
    1.68 +  }
    1.69 +  if (n >= 16) {
    1.70 +    _mm_store_si128((__m128i *)dest, _mm_loadu_si128((__m128i *)src));
    1.71 +    src += 16;
    1.72 +    dest += 16;
    1.73 +    n -= 16;
    1.74 +  }
    1.75 +  for (; n > 0; n--) {
    1.76 +    *dest++ = *src++;
    1.77 +  }
    1.78 +}
    1.79 +OIL_DEFINE_IMPL_FULL (copy_u8_sse_unroll2, copy_u8, OIL_IMPL_FLAG_SSE2);
    1.80 +
    1.81 +
    1.82 +#ifdef	__SYMBIAN32__
    1.83 + 
    1.84 +OilFunctionImpl* __oil_function_impl_copy_u8_sse, copy_u8() {
    1.85 +		return &_oil_function_impl_copy_u8_sse, copy_u8;
    1.86 +}
    1.87 +#endif
    1.88 +
    1.89 +#ifdef	__SYMBIAN32__
    1.90 + 
    1.91 +OilFunctionImpl* __oil_function_impl_copy_u8_sse_unroll2, copy_u8() {
    1.92 +		return &_oil_function_impl_copy_u8_sse_unroll2, copy_u8;
    1.93 +}
    1.94 +#endif
    1.95 +