Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2005 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
33 #include <liboil/liboil.h>
34 #include <liboil/liboilfunction.h>
35 #include <liboil/liboilclasses.h>
44 swab_u16_libc (uint16_t *d, const uint16_t *s, int n)
46 swab ((void *)s, (void *)d, n*2);
48 OIL_DEFINE_IMPL (swab_u16_libc, swab_u16);
51 swab_u16_ptr (uint16_t *d, const uint16_t *s, int n)
56 *d++ = (*s<<8) | (*s>>8);
60 OIL_DEFINE_IMPL (swab_u16_ptr, swab_u16);
63 swab_u32_ptr (uint32_t *d, const uint32_t *s, int n)
68 *d++ = (*s<<24) | ((*s&0x0000ff00)<<8) |
69 ((*s&0x00ff0000)>>8) | (*s>>24);
73 OIL_DEFINE_IMPL (swab_u32_ptr, swab_u32);
76 swab_u16_unroll2 (uint16_t *d, const uint16_t *s, int n)
81 *d++ = (*s<<8) | (*s>>8);
86 *d++ = (*s<<8) | (*s>>8);
88 *d++ = (*s<<8) | (*s>>8);
92 OIL_DEFINE_IMPL (swab_u16_unroll2, swab_u16);
95 swab_u16_unroll4 (uint16_t *d, const uint16_t *s, int n)
100 *d++ = (*s<<8) | (*s>>8);
106 *d++ = (*s<<8) | (*s>>8);
108 *d++ = (*s<<8) | (*s>>8);
110 *d++ = (*s<<8) | (*s>>8);
112 *d++ = (*s<<8) | (*s>>8);
116 OIL_DEFINE_IMPL (swab_u16_unroll4, swab_u16);
119 swab_u32_unroll2 (uint32_t *d, const uint32_t *s, int n)
124 *d++ = (*s<<24) | ((*s&0x0000ff00)<<8) |
125 ((*s&0x00ff0000)>>8) | (*s>>24);
130 *d++ = (*s<<24) | ((*s&0x0000ff00)<<8) |
131 ((*s&0x00ff0000)>>8) | (*s>>24);
133 *d++ = (*s<<24) | ((*s&0x0000ff00)<<8) |
134 ((*s&0x00ff0000)>>8) | (*s>>24);
138 OIL_DEFINE_IMPL (swab_u32_unroll2, swab_u32);
142 swab_u16_char (uint16_t *d, const uint16_t *s, int n)
145 uint8_t *bd = (uint8_t *)d;
146 uint8_t *bs = (uint8_t *)s;
157 OIL_DEFINE_IMPL (swab_u16_char, swab_u16);
160 swab_u32_char (uint32_t *d, const uint32_t *s, int n)
165 *d++ = (*s<<24) | ((*s&0x0000ff00)<<8) |
166 ((*s&0x00ff0000)>>8) | (*s>>24);
170 OIL_DEFINE_IMPL (swab_u32_char, swab_u32);
180 swab_u32_asm (uint32_t *d, uint32_t *s, int n)
184 " mov 0(%1), %%eax\n"
186 " mov %%eax, 0(%0)\n"
191 : "+r" (d), "+r" (s), "+r" (n)
195 OIL_DEFINE_IMPL (swab_u32_asm, swab_u32);
202 OilFunctionImpl* __oil_function_impl_swab_u16_libc() {
203 return &_oil_function_impl_swab_u16_libc;
209 OilFunctionImpl* __oil_function_impl_swab_u16_ptr() {
210 return &_oil_function_impl_swab_u16_ptr;
216 OilFunctionImpl* __oil_function_impl_swab_u32_ptr() {
217 return &_oil_function_impl_swab_u32_ptr;
223 OilFunctionImpl* __oil_function_impl_swab_u16_unroll2() {
224 return &_oil_function_impl_swab_u16_unroll2;
230 OilFunctionImpl* __oil_function_impl_swab_u16_unroll4() {
231 return &_oil_function_impl_swab_u16_unroll4;
237 OilFunctionImpl* __oil_function_impl_swab_u32_unroll2() {
238 return &_oil_function_impl_swab_u32_unroll2;
244 OilFunctionImpl* __oil_function_impl_swab_u16_char() {
245 return &_oil_function_impl_swab_u16_char;
251 OilFunctionImpl* __oil_function_impl_swab_u32_char() {
252 return &_oil_function_impl_swab_u32_char;
259 OilFunctionImpl* __oil_function_impl_swab_u32_asm() {
260 return &_oil_function_impl_swab_u32_asm;