Skip to content

Commit 897cc8f

Browse files
committed
[AMDGPU][MC] Disassembler warning for v_cmpx instructions
For GFX10+ the destnation reg of v_cmpx instructions is implicitly EXEC, which is encoded as 0x7E. However, the disassembler does not check this field, thus allowing any value. With this patch, if the field is not 0x7E a warning is issued.
1 parent 7c104b6 commit 897cc8f

File tree

2 files changed

+418
-1
lines changed

2 files changed

+418
-1
lines changed

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,8 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
663663
return MCDisassembler::Fail;
664664
} while (false);
665665

666+
DecodeStatus Status = MCDisassembler::Success;
667+
666668
if (MCII->get(MI.getOpcode()).TSFlags & SIInstrFlags::DPP) {
667669
if (isMacDPP(MI))
668670
convertMacDPPInst(MI);
@@ -801,8 +803,16 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
801803
if (ImmLitIdx != -1 && !IsSOPK)
802804
convertFMAanyK(MI, ImmLitIdx);
803805

806+
if (isGFX10Plus() &&
807+
(MCII->get(MI.getOpcode()).TSFlags & SIInstrFlags::VOP3) &&
808+
MCII->get(MI.getOpcode()).hasImplicitDefOfPhysReg(AMDGPU::EXEC)) {
809+
auto ExecEncoding = MRI.getEncodingValue(AMDGPU::EXEC_LO);
810+
if (Bytes_[0] != ExecEncoding)
811+
Status = MCDisassembler::SoftFail;
812+
}
813+
804814
Size = MaxInstBytesNum - Bytes.size();
805-
return MCDisassembler::Success;
815+
return Status;
806816
}
807817

808818
void AMDGPUDisassembler::convertEXPInst(MCInst &MI) const {

0 commit comments

Comments
 (0)