[llvm] 88c0a82 - [MC] Make MCAsmBackend::fixupNeedsRelaxation not pure virtual
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 13:46:34 PDT 2024
Author: Fangrui Song
Date: 2024-07-01T13:46:30-07:00
New Revision: 88c0a8258800bbc72e7c0b0586436d4a1c62a260
URL: https://github.com/llvm/llvm-project/commit/88c0a8258800bbc72e7c0b0586436d4a1c62a260
DIFF: https://github.com/llvm/llvm-project/commit/88c0a8258800bbc72e7c0b0586436d4a1c62a260.diff
LOG: [MC] Make MCAsmBackend::fixupNeedsRelaxation not pure virtual
This hook only needs to be implemented if mayNeedRelaxation may return
true.
Added:
Modified:
llvm/include/llvm/MC/MCAsmBackend.h
llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index 104f637b741ea..3b4c01ea95083 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -167,7 +167,9 @@ class MCAsmBackend {
/// Simple predicate for targets where !Resolved implies requiring relaxation
virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const = 0;
+ const MCAsmLayout &Layout) const {
+ llvm_unreachable("Needed if mayNeedRelaxation may return true");
+ }
/// Relax the instruction in the given fragment to the next wider instruction.
///
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
index 023660f0ff140..2337319590324 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h
@@ -49,13 +49,6 @@ class AVRAsmBackend : public MCAsmBackend {
return AVR::NumTargetFixupKinds;
}
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- llvm_unreachable("RelaxInstruction() unimplemented");
- return false;
- }
-
bool writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const override;
diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
index fccc4ee9f74ac..a7a08714f05f5 100644
--- a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
+++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
@@ -36,13 +36,6 @@ class BPFAsmBackend : public MCAsmBackend {
std::unique_ptr<MCObjectTargetWriter>
createObjectTargetWriter() const override;
- // No instruction requires relaxation
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- return false;
- }
-
unsigned getNumFixupKinds() const override {
return BPF::NumTargetFixupKinds;
}
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
index 52002c67f2d04..2ce91bdf3996c 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
@@ -644,13 +644,6 @@ class HexagonAsmBackend : public MCAsmBackend {
return false;
}
- /// Simple predicate for targets where !Resolved implies requiring relaxation
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- llvm_unreachable("Handled by fixupNeedsRelaxationAdvanced");
- }
-
void relaxInstruction(MCInst &Inst,
const MCSubtargetInfo &STI) const override {
assert(HexagonMCInstrInfo::isBundle(Inst) &&
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
index 87c7a68aee4a5..8bfc7b5b422b9 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h
@@ -60,12 +60,6 @@ class LoongArchAsmBackend : public MCAsmBackend {
const MCValue &Target,
const MCSubtargetInfo *STI) override;
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- return false;
- }
-
unsigned getNumFixupKinds() const override {
return LoongArch::NumTargetFixupKinds;
}
diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp
index e0d209c96259c..87e4126bde399 100644
--- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp
+++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp
@@ -47,12 +47,6 @@ class MSP430AsmBackend : public MCAsmBackend {
return createMSP430ELFObjectWriter(OSABI);
}
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- return false;
- }
-
bool fixupNeedsRelaxationAdvanced(const MCAssembler &Asm,
const MCFixup &Fixup, bool Resolved,
uint64_t Value,
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
index 2dd68b6012385..799dd569f1ad9 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
@@ -51,19 +51,6 @@ class MipsAsmBackend : public MCAsmBackend {
return Mips::NumTargetFixupKinds;
}
- /// @name Target Relaxation Interfaces
- /// @{
-
- /// fixupNeedsRelaxation - Target specific predicate for whether a given
- /// fixup requires the associated instruction to be relaxed.
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- // FIXME.
- llvm_unreachable("RelaxInstruction() unimplemented");
- return false;
- }
-
bool writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const override;
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
index e32023ccedf53..ed174f7ac01fa 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
@@ -122,11 +122,6 @@ class SystemZMCAsmBackend : public MCAsmBackend {
const MCValue &Target, MutableArrayRef<char> Data,
uint64_t Value, bool IsResolved,
const MCSubtargetInfo *STI) const override;
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *Fragment,
- const MCAsmLayout &Layout) const override {
- return false;
- }
bool writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const override;
};
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
index ffab67f8ab2b2..a468022044bd7 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
@@ -52,13 +52,6 @@ class WebAssemblyAsmBackend final : public MCAsmBackend {
std::unique_ptr<MCObjectTargetWriter>
createObjectTargetWriter() const override;
- // No instruction requires relaxation
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *DF,
- const MCAsmLayout &Layout) const override {
- return false;
- }
-
bool writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const override;
};
diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp
index db4484bb57c1a..a296a22247a5c 100644
--- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp
+++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp
@@ -43,9 +43,6 @@ class XtensaMCAsmBackend : public MCAsmBackend {
const MCSubtargetInfo *STI) const override;
bool mayNeedRelaxation(const MCInst &Inst,
const MCSubtargetInfo &STI) const override;
- bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
- const MCRelaxableFragment *Fragment,
- const MCAsmLayout &Layout) const override;
void relaxInstruction(MCInst &Inst,
const MCSubtargetInfo &STI) const override;
bool writeNopData(raw_ostream &OS, uint64_t Count,
@@ -172,12 +169,6 @@ bool XtensaMCAsmBackend::mayNeedRelaxation(const MCInst &Inst,
return false;
}
-bool XtensaMCAsmBackend::fixupNeedsRelaxation(
- const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *Fragment,
- const MCAsmLayout &Layout) const {
- return false;
-}
-
void XtensaMCAsmBackend::relaxInstruction(MCInst &Inst,
const MCSubtargetInfo &STI) const {}
More information about the llvm-commits
mailing list