Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sf_test.cpp File Reference
#include <xbyak/xbyak_util.h>
Include dependency graph for sf_test.cpp:

Go to the source code of this file.

Classes

struct  Code
 
struct  Code2
 

Macros

#define XBYAK_NO_OP_NAMES
 

Functions

void check (int x, int y)
 
void verify (const Xbyak::uint8 *f, int pNum)
 
void testAll ()
 
void testPartial ()
 
void put (const Xbyak::util::Pack &p)
 
void verifyPack (const Xbyak::util::Pack &p, const int *tbl, size_t tblNum)
 
void testPack ()
 
int main ()
 

Macro Definition Documentation

◆ XBYAK_NO_OP_NAMES

#define XBYAK_NO_OP_NAMES

Definition at line 1 of file sf_test.cpp.

Function Documentation

◆ check()

void check ( int x,
int y )

Definition at line 158 of file sf_test.cpp.

159{
160 if (x != y) {
161 printf("err x=%d, y=%d\n", x, y);
162 errNum++;
163 }
164}
int errNum
Definition cvt_test.cpp:47
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30

◆ main()

int main ( void )

Definition at line 323 of file sf_test.cpp.

325{
326 testAll();
327
328 testPartial();
329 testPack();
330 printf("errNum=%d\n", errNum);
331} catch (std::exception& e) {
332 printf("err %s\n", e.what());
333 return 1;
334} catch (...) {
335 puts("ERR");
336 return 1;
337}
void testPartial()
Definition sf_test.cpp:221
void testAll()
Definition sf_test.cpp:190
void testPack()
Definition sf_test.cpp:288
Here is the call graph for this function:

◆ put()

void put ( const Xbyak::util::Pack & p)

Definition at line 273 of file sf_test.cpp.

274{
275 for (size_t i = 0, n = p.size(); i < n; i++) {
276 printf("%s ", p[i].toString());
277 }
278 printf("\n");
279}
const mie::Vuint & p
Definition bn.cpp:27
size_t size() const
Definition zm.h:519
Here is the call graph for this function:

◆ testAll()

void testAll ( )

Definition at line 190 of file sf_test.cpp.

191{
192 Code2 code;
193 for (int stackSize = 0; stackSize < 32; stackSize += 7) {
194 for (int pNum = 0; pNum < 4; pNum++) {
195 for (int mode = 0; mode < 4; mode++) {
196 int maxNum = 0;
197 int opt = 0;
198 if (mode == 0) {
199 maxNum = 10;
200 } else if (mode == 1) {
201 maxNum = 9;
202 opt = UseRCX;
203 } else if (mode == 2) {
204 maxNum = 9;
205 opt = UseRDX;
206 } else {
207 maxNum = 8;
208 opt = UseRCX | UseRDX;
209 }
210 for (int tNum = 0; tNum < maxNum; tNum++) {
211// printf("pNum=%d, tNum=%d, stackSize=%d\n", pNum, tNum | opt, stackSize);
212 const Xbyak::uint8 *f = code.getCurr();
213 code.gen(pNum, tNum | opt, stackSize);
214 verify(f, pNum);
215 }
216 }
217 }
218 }
219}
void verify(const Xbyak::uint8 *f, int pNum)
Definition sf_test.cpp:166
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testPack()

void testPack ( )

Definition at line 288 of file sf_test.cpp.

289{
290 const int N = 10;
291 Xbyak::Reg64 regTbl[N];
292 for (int i = 0; i < N; i++) {
293 regTbl[i] = Xbyak::Reg64(i);
294 }
295 Xbyak::util::Pack p(regTbl, N);
296 const struct {
297 int pos;
298 int num;
299 int tbl[10];
300 } tbl[] = {
301 { 0, 10, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } },
302 { 1, 9, { 1, 2, 3, 4, 5, 6, 7, 8, 9 } },
303 { 2, 8, { 2, 3, 4, 5, 6, 7, 8, 9 } },
304 { 3, 7, { 3, 4, 5, 6, 7, 8, 9 } },
305 { 4, 6, { 4, 5, 6, 7, 8, 9 } },
306 { 5, 5, { 5, 6, 7, 8, 9 } },
307 { 6, 4, { 6, 7, 8, 9 } },
308 { 7, 3, { 7, 8, 9 } },
309 { 8, 2, { 8, 9 } },
310 { 9, 1, { 9 } },
311 { 3, 5, { 3, 4, 5, 6, 7 } },
312 };
313 for (size_t i = 0; i < sizeof(tbl) / sizeof(*tbl); i++) {
314 const int pos = tbl[i].pos;
315 const int num = tbl[i].num;
316 verifyPack(p.sub(pos, num), tbl[i].tbl, num);
317 if (pos + num == N) {
318 verifyPack(p.sub(pos), tbl[i].tbl, num);
319 }
320 }
321}
const struct Ptn tbl[]
const int N
Definition quantize.cpp:54
void verifyPack(const Xbyak::util::Pack &p, const int *tbl, size_t tblNum)
Definition sf_test.cpp:281
static void sub(VuintT &out, const VuintT &x, const VuintT &y)
Definition zm.h:597
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testPartial()

