Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2360,7 +2360,7 @@ Name == "lock" || Name == "rep" || Name == "repe" || Name == "repz" || Name == "repne" || Name == "repnz" || - Name == "rex64" || Name == "data16"; + Name == "rex64" || Name == "data16" || Name == "data32"; bool CurlyAsEndOfStatement = false; // This does the actual operand parsing. Don't parse any more if we have a Index: lib/Target/X86/X86InstrInfo.td =================================================================== --- lib/Target/X86/X86InstrInfo.td +++ lib/Target/X86/X86InstrInfo.td @@ -1965,7 +1965,12 @@ Requires<[In64BitMode]>; // Data16 instruction prefix -def DATA16_PREFIX : I<0x66, RawFrm, (outs), (ins), "data16", []>; +def DATA16_PREFIX : I<0x66, RawFrm, (outs), (ins), "data16", []>, + Requires<[Not16BitMode]>; + +// Data instruction prefix +def DATA32_PREFIX : I<0x66, RawFrm, (outs), (ins), "data32", []>, + Requires<[In16BitMode]>; // Repeat string operation instruction prefixes // These uses the DF flag in the EFLAGS register to inc or dec ECX Index: test/MC/X86/x86-16.s =================================================================== --- test/MC/X86/x86-16.s +++ test/MC/X86/x86-16.s @@ -959,3 +959,19 @@ // CHECK: lretl // CHECK: encoding: [0x66,0xcb] lretl + +// CHECK: data32 +// CHECK: encoding: [0x66] +data32 + +// CHECK: data32 +// CHECK: encoding: [0x66] +// CHECK: lgdtw 4(%eax) +// CHECK: encoding: [0x67,0x0f,0x01,0x50,0x04] +data32 lgdt 4(%eax) + +// CHECK: data32 +// CHECK: encoding: [0x66] +// CHECK: lgdtw 4(%eax) +// CHECK: encoding: [0x67,0x0f,0x01,0x50,0x04] +data32 lgdtw 4(%eax) Index: test/MC/X86/x86-32.s =================================================================== --- test/MC/X86/x86-32.s +++ test/MC/X86/x86-32.s @@ -1079,3 +1079,15 @@ // CHECK: lretw // CHECK: encoding: [0x66,0xcb] lretw + +// CHECK: data16 +// CHECK: encoding: [0x66] +// CHECK: lgdtl 4(%eax) +// CHECK: encoding: [0x0f,0x01,0x50,0x04] +data16 lgdt 4(%eax) + +// CHECK: data16 +// CHECK: encoding: [0x66] +// CHECK: lgdtl 4(%eax) +// CHECK: encoding: [0x0f,0x01,0x50,0x04] +data16 lgdtl 4(%eax) Index: test/MC/X86/x86-64.s =================================================================== --- test/MC/X86/x86-64.s +++ test/MC/X86/x86-64.s @@ -1119,6 +1119,18 @@ rex64 // CHECK: rex64 # encoding: [0x48] data16 // CHECK: data16 # encoding: [0x66] +// CHECK: data16 +// CHECK: encoding: [0x66] +// CHECK: lgdtq 4(%rax) +// CHECK: encoding: [0x0f,0x01,0x50,0x04] +data16 lgdt 4(%rax) + +// CHECK: data16 +// CHECK: encoding: [0x66] +// CHECK: lgdtq 4(%rax) +// CHECK: encoding: [0x0f,0x01,0x50,0x04] +data16 lgdtq 4(%rax) + // PR8855 movq 18446744073709551615,%rbx // CHECK: movq -1, %rbx Index: utils/TableGen/X86DisassemblerTables.cpp =================================================================== --- utils/TableGen/X86DisassemblerTables.cpp +++ utils/TableGen/X86DisassemblerTables.cpp @@ -879,6 +879,10 @@ newInfo.name == "XCHG64ar")) continue; // special case for XCHG*ar and NOOP + if (previousInfo.name == "DATA16_PREFIX" && + newInfo.name == "DATA32_PREFIX") + continue; // special case for data16 and data32 + if (outranks(previousInfo.insnContext, newInfo.insnContext)) continue;