[llvm] b5fb7e4 - [AMDGPU][MC] Corrected disassembly of s_waitcnt

Dmitry Preobrazhensky via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 09:18:28 PST 2022


Author: Dmitry Preobrazhensky
Date: 2022-01-17T20:22:03+03:00
New Revision: b5fb7e485e0f2d189d450fc120ede9ae5fbf27e7

URL: https://github.com/llvm/llvm-project/commit/b5fb7e485e0f2d189d450fc120ede9ae5fbf27e7
DIFF: https://github.com/llvm/llvm-project/commit/b5fb7e485e0f2d189d450fc120ede9ae5fbf27e7.diff

LOG: [AMDGPU][MC] Corrected disassembly of s_waitcnt

s_waitcnt with default expcnt, vmcnt and lgkmcnt values was disassembled without arguments.
See https://github.com/llvm/llvm-project/issues/52716

Differential Revision: https://reviews.llvm.org/D117305

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
    llvm/test/MC/AMDGPU/sopp.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
index b68b4b12e750b..76663b563150b 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
@@ -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 << ')';

diff  --git a/llvm/test/MC/AMDGPU/sopp.s b/llvm/test/MC/AMDGPU/sopp.s
index a8e2c451a72f3..aa23deb0b0fba 100644
--- a/llvm/test/MC/AMDGPU/sopp.s
+++ b/llvm/test/MC/AMDGPU/sopp.s
@@ -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]
@@ -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]
@@ -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)


        


More information about the llvm-commits mailing list