[llvm-commits] [llvm] r140370 - in /llvm/trunk: test/MC/Disassembler/X86/intel-syntax.txt utils/TableGen/X86DisassemblerTables.cpp utils/TableGen/X86DisassemblerTables.h utils/TableGen/X86RecognizableInstr.cpp utils/TableGen/X86RecognizableInstr.h
Craig Topper
craig.topper at gmail.com
Thu Sep 22 23:57:25 PDT 2011
Author: ctopper
Date: Fri Sep 23 01:57:25 2011
New Revision: 140370
URL: http://llvm.org/viewvc/llvm-project?rev=140370&view=rev
Log:
Don't allow 32-bit only instructions to be disassembled in 64-bit mode. Fixes part of PR10700.
Modified:
llvm/trunk/test/MC/Disassembler/X86/intel-syntax.txt
llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp
llvm/trunk/utils/TableGen/X86DisassemblerTables.h
llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp
llvm/trunk/utils/TableGen/X86RecognizableInstr.h
Modified: llvm/trunk/test/MC/Disassembler/X86/intel-syntax.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/intel-syntax.txt?rev=140370&r1=140369&r2=140370&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/intel-syntax.txt (original)
+++ llvm/trunk/test/MC/Disassembler/X86/intel-syntax.txt Fri Sep 23 01:57:25 2011
@@ -12,14 +12,11 @@
# CHECK: movsq
0x48 0xa5
-# CHECK: pop DS
-0x1f
+# CHECK: pop FS
+0x0f 0xa1
-# CHECK: pop ES
-0x07
-
-# CHECK: pop SS
-0x17
+# CHECK: pop GS
+0x0f 0xa9
# CHECK: in AL, DX
0xec
Modified: llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp?rev=140370&r1=140369&r2=140370&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp (original)
+++ llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp Fri Sep 23 01:57:25 2011
@@ -642,12 +642,16 @@
InstructionContext insnContext,
uint8_t opcode,
const ModRMFilter &filter,
- InstrUID uid) {
+ InstrUID uid,
+ bool is32bit) {
unsigned index;
ContextDecision &decision = *Tables[type];
for (index = 0; index < IC_max; ++index) {
+ if (is32bit && inheritsFrom((InstructionContext)index, IC_64BIT))
+ continue;
+
if (inheritsFrom((InstructionContext)index,
InstructionSpecifiers[uid].insnContext))
setTableFields(decision.opcodeDecisions[index].modRMDecisions[opcode],
Modified: llvm/trunk/utils/TableGen/X86DisassemblerTables.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86DisassemblerTables.h?rev=140370&r1=140369&r2=140370&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/X86DisassemblerTables.h (original)
+++ llvm/trunk/utils/TableGen/X86DisassemblerTables.h Fri Sep 23 01:57:25 2011
@@ -260,11 +260,13 @@
/// @param filter - The ModRMFilter that decides which ModR/M byte values
/// correspond to the desired instruction.
/// @param uid - The unique ID of the instruction.
+ /// @param is32bit - Instructon is only 32-bit
void setTableFields(OpcodeType type,
InstructionContext insnContext,
uint8_t opcode,
const ModRMFilter &filter,
- InstrUID uid);
+ InstrUID uid,
+ bool is32bit);
/// specForUID - Returns the instruction specifier for a given unique
/// instruction ID. Used when resolving collisions.
Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=140370&r1=140369&r2=140370&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original)
+++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Fri Sep 23 01:57:25 2011
@@ -231,10 +231,15 @@
HasVEX_LPrefix = has256BitOperands() || Rec->getValueAsBit("hasVEX_L");
// Check for 64-bit inst which does not require REX
+ Is32Bit = false;
Is64Bit = false;
// FIXME: Is there some better way to check for In64BitMode?
std::vector<Record*> Predicates = Rec->getValueAsListOfDefs("Predicates");
for (unsigned i = 0, e = Predicates.size(); i != e; ++i) {
+ if (Predicates[i]->getName().find("32Bit") != Name.npos) {
+ Is32Bit = true;
+ break;
+ }
if (Predicates[i]->getName().find("64Bit") != Name.npos) {
Is64Bit = true;
break;
@@ -947,7 +952,7 @@
insnContext(),
currentOpcode,
*filter,
- UID);
+ UID, Is32Bit);
Spec->modifierType = MODIFIER_OPCODE;
Spec->modifierBase = opcodeToSet;
@@ -957,14 +962,14 @@
insnContext(),
opcodeToSet,
*filter,
- UID);
+ UID, Is32Bit);
}
} else {
tables.setTableFields(opcodeType,
insnContext(),
opcodeToSet,
*filter,
- UID);
+ UID, Is32Bit);
Spec->modifierType = MODIFIER_NONE;
Spec->modifierBase = opcodeToSet;
Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.h?rev=140370&r1=140369&r2=140370&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/X86RecognizableInstr.h (original)
+++ llvm/trunk/utils/TableGen/X86RecognizableInstr.h Fri Sep 23 01:57:25 2011
@@ -64,8 +64,10 @@
bool HasLockPrefix;
/// The isCodeGenOnly filed from the record
bool IsCodeGenOnly;
- // Whether the instruction has the predicate "Mode64Bit"
+ // Whether the instruction has the predicate "In64BitMode"
bool Is64Bit;
+ // Whether the instruction has the predicate "In32BitMode"
+ bool Is32Bit;
/// The instruction name as listed in the tables
std::string Name;
More information about the llvm-commits
mailing list