MCAsmBackend: Remove MCSubtargetInfo argument

After #141311 removed the MCSubtargetInfo argument from
shouldForceRelocation, addReloc does not need this argument, either.

In a rare scenario that the information is needed, the target should
check the MCFragment subclass and get it from
MCDataFragment/MCRelaxableFragment.
This commit is contained in:
Fangrui Song
2025-05-23 20:55:42 -07:00
parent 89909d826a
commit f0ff2bea75
10 changed files with 20 additions and 25 deletions

View File

@@ -117,8 +117,7 @@ public:
virtual bool addReloc(MCAssembler &Asm, const MCFragment &F,
const MCFixup &Fixup, const MCValue &Target,
uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *);
uint64_t &FixedValue, bool IsResolved);
/// Apply the \p Value for given \p Fixup into the provided data fragment, at
/// the offset specified by the fixup and following the fixup kind as

View File

@@ -120,8 +120,7 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
bool MCAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
const MCFixup &Fixup, const MCValue &Target,
uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *STI) {
uint64_t &FixedValue, bool IsResolved) {
if (IsResolved && shouldForceRelocation(Asm, Fixup, Target))
IsResolved = false;
if (!IsResolved)

View File

@@ -199,7 +199,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
IsResolved = false;
IsResolved = getBackend().addReloc(const_cast<MCAssembler &>(*this), *DF,
Fixup, Target, Value, IsResolved, STI);
Fixup, Target, Value, IsResolved);
getBackend().applyFixup(*this, Fixup, Target, Contents, Value, IsResolved,
STI);
return true;

View File

@@ -370,8 +370,7 @@ AVRAsmBackend::createObjectTargetWriter() const {
bool AVRAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
const MCFixup &Fixup, const MCValue &Target,
uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *STI) {
uint64_t &FixedValue, bool IsResolved) {
// AVR sets the fixup value to bypass the assembly time overflow with a
// relocation.
if (IsResolved) {

View File

@@ -38,8 +38,8 @@ public:
createObjectTargetWriter() const override;
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *) override;
const MCValue &Target, uint64_t &FixedValue,
bool IsResolved) override;
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target, MutableArrayRef<char> Data,

View File

@@ -437,11 +437,10 @@ bool LoongArchAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
const MCFixup &Fixup, const MCValue &Target,
uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *CurSTI) {
uint64_t &FixedValue, bool IsResolved) {
auto Fallback = [&]() {
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
CurSTI);
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
IsResolved);
};
uint64_t FixedValueA, FixedValueB;
if (Target.getSubSym()) {

View File

@@ -36,8 +36,8 @@ public:
const MCTargetOptions &Options);
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *) override;
const MCValue &Target, uint64_t &FixedValue,
bool IsResolved) override;
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target, MutableArrayRef<char> Data,

View File

@@ -135,15 +135,15 @@ public:
}
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
const MCValue &TargetVal, uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *STI) override {
const MCValue &TargetVal, uint64_t &FixedValue,
bool IsResolved) override {
// In PPC64 ELFv1, .quad .TOC.@tocbase in the .opd section is expected to
// reference the null symbol.
auto Target = TargetVal;
if (Target.getSpecifier() == PPCMCExpr::VK_TOCBASE)
Target.setAddSym(nullptr);
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
STI);
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
IsResolved);
}
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,

View File

@@ -620,8 +620,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
const MCFixup &Fixup, const MCValue &Target,
uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *STI) {
uint64_t &FixedValue, bool IsResolved) {
uint64_t FixedValueA, FixedValueB;
if (Target.getSubSym()) {
assert(Target.getSpecifier() == 0 &&
@@ -668,8 +667,8 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
if (IsResolved &&
(getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
IsResolved = isPCRelFixupResolved(Asm, Target.getAddSym(), F);
IsResolved = MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
IsResolved, STI);
IsResolved =
MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved);
if (Fixup.isLinkerRelaxable()) {
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);

View File

@@ -50,8 +50,8 @@ public:
uint64_t &Value) override;
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
const MCSubtargetInfo *) override;
const MCValue &Target, uint64_t &FixedValue,
bool IsResolved) override;
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target, MutableArrayRef<char> Data,