if (Flags)
PatchedName = Name;
+
+ // Hacks to handle 'data16' and 'data32'
+ if (PatchedName == "data16" && is16BitMode()) {
+ return Error(NameLoc, "redundant data16 prefix");
+ }
+ if (PatchedName == "data32") {
+ if (is32BitMode())
+ return Error(NameLoc, "redundant data32 prefix");
+ if (is64BitMode())
+ return Error(NameLoc, "'data32' is not supported in 64-bit mode");
+ // Hack to 'data16' for the table lookup.
+ PatchedName = "data16";
+ }
+
Operands.push_back(X86Operand::CreateToken(PatchedName, NameLoc));
// This does the actual operand parsing. Don't parse any more if we have a
(getLexer().is(AsmToken::LCurly) || getLexer().is(AsmToken::RCurly));
if (getLexer().isNot(AsmToken::EndOfStatement) && !CurlyAsEndOfStatement)
return TokError("unexpected token in argument list");
- }
+ }
// Consume the EndOfStatement or the prefix separator Slash
if (getLexer().is(AsmToken::EndOfStatement) ||
// 0x66 to be interpreted as "data16" by the asm printer.
// Thus we add an adjustment here in order to print the "right" instruction.
else if (MI->getOpcode() == X86::DATA16_PREFIX &&
- (STI.getFeatureBits()[X86::Mode16Bit])) {
- MCInst Data32MI(*MI);
- Data32MI.setOpcode(X86::DATA32_PREFIX);
- printInstruction(&Data32MI, OS);
+ STI.getFeatureBits()[X86::Mode16Bit]) {
+ OS << "\tdata32";
}
// Try to print any aliases first.
else if (!printAliasInstr(MI, OS))
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
if ((TSFlags & X86II::NOTRACK) || (Flags & X86::IP_HAS_NOTRACK))
OS << "\tnotrack\t";
- printInstruction(MI, OS);
+ // In 16-bit mode, print data16 as data32.
+ if (MI->getOpcode() == X86::DATA16_PREFIX &&
+ STI.getFeatureBits()[X86::Mode16Bit]) {
+ OS << "\tdata32";
+ } else
+ printInstruction(MI, OS);
// Next always print the annotation.
printAnnotation(OS, Annot);
Requires<[In64BitMode]>;
// Data16 instruction prefix
-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]>;
+def DATA16_PREFIX : I<0x66, RawFrm, (outs), (ins), "data16", []>;
} // SchedRW
// Repeat string operation instruction prefixes
// RUN: not llvm-mc -triple i386-unknown-unknown-code16 --show-encoding %s 2> %t.err | FileCheck --check-prefix=16 %s
// RUN: FileCheck --check-prefix=ERR16 < %t.err %s
-// ERR64: error: instruction requires: 16-bit mode
-// ERR32: error: instruction requires: 16-bit mode
+// ERR64: error: 'data32' is not supported in 64-bit mode
+// ERR32: error: redundant data32 prefix
// 16: data32
// 16: encoding: [0x66]
// 16: lgdtw 0
// 32: encoding: [0x66]
// 32: lgdtl 0
// 32: encoding: [0x0f,0x01,0x15,0x00,0x00,0x00,0x00]
-// ERR16: error: instruction requires: Not 16-bit mode
+// ERR16: error: redundant data16 prefix
data16 lgdt 0
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;