[AVR] Fix inaccurate offsets in PC relative branch instructions
authorBen Shi <powerman1st@163.com>
Mon, 13 Feb 2023 11:46:02 +0000 (19:46 +0800)
committerBen Shi <powerman1st@163.com>
Tue, 14 Feb 2023 08:22:14 +0000 (16:22 +0800)
commit697a162fa63df328ec9ca334636c5e85390b2bf0
tree4a2bb69d1df79b6407a41de8b657ea9dd72f1e60
parent1e6921131aa46fae65344f057c6bb40610a43443
[AVR] Fix inaccurate offsets in PC relative branch instructions

In avr-gcc, the destination of "rjmp label + offset" is address
'label + offset', while destination of "rjmp . + offset" is
'address_of_rjmp + offset + 2'.

Clang is in accordance with avr-gcc for "rjmp label + offset", but
emits incorrect destination of "rjmp . + offset" to
'address_of_rjmp + offset', in which the expected offset 2 is missing.

This patch fixes the above issue.

Fixes https://github.com/llvm/llvm-project/issues/60019

Reviewed By: jacquesguan, aykevl

Differential Revision: https://reviews.llvm.org/D143901
llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
llvm/test/MC/AVR/inst-brbc.s
llvm/test/MC/AVR/inst-brbs.s
llvm/test/MC/AVR/inst-family-cond-branch.s
llvm/test/MC/AVR/inst-rcall.s
llvm/test/MC/AVR/inst-rjmp.s