Update contrib.
3 * Eric Anholt. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
26 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
32 #include <liboil/liboilfunction.h>
33 #include <liboil/liboiltest.h>
35 #define CLAMP_DEFINE_REF(type) \
36 static void clamp_ ## type ## _ref ( \
37 oil_type_ ## type *dest, \
38 const oil_type_ ## type *src, \
40 const oil_type_ ## type *min, \
41 const oil_type_ ## type *max) \
44 oil_type_ ## type x; \
45 for (i = 0; i < n; i++) { \
54 static void clamp_ ## type ## _test (OilTest *test) \
56 oil_type_ ## type *lo = (oil_type_ ## type *) \
57 (test->params[OIL_ARG_SRC2].src_data + \
58 test->params[OIL_ARG_SRC2].test_header); \
59 oil_type_ ## type *hi = (oil_type_ ## type *) \
60 (test->params[OIL_ARG_SRC3].src_data + \
61 test->params[OIL_ARG_SRC3].test_header); \
63 oil_type_ ## type tmp; \
69 OIL_DEFINE_CLASS_FULL(clamp_ ## type, \
70 "oil_type_" #type " *dest, " \
71 "oil_type_" #type " *src, " \
73 "oil_type_" #type " *s2_1, " \
74 "oil_type_" #type " *s3_1", \
75 clamp_ ## type ## _test); \
76 OIL_DEFINE_IMPL_REF(clamp_ ## type ## _ref, clamp_ ## type)
78 CLAMP_DEFINE_REF (s8);
79 CLAMP_DEFINE_REF (u8);
80 CLAMP_DEFINE_REF (s16);
81 CLAMP_DEFINE_REF (u16);
82 CLAMP_DEFINE_REF (s32);
83 CLAMP_DEFINE_REF (u32);
84 CLAMP_DEFINE_REF (f32);
85 CLAMP_DEFINE_REF (f64);
97 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
98 * the result in @dest.
109 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
110 * the result in @dest.
121 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
122 * the result in @dest.
133 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
134 * the result in @dest.
145 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
146 * the result in @dest.
157 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
158 * the result in @dest.
169 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
170 * the result in @dest.
181 * Clamps each value in @src to the range [@s2_1,@s3_1] and places
182 * the result in @dest.
185 #define CLAMPLOW_DEFINE_REF(type) \
186 static void clamplow_ ## type ## _ref ( \
187 oil_type_ ## type *dest, \
188 const oil_type_ ## type *src, \
190 const oil_type_ ## type *min) \
193 oil_type_ ## type x; \
194 for (i = 0; i < n; i++) { \
201 OIL_DEFINE_CLASS(clamplow_ ## type, \
202 "oil_type_" #type " *dest, " \
203 "oil_type_" #type " *src, " \
205 "oil_type_" #type " *s2_1"); \
206 OIL_DEFINE_IMPL_REF(clamplow_ ## type ## _ref, clamplow_ ## type)
208 CLAMPLOW_DEFINE_REF (s8);
209 CLAMPLOW_DEFINE_REF (u8);
210 CLAMPLOW_DEFINE_REF (s16);
211 CLAMPLOW_DEFINE_REF (u16);
212 CLAMPLOW_DEFINE_REF (s32);
213 CLAMPLOW_DEFINE_REF (u32);
214 CLAMPLOW_DEFINE_REF (f32);
215 CLAMPLOW_DEFINE_REF (f64);
224 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
236 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
247 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
259 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
270 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
282 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
293 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
305 * Clamps each value in @src to a lower bound of @s2_1 and places the result in
309 #define CLAMPHIGH_DEFINE_REF(type) \
310 static void clamphigh_ ## type ## _ref ( \
311 oil_type_ ## type *dest, \
312 const oil_type_ ## type *src, \
314 const oil_type_ ## type *max) \
317 oil_type_ ## type x; \
318 for (i = 0; i < n; i++) { \
325 OIL_DEFINE_CLASS(clamphigh_ ## type, \
326 "oil_type_" #type " *dest, " \
327 "oil_type_" #type " *src, " \
329 "oil_type_" #type " *s2_1"); \
330 OIL_DEFINE_IMPL_REF(clamphigh_ ## type ## _ref, clamphigh_ ## type)
332 CLAMPHIGH_DEFINE_REF (s8);
333 CLAMPHIGH_DEFINE_REF (u8);
334 CLAMPHIGH_DEFINE_REF (s16);
335 CLAMPHIGH_DEFINE_REF (u16);
336 CLAMPHIGH_DEFINE_REF (s32);
337 CLAMPHIGH_DEFINE_REF (u32);
338 CLAMPHIGH_DEFINE_REF (f32);
339 CLAMPHIGH_DEFINE_REF (f64);
343 OilFunctionClass* __oil_function_class_clamp_s8() {
344 return &_oil_function_class_clamp_s8;
350 OilFunctionClass* __oil_function_class_clamp_u8() {
351 return &_oil_function_class_clamp_u8;
357 OilFunctionClass* __oil_function_class_clamp_s16() {
358 return &_oil_function_class_clamp_s16;
363 OilFunctionClass* __oil_function_class_clamp_u16() {
364 return &_oil_function_class_clamp_u16;
369 OilFunctionClass* __oil_function_class_clamp_s32() {
370 return &_oil_function_class_clamp_s32;
375 OilFunctionClass* __oil_function_class_clamp_u32() {
376 return &_oil_function_class_clamp_u32;
381 OilFunctionClass* __oil_function_class_clamp_f32() {
382 return &_oil_function_class_clamp_f32;
387 OilFunctionClass* __oil_function_class_clamp_f64() {
388 return &_oil_function_class_clamp_f64;
395 OilFunctionClass* __oil_function_class_clamphigh_s8() {
396 return &_oil_function_class_clamp_s8;
402 OilFunctionClass* __oil_function_class_clamphigh_u8() {
403 return &_oil_function_class_clamp_u8;
409 OilFunctionClass* __oil_function_class_clamphigh_s16() {
410 return &_oil_function_class_clamp_s16;
415 OilFunctionClass* __oil_function_class_clamphigh_u16() {
416 return &_oil_function_class_clamp_u16;
421 OilFunctionClass* __oil_function_class_clamphigh_s32() {
422 return &_oil_function_class_clamp_s32;
427 OilFunctionClass* __oil_function_class_clamphigh_u32() {
428 return &_oil_function_class_clamp_u32;
433 OilFunctionClass* __oil_function_class_clamphigh_f32() {
434 return &_oil_function_class_clamp_f32;
439 OilFunctionClass* __oil_function_class_clamphigh_f64() {
440 return &_oil_function_class_clamp_f64;
449 OilFunctionClass* __oil_function_class_clamplow_s8() {
450 return &_oil_function_class_clamplow_s8;
456 OilFunctionClass* __oil_function_class_clamplow_u8() {
457 return &_oil_function_class_clamplow_u8;
463 OilFunctionClass* __oil_function_class_clamplow_s16() {
464 return &_oil_function_class_clamplow_s16;
469 OilFunctionClass* __oil_function_class_clamplow_u16() {
470 return &_oil_function_class_clamplow_u16;
475 OilFunctionClass* __oil_function_class_clamplow_s32() {
476 return &_oil_function_class_clamplow_s32;
481 OilFunctionClass* __oil_function_class_clamplow_u32() {
482 return &_oil_function_class_clamplow_u32;
487 OilFunctionClass* __oil_function_class_clamplow_f32() {
488 return &_oil_function_class_clamplow_f32;
493 OilFunctionClass* __oil_function_class_clamplow_f64() {
494 return &_oil_function_class_clamplow_f64;
504 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
515 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
526 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
537 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
548 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
559 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
570 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
581 * Clamps each value in @src to an upper bound of @s2_1 and places the result in
588 OilFunctionImpl* __oil_function_impl_clamp_s8_ref() {
589 return &_oil_function_impl_clamp_s8_ref;
595 OilFunctionImpl* __oil_function_impl_clamp_u8_ref() {
596 return &_oil_function_impl_clamp_u8_ref;
602 OilFunctionImpl* __oil_function_impl_clamp_s16_ref() {
603 return &_oil_function_impl_clamp_s16_ref;
609 OilFunctionImpl* __oil_function_impl_clamp_u16_ref() {
610 return &_oil_function_impl_clamp_u16_ref;
616 OilFunctionImpl* __oil_function_impl_clamp_s32_ref() {
617 return &_oil_function_impl_clamp_s32_ref;
623 OilFunctionImpl* __oil_function_impl_clamp_u32_ref() {
624 return &_oil_function_impl_clamp_u32_ref;
630 OilFunctionImpl* __oil_function_impl_clamp_f32_ref() {
631 return &_oil_function_impl_clamp_f32_ref;
637 OilFunctionImpl* __oil_function_impl_clamp_f64_ref() {
638 return &_oil_function_impl_clamp_f64_ref;
644 OilFunctionImpl* __oil_function_impl_clamplow_s8_ref() {
645 return &_oil_function_impl_clamplow_s8_ref;
651 OilFunctionImpl* __oil_function_impl_clamplow_u8_ref() {
652 return &_oil_function_impl_clamplow_u8_ref;
658 OilFunctionImpl* __oil_function_impl_clamplow_s16_ref() {
659 return &_oil_function_impl_clamplow_s16_ref;
665 OilFunctionImpl* __oil_function_impl_clamplow_u16_ref() {
666 return &_oil_function_impl_clamplow_u16_ref;
672 OilFunctionImpl* __oil_function_impl_clamplow_s32_ref() {
673 return &_oil_function_impl_clamplow_s32_ref;
679 OilFunctionImpl* __oil_function_impl_clamplow_u32_ref() {
680 return &_oil_function_impl_clamplow_u32_ref;
686 OilFunctionImpl* __oil_function_impl_clamplow_f32_ref() {
687 return &_oil_function_impl_clamplow_f32_ref;
693 OilFunctionImpl* __oil_function_impl_clamplow_f64_ref() {
694 return &_oil_function_impl_clamplow_f64_ref;
700 OilFunctionImpl* __oil_function_impl_clamphigh_s8_ref() {
701 return &_oil_function_impl_clamphigh_s8_ref;
707 OilFunctionImpl* __oil_function_impl_clamphigh_u8_ref() {
708 return &_oil_function_impl_clamphigh_u8_ref;
714 OilFunctionImpl* __oil_function_impl_clamphigh_s16_ref() {
715 return &_oil_function_impl_clamphigh_s16_ref;
721 OilFunctionImpl* __oil_function_impl_clamphigh_u16_ref() {
722 return &_oil_function_impl_clamphigh_u16_ref;
728 OilFunctionImpl* __oil_function_impl_clamphigh_s32_ref() {
729 return &_oil_function_impl_clamphigh_s32_ref;
735 OilFunctionImpl* __oil_function_impl_clamphigh_u32_ref() {
736 return &_oil_function_impl_clamphigh_u32_ref;
742 OilFunctionImpl* __oil_function_impl_clamphigh_f32_ref() {
743 return &_oil_function_impl_clamphigh_f32_ref;
749 OilFunctionImpl* __oil_function_impl_clamphigh_f64_ref() {
750 return &_oil_function_impl_clamphigh_f64_ref;
758 EXPORT_C void** _oil_function_class_ptr_clamp_s8 () {
759 oil_function_class_ptr_clamp_s8 = __oil_function_class_clamp_s8();
760 return &oil_function_class_ptr_clamp_s8->func;
766 EXPORT_C void** _oil_function_class_ptr_clamp_u8 () {
767 oil_function_class_ptr_clamp_u8 = __oil_function_class_clamp_u8();
768 return &oil_function_class_ptr_clamp_u8->func;
774 EXPORT_C void** _oil_function_class_ptr_clamp_s16 () {
775 oil_function_class_ptr_clamp_s16 = __oil_function_class_clamp_s16();
776 return &oil_function_class_ptr_clamp_s16->func;
782 EXPORT_C void** _oil_function_class_ptr_clamp_u16 () {
783 oil_function_class_ptr_clamp_u16 = __oil_function_class_clamp_u16();
784 return &oil_function_class_ptr_clamp_u16->func;
790 EXPORT_C void** _oil_function_class_ptr_clamp_s32 () {
791 oil_function_class_ptr_clamp_s32 = __oil_function_class_clamp_s32();
792 return &oil_function_class_ptr_clamp_s32->func;
798 EXPORT_C void** _oil_function_class_ptr_clamp_u32 () {
799 oil_function_class_ptr_clamp_u32 = __oil_function_class_clamp_u32();
800 return &oil_function_class_ptr_clamp_u32->func;
806 EXPORT_C void** _oil_function_class_ptr_clamp_f32 () {
807 oil_function_class_ptr_clamp_f32 = __oil_function_class_clamp_f32();
808 return &oil_function_class_ptr_clamp_f32->func;
814 EXPORT_C void** _oil_function_class_ptr_clamp_f64 () {
815 oil_function_class_ptr_clamp_f64 = __oil_function_class_clamp_f64();
816 return &oil_function_class_ptr_clamp_f64->func;
822 EXPORT_C void** _oil_function_class_ptr_clamphigh_s8 () {
823 oil_function_class_ptr_clamphigh_s8 = __oil_function_class_clamphigh_s8();
824 return &oil_function_class_ptr_clamphigh_s8->func;
830 EXPORT_C void** _oil_function_class_ptr_clamphigh_u8 () {
831 oil_function_class_ptr_clamphigh_u8 = __oil_function_class_clamphigh_u8();
832 return &oil_function_class_ptr_clamphigh_u8->func;
838 EXPORT_C void** _oil_function_class_ptr_clamphigh_s16 () {
839 oil_function_class_ptr_clamphigh_s16 = __oil_function_class_clamphigh_s16();
840 return &oil_function_class_ptr_clamphigh_s16->func;
846 EXPORT_C void** _oil_function_class_ptr_clamphigh_u16 () {
847 oil_function_class_ptr_clamphigh_u16 = __oil_function_class_clamphigh_u16();
848 return &oil_function_class_ptr_clamphigh_u16->func;
854 EXPORT_C void** _oil_function_class_ptr_clamphigh_s32 () {
855 oil_function_class_ptr_clamphigh_s32 = __oil_function_class_clamphigh_s32();
856 return &oil_function_class_ptr_clamphigh_s32->func;
862 EXPORT_C void** _oil_function_class_ptr_clamphigh_u32 () {
863 oil_function_class_ptr_clamphigh_u32 = __oil_function_class_clamphigh_u32();
864 return &oil_function_class_ptr_clamphigh_u32->func;
870 EXPORT_C void** _oil_function_class_ptr_clamphigh_f32 () {
871 oil_function_class_ptr_clamphigh_f32 = __oil_function_class_clamphigh_f32();
872 return &oil_function_class_ptr_clamphigh_f32->func;
878 EXPORT_C void** _oil_function_class_ptr_clamphigh_f64 () {
879 oil_function_class_ptr_clamphigh_f64 = __oil_function_class_clamphigh_f64();
880 return &oil_function_class_ptr_clamphigh_f64->func;
886 EXPORT_C void** _oil_function_class_ptr_clamplow_s8 () {
887 oil_function_class_ptr_clamplow_s8 = __oil_function_class_clamplow_s8();
888 return &oil_function_class_ptr_clamplow_s8->func;
894 EXPORT_C void** _oil_function_class_ptr_clamplow_u8 () {
895 oil_function_class_ptr_clamplow_u8 = __oil_function_class_clamplow_u8();
896 return &oil_function_class_ptr_clamplow_u8->func;
902 EXPORT_C void** _oil_function_class_ptr_clamplow_s16 () {
903 oil_function_class_ptr_clamplow_s16 = __oil_function_class_clamplow_s16();
904 return &oil_function_class_ptr_clamplow_s16->func;
910 EXPORT_C void** _oil_function_class_ptr_clamplow_u16 () {
911 oil_function_class_ptr_clamplow_u16 = __oil_function_class_clamplow_u16();
912 return &oil_function_class_ptr_clamplow_u16->func;
918 EXPORT_C void** _oil_function_class_ptr_clamplow_s32 () {
919 oil_function_class_ptr_clamplow_s32 = __oil_function_class_clamplow_s32();
920 return &oil_function_class_ptr_clamplow_s32->func;
926 EXPORT_C void** _oil_function_class_ptr_clamplow_u32 () {
927 oil_function_class_ptr_clamplow_u32 = __oil_function_class_clamplow_u32();
928 return &oil_function_class_ptr_clamplow_u32->func;
934 EXPORT_C void** _oil_function_class_ptr_clamplow_f32 () {
935 oil_function_class_ptr_clamplow_f32 = __oil_function_class_clamplow_f32();
936 return &oil_function_class_ptr_clamplow_f32->func;
942 EXPORT_C void** _oil_function_class_ptr_clamplow_f64 () {
943 oil_function_class_ptr_clamplow_f64 = __oil_function_class_clamplow_f64();
944 return &oil_function_class_ptr_clamplow_f64->func;