Commit cea787e2 authored by Andrew Brown's avatar Andrew Brown Committed by V8 LUCI CQ

[x64] Add disassembly tests for 256-bit instructions

A previous change (see ref) added a subset of 256-bit instructions to
the x64 assembler--this change adds a disassembly test for the added
instructions.

ref: https://chromium-review.googlesource.com/c/v8/v8/+/3123648
Change-Id: Ia56be7a7df636b8bf6c04f044912e914d949d19f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3133956
Auto-Submit: Andrew Brown <andrew.brown@intel.com>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76711}
parent 4613e86e
......@@ -280,6 +280,10 @@ int64_t Imm64(const uint8_t* data) {
//------------------------------------------------------------------------------
// DisassemblerX64 implementation.
// Forward-declare NameOfYMMRegister to keep its implementation with the
// NameConverter methods and register name arrays at bottom.
const char* NameOfYMMRegister(int reg);
// A new DisassemblerX64 object is created to disassemble each instruction.
// The object can only disassemble a single instruction.
class DisassemblerX64 {
......@@ -357,6 +361,12 @@ class DisassemblerX64 {
return (checked & 4) == 0;
}
bool vex_256() const {
DCHECK(vex_byte0_ == VEX3_PREFIX || vex_byte0_ == VEX2_PREFIX);
byte checked = vex_byte0_ == VEX3_PREFIX ? vex_byte2_ : vex_byte1_;
return (checked & 4) != 0;
}
bool vex_none() {
DCHECK(vex_byte0_ == VEX3_PREFIX || vex_byte0_ == VEX2_PREFIX);
byte checked = vex_byte0_ == VEX3_PREFIX ? vex_byte2_ : vex_byte1_;
......@@ -425,6 +435,14 @@ class DisassemblerX64 {
return converter_.NameOfXMMRegister(reg);
}
const char* NameOfAVXRegister(int reg) const {
if (vex_256()) {
return NameOfYMMRegister(reg);
} else {
return converter_.NameOfXMMRegister(reg);
}
}
const char* NameOfAddress(byte* addr) const {
return converter_.NameOfAddress(addr);
}
......@@ -449,6 +467,7 @@ class DisassemblerX64 {
int PrintRightOperand(byte* modrmp);
int PrintRightByteOperand(byte* modrmp);
int PrintRightXMMOperand(byte* modrmp);
int PrintRightAVXOperand(byte* modrmp);
int PrintOperands(const char* mnem, OperandType op_order, byte* data);
int PrintImmediate(byte* data, OperandSize size);
int PrintImmediateOp(byte* data);
......@@ -607,6 +626,10 @@ int DisassemblerX64::PrintRightXMMOperand(byte* modrmp) {
return PrintRightOperandHelper(modrmp, &DisassemblerX64::NameOfXMMRegister);
}
int DisassemblerX64::PrintRightAVXOperand(byte* modrmp) {
return PrintRightOperandHelper(modrmp, &DisassemblerX64::NameOfAVXRegister);
}
// Returns number of bytes used including the current *data.
// Writes instruction's mnemonic, left and right operands to 'tmp_buffer_'.
int DisassemblerX64::PrintOperands(const char* mnem, OperandType op_order,
......@@ -867,78 +890,78 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x18:
AppendToBuffer("vbroadcastss %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vbroadcastss %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x99:
AppendToBuffer("vfmadd132s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xA9:
AppendToBuffer("vfmadd213s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xB8:
AppendToBuffer("vfmadd231p%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xB9:
AppendToBuffer("vfmadd231s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x9B:
AppendToBuffer("vfmsub132s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xAB:
AppendToBuffer("vfmsub213s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xBB:
AppendToBuffer("vfmsub231s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xBC:
AppendToBuffer("vfnmadd231p%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x9D:
AppendToBuffer("vfnmadd132s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xAD:
AppendToBuffer("vfnmadd213s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xBD:
AppendToBuffer("vfnmadd231s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x9F:
AppendToBuffer("vfnmsub132s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xAF:
AppendToBuffer("vfnmsub213s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xBF:
AppendToBuffer("vfnmsub231s%c %s,%s,", float_size_code(),
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xF7:
AppendToBuffer("shlx%c %s,", operand_size_code(),
......@@ -949,9 +972,9 @@ int DisassemblerX64::AVXInstruction(byte* data) {
#define DECLARE_SSE_AVX_DIS_CASE(instruction, notUsed1, notUsed2, notUsed3, \
opcode) \
case 0x##opcode: { \
AppendToBuffer("v" #instruction " %s,%s,", NameOfXMMRegister(regop), \
NameOfXMMRegister(vvvv)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,%s,", NameOfAVXRegister(regop), \
NameOfAVXRegister(vvvv)); \
current += PrintRightAVXOperand(current); \
break; \
}
......@@ -963,8 +986,8 @@ int DisassemblerX64::AVXInstruction(byte* data) {
#define DECLARE_SSE_UNOP_AVX_DIS_CASE(instruction, notUsed1, notUsed2, \
notUsed3, opcode) \
case 0x##opcode: { \
AppendToBuffer("v" #instruction " %s,", NameOfXMMRegister(regop)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,", NameOfAVXRegister(regop)); \
current += PrintRightAVXOperand(current); \
break; \
}
SSSE3_UNOP_INSTRUCTION_LIST(DECLARE_SSE_UNOP_AVX_DIS_CASE)
......@@ -973,8 +996,8 @@ int DisassemblerX64::AVXInstruction(byte* data) {
#define DISASSEMBLE_AVX2_BROADCAST(instruction, _1, _2, _3, code) \
case 0x##code: \
AppendToBuffer("" #instruction " %s,", NameOfXMMRegister(regop)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("" #instruction " %s,", NameOfAVXRegister(regop)); \
current += PrintRightAVXOperand(current); \
break;
AVX2_BROADCAST_LIST(DISASSEMBLE_AVX2_BROADCAST)
#undef DISASSEMBLE_AVX2_BROADCAST
......@@ -987,96 +1010,96 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x08:
AppendToBuffer("vroundps %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vroundps %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x09:
AppendToBuffer("vroundpd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vroundpd %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x0A:
AppendToBuffer("vroundss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vroundss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x0B:
AppendToBuffer("vroundsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vroundsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x0E:
AppendToBuffer("vpblendw %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vpblendw %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x0F:
AppendToBuffer("vpalignr %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vpalignr %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x14:
AppendToBuffer("vpextrb ");
current += PrintRightByteOperand(current);
AppendToBuffer(",%s,0x%x,", NameOfXMMRegister(regop), *current++);
AppendToBuffer(",%s,0x%x,", NameOfAVXRegister(regop), *current++);
break;
case 0x15:
AppendToBuffer("vpextrw ");
current += PrintRightOperand(current);
AppendToBuffer(",%s,0x%x,", NameOfXMMRegister(regop), *current++);
AppendToBuffer(",%s,0x%x,", NameOfAVXRegister(regop), *current++);
break;
case 0x16:
AppendToBuffer("vpextr%c ", rex_w() ? 'q' : 'd');
current += PrintRightOperand(current);
AppendToBuffer(",%s,0x%x,", NameOfXMMRegister(regop), *current++);
AppendToBuffer(",%s,0x%x,", NameOfAVXRegister(regop), *current++);
break;
case 0x17:
AppendToBuffer("vextractps ");
current += PrintRightOperand(current);
AppendToBuffer(",%s,0x%x,", NameOfXMMRegister(regop), *current++);
AppendToBuffer(",%s,0x%x,", NameOfAVXRegister(regop), *current++);
break;
case 0x20:
AppendToBuffer("vpinsrb %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
AppendToBuffer("vpinsrb %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightByteOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x21:
AppendToBuffer("vinsertps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vinsertps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x22:
AppendToBuffer("vpinsr%c %s,%s,", rex_w() ? 'q' : 'd',
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x4A: {
AppendToBuffer("vblendvps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister((*current++) >> 4));
AppendToBuffer("vblendvps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister((*current++) >> 4));
break;
}
case 0x4B: {
AppendToBuffer("vblendvpd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister((*current++) >> 4));
AppendToBuffer("vblendvpd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister((*current++) >> 4));
break;
}
case 0x4C: {
AppendToBuffer("vpblendvb %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister((*current++) >> 4));
AppendToBuffer("vpblendvb %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister((*current++) >> 4));
break;
}
default:
......@@ -1087,95 +1110,95 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x10:
AppendToBuffer("vmovss %s,", NameOfXMMRegister(regop));
AppendToBuffer("vmovss %s,", NameOfAVXRegister(regop));
if (mod == 3) {
AppendToBuffer("%s,", NameOfXMMRegister(vvvv));
AppendToBuffer("%s,", NameOfAVXRegister(vvvv));
}
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x11:
AppendToBuffer("vmovss ");
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
if (mod == 3) {
AppendToBuffer(",%s", NameOfXMMRegister(vvvv));
AppendToBuffer(",%s", NameOfAVXRegister(vvvv));
}
AppendToBuffer(",%s", NameOfXMMRegister(regop));
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x16:
AppendToBuffer("vmovshdup %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovshdup %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x2A:
AppendToBuffer("%s %s,%s,", vex_w() ? "vcvtqsi2ss" : "vcvtlsi2ss",
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightOperand(current);
break;
case 0x2C:
AppendToBuffer("vcvttss2si%s %s,", vex_w() ? "q" : "",
NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x51:
AppendToBuffer("vsqrtss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vsqrtss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x58:
AppendToBuffer("vaddss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vaddss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x59:
AppendToBuffer("vmulss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmulss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5A:
AppendToBuffer("vcvtss2sd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcvtss2sd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5B:
AppendToBuffer("vcvttps2dq %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcvttps2dq %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x5C:
AppendToBuffer("vsubss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vsubss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5D:
AppendToBuffer("vminss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vminss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5E:
AppendToBuffer("vdivss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vdivss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5F:
AppendToBuffer("vmaxss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmaxss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x6F:
AppendToBuffer("vmovdqu %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovdqu %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x70:
AppendToBuffer("vpshufhw %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vpshufhw %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x7F:
AppendToBuffer("vmovdqu ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0xE6:
AppendToBuffer("vcvtdq2pd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcvtdq2pd %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
default:
UnimplementedInstruction();
......@@ -1185,92 +1208,92 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x10:
AppendToBuffer("vmovsd %s,", NameOfXMMRegister(regop));
AppendToBuffer("vmovsd %s,", NameOfAVXRegister(regop));
if (mod == 3) {
AppendToBuffer("%s,", NameOfXMMRegister(vvvv));
AppendToBuffer("%s,", NameOfAVXRegister(vvvv));
}
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x11:
AppendToBuffer("vmovsd ");
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
if (mod == 3) {
AppendToBuffer(",%s", NameOfXMMRegister(vvvv));
AppendToBuffer(",%s", NameOfAVXRegister(vvvv));
}
AppendToBuffer(",%s", NameOfXMMRegister(regop));
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x12:
AppendToBuffer("vmovddup %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovddup %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x2A:
AppendToBuffer("%s %s,%s,", vex_w() ? "vcvtqsi2sd" : "vcvtlsi2sd",
NameOfXMMRegister(regop), NameOfXMMRegister(vvvv));
NameOfAVXRegister(regop), NameOfAVXRegister(vvvv));
current += PrintRightOperand(current);
break;
case 0x2C:
AppendToBuffer("vcvttsd2si%s %s,", vex_w() ? "q" : "",
NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x2D:
AppendToBuffer("vcvtsd2si%s %s,", vex_w() ? "q" : "",
NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x51:
AppendToBuffer("vsqrtsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vsqrtsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x58:
AppendToBuffer("vaddsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vaddsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x59:
AppendToBuffer("vmulsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmulsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5A:
AppendToBuffer("vcvtsd2ss %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcvtsd2ss %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5C:
AppendToBuffer("vsubsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vsubsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5D:
AppendToBuffer("vminsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vminsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5E:
AppendToBuffer("vdivsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vdivsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0x5F:
AppendToBuffer("vmaxsd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmaxsd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
case 0xF0:
AppendToBuffer("vlddqu %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vlddqu %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x70:
AppendToBuffer("vpshuflw %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vpshuflw %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x7C:
AppendToBuffer("vhaddps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vhaddps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
break;
default:
UnimplementedInstruction();
......@@ -1388,90 +1411,90 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x10:
AppendToBuffer("vmovups %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovups %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x11:
AppendToBuffer("vmovups ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x12:
if (mod == 0b11) {
AppendToBuffer("vmovhlps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovhlps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
} else {
AppendToBuffer("vmovlps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovlps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
}
break;
case 0x13:
AppendToBuffer("vmovlps ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x16:
if (mod == 0b11) {
AppendToBuffer("vmovlhps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovlhps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
} else {
AppendToBuffer("vmovhps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovhps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
}
break;
case 0x17:
AppendToBuffer("vmovhps ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x28:
AppendToBuffer("vmovaps %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovaps %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x29:
AppendToBuffer("vmovaps ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x2E:
AppendToBuffer("vucomiss %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vucomiss %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x50:
AppendToBuffer("vmovmskps %s,", NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0xC2: {
AppendToBuffer("vcmpps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcmpps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(", (%s)", cmp_pseudo_op[*current]);
current += 1;
break;
}
case 0xC6: {
AppendToBuffer("vshufps %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vshufps %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
}
#define SSE_UNOP_CASE(instruction, unused, code) \
case 0x##code: \
AppendToBuffer("v" #instruction " %s,", NameOfXMMRegister(regop)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,", NameOfAVXRegister(regop)); \
current += PrintRightAVXOperand(current); \
break;
SSE_UNOP_INSTRUCTION_LIST(SSE_UNOP_CASE)
#undef SSE_UNOP_CASE
#define SSE_BINOP_CASE(instruction, unused, code) \
case 0x##code: \
AppendToBuffer("v" #instruction " %s,%s,", NameOfXMMRegister(regop), \
NameOfXMMRegister(vvvv)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,%s,", NameOfAVXRegister(regop), \
NameOfAVXRegister(vvvv)); \
current += PrintRightAVXOperand(current); \
break;
SSE_BINOP_INSTRUCTION_LIST(SSE_BINOP_CASE)
#undef SSE_BINOP_CASE
......@@ -1483,92 +1506,92 @@ int DisassemblerX64::AVXInstruction(byte* data) {
get_modrm(*current, &mod, &regop, &rm);
switch (opcode) {
case 0x10:
AppendToBuffer("vmovupd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovupd %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x11:
AppendToBuffer("vmovupd ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x28:
AppendToBuffer("vmovapd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovapd %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x29:
AppendToBuffer("vmovapd ");
current += PrintRightXMMOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0x50:
AppendToBuffer("vmovmskpd %s,", NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
case 0x6E:
AppendToBuffer("vmov%c %s,", vex_w() ? 'q' : 'd',
NameOfXMMRegister(regop));
NameOfAVXRegister(regop));
current += PrintRightOperand(current);
break;
case 0x6F:
AppendToBuffer("vmovdqa %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vmovdqa %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
break;
case 0x70:
AppendToBuffer("vpshufd %s,", NameOfXMMRegister(regop));
current += PrintRightXMMOperand(current);
AppendToBuffer("vpshufd %s,", NameOfAVXRegister(regop));
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0x71:
AppendToBuffer("vps%sw %s,", sf_str[regop / 2],
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%u", *current++);
break;
case 0x72:
AppendToBuffer("vps%sd %s,", sf_str[regop / 2],
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%u", *current++);
break;
case 0x73:
AppendToBuffer("vps%sq %s,", sf_str[regop / 2],
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(",%u", *current++);
break;
case 0x7E:
AppendToBuffer("vmov%c ", vex_w() ? 'q' : 'd');
current += PrintRightOperand(current);
AppendToBuffer(",%s", NameOfXMMRegister(regop));
AppendToBuffer(",%s", NameOfAVXRegister(regop));
break;
case 0xC2: {
AppendToBuffer("vcmppd %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
current += PrintRightXMMOperand(current);
AppendToBuffer("vcmppd %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightAVXOperand(current);
AppendToBuffer(", (%s)", cmp_pseudo_op[*current]);
current += 1;
break;
}
case 0xC4:
AppendToBuffer("vpinsrw %s,%s,", NameOfXMMRegister(regop),
NameOfXMMRegister(vvvv));
AppendToBuffer("vpinsrw %s,%s,", NameOfAVXRegister(regop),
NameOfAVXRegister(vvvv));
current += PrintRightOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0xC5:
AppendToBuffer("vpextrw %s,", NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
AppendToBuffer(",0x%x", *current++);
break;
case 0xD7:
AppendToBuffer("vpmovmskb %s,", NameOfCPURegister(regop));
current += PrintRightXMMOperand(current);
current += PrintRightAVXOperand(current);
break;
#define DECLARE_SSE_AVX_DIS_CASE(instruction, notUsed1, notUsed2, opcode) \
case 0x##opcode: { \
AppendToBuffer("v" #instruction " %s,%s,", NameOfXMMRegister(regop), \
NameOfXMMRegister(vvvv)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,%s,", NameOfAVXRegister(regop), \
NameOfAVXRegister(vvvv)); \
current += PrintRightAVXOperand(current); \
break; \
}
......@@ -1576,8 +1599,8 @@ int DisassemblerX64::AVXInstruction(byte* data) {
#undef DECLARE_SSE_AVX_DIS_CASE
#define DECLARE_SSE_UNOP_AVX_DIS_CASE(instruction, notUsed1, notUsed2, opcode) \
case 0x##opcode: { \
AppendToBuffer("v" #instruction " %s,", NameOfXMMRegister(regop)); \
current += PrintRightXMMOperand(current); \
AppendToBuffer("v" #instruction " %s,", NameOfAVXRegister(regop)); \
current += PrintRightAVXOperand(current); \
break; \
}
......@@ -2824,6 +2847,10 @@ static const char* const xmm_regs[16] = {
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"};
static const char* const ymm_regs[16] = {
"ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7",
"ymm8", "ymm9", "ymm10", "ymm11", "ymm12", "ymm13", "ymm14", "ymm15"};
const char* NameConverter::NameOfAddress(byte* addr) const {
v8::base::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr));
return tmp_buffer_.begin();
......@@ -2848,6 +2875,11 @@ const char* NameConverter::NameOfXMMRegister(int reg) const {
return "noxmmreg";
}
const char* NameOfYMMRegister(int reg) {
if (0 <= reg && reg < 16) return ymm_regs[reg];
return "noymmreg";
}
const char* NameConverter::NameInCode(byte* addr) const {
// X64 does not embed debug strings at the moment.
UNREACHABLE();
......
......@@ -667,10 +667,15 @@ TEST(DisasmX64) {
__ vmovdqa(xmm4, xmm5);
__ vmovdqa(xmm4, Operand(rbx, rcx, times_4, 10000));
__ vmovdqa(ymm4, ymm5);
__ vmovdqa(xmm4, Operand(rbx, rcx, times_4, 10000));
__ vmovdqu(xmm9, Operand(rbx, rcx, times_4, 10000));
__ vmovdqu(Operand(rbx, rcx, times_4, 10000), xmm0);
__ vmovdqu(xmm4, xmm5);
__ vmovdqu(ymm9, Operand(rbx, rcx, times_4, 10000));
__ vmovdqu(Operand(rbx, rcx, times_4, 10000), ymm0);
__ vmovdqu(ymm4, ymm5);
__ vmovhlps(xmm1, xmm3, xmm5);
__ vmovlps(xmm8, xmm9, Operand(rbx, rcx, times_4, 10000));
......@@ -760,14 +765,18 @@ TEST(DisasmX64) {
#define EMIT_SSE_UNOP_AVXINSTR(instruction, notUsed1, notUsed2) \
__ v##instruction(xmm10, xmm1); \
__ v##instruction(xmm10, Operand(rbx, rcx, times_4, 10000));
__ v##instruction(xmm10, Operand(rbx, rcx, times_4, 10000)); \
__ v##instruction(ymm10, ymm1); \
__ v##instruction(ymm10, Operand(rbx, rcx, times_4, 10000));
SSE_UNOP_INSTRUCTION_LIST(EMIT_SSE_UNOP_AVXINSTR)
#undef EMIT_SSE_UNOP_AVXINSTR
#define EMIT_SSE_BINOP_AVXINSTR(instruction, notUsed1, notUsed2) \
__ v##instruction(xmm10, xmm5, xmm1); \
__ v##instruction(xmm10, xmm5, Operand(rbx, rcx, times_4, 10000));
#define EMIT_SSE_BINOP_AVXINSTR(instruction, notUsed1, notUsed2) \
__ v##instruction(xmm10, xmm5, xmm1); \
__ v##instruction(xmm10, xmm5, Operand(rbx, rcx, times_4, 10000)); \
__ v##instruction(ymm10, ymm5, ymm1); \
__ v##instruction(ymm10, ymm5, Operand(rbx, rcx, times_4, 10000));
SSE_BINOP_INSTRUCTION_LIST(EMIT_SSE_BINOP_AVXINSTR)
#undef EMIT_SSE_BINOP_AVXINSTR
......@@ -1048,6 +1057,33 @@ TEST(DisasmX64) {
#endif
}
TEST(DisasmX64YMMRegister) {
if (!CpuFeatures::IsSupported(AVX)) return;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
v8::internal::byte buffer[8192];
Assembler assm(AssemblerOptions{},
ExternalAssemblerBuffer(buffer, sizeof buffer));
CpuFeatureScope fscope(&assm, AVX);
__ vmovdqa(ymm0, ymm1);
base::Vector<char> actual = base::Vector<char>::New(37);
disasm::NameConverter converter;
disasm::Disassembler disassembler(converter);
disassembler.InstructionDecode(actual, buffer);
#ifdef OBJECT_PRINT
fprintf(stdout, "Disassembled buffer: %s\n", actual.begin());
#endif
base::Vector<const char> expected =
base::StaticCharVector("c5fd6fc1 vmovdqa ymm0,ymm1\0");
CHECK(expected == actual);
actual.Dispose();
}
#undef __
} // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment