Skip to content

Commit 75dbda4

Browse files
committed
MCAsmBackend: Remove the MCAssembler argument from addReloc
1 parent 15c9f27 commit 75dbda4

File tree

10 files changed

+39
-48
lines changed

10 files changed

+39
-48
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ class MCAsmBackend {
120120
llvm_unreachable("Need to implement hook if target has custom fixups");
121121
}
122122

123-
virtual bool addReloc(MCAssembler &Asm, const MCFragment &F,
124-
const MCFixup &Fixup, const MCValue &Target,
123+
virtual bool addReloc(const MCFragment &, const MCFixup &, const MCValue &,
125124
uint64_t &FixedValue, bool IsResolved);
126125

127126
/// Apply the \p Value for given \p Fixup into the provided data fragment, at

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
120120
return fixupNeedsRelaxation(Fixup, Value);
121121
}
122122

123-
bool MCAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
124-
const MCFixup &Fixup, const MCValue &Target,
125-
uint64_t &FixedValue, bool IsResolved) {
123+
bool MCAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
124+
const MCValue &Target, uint64_t &FixedValue,
125+
bool IsResolved) {
126126
if (IsResolved && shouldForceRelocation(Fixup, Target))
127127
IsResolved = false;
128128
if (!IsResolved)
129-
Asm.getWriter().recordRelocation(Asm, &F, Fixup, Target, FixedValue);
129+
Asm->getWriter().recordRelocation(*Asm, &F, Fixup, Target, FixedValue);
130130
return IsResolved;
131131
}
132132

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
201201

202202
if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
203203
IsResolved = false;
204-
IsResolved = getBackend().addReloc(const_cast<MCAssembler &>(*this), *DF,
205-
Fixup, Target, Value, IsResolved);
204+
IsResolved = getBackend().addReloc(*DF, Fixup, Target, Value, IsResolved);
206205
getBackend().applyFixup(*DF, Fixup, Target, Contents, Value, IsResolved);
207206
return true;
208207
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,19 @@ AVRAsmBackend::createObjectTargetWriter() const {
368368
return createAVRELFObjectWriter(MCELFObjectTargetWriter::getOSABI(OSType));
369369
}
370370

371-
bool AVRAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
372-
const MCFixup &Fixup, const MCValue &Target,
373-
uint64_t &FixedValue, bool IsResolved) {
371+
bool AVRAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
372+
const MCValue &Target, uint64_t &FixedValue,
373+
bool IsResolved) {
374374
// AVR sets the fixup value to bypass the assembly time overflow with a
375375
// relocation.
376376
if (IsResolved) {
377377
auto TargetVal = MCValue::get(Target.getAddSym(), Target.getSubSym(),
378378
FixedValue, Target.getSpecifier());
379-
if (forceRelocation(Asm, F, Fixup, TargetVal))
379+
if (forceRelocation(F, Fixup, TargetVal))
380380
IsResolved = false;
381381
}
382382
if (!IsResolved)
383-
Asm.getWriter().recordRelocation(Asm, &F, Fixup, Target, FixedValue);
383+
Asm->getWriter().recordRelocation(*Asm, &F, Fixup, Target, FixedValue);
384384
return IsResolved;
385385
}
386386

@@ -513,8 +513,7 @@ bool AVRAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
513513
return true;
514514
}
515515

