Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[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/
  • Loading branch information
dylanmckay committed Jun 23, 2020
commit 6b2445d841e4c6947b718d0832d2c9c4de646a68
15 changes: 15 additions & 0 deletions llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
Value &= 0xfff;
}

/// 6-bit fixup for the immediate operand of the STD/LDD family of
/// instructions.
///
/// Resolves to:
/// 10q0 qq10 0000 1qqq
static void fixup_6(const MCFixup &Fixup, uint64_t &Value,
MCContext *Ctx = nullptr) {
unsigned_width(6, Value, std::string("immediate"), Fixup, Ctx);

Value = ((Value & 0x20) << 8) | ((Value & 0x18) << 7) | (Value & 0x07);
}

/// 6-bit fixup for the immediate operand of the ADIW family of
/// instructions.
///
Expand Down Expand Up @@ -336,6 +348,9 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
Value &= 0xffff;
break;

case AVR::fixup_6:
adjust::fixup_6(Fixup, Value, Ctx);
break;
case AVR::fixup_6_adiw:
adjust::fixup_6_adiw(Fixup, Value, Ctx);
break;
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/MC/AVR/relocations.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ bar:
; CHECK: R_AVR_LDI SYMBOL+0x3
ldi r21, SYMBOL+3

; CHECK: R_AVR_6 SYMBOL+0x4
ldd r8, Y+SYMBOL+4

; CHECK-NEXT: R_AVR_6_ADIW FOO
adiw r24, FOO

Expand Down