• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3 Copyright (c) 2009, 2010, 2011 STMicroelectronics
4 Written by Christophe Lyon
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 
24 */
25 
26 #define INSN_NAME vqsub
27 #define TEST_MSG "VQSUB/VQSUBQ"
28 
29 /* Extra tests for functions requiring types larger than 64 bits to
30    compute saturation */
31 void vqsub_64(void);
32 #define EXTRA_TESTS vqsub_64
33 
34 #include "ref_v_binary_sat_op.c"
35 
vqsub_64(void)36 void vqsub_64(void)
37 {
38   int i;
39 
40   DECL_VARIABLE_ALL_VARIANTS(vector1);
41   DECL_VARIABLE_ALL_VARIANTS(vector2);
42   DECL_VARIABLE_ALL_VARIANTS(vector_res);
43 
44   /* Initialize input "vector1" from "buffer"  */
45   TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer);
46 
47   VDUP(vector2, , int, s, 64, 1, 0x0);
48   VDUP(vector2, , uint, u, 64, 1, 0x0);
49   VDUP(vector2, q, int, s, 64, 2, 0x0);
50   VDUP(vector2, q, uint, u, 64, 2, 0x0);
51 
52   fprintf(ref_file,
53 	  "\n%s 64 bits saturation cumulative saturation output:\n",
54 	  TEST_MSG);
55   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
56   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
57   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
58   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
59 
60   fprintf(ref_file, "\n64 bits saturation:\n");
61   DUMP(TEST_MSG, int, 64, 1, PRIx64);
62   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
63   DUMP(TEST_MSG, int, 64, 2, PRIx64);
64   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
65 
66   /* Another set of tests */
67   VDUP(vector2, , int, s, 64, 1, 0x44);
68   VDUP(vector2, , uint, u, 64, 1, 0x88);
69   VDUP(vector2, q, int, s, 64, 2, 0x44);
70   VDUP(vector2, q, uint, u, 64, 2, 0x88);
71 
72   fprintf(ref_file,
73 	  "\n%s 64 bits saturation cumulative saturation output:\n",
74 	  TEST_MSG);
75   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
76   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
77   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
78   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
79 
80   DUMP(TEST_MSG, int, 64, 1, PRIx64);
81   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
82   DUMP(TEST_MSG, int, 64, 2, PRIx64);
83   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
84 
85   /* Another set of tests */
86   VDUP(vector2, , int, s, 64, 1, 0x7fffffffffffffffLL);
87   VDUP(vector2, , uint, u, 64, 1, 0xffffffffffffffffULL);
88 
89   /* To check positive saturation, we need to write a positive value
90      in vector1 */
91   VDUP(vector1, q, int, s, 64, 2, 0x3fffffffffffffffLL);
92   VDUP(vector2, q, int, s, 64, 2, 0x8000000000000000LL);
93 
94   VDUP(vector2, q, uint, u, 64, 2, 0xffffffffffffffffULL);
95 
96   fprintf(ref_file,
97 	  "\n%s 64 bits saturation cumulative saturation output:\n",
98 	  TEST_MSG);
99   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
100   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
101   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
102   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
103 
104   DUMP(TEST_MSG, int, 64, 1, PRIx64);
105   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
106   DUMP(TEST_MSG, int, 64, 2, PRIx64);
107   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
108 
109   /* To improve coverage, check saturation with less than 64 bits too */
110   fprintf(ref_file, "\nless than 64 bits saturation:\n");
111   VDUP(vector2, , int, s, 8, 8, 0x7F);
112   VDUP(vector2, , int, s, 16, 4, 0x7FFF);
113   VDUP(vector2, , int, s, 32, 2, 0x7FFFFFFF);
114   VDUP(vector2, q, int, s, 8, 16, 0x7F);
115   VDUP(vector2, q, int, s, 16, 8, 0x7FFF);
116   VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF);
117 
118   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8);
119   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4);
120   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2);
121   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16);
122   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8);
123   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4);
124 
125   DUMP(TEST_MSG, int, 8, 8, PRIx8);
126   DUMP(TEST_MSG, int, 16, 4, PRIx16);
127   DUMP(TEST_MSG, int, 32, 2, PRIx32);
128   DUMP(TEST_MSG, int, 8, 16, PRIx8);
129   DUMP(TEST_MSG, int, 16, 8, PRIx16);
130   DUMP(TEST_MSG, int, 32, 4, PRIx32);
131 
132 
133   VDUP(vector1, , uint, u, 8, 8, 0x10);
134   VDUP(vector1, , uint, u, 16, 4, 0x10);
135   VDUP(vector1, , uint, u, 32, 2, 0x10);
136   VDUP(vector1, q, uint, u, 8, 16, 0x10);
137   VDUP(vector1, q, uint, u, 16, 8, 0x10);
138   VDUP(vector1, q, uint, u, 32, 4, 0x10);
139 
140   VDUP(vector2, , uint, u, 8, 8, 0x20);
141   VDUP(vector2, , uint, u, 16, 4, 0x20);
142   VDUP(vector2, , uint, u, 32, 2, 0x20);
143   VDUP(vector2, q, uint, u, 8, 16, 0x20);
144   VDUP(vector2, q, uint, u, 16, 8, 0x20);
145   VDUP(vector2, q, uint, u, 32, 4, 0x20);
146 
147   fprintf(ref_file,
148 	  "\n%s less than 64 bits saturation cumulative saturation output:\n",
149 	  TEST_MSG);
150   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8);
151   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4);
152   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2);
153   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16);
154   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8);
155   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4);
156 
157   DUMP(TEST_MSG, uint, 8, 8, PRIx8);
158   DUMP(TEST_MSG, uint, 16, 4, PRIx16);
159   DUMP(TEST_MSG, uint, 32, 2, PRIx32);
160   DUMP(TEST_MSG, uint, 8, 16, PRIx8);
161   DUMP(TEST_MSG, uint, 16, 8, PRIx16);
162   DUMP(TEST_MSG, uint, 32, 4, PRIx32);
163 }
164