diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-03-24 07:48:54 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-03-24 07:48:54 +0000 |
| commit | 097b47a0fcc499ff735dc8a78273b8a226541c9f (patch) | |
| tree | 5a87bf8d4671598c7c62609faee2c3d5da936476 /llvm/lib | |
| parent | 86163630174961f1ab91c2a48a012b79fa7ce6ad (diff) | |
| download | bcm5719-llvm-097b47a0fcc499ff735dc8a78273b8a226541c9f.tar.gz bcm5719-llvm-097b47a0fcc499ff735dc8a78273b8a226541c9f.zip | |
[X86] Add a new disassembler opcode map for 3DNow. Stop treating 3DNow as an attribute.
This reduces the size of llvm-mc by at least 150k since we no longer have to multiply the attribute across 7 tables.
llvm-svn: 328416
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp | 58 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h | 3 |
2 files changed, 18 insertions, 43 deletions
diff --git a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp index 50d10feaae3..6a10278dc7f 100644 --- a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp @@ -103,6 +103,9 @@ static int modRMRequired(OpcodeType type, case XOPA_MAP: decision = &XOPA_MAP_SYM; break; + case THREEDNOW_MAP: + decision = &THREEDNOW_MAP_SYM; + break; } return decision->opcodeDecisions[insnContext].modRMDecisions[opcode]. @@ -147,6 +150,9 @@ static InstrUID decode(OpcodeType type, case XOPA_MAP: dec = &XOPA_MAP_SYM.opcodeDecisions[insnContext].modRMDecisions[opcode]; break; + case THREEDNOW_MAP: + dec = &THREEDNOW_MAP_SYM.opcodeDecisions[insnContext].modRMDecisions[opcode]; + break; } switch (dec->modrm_type) { @@ -588,44 +594,11 @@ static int readPrefixes(struct InternalInstruction* insn) { insn->vectorExtensionPrefix[0], insn->vectorExtensionPrefix[1], insn->vectorExtensionPrefix[2]); } - } else if (byte == 0x0f) { - uint8_t byte1; - - // Check for AMD 3DNow without a REX prefix - if (consumeByte(insn, &byte1)) { - unconsumeByte(insn); - } else { - if (byte1 != 0x0f) { - unconsumeByte(insn); - unconsumeByte(insn); - } else { - dbgprintf(insn, "Found AMD 3DNow prefix 0f0f"); - insn->vectorExtensionType = TYPE_3DNOW; - } - } } else if (isREX(insn, byte)) { if (lookAtByte(insn, &nextByte)) return -1; insn->rexPrefix = byte; dbgprintf(insn, "Found REX prefix 0x%hhx", byte); - - // Check for AMD 3DNow with a REX prefix - if (nextByte == 0x0f) { - consumeByte(insn, &nextByte); - uint8_t byte1; - - if (consumeByte(insn, &byte1)) { - unconsumeByte(insn); - } else { - if (byte1 != 0x0f) { - unconsumeByte(insn); - unconsumeByte(insn); - } else { - dbgprintf(insn, "Found AMD 3DNow prefix 0f0f"); - insn->vectorExtensionType = TYPE_3DNOW; - } - } - } } else unconsumeByte(insn); @@ -725,12 +698,6 @@ static int readOpcode(struct InternalInstruction* insn) { insn->opcodeType = XOPA_MAP; return consumeByte(insn, &insn->opcode); } - } else if (insn->vectorExtensionType == TYPE_3DNOW) { - // Consume operands before the opcode to comply with the 3DNow encoding - if (readModRM(insn)) - return -1; - insn->opcodeType = TWOBYTE; - return consumeByte(insn, &insn->opcode); } if (consumeByte(insn, ¤t)) @@ -756,6 +723,17 @@ static int readOpcode(struct InternalInstruction* insn) { return -1; insn->opcodeType = THREEBYTE_3A; + } else if (current == 0x0f) { + dbgprintf(insn, "Found a 3dnow escape prefix (0x%hhx)", current); + + // Consume operands before the opcode to comply with the 3DNow encoding + if (readModRM(insn)) + return -1; + + if (consumeByte(insn, ¤t)) + return -1; + + insn->opcodeType = THREEDNOW_MAP; } else { dbgprintf(insn, "Didn't find a three-byte escape prefix"); @@ -951,8 +929,6 @@ static int getID(struct InternalInstruction* insn, const void *miiArg) { if (lFromXOP3of3(insn->vectorExtensionPrefix[2])) attrMask |= ATTR_VEXL; - } else if (insn->vectorExtensionType == TYPE_3DNOW) { - attrMask |= ATTR_3DNOW; } else { return -1; } diff --git a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h index 2c2b7dcec63..44422a95f16 100644 --- a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h +++ b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h @@ -493,8 +493,7 @@ enum VectorExtensionType { TYPE_VEX_2B = 0x1, TYPE_VEX_3B = 0x2, TYPE_EVEX = 0x3, - TYPE_XOP = 0x4, - TYPE_3DNOW = 0x5 + TYPE_XOP = 0x4 }; /// \brief Type for the byte reader that the consumer must provide to |

