[llvm] [AMDGPU] Use a generic printer for NamedIntOperands. (PR #100399)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 08:11:32 PDT 2024


================
@@ -1812,14 +1711,18 @@ void AMDGPUInstPrinter::printEndpgm(const MCInst *MI, unsigned OpNo,
   O << ' ' << formatDec(Imm);
 }
 
-void AMDGPUInstPrinter::printByteSel(const MCInst *MI, unsigned OpNo,
-                                     const MCSubtargetInfo &STI,
-                                     raw_ostream &O) {
-  uint8_t Imm = MI->getOperand(OpNo).getImm();
-  if (!Imm)
-    return;
-
-  O << " byte_sel:" << formatDec(Imm);
+void AMDGPUInstPrinter::printNamedInt(const MCInst *MI, unsigned OpNo,
+                                      const MCSubtargetInfo &STI,
+                                      raw_ostream &O, StringRef Prefix,
+                                      unsigned Width, bool PrintInHex,
+                                      bool AlwaysPrint) {
+  int64_t V = MI->getOperand(OpNo).getImm();
+  if (AlwaysPrint || V != 0) {
+    if (Width)
+      V &= maxUIntN(Width);
----------------
jayfoad wrote:

This should go before the `V != 0` check, otherwise you can end up printing `0` when `AlwaysPrint` is false.

https://github.com/llvm/llvm-project/pull/100399


More information about the llvm-commits mailing list