Skip to content

Commit 48056a7

Browse files
committed
MCAsmBackend: Simplify evaluateTargetFixup
1 parent 75dbda4 commit 48056a7

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class MCAsmBackend {
114114
return false;
115115
}
116116

117-
virtual bool evaluateTargetFixup(const MCAssembler &Asm, const MCFixup &Fixup,
118-
const MCFragment *DF, const MCValue &Target,
117+
virtual bool evaluateTargetFixup(const MCFixup &Fixup, const MCValue &Target,
119118
uint64_t &Value) {
120119
llvm_unreachable("Need to implement hook if target has custom fixups");
121120
}

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
162162
bool IsResolved = false;
163163
unsigned FixupFlags = getBackend().getFixupKindInfo(Fixup.getKind()).Flags;
164164
if (FixupFlags & MCFixupKindInfo::FKF_IsTarget) {
165-
IsResolved =
166-
getBackend().evaluateTargetFixup(*this, Fixup, DF, Target, Value);
165+
IsResolved = getBackend().evaluateTargetFixup(Fixup, Target, Value);
167166
} else {
168167
const MCSymbol *Add = Target.getAddSym();
169168
const MCSymbol *Sub = Target.getSubSym();

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,7 @@ bool RISCVAsmBackend::isPCRelFixupResolved(const MCAssembler &Asm,
569569
return !Res.getSubSym();
570570
}
571571

572-
bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
573-
const MCFixup &Fixup,
574-
const MCFragment *DF,
572+
bool RISCVAsmBackend::evaluateTargetFixup(const MCFixup &Fixup,
575573
const MCValue &Target,
576574
uint64_t &Value) {
577575
const MCFixup *AUIPCFixup;
@@ -592,7 +590,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
592590
// MCAssembler::evaluateFixup will emit an error for this case when it sees
593591
// the %pcrel_hi, so don't duplicate it when also seeing the %pcrel_lo.
594592
const MCExpr *AUIPCExpr = AUIPCFixup->getValue();
595-
if (!AUIPCExpr->evaluateAsRelocatable(AUIPCTarget, &Asm))
593+
if (!AUIPCExpr->evaluateAsRelocatable(AUIPCTarget, Asm))
596594
return true;
597595
break;
598596
}
@@ -611,11 +609,11 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
611609
if (!IsResolved)
612610
return false;
613611

614-
Value = Asm.getSymbolOffset(SA) + AUIPCTarget.getConstant();
615-
Value -= Asm.getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
612+
Value = Asm->getSymbolOffset(SA) + AUIPCTarget.getConstant();
613+
Value -= Asm->getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
616614

617615
return AUIPCFixup->getTargetKind() == RISCV::fixup_riscv_pcrel_hi20 &&
618-
isPCRelFixupResolved(Asm, AUIPCTarget.getAddSym(), *AUIPCDF);
616+
isPCRelFixupResolved(*Asm, AUIPCTarget.getAddSym(), *AUIPCDF);
619617
}
620618

621619
bool RISCVAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class RISCVAsmBackend : public MCAsmBackend {
4545
bool shouldInsertFixupForCodeAlign(MCAssembler &Asm,
4646
MCAlignFragment &AF) override;
4747

48-
bool evaluateTargetFixup(const MCAssembler &Asm, const MCFixup &Fixup,
49-
const MCFragment *DF, const MCValue &Target,
48+
bool evaluateTargetFixup(const MCFixup &Fixup, const MCValue &Target,
5049
uint64_t &Value) override;
5150

5251
bool addReloc(const MCFragment &, const MCFixup &, const MCValue &,

0 commit comments

Comments
 (0)