Skip to content

Commit 8a1b4d0

Browse files
committed
[MC] Rework AVR llvm#121498 to not add extra argument to shouldForceRelocation
This removes the extra argument from commit 814b34f. Also remove unneeded `>= FirstLiteralRelocationKind`.
1 parent b09b9ac commit 8a1b4d0

File tree

19 files changed

+27
-28
lines changed

19 files changed

+27
-28
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class MCAsmBackend {
9696
virtual bool shouldForceRelocation(const MCAssembler &Asm,
9797
const MCFixup &Fixup,
9898
const MCValue &Target,
99-
const uint64_t Value,
10099
const MCSubtargetInfo *STI) {
101100
return false;
102101
}

llvm/lib/MC/MCAssembler.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,17 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
221221
}
222222

223223
// .reloc directive and the backend might force the relocation.
224-
if (IsResolved &&
225-
(Fixup.getKind() >= FirstLiteralRelocationKind ||
226-
getBackend().shouldForceRelocation(*this, Fixup, Target, Value, STI))) {
227-
IsResolved = false;
228-
WasForced = true;
224+
// Backends that customize shouldForceRelocation generally just need the fixup
225+
// kind. AVR needs the fixup value to bypass the assembly time overflow with a
226+
// relocation.
227+
if (IsResolved) {
228+
auto TargetVal = MCValue::get(Target.getSymA(), Target.getSymB(), Value,
229+
Target.getRefKind());
230+
if (Fixup.getKind() >= FirstLiteralRelocationKind ||
231+
getBackend().shouldForceRelocation(*this, Fixup, TargetVal, STI)) {
232+
IsResolved = false;
233+
WasForced = true;
234+
}
229235
}
230236

231237
// A linker relaxation target may emit ADD/SUB relocations for A-B+C. Let

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class AArch64AsmBackend : public MCAsmBackend {
9898
unsigned getFixupKindContainereSizeInBytes(unsigned Kind) const;
9999

100100
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
101-
const MCValue &Target, const uint64_t Value,
101+
const MCValue &Target,
102102
const MCSubtargetInfo *STI) override;
103103
};
104104

@@ -520,7 +520,6 @@ bool AArch64AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
520520
bool AArch64AsmBackend::shouldForceRelocation(const MCAssembler &Asm,
521521
const MCFixup &Fixup,
522522
const MCValue &Target,
523-
const uint64_t,
524523
const MCSubtargetInfo *STI) {
525524
// The ADRP instruction adds some multiple of 0x1000 to the current PC &
526525
// ~0xfff. This means that the required offset to reach a symbol can vary by

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
955955

956956
bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
957957
const MCFixup &Fixup,
958-
const MCValue &Target, const uint64_t,
958+
const MCValue &Target,
959959
const MCSubtargetInfo *STI) {
960960
const MCSymbolRefExpr *A = Target.getSymA();
961961
const MCSymbol *Sym = A ? &A->getSymbol() : nullptr;

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ARMAsmBackend : public MCAsmBackend {
3636
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
3737

3838
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
39-
const MCValue &Target, const uint64_t Value,
39+
const MCValue &Target,
4040
const MCSubtargetInfo *STI) override;
4141

4242
unsigned adjustFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,23 +501,22 @@ bool AVRAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
501501
bool AVRAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
502502
const MCFixup &Fixup,
503503
const MCValue &Target,
504-
const uint64_t Value,
505504
const MCSubtargetInfo *STI) {
506505
switch ((unsigned)Fixup.getKind()) {
507506
default:
508-
return Fixup.getKind() >= FirstLiteralRelocationKind;
507+
return false;
509508

510509
case AVR::fixup_7_pcrel:
511510
case AVR::fixup_13_pcrel: {
512-
uint64_t ValueEx = Value;
511+
uint64_t Offset = Target.getConstant();
513512
uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize;
514513

515514
// If the jump is too large to encode it, fall back to a relocation.
516515
//
517516
// Note that trying to actually link that relocation *would* fail, but the
518517
// hopes are that the module we're currently compiling won't be actually
519518
// linked to the final binary.
520-
return !adjust::adjustRelativeBranch(Size, Fixup, ValueEx, STI);
519+
return !adjust::adjustRelativeBranch(Size, Fixup, Offset, STI);
521520
}
522521

523522
case AVR::fixup_call:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class AVRAsmBackend : public MCAsmBackend {
5353
const MCSubtargetInfo *STI) const override;
5454

5555
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
56-
const MCValue &Target, const uint64_t Value,
56+
const MCValue &Target,
5757
const MCSubtargetInfo *STI) override;
5858

5959
private:

llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ bool CSKYAsmBackend::mayNeedRelaxation(const MCInst &Inst,
262262
bool CSKYAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
263263
const MCFixup &Fixup,
264264
const MCValue &Target,
265-
const uint64_t /*Value*/,
266265
const MCSubtargetInfo * /*STI*/) {
267266
if (Fixup.getKind() >= FirstLiteralRelocationKind)
268267
return true;

llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CSKYAsmBackend : public MCAsmBackend {
5252
const MCSubtargetInfo *STI) const override;
5353

5454
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
55-
const MCValue &Target, const uint64_t Value,
55+
const MCValue &Target,
5656
const MCSubtargetInfo *STI) override;
5757

5858
std::unique_ptr<MCObjectTargetWriter>

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class HexagonAsmBackend : public MCAsmBackend {
201201
}
202202

203203
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
204-
const MCValue &Target, const uint64_t,
204+
const MCValue &Target,
205205
const MCSubtargetInfo *STI) override {
206206
switch(Fixup.getTargetKind()) {
207207
default:

0 commit comments

Comments
 (0)