[llvm] 303bc0d - SPIRV: Replace deprecated MCExpr::print with MCAsmInfo::printExpr

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 28 12:36:13 PDT 2025


Author: Fangrui Song
Date: 2025-06-28T12:36:08-07:00
New Revision: 303bc0df6ade72ba05fa5c8d469ac8f1091da9ce

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

LOG: SPIRV: Replace deprecated MCExpr::print with MCAsmInfo::printExpr

The questionable use might be copied from BPF.

Added: 
    

Modified: 
    llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp
index 3e7d56a9d490b..2a424e673ddf6 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp
@@ -369,19 +369,6 @@ void SPIRVInstPrinter::printUnknownType(const MCInst *MI, raw_ostream &O) {
   printRemainingVariableOps(MI, NumFixedOps, O, true);
 }
 
-static void printExpr(const MCExpr *Expr, raw_ostream &O) {
-#ifndef NDEBUG
-  const MCSymbolRefExpr *SRE;
-
-  if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr))
-    SRE = cast<MCSymbolRefExpr>(BE->getLHS());
-  else
-    SRE = cast<MCSymbolRefExpr>(Expr);
-  assert(SRE->getSpecifier() == 0);
-#endif
-  O << *Expr;
-}
-
 void SPIRVInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                     raw_ostream &O) {
   if (OpNo < MI->getNumOperands()) {
@@ -393,7 +380,7 @@ void SPIRVInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
     else if (Op.isDFPImm())
       O << formatImm((double)Op.getDFPImm());
     else if (Op.isExpr())
-      printExpr(Op.getExpr(), O);
+      MAI.printExpr(O, *Op.getExpr());
     else
       llvm_unreachable("Unexpected operand type");
   }


        


More information about the llvm-commits mailing list