Skip to content

Commit f0ff2be

Browse files
committed
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.
1 parent 89909d8 commit f0ff2be

File tree

10 files changed

+20
-25
lines changed

10 files changed

+20
-25
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ class MCAsmBackend {
117117

118118
virtual bool addReloc(MCAssembler &Asm, const MCFragment &F,
119119
const MCFixup &Fixup, const MCValue &Target,
120-
uint64_t &FixedValue, bool IsResolved,
121-
const MCSubtargetInfo *);
120+
uint64_t &FixedValue, bool IsResolved);
122121

123122
/// Apply the \p Value for given \p Fixup into the provided data fragment, at
124123
/// the offset specified by the fixup and following the fixup kind as

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
120120

121121
bool MCAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
122122
const MCFixup &Fixup, const MCValue &Target,
123-
uint64_t &FixedValue, bool IsResolved,
124-
const MCSubtargetInfo *STI) {
123+
uint64_t &FixedValue, bool IsResolved) {
125124
if (IsResolved && shouldForceRelocation(Asm, Fixup, Target))
126125
IsResolved = false;
127126
if (!IsResolved)

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
199199
if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
200200
IsResolved = false;
201201
IsResolved = getBackend().addReloc(const_cast<MCAssembler &>(*this), *DF,
202-
Fixup, Target, Value, IsResolved, STI);
202+
Fixup, Target, Value, IsResolved);
203203
getBackend().applyFixup(*this, Fixup, Target, Contents, Value, IsResolved,
204204
STI);
205205
return true;

llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,7 @@ AVRAsmBackend::createObjectTargetWriter() const {
370370

371371
bool AVRAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
372372
const MCFixup &Fixup, const MCValue &Target,
373-
uint64_t &FixedValue, bool IsResolved,
374-
const MCSubtargetInfo *STI) {
373+
uint64_t &FixedValue, bool IsResolved) {
375374
// AVR sets the fixup value to bypass the assembly time overflow with a
376375
// relocation.
377376
if (IsResolved) {

llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class AVRAsmBackend : public MCAsmBackend {
3838
createObjectTargetWriter() const override;
3939

4040
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
41-
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
42-
const MCSubtargetInfo *) override;
41+
const MCValue &Target, uint64_t &FixedValue,
42+
bool IsResolved) override;
4343

4444
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
4545
const MCValue &Target, MutableArrayRef<char> Data,

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,10 @@ bool LoongArchAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
437437

438438
bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
439439
const MCFixup &Fixup, const MCValue &Target,
440-
uint64_t &FixedValue, bool IsResolved,
441-
const MCSubtargetInfo *CurSTI) {
440+
uint64_t &FixedValue, bool IsResolved) {
442441
auto Fallback = [&]() {
443-
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
444-
CurSTI);
442+
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
443+
IsResolved);
445444
};
446445
uint64_t FixedValueA, FixedValueB;
447446
if (Target.getSubSym()) {

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class LoongArchAsmBackend : public MCAsmBackend {
3636
const MCTargetOptions &Options);
3737

3838
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
39-
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
40-
const MCSubtargetInfo *) override;
39+
const MCValue &Target, uint64_t &FixedValue,
40+
bool IsResolved) override;
4141

4242
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
4343
const MCValue &Target, MutableArrayRef<char> Data,

llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ class PPCAsmBackend : public MCAsmBackend {
135135
}
136136

137137
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
138-
const MCValue &TargetVal, uint64_t &FixedValue, bool IsResolved,
139-
const MCSubtargetInfo *STI) override {
138+
const MCValue &TargetVal, uint64_t &FixedValue,
139+
bool IsResolved) override {
140140
// In PPC64 ELFv1, .quad .TOC.@tocbase in the .opd section is expected to
141141
// reference the null symbol.
142142
auto Target = TargetVal;
143143
if (Target.getSpecifier() == PPCMCExpr::VK_TOCBASE)
144144
Target.setAddSym(nullptr);
145-
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved,
146-
STI);
145+
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
146+
IsResolved);
147147
}
148148

149149
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
620620

621621
bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
622622
const MCFixup &Fixup, const MCValue &Target,
623-
uint64_t &FixedValue, bool IsResolved,
624-
const MCSubtargetInfo *STI) {
623+
uint64_t &FixedValue, bool IsResolved) {
625624
uint64_t FixedValueA, FixedValueB;
626625
if (Target.getSubSym()) {
627626
assert(Target.getSpecifier() == 0 &&
@@ -668,8 +667,8 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
668667
if (IsResolved &&
669668
(getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
670669
IsResolved = isPCRelFixupResolved(Asm, Target.getAddSym(), F);
671-
IsResolved = MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
672-
IsResolved, STI);
670+
IsResolved =
671+
MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved);
673672

674673
if (Fixup.isLinkerRelaxable()) {
675674
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class RISCVAsmBackend : public MCAsmBackend {
5050
uint64_t &Value) override;
5151

5252
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
53-
const MCValue &Target, uint64_t &FixedValue, bool IsResolved,
54-
const MCSubtargetInfo *) override;
53+
const MCValue &Target, uint64_t &FixedValue,
54+
bool IsResolved) override;
5555

5656
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
5757
const MCValue &Target, MutableArrayRef<char> Data,

0 commit comments

Comments
 (0)