[llvm] 869c2a9 - [PowerPC] Simplify evaluateAsRelocatableImpl

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 24 09:51:25 PDT 2025


Author: Fangrui Song
Date: 2025-03-24T09:51:20-07:00
New Revision: 869c2a9a1052144957d3ed57378cf927078f4b27

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

LOG: [PowerPC] Simplify evaluateAsRelocatableImpl

In addition, rename *MCExpr::getKind, which confusingly shadows the base class getKind.

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
index ddc5a522a2fb2..1964f1b70957d 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
@@ -44,7 +44,7 @@ static PPCMCExpr::Specifier getAccessVariant(const MCValue &Target,
 
   if (Expr->getKind() != MCExpr::Target)
     return PPCMCExpr::Specifier(Target.getAccessVariant());
-  return cast<PPCMCExpr>(Expr)->getKind();
+  return cast<PPCMCExpr>(Expr)->getSpecifier();
 }
 
 unsigned PPCELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
index 1df93567d3708..963e64574f553 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
@@ -85,8 +85,7 @@ bool PPCMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
   if (Res.isAbsolute() && MaybeInt) {
     Res = MCValue::get(*MaybeInt);
   } else {
-    Res = MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(),
-                       getKind());
+    Res.setSpecifier(specifier);
   }
 
   return true;

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
index 62216a9d79dd6..19d35649ca36e 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
@@ -131,9 +131,7 @@ class PPCMCExpr : public MCTargetExpr {
   /// @name Accessors
   /// @{
 
-  Specifier getKind() const { return specifier; }
-
-  /// getSubExpr - Get the child of this expression.
+  Specifier getSpecifier() const { return specifier; }
   const MCExpr *getSubExpr() const { return Expr; }
 
   /// @}


        


More information about the llvm-commits mailing list