From d2e8e55e02f7e082cd7bae4d834ba5ee08f8b46c Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 28 Jun 2025 15:14:55 -0700 Subject: [PATCH] CSKY: Replace deprecated MCExpr::print with MCAsmInfo::printExpr --- llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 2 +- llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp | 6 +++--- llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 52b26c95c075..a2252d8f00f0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -474,7 +474,7 @@ unsigned DIEExpr::sizeOf(const dwarf::FormParams &FormParams, LLVM_DUMP_METHOD void DIEExpr::print(raw_ostream &O) const { O << "Expr: "; - Expr->print(O, nullptr); + MCAsmInfo().printExpr(O, *Expr); } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp index 47c05d67296e..981712a5089a 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp @@ -138,7 +138,7 @@ void CSKYInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, } assert(MO.isExpr() && "Unknown operand kind in printOperand"); - MO.getExpr()->print(O, &MAI); + MAI.printExpr(O, *MO.getExpr()); } void CSKYInstPrinter::printDataSymbol(const MCInst *MI, unsigned OpNo, @@ -150,7 +150,7 @@ void CSKYInstPrinter::printDataSymbol(const MCInst *MI, unsigned OpNo, if (MO.isImm()) O << MO.getImm(); else - MO.getExpr()->print(O, &MAI); + MAI.printExpr(O, *MO.getExpr()); O << "]"; } @@ -173,7 +173,7 @@ void CSKYInstPrinter::printConstpool(const MCInst *MI, uint64_t Address, assert(MO.isExpr() && "Unknown operand kind in printConstpool"); O << "["; - MO.getExpr()->print(O, &MAI); + MAI.printExpr(O, *MO.getExpr()); O << "]"; } diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp index 696cd1daa035..86e731bb231c 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp @@ -8,6 +8,7 @@ #include "CSKYMCExpr.h" #include "CSKYFixupKinds.h" +#include "MCTargetDesc/CSKYMCAsmInfo.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCContext.h" @@ -63,7 +64,8 @@ void CSKYMCExpr::visitUsedExpr(MCStreamer &Streamer) const { } void CSKYMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { - Expr->print(OS, MAI); + if (MAI) + MAI->printExpr(OS, *Expr); OS << getVariantKindName(getSpecifier()); }