/* * libbinrec: a recompiling translator for machine code * Copyright (c) 2016 Andrew Church * * This software may be copied and redistributed under certain conditions; * see the file "COPYING" in the source code distribution for details. * NO WARRANTY is provided with this software. */ #include "tests/common.h" #include "tests/host-x86/common.h" static const binrec_setup_t setup = { .host = BINREC_ARCH_X86_64_WINDOWS, // So we can confirm XMM15 is pushed. }; static const unsigned int host_opt = 0; static int add_rtl(RTLUnit *unit) { int base, regs[16]; EXPECT(base = rtl_alloc_register(unit, RTLTYPE_ADDRESS)); EXPECT(rtl_add_insn(unit, RTLOP_LOAD_ARG, base, 0, 0, 0)); for (int i = 0; i < lenof(regs); i++) { EXPECT(regs[i] = rtl_alloc_register(unit, RTLTYPE_FLOAT32)); EXPECT(rtl_add_insn(unit, RTLOP_LOAD, regs[i], base, 0, i*4)); } for (int i = 0; i < lenof(regs); i++) { EXPECT(rtl_add_insn(unit, RTLOP_NOP, 0, regs[i], 0, 0)); } int alias; EXPECT(alias = rtl_alloc_alias_register(unit, RTLTYPE_FLOAT32)); EXPECT(rtl_add_insn(unit, RTLOP_SET_ALIAS, 0, regs[14], 0, alias)); return EXIT_SUCCESS; } static const uint8_t expected_code[] = { 0x48,0x81,0xEC,0xB8,0x00,0x00,0x00, // sub $184,%rsp 0x0F,0x29,0x74,0x24,0x10, // movaps %xmm6,16(%rsp) 0x0F,0x29,0x7C,0x24,0x20, // movaps %xmm7,32(%rsp) 0x44,0x0F,0x29,0x44,0x24,0x30, // movaps %xmm8,48(%rsp) 0x44,0x0F,0x29,0x4C,0x24,0x40, // movaps %xmm9,64(%rsp) 0x44,0x0F,0x29,0x54,0x24,0x50, // movaps %xmm10,80(%rsp) 0x44,0x0F,0x29,0x5C,0x24,0x60, // movaps %xmm11,96(%rsp) 0x44,0x0F,0x29,0x64,0x24,0x70, // movaps %xmm12,112(%rsp) 0x44,0x0F,0x29,0xAC,0x24,0x80,0x00, // movaps %xmm13,128(%rsp) 0x00,0x00, 0x44,0x0F,0x29,0xB4,0x24,0x90,0x00, // movaps %xmm14,144(%rsp) 0x00,0x00, 0x44,0x0F,0x29,0xBC,0x24,0xA0,0x00, // movaps %xmm15,160(%rsp) 0x00,0x00, 0xF3,0x0F,0x10,0x01, // movss (%rcx),%xmm0 0xF3,0x0F,0x10,0x49,0x04, // movss 4(%rcx),%xmm1 0xF3,0x0F,0x10,0x51,0x08, // movss 8(%rcx),%xmm2 0xF3,0x0F,0x10,0x59,0x0C, // movss 12(%rcx),%xmm3 0xF3,0x0F,0x10,0x61,0x10, // movss 16(%rcx),%xmm4 0xF3,0x0F,0x10,0x69,0x14, // movss 20(%rcx),%xmm5 0xF3,0x0F,0x10,0x71,0x18, // movss 24(%rcx),%xmm6 0xF3,0x0F,0x10,0x79,0x1C, // movss 28(%rcx),%xmm7 0xF3,0x44,0x0F,0x10,0x41,0x20, // movss 32(%rcx),%xmm8 0xF3,0x44,0x0F,0x10,0x49,0x24, // movss 36(%rcx),%xmm9 0xF3,0x44,0x0F,0x10,0x51,0x28, // movss 40(%rcx),%xmm10 0xF3,0x44,0x0F,0x10,0x59,0x2C, // movss 44(%rcx),%xmm11 0xF3,0x44,0x0F,0x10,0x61,0x30, // movss 48(%rcx),%xmm12 0xF3,0x44,0x0F,0x10,0x69,0x34, // movss 52(%rcx),%xmm13 0xF3,0x44,0x0F,0x10,0x71,0x38, // movss 56(%rcx),%xmm14 0xF3,0x44,0x0F,0x11,0x74,0x24,0x04, // movss %xmm14,4(%rsp) 0xF3,0x44,0x0F,0x10,0x71,0x3C, // movss 60(%rcx),%xmm14 0xF3,0x44,0x0F,0x10,0x7C,0x24,0x04, // movss 4(%rsp),%xmm15 0xF3,0x44,0x0F,0x11,0x3C,0x24, // movss %xmm15,(%rsp) 0x44,0x0F,0x28,0xBC,0x24,0xA0,0x00, // movaps 160(%rsp),%xmm15 0x00,0x00, 0x44,0x0F,0x28,0xB4,0x24,0x90,0x00, // movaps 144(%rsp),%xmm14 0x00,0x00, 0x44,0x0F,0x28,0xAC,0x24,0x80,0x00, // movaps 128(%rsp),%xmm13 0x00,0x00, 0x44,0x0F,0x28,0x64,0x24,0x70, // movaps 112(%rsp),%xmm12 0x44,0x0F,0x28,0x5C,0x24,0x60, // movaps 96(%rsp),%xmm11 0x44,0x0F,0x28,0x54,0x24,0x50, // movaps 80(%rsp),%xmm10 0x44,0x0F,0x28,0x4C,0x24,0x40, // movaps 64(%rsp),%xmm9 0x44,0x0F,0x28,0x44,0x24,0x30, // movaps 48(%rsp),%xmm8 0x0F,0x28,0x7C,0x24,0x20, // movaps 32(%rsp),%xmm7 0x0F,0x28,0x74,0x24,0x10, // movaps 16(%rsp),%xmm6 0x48,0x81,0xC4,0xB8,0x00,0x00,0x00, // add $184,%rsp 0xC3, // ret }; static const char expected_log[] = ""; #include "tests/rtl-translate-test.i"