assert(emitGetInsAmdAny(id) == disp); // make sure "disp" is stored properly
sz = emitInsSizeAM(id, insCodeRM(ins));
+
+ if (Is4ByteSSE4Instruction(ins))
+ {
+ // The 4-Byte SSE4 instructions require two additional bytes
+ sz += 2;
+ }
+
id->idCodeSize(sz);
dispIns(id);
code &= 0x0000FFFF;
}
- // If byte 4 is 0xC0, then it contains the Mod/RM encoding for a 3-byte
- // encoding. Otherwise, this is an instruction with a 4-byte encoding,
- // and the Mod/RM encoding needs to go in the 5th byte.
- // TODO-XArch-CQ: Currently, this will only support registers in the 5th byte.
- // We probably need a different mechanism to identify the 4-byte encodings.
- if ((code & 0xFF) == 0x00)
+ // TODO-XArch-CQ: Right now support 4-byte opcode instructions only
+ if ((code & 0xFF00) == 0xC000)
{
- // This case happens for SSE4/AVX instructions only
- assert(IsAVXInstruction(ins) || IsSSE4Instruction(ins));
- if ((code & 0xFF00) == 0xC000)
- {
- dst += emitOutputWord(dst, code | (regCode << 8));
- }
- else
- {
- dst += emitOutputByte(dst, (code >> 8) & 0xFF);
- dst += emitOutputByte(dst, (0xC0 | regCode));
- }
+ dst += emitOutputWord(dst, code | (regCode << 8));
}
- else if ((code & 0xFF00) == 0xC000)
+ else if ((code & 0xFF) == 0x00)
{
- dst += emitOutputWord(dst, code | (regCode << 8));
+ // This case happens for SSE4/AVX instructions only
+ assert(IsAVXInstruction(ins) || IsSSE4Instruction(ins));
+
+ dst += emitOutputByte(dst, (code >> 8) & 0xFF);
+ dst += emitOutputByte(dst, (0xC0 | regCode));
}
else
{
code &= 0x0000FFFF;
}
- // If byte 4 is 0xC0, then it contains the Mod/RM encoding for a 3-byte
- // encoding. Otherwise, this is an instruction with a 4-byte encoding,
- // and the MOd/RM encoding needs to go in the 5th byte.
- // TODO-XArch-CQ: Currently, this will only support registers in the 5th byte.
- // We probably need a different mechanism to identify the 4-byte encodings.
- if ((code & 0xFF) == 0x00)
+ // TODO-XArch-CQ: Right now support 4-byte opcode instructions only
+ if ((code & 0xFF00) == 0xC000)
{
- // This case happens for AVX instructions only
- assert(IsAVXInstruction(ins));
- if ((code & 0xFF00) == 0xC000)
- {
- dst += emitOutputByte(dst, (0xC0 | regCode));
- }
- else
- {
- dst += emitOutputByte(dst, (code >> 8) & 0xFF);
- dst += emitOutputByte(dst, (0xC0 | regCode));
- }
+ dst += emitOutputWord(dst, code | (regCode << 8));
}
- else if ((code & 0xFF00) == 0xC000)
+ else if ((code & 0xFF) == 0x00)
{
- dst += emitOutputWord(dst, code | (regCode << 8));
+ // This case happens for AVX instructions only
+ assert(IsAVXInstruction(ins));
+
+ dst += emitOutputByte(dst, (code >> 8) & 0xFF);
+ dst += emitOutputByte(dst, (0xC0 | regCode));
}
else
{
code &= 0x0000FFFF;
}
- // If byte 4 is 0xC0, then it contains the Mod/RM encoding for a 3-byte
- // encoding. Otherwise, this is an instruction with a 4-byte encoding,
- // and the Mod/RM encoding needs to go in the 5th byte.
- // TODO-XArch-CQ: Currently, this will only support registers in the 5th byte.
- // We probably need a different mechanism to identify the 4-byte encodings.
- if ((code & 0xFF) == 0x00)
+ // TODO-XArch-CQ: Right now support 4-byte opcode instructions only
+ if ((code & 0xFF00) == 0xC000)
{
- // This case happens for SSE4/AVX instructions only
- assert(IsAVXInstruction(ins) || IsSSE4Instruction(ins));
- if ((code & 0xFF00) == 0xC000)
- {
- dst += emitOutputWord(dst, code | (regcode << 8));
- }
- else
- {
- dst += emitOutputByte(dst, (code >> 8) & 0xFF);
- dst += emitOutputByte(dst, (0xC0 | regcode));
- }
+ dst += emitOutputWord(dst, code | (regcode << 8));
}
- else if ((code & 0xFF00) == 0xC000)
+ else if ((code & 0xFF) == 0x00)
{
- dst += emitOutputWord(dst, code | (regcode << 8));
+ // This case happens for SSE4/AVX instructions only
+ assert(IsAVXInstruction(ins) || IsSSE4Instruction(ins));
+
+ dst += emitOutputByte(dst, (code >> 8) & 0xFF);
+ dst += emitOutputByte(dst, (0xC0 | regcode));
}
else
{