diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-04-22 00:52:02 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-04-22 00:52:02 +0000 |
| commit | e33ed7d667c8daf22b544c77c6bbb6e919d2f3f0 (patch) | |
| tree | 36569c51f38c780e4c58b848f4bda05189617940 /llvm | |
| parent | 2a58ca7dfe117bd3ac8f41deac573fd25399143d (diff) | |
| download | bcm5719-llvm-e33ed7d667c8daf22b544c77c6bbb6e919d2f3f0.tar.gz bcm5719-llvm-e33ed7d667c8daf22b544c77c6bbb6e919d2f3f0.zip | |
[X86] Remove DATA32_PREFIX. Hack the printing for DATA16_PREFIX to print 'data32' in 16-bit mode. Hack the asm parser to convert 'data32' to 'data16' in 16-bit mode.
Improve the error messages to match GNU assembler.
This also allows us to remove the hack from the disassembler table building.
llvm-svn: 330531
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.td | 7 | ||||
| -rw-r--r-- | llvm/test/MC/X86/data-prefix-fail.s | 6 | ||||
| -rw-r--r-- | llvm/utils/TableGen/X86DisassemblerTables.cpp | 4 |
6 files changed, 28 insertions, 19 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 36aecb86347..b9d254e0e67 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -2385,6 +2385,20 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, 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 @@ -2419,7 +2433,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, (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) || diff --git a/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp index dbc2570160e..8780e8b05c8 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp +++ b/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp @@ -78,10 +78,8 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, // 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)) diff --git a/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp b/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp index 0e069751821..57b5f777ccf 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp +++ b/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp @@ -19,6 +19,7 @@ #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> @@ -52,7 +53,12 @@ void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, 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); diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index 0990f210871..507746218ec 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -2063,12 +2063,7 @@ def REX64_PREFIX : I<0x48, RawFrm, (outs), (ins), "rex64", []>, 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 diff --git a/llvm/test/MC/X86/data-prefix-fail.s b/llvm/test/MC/X86/data-prefix-fail.s index 2b910cdc109..1d2b528a451 100644 --- a/llvm/test/MC/X86/data-prefix-fail.s +++ b/llvm/test/MC/X86/data-prefix-fail.s @@ -5,8 +5,8 @@ // 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 @@ -21,5 +21,5 @@ data32 lgdt 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 diff --git a/llvm/utils/TableGen/X86DisassemblerTables.cpp b/llvm/utils/TableGen/X86DisassemblerTables.cpp index 9c69abe1f3d..2b5cc127960 100644 --- a/llvm/utils/TableGen/X86DisassemblerTables.cpp +++ b/llvm/utils/TableGen/X86DisassemblerTables.cpp @@ -1088,10 +1088,6 @@ void DisassemblerTables::setTableFields(ModRMDecision &decision, 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; |

