Skip to content

Commit 6b2445d

Browse files
committed
[LLVM][AVR] Support for R_AVR_6 fixup
Summary: Handle the emission of `R_AVR_6` ELF relocation type. Reviewers: dylanmckay Reviewed By: dylanmckay Subscribers: hiraditya, Jim, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78721 Patch by @LemonBoy https://reviews.llvm.org/p/LemonBoy/
1 parent 93ee4da commit 6b2445d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
139139
Value &= 0xfff;
140140
}
141141

142+
/// 6-bit fixup for the immediate operand of the STD/LDD family of
143+
/// instructions.
144+
///
145+
/// Resolves to:
146+
/// 10q0 qq10 0000 1qqq
147+
static void fixup_6(const MCFixup &Fixup, uint64_t &Value,
148+
MCContext *Ctx = nullptr) {
149+
unsigned_width(6, Value, std::string("immediate"), Fixup, Ctx);
150+
151+
Value = ((Value & 0x20) << 8) | ((Value & 0x18) << 7) | (Value & 0x07);
152+
}
153+
142154
/// 6-bit fixup for the immediate operand of the ADIW family of
143155
/// instructions.
144156
///
@@ -336,6 +348,9 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
336348
Value &= 0xffff;
337349
break;
338350

351+
case AVR::fixup_6:
352+
adjust::fixup_6(Fixup, Value, Ctx);
353+
break;
339354
case AVR::fixup_6_adiw:
340355
adjust::fixup_6_adiw(Fixup, Value, Ctx);
341356
break;

llvm/test/MC/AVR/relocations.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ bar:
99
; CHECK: R_AVR_LDI SYMBOL+0x3
1010
ldi r21, SYMBOL+3
1111

12+
; CHECK: R_AVR_6 SYMBOL+0x4
13+
ldd r8, Y+SYMBOL+4
14+
1215
; CHECK-NEXT: R_AVR_6_ADIW FOO
1316
adiw r24, FOO
1417

0 commit comments

Comments
 (0)