[llvm] f96832a - BPF: Replace deprecated MCExpr::print with MCAsmInfo::printExpr

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


Author: Fangrui Song
Date: 2025-06-28T12:27:23-07:00
New Revision: f96832a52019f47f69c7f122d9233ae46060cc23

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

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

Added: 
    

Modified: 
    llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
index 83ff3ef327de3..a0011e81ddd47 100644
--- a/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
+++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
@@ -32,20 +32,6 @@ void BPFInstPrinter::printInst(const MCInst *MI, uint64_t Address,
   printAnnotation(O, Annot);
 }
 
-static void printExpr(const MCExpr *Expr, raw_ostream &O) {
-  const MCSymbolRefExpr *SRE;
-
-  if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr))
-    SRE = dyn_cast<MCSymbolRefExpr>(BE->getLHS());
-  else
-    SRE = dyn_cast<MCSymbolRefExpr>(Expr);
-  if (!SRE)
-    report_fatal_error("Unexpected MCExpr type.");
-
-  assert(SRE->getSpecifier() == 0);
-  O << *Expr;
-}
-
 void BPFInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                   raw_ostream &O) {
   const MCOperand &Op = MI->getOperand(OpNo);
@@ -55,7 +41,7 @@ void BPFInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
     O << formatImm((int32_t)Op.getImm());
   } else {
     assert(Op.isExpr() && "Expected an expression");
-    printExpr(Op.getExpr(), O);
+    MAI.printExpr(O, *Op.getExpr());
   }
 }
 
@@ -86,7 +72,7 @@ void BPFInstPrinter::printImm64Operand(const MCInst *MI, unsigned OpNo,
   if (Op.isImm())
     O << formatImm(Op.getImm());
   else if (Op.isExpr())
-    printExpr(Op.getExpr(), O);
+    MAI.printExpr(O, *Op.getExpr());
   else
     O << Op;
 }
@@ -103,7 +89,7 @@ void BPFInstPrinter::printBrTargetOperand(const MCInst *MI, unsigned OpNo,
       O << ((Imm >= 0) ? "+" : "") << formatImm(Imm);
     }
   } else if (Op.isExpr()) {
-    printExpr(Op.getExpr(), O);
+    MAI.printExpr(O, *Op.getExpr());
   } else {
     O << Op;
   }


        


More information about the llvm-commits mailing list