OpcodeDispatcher: Handle VSQRTSD

This commit is contained in:
lioncash 2022-12-07 20:19:13 +00:00
parent 9ef5247dd7
commit e42de0b645
3 changed files with 82 additions and 1 deletions

View File

@ -5829,6 +5829,7 @@ void OpDispatchBuilder::InstallHostSpecificOpcodeHandlers() {
{OPD(1, 0b00, 0x51), 1, &OpDispatchBuilder::AVXVectorUnaryOp<IR::OP_VFSQRT, 4, false>},
{OPD(1, 0b01, 0x51), 1, &OpDispatchBuilder::AVXVectorUnaryOp<IR::OP_VFSQRT, 8, false>},
{OPD(1, 0b10, 0x51), 1, &OpDispatchBuilder::AVXVectorUnaryOp<IR::OP_VFSQRT, 4, true>},
{OPD(1, 0b11, 0x51), 1, &OpDispatchBuilder::AVXVectorUnaryOp<IR::OP_VFSQRT, 8, true>},
{OPD(1, 0b00, 0x54), 1, &OpDispatchBuilder::AVXVectorALUOp<IR::OP_VAND, 16>},
{OPD(1, 0b01, 0x54), 1, &OpDispatchBuilder::AVXVectorALUOp<IR::OP_VAND, 16>},

View File

@ -54,7 +54,7 @@ void InitializeVEXTables() {
{OPD(1, 0b00, 0x51), 1, X86InstInfo{"VSQRTPS", TYPE_INST, GenFlagsSameSize(SIZE_128BIT) | FLAGS_MODRM | FLAGS_XMM_FLAGS, 0, nullptr}},
{OPD(1, 0b01, 0x51), 1, X86InstInfo{"VSQRTPD", TYPE_INST, GenFlagsSameSize(SIZE_128BIT) | FLAGS_MODRM | FLAGS_XMM_FLAGS, 0, nullptr}},
{OPD(1, 0b10, 0x51), 1, X86InstInfo{"VSQRTSS", TYPE_INST, GenFlagsSizes(SIZE_128BIT, SIZE_32BIT) | FLAGS_MODRM | FLAGS_VEX_1ST_SRC | FLAGS_XMM_FLAGS, 0, nullptr}},
{OPD(1, 0b11, 0x51), 1, X86InstInfo{"VSQRTSD", TYPE_UNDEC, FLAGS_NONE, 0, nullptr}},
{OPD(1, 0b11, 0x51), 1, X86InstInfo{"VSQRTSD", TYPE_INST, GenFlagsSizes(SIZE_128BIT, SIZE_64BIT) | FLAGS_MODRM | FLAGS_VEX_1ST_SRC | FLAGS_XMM_FLAGS, 0, nullptr}},
{OPD(1, 0b00, 0x52), 1, X86InstInfo{"VRSQRTPS", TYPE_UNDEC, FLAGS_NONE, 0, nullptr}},
{OPD(1, 0b10, 0x52), 1, X86InstInfo{"VRSQRTSS", TYPE_UNDEC, FLAGS_NONE, 0, nullptr}},

View File

@ -0,0 +1,80 @@
%ifdef CONFIG
{
"HostFeatures": ["AVX"],
"RegData": {
"XMM0": ["0x3FF0000000000000", "0x3FF0000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM1": ["0x4000000000000000", "0x4010000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM2": ["0x4008000000000000", "0x4022000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM3": ["0x4010000000000000", "0x4030000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM4": ["0x3FF0000000000000", "0x4039000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM5": ["0x4000000000000000", "0x4010000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM6": ["0x4008000000000000", "0x4022000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM7": ["0x4010000000000000", "0x4030000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM8": ["0x3FF0000000000000", "0x4030000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM9": ["0x4000000000000000", "0x4039000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM10": ["0x4008000000000000", "0x4010000000000000", "0x0000000000000000", "0x0000000000000000"],
"XMM11": ["0x4010000000000000", "0x4022000000000000", "0x0000000000000000", "0x0000000000000000"]
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
lea rdx, [rel .data]
vmovapd ymm0, [rdx + 32 * 0]
vmovapd ymm1, [rdx + 32 * 1]
vmovapd ymm2, [rdx + 32 * 2]
vmovapd ymm3, [rdx + 32 * 3]
vmovapd ymm4, [rdx + 32 * 4]
vmovapd ymm5, [rdx + 32 * 1]
vmovapd ymm6, [rdx + 32 * 2]
vmovapd ymm7, [rdx + 32 * 3]
; Register only
vsqrtsd xmm0, xmm0, xmm0
vsqrtsd xmm1, xmm1, xmm1
vsqrtsd xmm2, xmm2, xmm2
vsqrtsd xmm3, xmm3, xmm3
; Memory operand
vsqrtsd xmm4, xmm4, [rdx + 32 * 0]
vsqrtsd xmm5, xmm5, [rdx + 32 * 1]
vsqrtsd xmm6, xmm6, [rdx + 32 * 2]
vsqrtsd xmm7, xmm7, [rdx + 32 * 3]
; Merge different source register
vsqrtsd xmm8, xmm3, [rdx + 32 * 0]
vsqrtsd xmm9, xmm4, [rdx + 32 * 1]
vsqrtsd xmm10, xmm5, [rdx + 32 * 2]
vsqrtsd xmm11, xmm6, [rdx + 32 * 3]
hlt
align 32
.data:
dq 0x3FF0000000000000 ; 1.0
dq 0x3FF0000000000000
dq 0x3FF0000000000000
dq 0x3FF0000000000000
dq 0x4010000000000000 ; 4.0
dq 0x4010000000000000
dq 0x4010000000000000
dq 0x4010000000000000
dq 0x4022000000000000 ; 9.0
dq 0x4022000000000000
dq 0x4022000000000000
dq 0x4022000000000000
dq 0x4030000000000000 ; 16.0
dq 0x4030000000000000
dq 0x4030000000000000
dq 0x4030000000000000
dq 0x4039000000000000 ; 25.0
dq 0x4039000000000000
dq 0x4039000000000000
dq 0x4039000000000000