refactor test

This commit is contained in:
MITSUNARI Shigeo 2020-01-03 22:13:55 +09:00
parent 508b543cb8
commit a29fa27b92
8 changed files with 31 additions and 48 deletions

View file

@ -37,7 +37,7 @@ cvt_test: cvt_test.cpp ../xbyak/xbyak.h
cvt_test32: cvt_test.cpp ../xbyak/xbyak.h cvt_test32: cvt_test.cpp ../xbyak/xbyak.h
$(CXX) $(CFLAGS) $< -o $@ -DXBYAK32 $(CXX) $(CFLAGS) $< -o $@ -DXBYAK32
test: normalize_prefix jmp bad_address $(TARGET) test_nm: normalize_prefix jmp bad_address $(TARGET)
$(MAKE) -C ../gen $(MAKE) -C ../gen
./test_nm.sh ./test_nm.sh
./test_nm.sh Y ./test_nm.sh Y
@ -69,6 +69,12 @@ test_avx512: normalize_prefix
ifeq ($(BIT),64) ifeq ($(BIT),64)
./test_avx512.sh 64 ./test_avx512.sh 64
endif endif
test:
$(MAKE) test_nm
$(MAKE) test_avx
$(MAKE) test_avx512
clean: clean:
rm -rf *.o $(TARGET) lib_run nm.cpp nm_frame make_512 rm -rf *.o $(TARGET) lib_run nm.cpp nm_frame make_512

View file

@ -1,47 +1,28 @@
#include <xbyak/xbyak.h> #include <xbyak/xbyak.h>
#include <cybozu/test.hpp>
#define TEST_EXCEPTION(state) \
{ \
num++; \
bool exception = false; \
try { \
state; \
} catch (...) { \
exception = true; \
} \
if (!exception) { \
printf("exception should arise for %s\n", #state); \
err++; \
} \
}
struct Code : Xbyak::CodeGenerator { struct Code : Xbyak::CodeGenerator {
Code() Code()
{ {
int err = 0; CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp + esp]), std::exception);
int num = 0; CYBOZU_TEST_EXCEPTION(mov(eax, ptr [ax]), std::exception); // not support
TEST_EXCEPTION(mov(eax, ptr [esp + esp])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [esp * 4]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [ax])); // not support CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 16]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [esp * 4])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax + eax + eax]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [eax * 16])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [eax + eax + eax])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [eax * 2 + ecx * 4])); CYBOZU_TEST_EXCEPTION(fld(dword [xmm0]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [xmm0])); CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [eax * 2], ymm3), std::exception);
TEST_EXCEPTION(fld(dword [xmm0])); CYBOZU_TEST_EXCEPTION(vgatherdpd(xmm0, ptr [xmm0 + xmm1], ymm3), std::exception);
TEST_EXCEPTION(vgatherdpd(xmm0, ptr [eax * 2], ymm3));
TEST_EXCEPTION(vgatherdpd(xmm0, ptr [xmm0 + xmm1], ymm3));
#ifdef XBYAK64 #ifdef XBYAK64
TEST_EXCEPTION(mov(eax, ptr [rax + eax])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [rax + eax]), std::exception);
TEST_EXCEPTION(mov(eax, ptr [xmm0 + ymm0])); CYBOZU_TEST_EXCEPTION(mov(eax, ptr [xmm0 + ymm0]), std::exception);
#endif #endif
if (!err) {
printf("bad_address test %d ok\n", num);
}
} }
}; };
int main() CYBOZU_TEST_AUTO(exception)
{ {
Code c; Code c;
} }

View file

@ -574,9 +574,9 @@ public:
for (size_t k = 0; k < N; k++) { for (size_t k = 0; k < N; k++) {
#ifdef XBYAK64 #ifdef XBYAK64
for (int kIdx = 0; kIdx < 8; kIdx++) { for (int kIdx = 0; kIdx < 8; kIdx++) {
put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx);
put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx);
for (int z = 0; z < 2; z++) { for (int z = 0; z < 2; z++) {
put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx, z == 1);
put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx, z == 1);
for (int sae = 0; sae < 5; sae++) { for (int sae = 0; sae < 5; sae++) {
put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae); put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae);
} }

View file

@ -2664,9 +2664,9 @@ public:
for (size_t k = 0; k < N; k++) { for (size_t k = 0; k < N; k++) {
#ifdef XBYAK64 #ifdef XBYAK64
for (int kIdx = 0; kIdx < 8; kIdx++) { for (int kIdx = 0; kIdx < 8; kIdx++) {
put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx);
put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx);
for (int z = 0; z < 2; z++) { for (int z = 0; z < 2; z++) {
put_vaddpd(xTbl[i], xTbl[j], xTbl[k], kIdx, z == 1);
put_vaddpd(yTbl[i], yTbl[j], yTbl[k], kIdx, z == 1);
for (int sae = 0; sae < 5; sae++) { for (int sae = 0; sae < 5; sae++) {
put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae); put_vaddpd(zTbl[i], zTbl[j], zTbl[k], kIdx, z == 1, sae);
} }

View file

@ -20,7 +20,6 @@ echo "compile nm_frame.cpp"
g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame
./nm_frame > x.lst ./nm_frame > x.lst
diff ok.lst x.lst && echo "ok" diff ok.lst x.lst && echo "ok"
wc x.lst
} }

View file

@ -33,12 +33,11 @@ g++ $CFLAGS make_nm.cpp -o make_nm
./make_nm > a.asm ./make_nm > a.asm
echo "asm" echo "asm"
$EXE -f$OPT3 a.asm -l a.lst $EXE -f$OPT3 a.asm -l a.lst
awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER > ok.lst awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER | grep -v "1+1" > ok.lst
echo "xbyak" echo "xbyak"
./make_nm jit > nm.cpp ./make_nm jit > nm.cpp
echo "compile nm_frame.cpp" echo "compile nm_frame.cpp"
g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame
./nm_frame | $FILTER > x.lst ./nm_frame | $FILTER > x.lst
diff ok.lst x.lst && echo "ok" diff -B ok.lst x.lst && echo "ok"
exit 0

View file

@ -29,5 +29,4 @@ echo "xbyak"
echo "compile nm_frame.cpp" echo "compile nm_frame.cpp"
g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame -DXBYAK_AVX512 g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame -DXBYAK_AVX512
./nm_frame | $FILTER > x.lst ./nm_frame | $FILTER > x.lst
diff ok.lst x.lst && echo "ok" diff -B ok.lst x.lst && echo "ok"
exit 0

View file

@ -39,12 +39,11 @@ g++ $CFLAGS make_nm.cpp -o make_nm
./make_nm > a.asm ./make_nm > a.asm
echo "asm" echo "asm"
$EXE -f$OPT3 a.asm -l a.lst $EXE -f$OPT3 a.asm -l a.lst
awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER > ok.lst awk '{if (index($3, "-")) { conti=substr($3, 0, length($3) - 1) } else { conti = conti $3; print conti; conti = "" }} ' < a.lst | $FILTER | grep -v "1+1" > ok.lst
echo "xbyak" echo "xbyak"
./make_nm jit > nm.cpp ./make_nm jit > nm.cpp
echo "compile nm_frame.cpp" echo "compile nm_frame.cpp"
g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame g++ $CFLAGS -DXBYAK_TEST nm_frame.cpp -o nm_frame
./nm_frame | $FILTER > x.lst ./nm_frame | $FILTER > x.lst
diff ok.lst x.lst && echo "ok" diff -B ok.lst x.lst && echo "ok"
exit 0