[llvm] e933948 - ARM,Sparc: Avoid using the MCContext & argument
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat May 24 21:25:23 PDT 2025
Author: Fangrui Song
Date: 2025-05-24T21:25:19-07:00
New Revision: e9339481e5b75e99c295f0faf15091a70630b3d8
URL: https://github.com/llvm/llvm-project/commit/e9339481e5b75e99c295f0faf15091a70630b3d8
DIFF: https://github.com/llvm/llvm-project/commit/e9339481e5b75e99c295f0faf15091a70630b3d8.diff
LOG: ARM,Sparc: Avoid using the MCContext & argument
Prepare for removing MCContext from getRelocType functions.
Added:
Modified:
llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
index bf2e717aa20c8..4b691b6e2a1ef 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
@@ -25,23 +25,23 @@ using namespace llvm;
namespace {
- class ARMELFObjectWriter : public MCELFObjectTargetWriter {
- enum { DefaultEABIVersion = 0x05000000U };
+class ARMELFObjectWriter : public MCELFObjectTargetWriter {
+ enum { DefaultEABIVersion = 0x05000000U };
- unsigned GetRelocTypeInner(const MCValue &Target, const MCFixup &Fixup,
- bool IsPCRel, MCContext &Ctx) const;
+ unsigned getRelocTypeInner(const MCValue &Target, const MCFixup &Fixup,
+ bool IsPCRel) const;
- public:
- ARMELFObjectWriter(uint8_t OSABI);
+public:
+ ARMELFObjectWriter(uint8_t OSABI);
- ~ARMELFObjectWriter() override = default;
+ ~ARMELFObjectWriter() override = default;
- unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
- const MCFixup &Fixup, bool IsPCRel) const override;
+ unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
+ const MCFixup &Fixup, bool IsPCRel) const override;
- bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
- unsigned Type) const override;
- };
+ bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
+ unsigned Type) const override;
+};
} // end anonymous namespace
@@ -72,13 +72,12 @@ bool ARMELFObjectWriter::needsRelocateWithSymbol(const MCValue &,
unsigned ARMELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
const MCFixup &Fixup,
bool IsPCRel) const {
- return GetRelocTypeInner(Target, Fixup, IsPCRel, Ctx);
+ return getRelocTypeInner(Target, Fixup, IsPCRel);
}
-unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
+unsigned ARMELFObjectWriter::getRelocTypeInner(const MCValue &Target,
const MCFixup &Fixup,
- bool IsPCRel,
- MCContext &Ctx) const {
+ bool IsPCRel) const {
unsigned Kind = Fixup.getTargetKind();
uint8_t Specifier = Target.getSpecifier();
auto CheckFDPIC = [&](uint32_t Type) {
diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
index b54958c94834f..89297450b72c7 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
@@ -88,7 +88,7 @@ unsigned SparcELFObjectWriter::getRelocType(MCContext &Ctx,
case FK_Data_4: return ELF::R_SPARC_DISP32;
case FK_Data_8: return ELF::R_SPARC_DISP64;
case Sparc::fixup_sparc_call30:
- if (Ctx.getObjectFileInfo()->isPositionIndependent())
+ if (getContext().getObjectFileInfo()->isPositionIndependent())
return ELF::R_SPARC_WPLT30;
return ELF::R_SPARC_WDISP30;
}
@@ -110,7 +110,7 @@ unsigned SparcELFObjectWriter::getRelocType(MCContext &Ctx,
? ELF::R_SPARC_UA64
: ELF::R_SPARC_64);
case Sparc::fixup_sparc_13:
- if (Ctx.getObjectFileInfo()->isPositionIndependent())
+ if (getContext().getObjectFileInfo()->isPositionIndependent())
return ELF::R_SPARC_GOT13;
return ELF::R_SPARC_13;
}
More information about the llvm-commits
mailing list