llvm.org GIT mirror llvm / 8619698
[X86][Disassembler] Fix LOCK prefix disassembler support Summary: If LOCK prefix is not the first prefix in an instruction, LLVM disassembler silently drops the prefix. The fix is to select a proper instruction with a builtin LOCK prefix if one exists. Reviewers: craig.topper Reviewed By: craig.topper Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49001 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336400 91177308-0d34-0410-b5e6-96231b3b80d8 Maksim Panchenko 2 years ago
4 changed file(s) with 11 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
246246 // It should not be 'pause' f3 90
247247 InternalInstr.opcode != 0x90)
248248 Flags |= X86::IP_HAS_REPEAT;
249 if (InternalInstr.hasLockPrefix)
250 Flags |= X86::IP_HAS_LOCK;
249251 }
250252 Instr.setFlags(Flags);
251253 }
297297 static void setPrefixPresent(struct InternalInstruction *insn, uint8_t prefix) {
298298 uint8_t nextByte;
299299 switch (prefix) {
300 case 0xf0:
301 insn->hasLockPrefix = true;
302 break;
300303 case 0xf2:
301304 case 0xf3:
302305 if (lookAtByte(insn, &nextByte))
562562 bool hasAdSize;
563563 // Operand-size override
564564 bool hasOpSize;
565 // Lock prefix
566 bool hasLockPrefix;
565567 // The repeat prefix if any
566568 uint8_t repeatPrefix;
567569
100100 # CHECK: movq %mm0, %mm1
101101 0x46 0x0f 0x7f 0xc1
102102
103 # Test that lock prefix is not dropped if it's not the first prefix
104 # CHECK: lock cmpxchgw %di, (%rcx)
105 0x66 0xf0 0x0f 0xb1 0x39
106
103107 # Test that a prefix on it's own works. It's debatable as to if this is
104108 # something that is considered valid, but however as LLVM's own disassembler
105109 # has decided to disassemble prefixes as being separate opcodes, it therefore