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.
32 #include <liboil/liboilfunction.h>
33 #include <liboil/simdpack/simdpack.h>
35 #define oil_type_min_f32 -1.0
36 #define oil_type_max_f32 1.0
37 #define oil_type_min_f64 -1.0
38 #define oil_type_max_f64 1.0
40 #define VECTORADD_S_DEFINE_IMPL(type,bigger) \
41 static void vectoradd_s_ ## type ## _ref ( \
42 oil_type_ ## type *dest, int dstr, \
43 oil_type_ ## type *src1, int sstr1, \
44 oil_type_ ## type *src2, int sstr2, \
49 OIL_GET(dest,i*dstr, oil_type_ ## type) = CLAMP((oil_type_ ## bigger)OIL_GET(src1,i*sstr1, oil_type_ ## type) + \
50 (oil_type_ ## bigger)OIL_GET(src2,i*sstr2, oil_type_ ## type),oil_type_min_ ## type, oil_type_max_ ## type); \
53 OIL_DEFINE_CLASS (vectoradd_s_ ## type, \
54 "oil_type_" #type " *d, int dstr, " \
55 "oil_type_" #type " *s1, int sstr1, " \
56 "oil_type_" #type " *s2, int sstr2, " \
58 OIL_DEFINE_IMPL_REF (vectoradd_s_ ## type ## _ref, vectoradd_s_ ## type);
71 * Adds each element of @s1 to @s2 and clamps the result to the range
72 * of the type and places the result in @d.
74 * FIXME: This function is difficult to optimize and will likely be
77 VECTORADD_S_DEFINE_IMPL (s8,s16);
88 * Adds each element of @s1 to @s2 and clamps the result to the range
89 * of the type and places the result in @d.
91 * FIXME: This function is difficult to optimize and will likely be
94 VECTORADD_S_DEFINE_IMPL (u8,u16);
96 * oil_vectoradd_s_s16:
105 * Adds each element of @s1 to @s2 and clamps the result to the range
106 * of the type and places the result in @d.
108 * FIXME: This function is difficult to optimize and will likely be
111 VECTORADD_S_DEFINE_IMPL (s16,s32);
113 * oil_vectoradd_s_u16:
122 * Adds each element of @s1 to @s2 and clamps the result to the range
123 * of the type and places the result in @d.
125 * FIXME: This function is difficult to optimize and will likely be
128 VECTORADD_S_DEFINE_IMPL (u16,u32);
130 * oil_vectoradd_s_f32:
139 * Adds each element of @s1 to @s2 and clamps the result to the range
140 * [-1,1] and places the result in @d.
142 * FIXME: This function is difficult to optimize and will likely be
145 VECTORADD_S_DEFINE_IMPL (f32,f32);
147 * oil_vectoradd_s_f64:
156 * Adds each element of @s1 to @s2 and clamps the result to the range
157 * [-1,1] and places the result in @d.
159 * FIXME: This function is difficult to optimize and will likely be
162 VECTORADD_S_DEFINE_IMPL (f64,f64);