From 1bf172ae25c3fa75e68108e7e682323a9d9bc678 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 23 May 2025 21:05:05 -0700 Subject: [PATCH] MCAsmBackend: Simplify applyFixup Remove the MCSubtargetInfo argument from applyFixup, introduced in https://reviews.llvm.org/D45962 , as it's only required by ARM. Instead, add const MCFragment & so that ARMAsmBackend can retrieve MCSubtargetInfo via a static member function. Additionally, remove the MCAssembler argument, which is also only required by ARM. Additionally, make applyReloc non-const. Its arguments now fully cover addReloc's functionality. --- llvm/include/llvm/MC/MCAsmBackend.h | 11 +++++----- llvm/include/llvm/MC/MCAssembler.h | 5 ++--- llvm/lib/MC/MCAsmBackend.cpp | 21 +++++++++++++++++++ llvm/lib/MC/MCAssembler.cpp | 21 +++++++------------ .../MCTargetDesc/AArch64AsmBackend.cpp | 12 +++++------ .../AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp | 13 +++++------- .../Target/ARM/MCTargetDesc/ARMAsmBackend.cpp | 8 +++---- .../Target/ARM/MCTargetDesc/ARMAsmBackend.h | 7 +++---- .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp | 5 ++--- .../Target/AVR/MCTargetDesc/AVRAsmBackend.h | 7 +++---- .../Target/BPF/MCTargetDesc/BPFAsmBackend.cpp | 12 +++++------ .../CSKY/MCTargetDesc/CSKYAsmBackend.cpp | 5 ++--- .../Target/CSKY/MCTargetDesc/CSKYAsmBackend.h | 8 +++---- .../MCTargetDesc/DirectXMCTargetDesc.cpp | 7 +++---- .../MCTargetDesc/HexagonAsmBackend.cpp | 5 ++--- .../Lanai/MCTargetDesc/LanaiAsmBackend.cpp | 12 +++++------ .../MCTargetDesc/LoongArchAsmBackend.cpp | 6 ++---- .../MCTargetDesc/LoongArchAsmBackend.h | 7 +++---- .../M68k/MCTargetDesc/M68kAsmBackend.cpp | 5 ++--- .../MSP430/MCTargetDesc/MSP430AsmBackend.cpp | 14 ++++++------- .../Mips/MCTargetDesc/MipsAsmBackend.cpp | 5 ++--- .../Target/Mips/MCTargetDesc/MipsAsmBackend.h | 7 +++---- .../PowerPC/MCTargetDesc/PPCAsmBackend.cpp | 5 ++--- .../RISCV/MCTargetDesc/RISCVAsmBackend.cpp | 5 ++--- .../RISCV/MCTargetDesc/RISCVAsmBackend.h | 7 +++---- .../SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp | 7 +++---- .../Sparc/MCTargetDesc/SparcAsmBackend.cpp | 5 ++--- .../MCTargetDesc/SystemZMCAsmBackend.cpp | 13 +++++------- .../Target/VE/MCTargetDesc/VEAsmBackend.cpp | 5 ++--- .../MCTargetDesc/WebAssemblyAsmBackend.cpp | 12 ++++------- .../Target/X86/MCTargetDesc/X86AsmBackend.cpp | 12 +++++------ .../Xtensa/MCTargetDesc/XtensaAsmBackend.cpp | 12 +++++------ 32 files changed, 129 insertions(+), 157 deletions(-) diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h index 386bf04bb6493..29aa4b8f1de8f 100644 --- a/llvm/include/llvm/MC/MCAsmBackend.h +++ b/llvm/include/llvm/MC/MCAsmBackend.h @@ -129,12 +129,9 @@ class MCAsmBackend { /// the offset specified by the fixup and following the fixup kind as /// appropriate. Errors (such as an out of range fixup value) should be /// reported via \p Ctx. - /// The \p STI is present only for fragments of type MCRelaxableFragment and - /// MCDataFragment with hasInstructions() == true. - virtual void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + virtual void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const = 0; + uint64_t Value, bool IsResolved) = 0; /// @} @@ -222,6 +219,10 @@ class MCAsmBackend { bool isDarwinCanonicalPersonality(const MCSymbol *Sym) const; + // Return STI for fragments of type MCRelaxableFragment and MCDataFragment + // with hasInstructions() == true. + static const MCSubtargetInfo *getSubtargetInfo(const MCFragment &F); + private: const bool LinkerRelaxation; }; diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h index becd7cf6e8d1b..ab6321f53a3c9 100644 --- a/llvm/include/llvm/MC/MCAssembler.h +++ b/llvm/include/llvm/MC/MCAssembler.h @@ -90,16 +90,15 @@ class MCAssembler { /// Evaluate a fixup to a relocatable expression and the value which should be /// placed into the fixup. /// + /// \param F The fragment the fixup is inside. /// \param Fixup The fixup to evaluate. - /// \param DF The fragment the fixup is inside. /// \param Target [out] On return, the relocatable expression the fixup /// evaluates to. /// \param Value [out] On return, the value of the fixup as currently laid /// out. /// \param RecordReloc Record relocation if needed. /// relocation. - bool evaluateFixup(const MCFixup &Fixup, const MCFragment *DF, - MCValue &Target, const MCSubtargetInfo *STI, + bool evaluateFixup(const MCFragment *F, const MCFixup &Fixup, MCValue &Target, uint64_t &Value, bool RecordReloc, MutableArrayRef Contents) const; diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp index c8d1831ae6d3e..dc24f8305904c 100644 --- a/llvm/lib/MC/MCAsmBackend.cpp +++ b/llvm/lib/MC/MCAsmBackend.cpp @@ -145,3 +145,24 @@ bool MCAsmBackend::isDarwinCanonicalPersonality(const MCSymbol *Sym) const { // Reserving an empty slot for it seems silly. return name == "___gxx_personality_v0" || name == "___objc_personality_v0"; } + +const MCSubtargetInfo *MCAsmBackend::getSubtargetInfo(const MCFragment &F) { + const MCSubtargetInfo *STI = nullptr; + switch (F.getKind()) { + case MCFragment::FT_Data: { + auto &DF = cast(F); + STI = DF.getSubtargetInfo(); + assert(!DF.hasInstructions() || STI != nullptr); + break; + } + case MCFragment::FT_Relaxable: { + auto &RF = cast(F); + STI = RF.getSubtargetInfo(); + assert(!RF.hasInstructions() || STI != nullptr); + break; + } + default: + break; + } + return STI; +} diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index ac67a0d2c05d9..73994461ab8eb 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -139,9 +139,9 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const { return true; } -bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF, - MCValue &Target, const MCSubtargetInfo *STI, - uint64_t &Value, bool RecordReloc, +bool MCAssembler::evaluateFixup(const MCFragment *DF, const MCFixup &Fixup, + MCValue &Target, uint64_t &Value, + bool RecordReloc, MutableArrayRef Contents) const { ++stats::evaluateFixup; @@ -203,8 +203,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF, IsResolved = false; IsResolved = getBackend().addReloc(const_cast(*this), *DF, Fixup, Target, Value, IsResolved); - getBackend().applyFixup(*this, Fixup, Target, Contents, Value, IsResolved, - STI); + getBackend().applyFixup(*DF, Fixup, Target, Contents, Value, IsResolved); return true; } @@ -909,7 +908,6 @@ void MCAssembler::layout() { for (MCFragment &Frag : Sec) { MutableArrayRef Fixups; MutableArrayRef Contents; - const MCSubtargetInfo *STI = nullptr; // Process MCAlignFragment and MCEncodedFragmentWithFixups here. switch (Frag.getKind()) { @@ -927,16 +925,12 @@ void MCAssembler::layout() { MCDataFragment &DF = cast(Frag); Fixups = DF.getFixups(); Contents = DF.getContents(); - STI = DF.getSubtargetInfo(); - assert(!DF.hasInstructions() || STI != nullptr); break; } case MCFragment::FT_Relaxable: { MCRelaxableFragment &RF = cast(Frag); Fixups = RF.getFixups(); Contents = RF.getContents(); - STI = RF.getSubtargetInfo(); - assert(!RF.hasInstructions() || STI != nullptr); break; } case MCFragment::FT_CVDefRange: { @@ -973,7 +967,7 @@ void MCAssembler::layout() { for (const MCFixup &Fixup : Fixups) { uint64_t FixedValue; MCValue Target; - evaluateFixup(Fixup, &Frag, Target, STI, FixedValue, + evaluateFixup(&Frag, Fixup, Target, FixedValue, /*RecordReloc=*/true, Contents); } } @@ -994,9 +988,8 @@ bool MCAssembler::fixupNeedsRelaxation(const MCFixup &Fixup, assert(getBackendPtr() && "Expected assembler backend"); MCValue Target; uint64_t Value; - bool Resolved = - evaluateFixup(const_cast(Fixup), DF, Target, - DF->getSubtargetInfo(), Value, /*RecordReloc=*/false, {}); + bool Resolved = evaluateFixup(DF, const_cast(Fixup), Target, Value, + /*RecordReloc=*/false, {}); return getBackend().fixupNeedsRelaxationAdvanced(*this, Fixup, Target, Value, Resolved); } diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp index 3c5509a7688ac..eda0a09970f63 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -81,10 +81,9 @@ class AArch64AsmBackend : public MCAsmBackend { return Infos[Kind - FirstTargetFixupKind]; } - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value) const override; @@ -415,11 +414,10 @@ unsigned AArch64AsmBackend::getFixupKindContainereSizeInBytes(unsigned Kind) con } } -void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void AArch64AsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCFixupKind Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp index 0a2c9cca3887a..505ddbd11f6c0 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp @@ -32,11 +32,9 @@ class AMDGPUAsmBackend : public MCAsmBackend { public: AMDGPUAsmBackend(const Target &T) : MCAsmBackend(llvm::endianness::little) {} - - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value) const override; @@ -133,11 +131,10 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value, } } -void AMDGPUAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void AMDGPUAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { if (mc::isRelocation(Fixup.getKind())) return; diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 09d34abf0a272..1e0665f6970a2 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -1127,16 +1127,16 @@ static unsigned getFixupKindContainerSizeBytes(unsigned Kind) { } } -void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void ARMAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo* STI) const { + bool IsResolved) { auto Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; MCContext &Ctx = getContext(); - Value = adjustFixupValue(Asm, Fixup, Target, Value, IsResolved, Ctx, STI); + Value = adjustFixupValue(*Asm, Fixup, Target, Value, IsResolved, Ctx, + getSubtargetInfo(F)); if (!Value) return; // Doesn't change encoding. const unsigned NumBytes = getFixupKindNumBytes(Kind); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h index e8ade37e0ac5e..49a346b51aa66 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h @@ -38,10 +38,9 @@ class ARMAsmBackend : public MCAsmBackend { bool IsResolved, MCContext &Ctx, const MCSubtargetInfo *STI) const; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; unsigned getRelaxedOpcode(unsigned Op, const MCSubtargetInfo &STI) const; diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp index 4235541508aae..77a9496fdea21 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp @@ -384,11 +384,10 @@ bool AVRAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F, return IsResolved; } -void AVRAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void AVRAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { if (mc::isRelocation(Fixup.getKind())) return; adjustFixupValue(Fixup, Target, Value, &getContext()); diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h index d106a0d21a316..b31331ec80a13 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h @@ -41,10 +41,9 @@ class AVRAsmBackend : public MCAsmBackend { const MCValue &Target, uint64_t &FixedValue, bool IsResolved) override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::optional getFixupKind(StringRef Name) const override; MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp index d2610e8a74457..1704fecaff031 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp @@ -27,10 +27,9 @@ class BPFAsmBackend : public MCAsmBackend { BPFAsmBackend(llvm::endianness Endian) : MCAsmBackend(Endian) {} ~BPFAsmBackend() override = default; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::unique_ptr createObjectTargetWriter() const override; @@ -67,11 +66,10 @@ bool BPFAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count, return true; } -void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void BPFAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { if (Fixup.getKind() == FK_SecRel_8) { // The Value is 0 for global variables, and the in-section offset // for static variables. Write to the immediate field of the inst. diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp index 25453d99d0aab..a9ca53728dda8 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp @@ -189,11 +189,10 @@ bool CSKYAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &, } } -void CSKYAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void CSKYAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCFixupKind Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h index 33aaf985577ec..a765bfe86e80a 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h @@ -22,11 +22,9 @@ class CSKYAsmBackend : public MCAsmBackend { CSKYAsmBackend(const MCSubtargetInfo &STI, const MCTargetOptions &OP) : MCAsmBackend(llvm::endianness::little) {} - - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; diff --git a/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp index 02baa1fcd1406..5323be65f2c16 100644 --- a/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp +++ b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp @@ -77,10 +77,9 @@ class DXILAsmBackend : public MCAsmBackend { : MCAsmBackend(llvm::endianness::little) {} ~DXILAsmBackend() override = default; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override {} + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override {} std::unique_ptr createObjectTargetWriter() const override { diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp index 058f97426ed00..170e6470af43a 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp @@ -407,10 +407,9 @@ class HexagonAsmBackend : public MCAsmBackend { /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided /// data fragment, at the offset specified by the fixup and following the /// fixup kind as appropriate. - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + void applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, - uint64_t FixupValue, bool IsResolved, - const MCSubtargetInfo *STI) const override { + uint64_t FixupValue, bool IsResolved) override { // When FixupValue is 0 the relocation is external and there // is nothing for us to do. diff --git a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp index 0a5f37f31296c..a0bc4f17ad884 100644 --- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp +++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp @@ -47,10 +47,9 @@ class LanaiAsmBackend : public MCAsmBackend { LanaiAsmBackend(const Target &T, Triple::OSType OST) : MCAsmBackend(llvm::endianness::big), OSType(OST) {} - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::unique_ptr createObjectTargetWriter() const override; @@ -72,11 +71,10 @@ bool LanaiAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count, return true; } -void LanaiAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void LanaiAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool /*IsResolved*/, - const MCSubtargetInfo * /*STI*/) const { + bool) { MCFixupKind Kind = Fixup.getKind(); Value = adjustFixupValue(static_cast(Kind), Value); diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp index 2586039b2bb68..467c443f9e898 100644 --- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp +++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp @@ -140,12 +140,10 @@ static void fixupLeb128(MCContext &Ctx, const MCFixup &Fixup, Ctx.reportError(Fixup.getLoc(), "Invalid uleb128 value!"); } -void LoongArchAsmBackend::applyFixup(const MCAssembler &Asm, - const MCFixup &Fixup, +void LoongArchAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { if (!Value) return; // Doesn't change encoding. diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h index 787bcb4a04af8..3b9b4214496e5 100644 --- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h +++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h @@ -39,10 +39,9 @@ class LoongArchAsmBackend : public MCAsmBackend { const MCValue &Target, uint64_t &FixedValue, bool IsResolved) override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; // Return Size with extra Nop Bytes for alignment directive in code section. bool shouldInsertExtraNopBytesForCodeAlign(const MCAlignFragment &AF, diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp index 8eabc05008bd1..20a37302a5e1c 100644 --- a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp +++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp @@ -52,9 +52,8 @@ class M68kAsmBackend : public MCAsmBackend { .CasesLower("m68020", "m68030", "m68040", true) .Default(false)) {} - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &, - MutableArrayRef Data, uint64_t Value, bool, - const MCSubtargetInfo *STI) const override { + void applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &, + MutableArrayRef Data, uint64_t Value, bool) override { unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind()); assert(Fixup.getOffset() + Size <= Data.size() && "Invalid fixup offset!"); diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp index 646d7807cb5d4..54fd008790f90 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp @@ -36,10 +36,9 @@ class MSP430AsmBackend : public MCAsmBackend { : MCAsmBackend(llvm::endianness::little), OSABI(OSABI) {} ~MSP430AsmBackend() override = default; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::unique_ptr createObjectTargetWriter() const override { @@ -104,11 +103,10 @@ uint64_t MSP430AsmBackend::adjustFixupValue(const MCFixup &Fixup, } } -void MSP430AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void MSP430AsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, - MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const { + MutableArrayRef Data, uint64_t Value, + bool IsResolved) { Value = adjustFixupValue(Fixup, Value, getContext()); MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind()); if (!Value) diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp index 9e421c77d23bb..5ed8eb0996668 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -242,11 +242,10 @@ static unsigned calculateMMLEIndex(unsigned i) { /// ApplyFixup - 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 appropriate. -void MipsAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void MipsAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCFixupKind Kind = Fixup.getKind(); MCContext &Ctx = getContext(); Value = adjustFixupValue(Fixup, Value, Ctx); diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h index b518769e385bb..67857eb7bbd95 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h @@ -39,10 +39,9 @@ class MipsAsmBackend : public MCAsmBackend { std::unique_ptr createObjectTargetWriter() const override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::optional getFixupKind(StringRef Name) const override; MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp index 7751ba4a13bd1..ceee36444cdf6 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp @@ -146,10 +146,9 @@ class PPCAsmBackend : public MCAsmBackend { IsResolved); } - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + void applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override { + uint64_t Value, bool IsResolved) override { MCFixupKind Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp index d919c0d2d1381..6b19a2a26e2c7 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -679,11 +679,10 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F, return false; } -void RISCVAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void RISCVAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCFixupKind Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h index d53a70d0aa585..b651341b02e4f 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h @@ -53,10 +53,9 @@ class RISCVAsmBackend : public MCAsmBackend { const MCValue &Target, uint64_t &FixedValue, bool IsResolved) override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; std::unique_ptr createObjectTargetWriter() const override; diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp index 3e4896c7378e3..94d39358d9b3d 100644 --- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp +++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp @@ -20,10 +20,9 @@ class SPIRVAsmBackend : public MCAsmBackend { public: SPIRVAsmBackend(llvm::endianness Endian) : MCAsmBackend(Endian) {} - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override {} + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override {} std::unique_ptr createObjectTargetWriter() const override { diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp index 9ef335a5af4a3..95b78e0905b6d 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp @@ -228,10 +228,9 @@ namespace { ELFSparcAsmBackend(const MCSubtargetInfo &STI, Triple::OSType OSType) : SparcAsmBackend(STI), OSType(OSType) {} - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + void applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override { + uint64_t Value, bool IsResolved) override { if (!IsResolved) return; Value = adjustFixupValue(Fixup.getKind(), Value); diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp index dcdbd2bb95adb..928f78a926074 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp @@ -115,10 +115,9 @@ class SystemZMCAsmBackend : public MCAsmBackend { MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; bool shouldForceRelocation(const MCAssembler &, const MCFixup &, const MCValue &) override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; bool writeNopData(raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const override; }; @@ -161,12 +160,10 @@ bool SystemZMCAsmBackend::shouldForceRelocation(const MCAssembler &, return Target.getSpecifier(); } -void SystemZMCAsmBackend::applyFixup(const MCAssembler &Asm, - const MCFixup &Fixup, +void SystemZMCAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCFixupKind Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp index d51423942eec4..4248439cb88a2 100644 --- a/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp +++ b/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp @@ -176,10 +176,9 @@ class ELFVEAsmBackend : public VEAsmBackend { ELFVEAsmBackend(const Target &T, Triple::OSType OSType) : VEAsmBackend(T), OSType(OSType) {} - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + void applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override { + uint64_t Value, bool IsResolved) override { Value = adjustFixupValue(Fixup.getKind(), Value); if (!Value) return; // Doesn't change encoding. diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp index 91a1db80deb3c..7bc672c069476 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp @@ -38,10 +38,8 @@ class WebAssemblyAsmBackend final : public MCAsmBackend { MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsPCRel, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, bool) override; std::unique_ptr createObjectTargetWriter() const override; @@ -80,12 +78,10 @@ bool WebAssemblyAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count, return true; } -void WebAssemblyAsmBackend::applyFixup(const MCAssembler &Asm, - const MCFixup &Fixup, +void WebAssemblyAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsPCRel, - const MCSubtargetInfo *STI) const { + uint64_t Value, bool) { MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind()); assert(Info.Flags == 0 && "WebAssembly does not use MCFixupKindInfo flags"); diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp index 8751e978e1e16..9ae67d34e2a60 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp @@ -172,10 +172,9 @@ class X86AsmBackend : public MCAsmBackend { bool shouldForceRelocation(const MCAssembler &, const MCFixup &, const MCValue &) override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override; @@ -697,10 +696,9 @@ bool X86AsmBackend::shouldForceRelocation(const MCAssembler &, const MCFixup &, return Target.getSpecifier(); } -void X86AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void X86AsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const { + uint64_t Value, bool IsResolved) { auto Kind = Fixup.getKind(); if (mc::isRelocation(Kind)) return; diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp index c77da070a595f..deefb22e47a01 100644 --- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp +++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp @@ -34,10 +34,9 @@ class XtensaAsmBackend : public MCAsmBackend { IsLittleEndian(isLE) {} MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override; - void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, - const MCValue &Target, MutableArrayRef Data, - uint64_t Value, bool IsResolved, - const MCSubtargetInfo *STI) const override; + void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) override; bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override; void relaxInstruction(MCInst &Inst, @@ -144,11 +143,10 @@ static unsigned getSize(unsigned Kind) { } } -void XtensaAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, +void XtensaAsmBackend::applyFixup(const MCFragment &, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, uint64_t Value, - bool IsResolved, - const MCSubtargetInfo *STI) const { + bool IsResolved) { MCContext &Ctx = getContext(); MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());