From 232110be3961b73e89df4973267745156b14b785 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 28 Aug 2018 15:46:30 +0900 Subject: [PATCH] update test --- test/jmp.cpp | 50 ++++++++++++++++++++++++++++++++++++++++-- test/rip-label-imm.cpp | 4 ++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/test/jmp.cpp b/test/jmp.cpp index 2578adb..4fb1221 100644 --- a/test/jmp.cpp +++ b/test/jmp.cpp @@ -987,6 +987,52 @@ struct GetAddressCode1 : Xbyak::CodeGenerator { } }; +struct CodeLabelTable : Xbyak::CodeGenerator { + static const int ret0 = 3; + static const int ret1 = 5; + static const int ret2 = 8; + CodeLabelTable() + { + using namespace Xbyak; +#ifdef XBYAK64_WIN + const Reg64& p0 = rcx; + const Reg64& a = rax; +#elif defined (XBYAK64_GCC) + const Reg64& p0 = rdi; + const Reg64& a = rax; +#else + const Reg32& p0 = edx; + const Reg32& a = eax; + mov(edx, ptr [esp + 4]); +#endif + Label labelTbl, L0, L1, L2; + mov(a, labelTbl); + jmp(ptr [a + p0 * sizeof(void*)]); + L(labelTbl); + putL(L0); + putL(L1); + putL(L2); + L(L0); + mov(a, ret0); + ret(); + L(L1); + mov(a, ret1); + ret(); + L(L2); + mov(a, ret2); + ret(); + } +}; + +CYBOZU_TEST_AUTO(LabelTable) +{ + CodeLabelTable c; + int (*f)(int) = c.getCode(); + CYBOZU_TEST_EQUAL(f(0), c.ret0); + CYBOZU_TEST_EQUAL(f(1), c.ret1); + CYBOZU_TEST_EQUAL(f(2), c.ret2); +} + CYBOZU_TEST_AUTO(getAddress1) { GetAddressCode1 c; @@ -1143,11 +1189,11 @@ CYBOZU_TEST_AUTO(rip_addr_with_fixed_buf) ret(); } } code; - Xbyak::CodeArray::protect(p, 4096, Xbyak::CodeArray::PROTECT_RE); + code.setProtectModeRE(); code.getCode()(); CYBOZU_TEST_EQUAL(*x0, 123); CYBOZU_TEST_EQUAL(*x1, 456); CYBOZU_TEST_EQUAL(buf[8], 99); - Xbyak::CodeArray::protect(p, 4096, Xbyak::CodeArray::PROTECT_RW); + code.setProtectModeRW(); } #endif diff --git a/test/rip-label-imm.cpp b/test/rip-label-imm.cpp index 4ed208e..8dbf925 100644 --- a/test/rip-label-imm.cpp +++ b/test/rip-label-imm.cpp @@ -40,8 +40,8 @@ struct Code : Xbyak::CodeGenerator { cmpss(xmm0, ptr[rip + label], 0); test(dword[rip + label], 33); bt(dword[rip + label ], 3); - vblendpd(xmm0, dword[rip + label], 3); - vpalignr(xmm0, qword[rip + label], 4); + vblendpd(xmm0, xmm0, dword[rip + label], 3); + vpalignr(xmm0, xmm0, qword[rip + label], 4); vextractf128(dword[rip + label], ymm3, 12); vperm2i128(ymm0, ymm1, qword[rip + label], 13); vcvtps2ph(ptr[rip + label], xmm2, 44);