os/ossrv/genericopenlibs/liboil/src/mmx/copy_mmx.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
 * Copyright (c) 2005
sl@0
     3
 *	Eric Anholt.  All rights reserved.
sl@0
     4
 *
sl@0
     5
 * Redistribution and use in source and binary forms, with or without
sl@0
     6
 * modification, are permitted provided that the following conditions
sl@0
     7
 * are met:
sl@0
     8
 * 1. Redistributions of source code must retain the above copyright
sl@0
     9
 *    notice, this list of conditions and the following disclaimer.
sl@0
    10
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    11
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    12
 *    documentation and/or other materials provided with the distribution.
sl@0
    13
 *
sl@0
    14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
sl@0
    15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
sl@0
    18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    24
 * SUCH DAMAGE.
sl@0
    25
 */
sl@0
    26
//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
sl@0
    27
sl@0
    28
#ifdef HAVE_CONFIG_H
sl@0
    29
#include "config.h"
sl@0
    30
#endif
sl@0
    31
#include <liboil/liboilclasses.h>
sl@0
    32
#include <liboil/liboilfunction.h>
sl@0
    33
sl@0
    34
#ifdef HAVE_GCC_ASM 
sl@0
    35
#include <mmintrin.h>  
sl@0
    36
#endif
sl@0
    37
sl@0
    38
static void
sl@0
    39
copy_u8_mmx (uint8_t *dest, const uint8_t *src, int n)
sl@0
    40
{
sl@0
    41
#ifdef HAVE_GCC_ASM 
sl@0
    42
  for (; n >= 8; n -= 8) {
sl@0
    43
    *(__m64 *)dest = *(__m64 *)src;
sl@0
    44
    src += 8;
sl@0
    45
    dest += 8;
sl@0
    46
  }
sl@0
    47
  for (; n > 0; n--) {
sl@0
    48
    *dest++ = *src++;
sl@0
    49
  }
sl@0
    50
  _mm_empty();
sl@0
    51
#endif  
sl@0
    52
}
sl@0
    53
OIL_DEFINE_IMPL_FULL (copy_u8_mmx, copy_u8, OIL_IMPL_FLAG_MMX);
sl@0
    54
sl@0
    55
static void
sl@0
    56
copy_u8_mmx_unroll4 (uint8_t *dest, const uint8_t *src, int n)
sl@0
    57
{
sl@0
    58
#ifdef HAVE_GCC_ASM 
sl@0
    59
  for (; n >= 32; n -= 32) {
sl@0
    60
    ((__m64 *)dest)[0] = ((__m64 *)src)[0];
sl@0
    61
    ((__m64 *)dest)[1] = ((__m64 *)src)[1];
sl@0
    62
    ((__m64 *)dest)[2] = ((__m64 *)src)[2];
sl@0
    63
    ((__m64 *)dest)[3] = ((__m64 *)src)[3];
sl@0
    64
    src += 32;
sl@0
    65
    dest += 32;
sl@0
    66
  }
sl@0
    67
  for (; n >= 8; n -= 8) {
sl@0
    68
    *(__m64 *)dest = *(__m64 *)src;
sl@0
    69
    src += 8;
sl@0
    70
    dest += 8;
sl@0
    71
  }
sl@0
    72
  for (; n > 0; n--) {
sl@0
    73
    *dest++ = *src++;
sl@0
    74
  }
sl@0
    75
  _mm_empty();
sl@0
    76
#endif  
sl@0
    77
}
sl@0
    78
OIL_DEFINE_IMPL_FULL (copy_u8_mmx_unroll4, copy_u8, OIL_IMPL_FLAG_MMX);
sl@0
    79
sl@0
    80
sl@0
    81
#ifdef	__SYMBIAN32__
sl@0
    82
 
sl@0
    83
OilFunctionImpl* __oil_function_impl_copy_u8_mmx() {
sl@0
    84
		return &_oil_function_impl_copy_u8_mmx;
sl@0
    85
}
sl@0
    86
#endif
sl@0
    87
sl@0
    88
#ifdef	__SYMBIAN32__
sl@0
    89
 
sl@0
    90
OilFunctionImpl* __oil_function_impl_copy_u8_mmx_unroll4() {
sl@0
    91
		return &_oil_function_impl_copy_u8_mmx_unroll4;
sl@0
    92
}
sl@0
    93
#endif
sl@0
    94