Skip to content

[AMDGPU][MC] Disassembler warning for v_cmpx instructions #128256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class MCDisassembler {

private:
MCContext &Ctx;
std::string ErrorOrWarningMsg;

protected:
// Subtarget information, for instruction decoding predicates if required.
Expand Down Expand Up @@ -222,6 +223,9 @@ class MCDisassembler {
// Marked mutable because we cache it inside the disassembler, rather than
// having to pass it around as an argument through all the autogenerated code.
mutable raw_ostream *CommentStream = nullptr;

const std::string &getErrorOrWarningMsg() const { return ErrorOrWarningMsg; }
void setErrorOrWarningMsg(const std::string &Msg) { ErrorOrWarningMsg = Msg; }
Comment on lines +227 to +228
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably isn't the right strategy for improving diagnostics

};

} // end namespace llvm
Expand Down
14 changes: 13 additions & 1 deletion llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
return MCDisassembler::Fail;
} while (false);

DecodeStatus Status = MCDisassembler::Success;

if (MCII->get(MI.getOpcode()).TSFlags & SIInstrFlags::DPP) {
if (isMacDPP(MI))
convertMacDPPInst(MI);
Expand Down Expand Up @@ -801,8 +803,18 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
if (ImmLitIdx != -1 && !IsSOPK)
convertFMAanyK(MI, ImmLitIdx);

if ((MCII->get(MI.getOpcode()).TSFlags & SIInstrFlags::VOP3) &&
MCII->get(MI.getOpcode()).hasImplicitDefOfPhysReg(AMDGPU::EXEC)) {
auto ExecEncoding = MRI.getEncodingValue(AMDGPU::EXEC_LO);
if (Bytes_[0] != ExecEncoding) {
const_cast<AMDGPUDisassembler *>(this)->setErrorOrWarningMsg(
"invalid vdst encoding");
Status = MCDisassembler::SoftFail;
}
}

Size = MaxInstBytesNum - Bytes.size();
return MCDisassembler::Success;
return Status;
}

void AMDGPUDisassembler::convertEXPInst(MCInst &MI) const {
Expand Down
Loading