[llvm] 48056a7 - MCAsmBackend: Simplify evaluateTargetFixup
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri May 23 23:41:10 PDT 2025
Author: Fangrui Song
Date: 2025-05-23T23:41:05-07:00
New Revision: 48056a70589bdb737daaa8f7f577950be4b3a74e
URL: https://github.com/llvm/llvm-project/commit/48056a70589bdb737daaa8f7f577950be4b3a74e
DIFF: https://github.com/llvm/llvm-project/commit/48056a70589bdb737daaa8f7f577950be4b3a74e.diff
LOG: MCAsmBackend: Simplify evaluateTargetFixup
Added:
Modified:
llvm/include/llvm/MC/MCAsmBackend.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index da7337ebeff56..89f3fdc88e7da 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -114,8 +114,7 @@ class MCAsmBackend {
return false;
}
- virtual bool evaluateTargetFixup(const MCAssembler &Asm, const MCFixup &Fixup,
- const MCFragment *DF, const MCValue &Target,
+ virtual bool evaluateTargetFixup(const MCFixup &Fixup, const MCValue &Target,
uint64_t &Value) {
llvm_unreachable("Need to implement hook if target has custom fixups");
}
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index d32e012afd381..8a66cdbaed41d 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -162,8 +162,7 @@ bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup,
bool IsResolved = false;
unsigned FixupFlags = getBackend().getFixupKindInfo(Fixup.getKind()).Flags;
if (FixupFlags & MCFixupKindInfo::FKF_IsTarget) {
- IsResolved =
- getBackend().evaluateTargetFixup(*this, Fixup, DF, Target, Value);
+ IsResolved = getBackend().evaluateTargetFixup(Fixup, Target, Value);
} else {
const MCSymbol *Add = Target.getAddSym();
const MCSymbol *Sub = Target.getSubSym();
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 7b015c649f2fe..33b333dcdf1cb 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -569,9 +569,7 @@ bool RISCVAsmBackend::isPCRelFixupResolved(const MCAssembler &Asm,
return !Res.getSubSym();
}
-bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
- const MCFixup &Fixup,
- const MCFragment *DF,
+bool RISCVAsmBackend::evaluateTargetFixup(const MCFixup &Fixup,
const MCValue &Target,
uint64_t &Value) {
const MCFixup *AUIPCFixup;
@@ -592,7 +590,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
// MCAssembler::evaluateFixup will emit an error for this case when it sees
// the %pcrel_hi, so don't duplicate it when also seeing the %pcrel_lo.
const MCExpr *AUIPCExpr = AUIPCFixup->getValue();
- if (!AUIPCExpr->evaluateAsRelocatable(AUIPCTarget, &Asm))
+ if (!AUIPCExpr->evaluateAsRelocatable(AUIPCTarget, Asm))
return true;
break;
}
@@ -611,11 +609,11 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
if (!IsResolved)
return false;
- Value = Asm.getSymbolOffset(SA) + AUIPCTarget.getConstant();
- Value -= Asm.getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
+ Value = Asm->getSymbolOffset(SA) + AUIPCTarget.getConstant();
+ Value -= Asm->getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
return AUIPCFixup->getTargetKind() == RISCV::fixup_riscv_pcrel_hi20 &&
- isPCRelFixupResolved(Asm, AUIPCTarget.getAddSym(), *AUIPCDF);
+ isPCRelFixupResolved(*Asm, AUIPCTarget.getAddSym(), *AUIPCDF);
}
bool RISCVAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
index 94d82df970199..b03706943863d 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
@@ -45,8 +45,7 @@ class RISCVAsmBackend : public MCAsmBackend {
bool shouldInsertFixupForCodeAlign(MCAssembler &Asm,
MCAlignFragment &AF) override;
- bool evaluateTargetFixup(const MCAssembler &Asm, const MCFixup &Fixup,
- const MCFragment *DF, const MCValue &Target,
+ bool evaluateTargetFixup(const MCFixup &Fixup, const MCValue &Target,
uint64_t &Value) override;
bool addReloc(const MCFragment &, const MCFixup &, const MCValue &,
More information about the llvm-commits
mailing list