Skip to content

Commit

Permalink
[AMDGPU][MC] Corrected disassembly of s_waitcnt
Browse files Browse the repository at this point in the history
s_waitcnt with default expcnt, vmcnt and lgkmcnt values was disassembled without arguments.
See #52716

Differential Revision: https://reviews.llvm.org/D117305
  • Loading branch information
dpreobra committed Jan 17, 2022
1 parent 32417b3 commit b5fb7e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
Expand Up @@ -1397,21 +1397,26 @@ void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
unsigned Vmcnt, Expcnt, Lgkmcnt;
decodeWaitcnt(ISA, SImm16, Vmcnt, Expcnt, Lgkmcnt);

bool IsDefaultVmcnt = Vmcnt == getVmcntBitMask(ISA);
bool IsDefaultExpcnt = Expcnt == getExpcntBitMask(ISA);
bool IsDefaultLgkmcnt = Lgkmcnt == getLgkmcntBitMask(ISA);
bool PrintAll = IsDefaultVmcnt && IsDefaultExpcnt && IsDefaultLgkmcnt;

bool NeedSpace = false;

if (Vmcnt != getVmcntBitMask(ISA)) {
if (!IsDefaultVmcnt || PrintAll) {
O << "vmcnt(" << Vmcnt << ')';
NeedSpace = true;
}

if (Expcnt != getExpcntBitMask(ISA)) {
if (!IsDefaultExpcnt || PrintAll) {
if (NeedSpace)
O << ' ';
O << "expcnt(" << Expcnt << ')';
NeedSpace = true;
}

if (Lgkmcnt != getLgkmcntBitMask(ISA)) {
if (!IsDefaultLgkmcnt || PrintAll) {
if (NeedSpace)
O << ' ';
O << "lgkmcnt(" << Lgkmcnt << ')';
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/MC/AMDGPU/sopp.s
Expand Up @@ -81,31 +81,31 @@ s_waitcnt vmcnt(9)
// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]

s_waitcnt vmcnt(15)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt vmcnt_sat(9)
// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]

s_waitcnt vmcnt_sat(15)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt vmcnt_sat(16)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt expcnt(2)
// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]

s_waitcnt expcnt(7)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt expcnt_sat(2)
// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]

s_waitcnt expcnt_sat(7)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt expcnt_sat(0xFFFF0000)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt lgkmcnt(3)
// GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
Expand All @@ -114,7 +114,7 @@ s_waitcnt lgkmcnt(9)
// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]

s_waitcnt lgkmcnt(15)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt vmcnt(0), expcnt(0)
// GCN: s_waitcnt vmcnt(0) expcnt(0) ; encoding: [0x00,0x0f,0x8c,0xbf]
Expand All @@ -126,10 +126,10 @@ s_waitcnt lgkmcnt_sat(9)
// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]

s_waitcnt lgkmcnt_sat(15)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

s_waitcnt lgkmcnt_sat(16)
// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]

x=1
s_waitcnt lgkmcnt_sat(x+1)
Expand Down

0 comments on commit b5fb7e4

Please sign in to comment.