[PATCH] D74213: [AVR] Don't adjust addresses by 2 for absolute values
Ayke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 06:46:35 PST 2020
aykevl updated this revision to Diff 246434.
aykevl edited the summary of this revision.
aykevl added a comment.
I found a way to test at least the case where the value should not be shifted. If it is shifted, the instruction becomes something other than a `nop`.
For the other case (when the value should be shifted), the AVR backend needs to be able to disassemble branch instructions.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74213/new/
https://reviews.llvm.org/D74213
Files:
llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
llvm/test/MC/AVR/relocations-abs.s
Index: llvm/test/MC/AVR/relocations-abs.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AVR/relocations-abs.s
@@ -0,0 +1,8 @@
+; RUN: llvm-mc -filetype=obj -triple=avr %s | llvm-objdump -dr - | FileCheck %s
+
+; CHECK: bar:
+; CHECK-NEXT: 00 00 nop
+; CHECK-NEXT: R_AVR_16 .text+0x2
+bar:
+ .short 1f
+1:
Index: llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
===================================================================
--- llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
+++ llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
@@ -244,8 +244,18 @@
// To handle both cases, we simply un-adjust the temporary label
// case so it acts like all other labels.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
- if (A->getSymbol().isTemporary())
- Value += 2;
+ if (A->getSymbol().isTemporary()) {
+ switch (Kind) {
+ case FK_Data_1:
+ case FK_Data_2:
+ case FK_Data_4:
+ case FK_Data_8:
+ // Don't shift value for absolute addresses.
+ break;
+ default:
+ Value += 2;
+ }
+ }
}
switch (Kind) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74213.246434.patch
Type: text/x-patch
Size: 1148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200225/105c8857/attachment.bin>
More information about the llvm-commits
mailing list