516-
bool AVRAsmBackend::forceRelocation(const MCAssembler &Asm, const MCFragment &F,
517-
const MCFixup &Fixup,
516+
bool AVRAsmBackend::forceRelocation(const MCFragment &F, const MCFixup &Fixup,
518517
const MCValue &Target) {
519518
switch ((unsigned)Fixup.getKind()) {
520519
default:

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ class AVRAsmBackend : public MCAsmBackend {
3737
std::unique_ptr<MCObjectTargetWriter>
3838
createObjectTargetWriter() const override;
3939

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

4443
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
4544
MutableArrayRef<char> Data, uint64_t Value,
@@ -51,8 +50,8 @@ class AVRAsmBackend : public MCAsmBackend {
5150
bool writeNopData(raw_ostream &OS, uint64_t Count,
5251
const MCSubtargetInfo *STI) const override;
5352

54-
bool forceRelocation(const MCAssembler &Asm, const MCFragment &F,
55-
const MCFixup &Fixup, const MCValue &Target);
53+
bool forceRelocation(const MCFragment &F, const MCFixup &Fixup,
54+
const MCValue &Target);
5655

5756
private:
5857
Triple::OSType OSType;

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,11 @@ bool LoongArchAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
432432
return true;
433433
}
434434

435-
bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
436-
const MCFixup &Fixup, const MCValue &Target,
437-
uint64_t &FixedValue, bool IsResolved) {
435+
bool LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
436+
const MCValue &Target, uint64_t &FixedValue,
437+
bool IsResolved) {
438438
auto Fallback = [&]() {
439-
return MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
440-
IsResolved);
439+
return MCAsmBackend::addReloc(F, Fixup, Target, FixedValue, IsResolved);
441440
};
442441
uint64_t FixedValueA, FixedValueB;
443442
if (Target.getSubSym()) {
@@ -490,8 +489,8 @@ bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
490489
MCValue B = MCValue::get(Target.getSubSym());
491490
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, std::get<0>(FK));
492491
auto FB = MCFixup::create(Fixup.getOffset(), nullptr, std::get<1>(FK));
493-
Asm.getWriter().recordRelocation(Asm, &F, FA, A, FixedValueA);
494-
Asm.getWriter().recordRelocation(Asm, &F, FB, B, FixedValueB);
492+
Asm->getWriter().recordRelocation(*Asm, &F, FA, A, FixedValueA);
493+
Asm->getWriter().recordRelocation(*Asm, &F, FB, B, FixedValueB);
495494
FixedValue = FixedValueA - FixedValueB;
496495
return false;
497496
}
@@ -501,8 +500,8 @@ bool LoongArchAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
501500
// append a RELAX relocation.
502501
if (Fixup.isLinkerRelaxable()) {
503502
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_LARCH_RELAX);
504-
Asm.getWriter().recordRelocation(Asm, &F, FA, MCValue::get(nullptr),
505-
FixedValueA);
503+
Asm->getWriter().recordRelocation(*Asm, &F, FA, MCValue::get(nullptr),
504+
FixedValueA);
506505
}
507506

508507
return true;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ class LoongArchAsmBackend : public MCAsmBackend {
3535
LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit,
3636
const MCTargetOptions &Options);
3737

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

4241
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
4342
MutableArrayRef<char> Data, uint64_t Value,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,15 @@ class PPCAsmBackend : public MCAsmBackend {
134134
: InfosBE)[Kind - FirstTargetFixupKind];
135135
}
136136

137-
bool addReloc(MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup,
137+
bool addReloc(const MCFragment &F, const MCFixup &Fixup,
138138
const MCValue &TargetVal, uint64_t &FixedValue,
139139
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,
146-
IsResolved);
145+
return MCAsmBackend::addReloc(F, Fixup, Target, FixedValue, IsResolved);
147146
}
148147

149148
void applyFixup(const MCFragment &, const MCFixup &Fixup,

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
618618
isPCRelFixupResolved(Asm, AUIPCTarget.getAddSym(), *AUIPCDF);
619619
}
620620

621-
bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
622-
const MCFixup &Fixup, const MCValue &Target,
623-
uint64_t &FixedValue, bool IsResolved) {
621+
bool RISCVAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
622+
const MCValue &Target, uint64_t &FixedValue,
623+
bool IsResolved) {
624624
uint64_t FixedValueA, FixedValueB;
625625
if (Target.getSubSym()) {
626626
assert(Target.getSpecifier() == 0 &&
@@ -654,8 +654,8 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
654654
MCValue B = MCValue::get(Target.getSubSym());
655655
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, TA);
656656
auto FB = MCFixup::create(Fixup.getOffset(), nullptr, TB);
657-
Asm.getWriter().recordRelocation(Asm, &F, FA, A, FixedValueA);
658-
Asm.getWriter().recordRelocation(Asm, &F, FB, B, FixedValueB);
657+
Asm->getWriter().recordRelocation(*Asm, &F, FA, A, FixedValueA);
658+
Asm->getWriter().recordRelocation(*Asm, &F, FB, B, FixedValueB);
659659
FixedValue = FixedValueA - FixedValueB;
660660
return false;
661661
}
@@ -666,14 +666,13 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
666666
IsResolved = false;
667667
if (IsResolved &&
668668
(getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
669-
IsResolved = isPCRelFixupResolved(Asm, Target.getAddSym(), F);
670-
IsResolved =
671-
MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue, IsResolved);
669+
IsResolved = isPCRelFixupResolved(*Asm, Target.getAddSym(), F);
670+
IsResolved = MCAsmBackend::addReloc(F, Fixup, Target, FixedValue, IsResolved);
672671

673672
if (Fixup.isLinkerRelaxable()) {
674673
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);
675-
Asm.getWriter().recordRelocation(Asm, &F, FA, MCValue::get(nullptr),
676-
FixedValueA);
674+
Asm->getWriter().recordRelocation(*Asm, &F, FA, MCValue::get(nullptr),
675+
FixedValueA);
677676
}
678677

679678
return false;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class RISCVAsmBackend : public MCAsmBackend {
4949
const MCFragment *DF, const MCValue &Target,
5050
uint64_t &Value) override;
5151

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

5655
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
5756
MutableArrayRef<char> Data, uint64_t Value,

0 commit comments

Comments
 (0)