blob: 56081043338730bf1cd717cff6544cf430280438 [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written by Christophe Lyon
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22THE SOFTWARE.
23
24*/
25
26/* Template file for binary saturating operator validation */
27
28#ifdef __arm__
29#include <arm_neon.h>
30#else
31#error Target not supported
32#endif
33
34#include "stm-arm-neon-ref.h"
35
36#define FNNAME1(NAME) void exec_ ## NAME (void)
37#define FNNAME(NAME) FNNAME1(NAME)
38
39FNNAME (INSN_NAME)
40{
41 /* vector_res = OP(vector1,vector2), then store the result. */
42#define TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N) \
43 Neon_Overflow = 0; \
44 VECT_VAR(vector_res, T1, W, N) = \
45 INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \
46 VECT_VAR(vector2, T1, W, N)); \
47 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
48 VECT_VAR(vector_res, T1, W, N)); \
49 dump_neon_overflow(TEST_MSG, xSTR(INSN##Q##_##T2##W))
50
51#define TEST_BINARY_SAT_OP(INSN, Q, T1, T2, W, N) \
52 TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N)
53
54 /* With ARM RVCT, we need to declare variables before any executable
55 statement */
56 DECL_VARIABLE_ALL_VARIANTS(vector1);
57 DECL_VARIABLE_ALL_VARIANTS(vector2);
58 DECL_VARIABLE_ALL_VARIANTS(vector_res);
59
60 clean_results ();
61
62 /* Initialize input "vector1" from "buffer" */
63 TEST_MACRO_ALL_VARIANTS_2_5(TEST_VLOAD, vector1, buffer);
64
65 /* Choose arbitrary initialization values */
66 TEST_VDUP(vector2, , int, s, 8, 8, 0x11);
67 TEST_VDUP(vector2, , int, s, 16, 4, 0x22);
68 TEST_VDUP(vector2, , int, s, 32, 2, 0x33);
69 TEST_VDUP(vector2, , int, s, 64, 1, 0x44);
70 TEST_VDUP(vector2, , uint, u, 8, 8, 0x55);
71 TEST_VDUP(vector2, , uint, u, 16, 4, 0x66);
72 TEST_VDUP(vector2, , uint, u, 32, 2, 0x77);
73 TEST_VDUP(vector2, , uint, u, 64, 1, 0x88);
74
75 TEST_VDUP(vector2, q, int, s, 8, 16, 0x11);
76 TEST_VDUP(vector2, q, int, s, 16, 8, 0x22);
77 TEST_VDUP(vector2, q, int, s, 32, 4, 0x33);
78 TEST_VDUP(vector2, q, int, s, 64, 2, 0x44);
79 TEST_VDUP(vector2, q, uint, u, 8, 16, 0x55);
80 TEST_VDUP(vector2, q, uint, u, 16, 8, 0x66);
81 TEST_VDUP(vector2, q, uint, u, 32, 4, 0x77);
82 TEST_VDUP(vector2, q, uint, u, 64, 2, 0x88);
83
84 fprintf(ref_file, "\n%s overflow output:\n", TEST_MSG);
85 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8);
86 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4);
87 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2);
88 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
89 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8);
90 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4);
91 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2);
92 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
93
94 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16);
95 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8);
96 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4);
97 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
98 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16);
99 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8);
100 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4);
101 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
102
103 dump_results_hex (TEST_MSG);
104
105#ifdef EXTRA_TESTS
106 EXTRA_TESTS();
107#endif
108}