Fix x86-64 encoding bug. REX prefix must always follow 0x0F prefix. For example, extractps in 64bit mode: 66 REX 0F 3A 17, not 66 0F 3A REX 17.

llvm-svn: 49157
This commit is contained in:
Evan Cheng 2008-04-03 08:53:17 +00:00
parent d9129d1de3
commit 6db4b4cc65
1 changed files with 13 additions and 10 deletions

View File

@ -558,16 +558,10 @@ void Emitter::emitInstruction(const MachineInstr &MI,
bool Need0FPrefix = false;
switch (Desc->TSFlags & X86II::Op0Mask) {
case X86II::TB:
Need0FPrefix = true; // Two-byte opcode prefix
break;
case X86II::T8:
MCE.emitByte(0x0F);
MCE.emitByte(0x38);
break;
case X86II::TA:
MCE.emitByte(0x0F);
MCE.emitByte(0x3A);
case X86II::TB: // Two-byte opcode prefix
case X86II::T8: // 0F 38
case X86II::TA: // 0F 3A
Need0FPrefix = true;
break;
case X86II::REP: break; // already handled.
case X86II::XS: // F3 0F
@ -599,6 +593,15 @@ void Emitter::emitInstruction(const MachineInstr &MI,
if (Need0FPrefix)
MCE.emitByte(0x0F);
switch (Desc->TSFlags & X86II::Op0Mask) {
case X86II::T8: // 0F 38
MCE.emitByte(0x38);
break;
case X86II::TA: // 0F 3A
MCE.emitByte(0x3A);
break;
}
// If this is a two-address instruction, skip one of the register operands.
unsigned NumOps = Desc->getNumOperands();
unsigned CurOp = 0;