void testPartial ( )

Definition at line 221 of file sf_test.cpp.

222{
223 Code code;
224 int (*f1)(int) = code.getCurr<int (*)(int)>();
225 code.gen1();
226 check(5, f1(5));
227
228 int (*f2)(int, int) = code.getCurr<int (*)(int, int)>();
229 code.gen2();
230 check(9, f2(3, 6));
231
232 int (*f3)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
233 code.gen3();
234 check(14, f3(1, 4, 9));
235
236 int (*f4)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
237 code.gen4();
238 check(30, f4(1, 4, 9, 16));
239
240 int (*f5)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
241 code.gen5();
242 check(23, f5(2, 5, 7, 9));
243
244 int (*f6)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
245 code.gen6();
246 check(18, f6(3, 4, 5, 6));
247
248 int (*f7)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
249 code.gen7();
250 check(12, f7(3, 4, 5));
251
252 int (*f8)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
253 code.gen8();
254 check(23, f8(5, 8, 10));
255
256 int (*f9)(int, int, int) = code.getCurr<int (*)(int, int, int)>();
257 code.gen9();
258 check(60, f9(10, 20, 30));
259
260 int (*f10)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
261 code.gen10();
262 check(100, f10(10, 20, 30, 40));
263
264 int (*f11)() = code.getCurr<int (*)()>();
265 code.gen11();
266 check(3, f11());
267
268 int (*f12)(int, int, int, int) = code.getCurr<int (*)(int, int, int, int)>();
269 code.gen12();
270 check(24, f12(3, 5, 7, 9));
271}
const uint8 * getCurr() const
Definition xbyak.h:908
const T1 const T2 const T3 & f3
const T1 const T2 const T3 const T4 const T5 const T6 const T7 const T8 const T9 & f9
const T1 const T2 const T3 const T4 const T5 const T6 const T7 & f7
const T1 const T2 const T3 const T4 const T5 const T6 & f6
const T1 const T2 & f2
const T1 & f1
const T1 const T2 const T3 const T4 const T5 & f5
const T1 const T2 const T3 const T4 const T5 const T6 const T7 const T8 & f8
const T1 const T2 const T3 const T4 & f4
Definition bench.cpp:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify()

void verify ( const Xbyak::uint8 * f,
int pNum )

Definition at line 166 of file sf_test.cpp.

167{
168 switch (pNum) {
169 case 0:
170 check(1, Xbyak::CastTo<int (*)()>(f)());
171 return;
172 case 1:
173 check(11, Xbyak::CastTo<int (*)(int)>(f)(10));
174 return;
175 case 2:
176 check(111, Xbyak::CastTo<int (*)(int, int)>(f)(10, 100));
177 return;
178 case 3:
179 check(1111, Xbyak::CastTo<int (*)(int, int, int)>(f)(10, 100, 1000));
180 return;
181 case 4:
182 check(11111, Xbyak::CastTo<int (*)(int, int, int, int)>(f)(10, 100, 1000, 10000));
183 return;
184 default:
185 printf("ERR pNum=%d\n", pNum);
186 exit(1);
187 }
188}
const To CastTo(From p)
Definition xbyak.h:279
Here is the call graph for this function:
Here is the caller graph for this function:

◆ verifyPack()

void verifyPack ( const Xbyak::util::Pack & p,
const int * tbl,
size_t tblNum )

Definition at line 281 of file sf_test.cpp.

282{
283 for (size_t i = 0; i < tblNum; i++) {
284 check(p[i].getIdx(), tbl[i]);
285 }
286}
Here is the caller graph for this function: