2011-08-27 17:47:16 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// $Id$
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-01-10 23:40:38 +04:00
|
|
|
// Copyright (c) 2011-2014 Stanislav Shwartsman
|
2011-08-27 17:47:16 +04:00
|
|
|
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define NEED_CPU_REG_SHORTCUTS 1
|
|
|
|
#include "bochs.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#define LOG_THIS BX_CPU_THIS_PTR
|
|
|
|
|
2011-10-20 00:54:04 +04:00
|
|
|
#if BX_SUPPORT_AVX
|
2011-08-27 17:47:16 +04:00
|
|
|
|
|
|
|
bx_address BX_CPP_AttrRegparmN(2) BX_CPU_C::BxResolveGatherD(bxInstruction_c *i, unsigned element)
|
|
|
|
{
|
2013-12-08 00:15:56 +04:00
|
|
|
Bit32s index = BX_READ_AVX_REG(i->sibIndex()).vmm32s(element);
|
2011-08-27 17:47:16 +04:00
|
|
|
|
|
|
|
if (i->as64L())
|
|
|
|
return (BX_READ_64BIT_REG(i->sibBase()) + (((Bit64s) index) << i->sibScale()) + i->displ32s());
|
|
|
|
else
|
|
|
|
return (Bit32u) (BX_READ_32BIT_REG(i->sibBase()) + (index << i->sibScale()) + i->displ32s());
|
|
|
|
}
|
|
|
|
|
|
|
|
bx_address BX_CPP_AttrRegparmN(2) BX_CPU_C::BxResolveGatherQ(bxInstruction_c *i, unsigned element)
|
|
|
|
{
|
2013-12-08 00:15:56 +04:00
|
|
|
Bit64s index = BX_READ_AVX_REG(i->sibIndex()).vmm64s(element);
|
2011-08-27 17:47:16 +04:00
|
|
|
|
|
|
|
if (i->as64L())
|
|
|
|
return (BX_READ_64BIT_REG(i->sibBase()) + (index << i->sibScale()) + i->displ32s());
|
|
|
|
else
|
|
|
|
return (Bit32u) (BX_READ_32BIT_REG(i->sibBase()) + (index << i->sibScale()) + i->displ32s());
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERDPS_VpsHps(bxInstruction_c *i)
|
|
|
|
{
|
2012-08-05 17:52:40 +04:00
|
|
|
if (i->sibIndex() == i->src2() || i->sibIndex() == i->dst() || i->src2() == i->dst()) {
|
2013-12-03 00:06:59 +04:00
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
2011-08-27 17:47:16 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BxPackedYmmRegister *mask = &BX_YMM_REG(i->src2()), *dest = &BX_YMM_REG(i->dst());
|
2011-08-27 17:47:16 +04:00
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
// index size = 32, element_size = 32, max vector size = 256
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 4
|
|
|
|
// 256 bit => 8
|
|
|
|
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = DWORD_ELEMENTS(i->getVL());
|
2012-06-06 18:01:45 +04:00
|
|
|
|
|
|
|
for (n=0; n < num_elements; n++) {
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm32u(n) & 0x80000000)
|
|
|
|
mask->ymm32u(n) = 0xffffffff;
|
2012-06-06 18:01:45 +04:00
|
|
|
else
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
2012-06-06 18:01:45 +04:00
|
|
|
}
|
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
for (n=0; n < 8; n++)
|
2011-08-27 17:47:16 +04:00
|
|
|
{
|
|
|
|
if (n >= num_elements) {
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
|
|
|
dest->ymm32u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm32u(n)) {
|
|
|
|
dest->ymm32u(n) = read_virtual_dword(i->seg(), BxResolveGatherD(i, n));
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2011-09-04 23:50:18 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BX_CLEAR_AVX_HIGH256(i->dst());
|
|
|
|
BX_CLEAR_AVX_HIGH256(i->src2());
|
|
|
|
|
2011-09-04 23:50:18 +04:00
|
|
|
BX_NEXT_INSTR(i);
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERQPS_VpsHps(bxInstruction_c *i)
|
|
|
|
{
|
2012-08-05 17:52:40 +04:00
|
|
|
if (i->sibIndex() == i->src2() || i->sibIndex() == i->dst() || i->src2() == i->dst()) {
|
2013-12-03 00:06:59 +04:00
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
2011-08-27 17:47:16 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
// index size = 64, element_size = 32, max vector size = 256
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BxPackedYmmRegister *mask = &BX_YMM_REG(i->src2()), *dest = &BX_YMM_REG(i->dst());
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2012-06-06 18:01:45 +04:00
|
|
|
|
|
|
|
for (n=0; n < num_elements; n++) {
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm32u(n) & 0x80000000)
|
|
|
|
mask->ymm32u(n) = 0xffffffff;
|
2012-06-06 18:01:45 +04:00
|
|
|
else
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
2012-06-06 18:01:45 +04:00
|
|
|
}
|
2011-08-27 17:47:16 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
for (n=0; n < 4; n++)
|
2011-08-27 17:47:16 +04:00
|
|
|
{
|
|
|
|
if (n >= num_elements) {
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
|
|
|
dest->ymm32u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm32u(n)) {
|
|
|
|
dest->ymm32u(n) = read_virtual_dword(i->seg(), BxResolveGatherQ(i, n));
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm32u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2011-09-04 23:50:18 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BX_CLEAR_AVX_HIGH128(i->dst());
|
|
|
|
BX_CLEAR_AVX_HIGH128(i->src2());
|
2012-06-06 18:01:45 +04:00
|
|
|
|
2011-09-04 23:50:18 +04:00
|
|
|
BX_NEXT_INSTR(i);
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERDPD_VpdHpd(bxInstruction_c *i)
|
|
|
|
{
|
2012-08-05 17:52:40 +04:00
|
|
|
if (i->sibIndex() == i->src2() || i->sibIndex() == i->dst() || i->src2() == i->dst()) {
|
2013-12-03 00:06:59 +04:00
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
2011-08-27 17:47:16 +04:00
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
// index size = 32, element_size = 64, max vector size = 256
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BxPackedYmmRegister *mask = &BX_YMM_REG(i->src2()), *dest = &BX_YMM_REG(i->dst());
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2012-06-06 18:01:45 +04:00
|
|
|
|
|
|
|
for (n=0; n < num_elements; n++) {
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm64u(n) & BX_CONST64(0x8000000000000000))
|
|
|
|
mask->ymm64u(n) = BX_CONST64(0xffffffffffffffff);
|
2012-06-06 18:01:45 +04:00
|
|
|
else
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
2012-06-06 18:01:45 +04:00
|
|
|
}
|
2011-08-27 17:47:16 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
for (unsigned n=0; n < 4; n++)
|
2011-08-27 17:47:16 +04:00
|
|
|
{
|
|
|
|
if (n >= num_elements) {
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
|
|
|
dest->ymm64u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm64u(n)) {
|
|
|
|
dest->ymm64u(n) = read_virtual_qword(i->seg(), BxResolveGatherD(i, n));
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2011-09-04 23:50:18 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BX_CLEAR_AVX_HIGH256(i->dst());
|
|
|
|
BX_CLEAR_AVX_HIGH256(i->src2());
|
|
|
|
|
2011-09-04 23:50:18 +04:00
|
|
|
BX_NEXT_INSTR(i);
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERQPD_VpdHpd(bxInstruction_c *i)
|
|
|
|
{
|
2012-08-05 17:52:40 +04:00
|
|
|
if (i->sibIndex() == i->src2() || i->sibIndex() == i->dst() || i->src2() == i->dst()) {
|
2011-08-27 17:47:16 +04:00
|
|
|
BX_ERROR(("VGATHERQPD_VpdHpd: incorrect source operands"));
|
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
// index size = 64, element_size = 64, max vector size = 256
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BxPackedYmmRegister *mask = &BX_YMM_REG(i->src2()), *dest = &BX_YMM_REG(i->dst());
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2012-06-06 18:01:45 +04:00
|
|
|
|
|
|
|
for (n=0; n < num_elements; n++) {
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm64u(n) & BX_CONST64(0x8000000000000000))
|
|
|
|
mask->ymm64u(n) = BX_CONST64(0xffffffffffffffff);
|
2012-06-06 18:01:45 +04:00
|
|
|
else
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
2012-06-06 18:01:45 +04:00
|
|
|
}
|
2011-08-27 17:47:16 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
2012-06-06 18:01:45 +04:00
|
|
|
for (n=0; n < 4; n++)
|
2011-08-27 17:47:16 +04:00
|
|
|
{
|
|
|
|
if (n >= num_elements) {
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
|
|
|
dest->ymm64u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
if (mask->ymm64u(n)) {
|
|
|
|
dest->ymm64u(n) = read_virtual_qword(i->seg(), BxResolveGatherQ(i, n));
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2013-07-26 16:50:56 +04:00
|
|
|
mask->ymm64u(n) = 0;
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
2011-09-04 23:50:18 +04:00
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
2013-07-26 16:50:56 +04:00
|
|
|
BX_CLEAR_AVX_HIGH256(i->dst());
|
|
|
|
BX_CLEAR_AVX_HIGH256(i->src2());
|
|
|
|
|
2011-09-04 23:50:18 +04:00
|
|
|
BX_NEXT_INSTR(i);
|
2011-08-27 17:47:16 +04:00
|
|
|
}
|
|
|
|
|
2013-12-08 00:15:56 +04:00
|
|
|
#if BX_SUPPORT_EVEX
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERDPS_MASK_VpsVSib(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
if (i->sibIndex() == i->dst()) {
|
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
BxPackedAvxRegister *dest = &BX_AVX_REG(i->dst());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
|
|
|
// index size = 32, element_size = 32, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 4
|
|
|
|
// 256 bit => 8
|
|
|
|
// 512 bit => 16
|
|
|
|
|
2014-01-19 00:10:05 +04:00
|
|
|
unsigned n, len = i->getVL(), num_elements = DWORD_ELEMENTS(len);
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
dest->vmm32u(n) = read_virtual_dword(i->seg(), BxResolveGatherD(i, n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_CLEAR_AVX_REGZ(i->dst(), len);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERQPS_MASK_VpsVSib(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
if (i->sibIndex() == i->dst()) {
|
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// index size = 64, element_size = 32, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
|
|
|
BxPackedAvxRegister *dest = &BX_AVX_REG(i->dst());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
2014-01-19 00:10:05 +04:00
|
|
|
unsigned n, len = i->getVL(), num_elements = QWORD_ELEMENTS(len);
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
dest->vmm32u(n) = read_virtual_dword(i->seg(), BxResolveGatherQ(i, n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ensure correct upper part clearing of the destination register
|
|
|
|
if (len == BX_VL128) dest->vmm64u(1) = 0;
|
|
|
|
else len--;
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_CLEAR_AVX_REGZ(i->dst(), len);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERDPD_MASK_VpdVSib(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
if (i->sibIndex() == i->dst()) {
|
|
|
|
BX_ERROR(("%s: incorrect source operands", i->getIaOpcodeNameShort()));
|
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// index size = 32, element_size = 64, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
|
|
|
BxPackedAvxRegister *dest = &BX_AVX_REG(i->dst());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
2014-01-19 00:10:05 +04:00
|
|
|
unsigned n, len = i->getVL(), num_elements = QWORD_ELEMENTS(len);
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
dest->vmm64u(n) = read_virtual_qword(i->seg(), BxResolveGatherD(i, n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_CLEAR_AVX_REGZ(i->dst(), len);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VGATHERQPD_MASK_VpdVSib(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
if (i->sibIndex() == i->dst()) {
|
|
|
|
BX_ERROR(("VGATHERQPD_VpdHpd: incorrect source operands"));
|
|
|
|
exception(BX_UD_EXCEPTION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// index size = 64, element_size = 64, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
|
|
|
BxPackedAvxRegister *dest = &BX_AVX_REG(i->dst());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
2014-01-19 00:10:05 +04:00
|
|
|
unsigned n, len = i->getVL(), num_elements = QWORD_ELEMENTS(len);
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
dest->vmm64u(n) = read_virtual_qword(i->seg(), BxResolveGatherQ(i, n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_CLEAR_AVX_REGZ(i->dst(), len);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VSCATTERDPS_MASK_VSibVps(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BxPackedAvxRegister *src = &BX_AVX_REG(i->src());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
|
|
|
// index size = 32, element_size = 32, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 4
|
|
|
|
// 256 bit => 8
|
|
|
|
// 512 bit => 16
|
|
|
|
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = DWORD_ELEMENTS(i->getVL());
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
write_virtual_dword(i->seg(), BxResolveGatherD(i, n), src->vmm32u(n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VSCATTERQPS_MASK_VSibVps(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BxPackedAvxRegister *src = &BX_AVX_REG(i->src());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
|
|
|
// index size = 64, element_size = 32, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
write_virtual_dword(i->seg(), BxResolveGatherQ(i, n), src->vmm32u(n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VSCATTERDPD_MASK_VSibVpd(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BxPackedAvxRegister *src = &BX_AVX_REG(i->src());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
|
|
|
// index size = 32, element_size = 64, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
write_virtual_qword(i->seg(), BxResolveGatherD(i, n), src->vmm64u(n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::VSCATTERQPD_MASK_VSibVpd(bxInstruction_c *i)
|
|
|
|
{
|
|
|
|
BxPackedAvxRegister *src = &BX_AVX_REG(i->src());
|
|
|
|
Bit64u opmask = BX_READ_OPMASK(i->opmask()), mask;
|
|
|
|
|
|
|
|
// index size = 64, element_size = 64, max vector size = 512
|
|
|
|
// num_elements:
|
|
|
|
// 128 bit => 2
|
|
|
|
// 256 bit => 4
|
|
|
|
// 512 bit => 8
|
|
|
|
|
2014-01-10 23:40:38 +04:00
|
|
|
unsigned n, num_elements = QWORD_ELEMENTS(i->getVL());
|
2013-12-08 00:15:56 +04:00
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
unsigned save_alignment_check_mask = BX_CPU_THIS_PTR alignment_check_mask;
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (n=0, mask = 0x1; n < num_elements; n++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (opmask & mask) {
|
|
|
|
write_virtual_qword(i->seg(), BxResolveGatherQ(i, n), src->vmm64u(n));
|
|
|
|
opmask &= ~mask;
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), opmask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_ALIGNMENT_CHECK
|
|
|
|
BX_CPU_THIS_PTR alignment_check_mask = save_alignment_check_mask;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BX_WRITE_OPMASK(i->opmask(), 0);
|
|
|
|
BX_NEXT_INSTR(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // BX_SUPPORT_EVEX
|
|
|
|
|
2011-08-27 17:47:16 +04:00
|
|
|
#endif
|