[llvm] c41d425 - [AVR][MC] Fix illegal operand forms.
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 22 17:48:23 PST 2022
Author: Ben Shi
Date: 2022-12-23T09:48:06+08:00
New Revision: c41d425030dfd5cd84eb89b861e157821f2bf45f
URL: https://github.com/llvm/llvm-project/commit/c41d425030dfd5cd84eb89b861e157821f2bf45f
DIFF: https://github.com/llvm/llvm-project/commit/c41d425030dfd5cd84eb89b861e157821f2bf45f.diff
LOG: [AVR][MC] Fix illegal operand forms.
These operands are illegal and rejected by avr-gcc.
subi r24, -lo8(symobl+offset)
sbci r25, -hi8(symobl+offset)
And their correct form should be
subi r24, lo8(-(symobl+offset))
sbci r25, hi8(-(symobl+offset))
Reviewed By: aykevl
Differential Revision: https://reviews.llvm.org/D140473
Added:
Modified:
llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
llvm/test/CodeGen/AVR/elpm.ll
llvm/test/CodeGen/AVR/lpmx.ll
llvm/test/MC/AVR/modifiers.s
llvm/test/MC/AVR/relocations.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 5afec10e5a92f..f58d2cff24f11 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -448,32 +448,21 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
SMLoc S = Parser.getTok().getLoc();
- // Check for sign
- AsmToken tokens[2];
- size_t ReadCount = Parser.getLexer().peekTokens(tokens);
-
- if (ReadCount == 2) {
- if ((tokens[0].getKind() == AsmToken::Identifier &&
- tokens[1].getKind() == AsmToken::LParen) ||
- (tokens[0].getKind() == AsmToken::LParen &&
- tokens[1].getKind() == AsmToken::Minus)) {
+ // Reject the form in which sign comes first. This behaviour is
+ // in accordance with avr-gcc.
+ AsmToken::TokenKind CurTok = Parser.getLexer().getKind();
+ if (CurTok == AsmToken::Minus || CurTok == AsmToken::Plus)
+ return true;
- AsmToken::TokenKind CurTok = Parser.getLexer().getKind();
- if (CurTok == AsmToken::Minus || tokens[1].getKind() == AsmToken::Minus) {
+ // Check for sign.
+ AsmToken tokens[2];
+ if (Parser.getLexer().peekTokens(tokens) == 2)
+ if (tokens[0].getKind() == AsmToken::LParen &&
+ tokens[1].getKind() == AsmToken::Minus)
isNegated = true;
- } else {
- assert(CurTok == AsmToken::Plus);
- isNegated = false;
- }
-
- // Eat the sign
- if (CurTok == AsmToken::Minus || CurTok == AsmToken::Plus)
- Parser.Lex();
- }
- }
// Check if we have a target specific modifier (lo8, hi8, &c)
- if (Parser.getTok().getKind() != AsmToken::Identifier ||
+ if (CurTok != AsmToken::Identifier ||
Parser.getLexer().peekTok().getKind() != AsmToken::LParen) {
// Not a reloc expr
return true;
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
index 7e735ffa6cec1..d6b6546acb636 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
@@ -42,12 +42,12 @@ const AVRMCExpr *AVRMCExpr::create(VariantKind Kind, const MCExpr *Expr,
void AVRMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
assert(Kind != VK_AVR_None);
-
- if (isNegated())
- OS << '-';
-
OS << getName() << '(';
+ if (isNegated())
+ OS << '-' << '(';
getSubExpr()->print(OS, MAI);
+ if (isNegated())
+ OS << ')';
OS << ')';
}
diff --git a/llvm/test/CodeGen/AVR/elpm.ll b/llvm/test/CodeGen/AVR/elpm.ll
index a18f133e083c4..a322ab773014a 100644
--- a/llvm/test/CodeGen/AVR/elpm.ll
+++ b/llvm/test/CodeGen/AVR/elpm.ll
@@ -10,15 +10,15 @@ define i16 @foo0(i16 %a, i16 %b) {
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: lsl r22
; CHECK-NEXT: rol r23
-; CHECK-NEXT: subi r22, -lo8(arr0)
-; CHECK-NEXT: sbci r23, -hi8(arr0)
+; CHECK-NEXT: subi r22, lo8(-(arr0))
+; CHECK-NEXT: sbci r23, hi8(-(arr0))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: lpm r18, Z+
; CHECK-NEXT: lpm r19, Z
; CHECK-NEXT: lsl r24
; CHECK-NEXT: rol r25
-; CHECK-NEXT: subi r24, -lo8(arr0)
-; CHECK-NEXT: sbci r25, -hi8(arr0)
+; CHECK-NEXT: subi r24, lo8(-(arr0))
+; CHECK-NEXT: sbci r25, hi8(-(arr0))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: lpm r24, Z+
; CHECK-NEXT: lpm r25, Z
@@ -39,8 +39,8 @@ define i16 @foo1(i16 %a, i16 %b) {
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: lsl r22
; CHECK-NEXT: rol r23
-; CHECK-NEXT: subi r22, -lo8(arr1)
-; CHECK-NEXT: sbci r23, -hi8(arr1)
+; CHECK-NEXT: subi r22, lo8(-(arr1))
+; CHECK-NEXT: sbci r23, hi8(-(arr1))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: ldi r18, 1
; CHECK-NEXT: out 59, r18
@@ -48,8 +48,8 @@ define i16 @foo1(i16 %a, i16 %b) {
; CHECK-NEXT: elpm r21, Z
; CHECK-NEXT: lsl r24
; CHECK-NEXT: rol r25
-; CHECK-NEXT: subi r24, -lo8(arr0)
-; CHECK-NEXT: sbci r25, -hi8(arr0)
+; CHECK-NEXT: subi r24, lo8(-(arr0))
+; CHECK-NEXT: sbci r25, hi8(-(arr0))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: lpm r24, Z+
; CHECK-NEXT: lpm r25, Z
@@ -70,8 +70,8 @@ define i16 @foo2(i16 %a, i16 %b) {
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: lsl r24
; CHECK-NEXT: rol r25
-; CHECK-NEXT: subi r24, -lo8(arr2)
-; CHECK-NEXT: sbci r25, -hi8(arr2)
+; CHECK-NEXT: subi r24, lo8(-(arr2))
+; CHECK-NEXT: sbci r25, hi8(-(arr2))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: ldi r18, 2
; CHECK-NEXT: out 59, r18
@@ -79,8 +79,8 @@ define i16 @foo2(i16 %a, i16 %b) {
; CHECK-NEXT: elpm r25, Z
; CHECK-NEXT: lsl r22
; CHECK-NEXT: rol r23
-; CHECK-NEXT: subi r22, -lo8(arr0)
-; CHECK-NEXT: sbci r23, -hi8(arr0)
+; CHECK-NEXT: subi r22, lo8(-(arr0))
+; CHECK-NEXT: sbci r23, hi8(-(arr0))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: lpm r18, Z+
; CHECK-NEXT: lpm r19, Z
@@ -101,8 +101,8 @@ define i16 @foo3(i16 %a, i16 %b) {
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: lsl r22
; CHECK-NEXT: rol r23
-; CHECK-NEXT: subi r22, -lo8(arr1)
-; CHECK-NEXT: sbci r23, -hi8(arr1)
+; CHECK-NEXT: subi r22, lo8(-(arr1))
+; CHECK-NEXT: sbci r23, hi8(-(arr1))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: ldi r18, 1
; CHECK-NEXT: out 59, r18
@@ -110,8 +110,8 @@ define i16 @foo3(i16 %a, i16 %b) {
; CHECK-NEXT: elpm r21, Z
; CHECK-NEXT: lsl r24
; CHECK-NEXT: rol r25
-; CHECK-NEXT: subi r24, -lo8(arr2)
-; CHECK-NEXT: sbci r25, -hi8(arr2)
+; CHECK-NEXT: subi r24, lo8(-(arr2))
+; CHECK-NEXT: sbci r25, hi8(-(arr2))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: ldi r18, 2
; CHECK-NEXT: out 59, r18
@@ -136,12 +136,12 @@ entry:
define signext i8 @foob0(i16 %a, i16 %b) {
; CHECK-LABEL: foob0:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: subi r22, -lo8(arrb1)
-; CHECK-NEXT: sbci r23, -hi8(arrb1)
+; CHECK-NEXT: subi r22, lo8(-(arrb1))
+; CHECK-NEXT: sbci r23, hi8(-(arrb1))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: lpm r18, Z
-; CHECK-NEXT: subi r24, -lo8(arrb1)
-; CHECK-NEXT: sbci r25, -hi8(arrb1)
+; CHECK-NEXT: subi r24, lo8(-(arrb1))
+; CHECK-NEXT: sbci r25, hi8(-(arrb1))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: lpm r24, Z
; CHECK-NEXT: sub r24, r18
@@ -161,14 +161,14 @@ entry:
define signext i8 @foob1(i16 %a, i16 %b) {
; CHECK-LABEL: foob1:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: subi r22, -lo8(arrb3)
-; CHECK-NEXT: sbci r23, -hi8(arrb3)
+; CHECK-NEXT: subi r22, lo8(-(arrb3))
+; CHECK-NEXT: sbci r23, hi8(-(arrb3))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: ldi r18, 2
; CHECK-NEXT: out 59, r18
; CHECK-NEXT: elpm r18, Z
-; CHECK-NEXT: subi r24, -lo8(arrb1)
-; CHECK-NEXT: sbci r25, -hi8(arrb1)
+; CHECK-NEXT: subi r24, lo8(-(arrb1))
+; CHECK-NEXT: sbci r25, hi8(-(arrb1))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: lpm r24, Z
; CHECK-NEXT: sub r24, r18
@@ -188,14 +188,14 @@ entry:
define signext i8 @foob2(i16 %a, i16 %b) {
; CHECK-LABEL: foob2:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: subi r24, -lo8(arrb5)
-; CHECK-NEXT: sbci r25, -hi8(arrb5)
+; CHECK-NEXT: subi r24, lo8(-(arrb5))
+; CHECK-NEXT: sbci r25, hi8(-(arrb5))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: ldi r24, 4
; CHECK-NEXT: out 59, r24
; CHECK-NEXT: elpm r24, Z
-; CHECK-NEXT: subi r22, -lo8(arrb1)
-; CHECK-NEXT: sbci r23, -hi8(arrb1)
+; CHECK-NEXT: subi r22, lo8(-(arrb1))
+; CHECK-NEXT: sbci r23, hi8(-(arrb1))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: lpm r25, Z
; CHECK-NEXT: sub r24, r25
@@ -215,14 +215,14 @@ entry:
define signext i8 @foob3(i16 %a, i16 %b) {
; CHECK-LABEL: foob3:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: subi r22, -lo8(arrb5)
-; CHECK-NEXT: sbci r23, -hi8(arrb5)
+; CHECK-NEXT: subi r22, lo8(-(arrb5))
+; CHECK-NEXT: sbci r23, hi8(-(arrb5))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: ldi r18, 4
; CHECK-NEXT: out 59, r18
; CHECK-NEXT: elpm r18, Z
-; CHECK-NEXT: subi r24, -lo8(arrb3)
-; CHECK-NEXT: sbci r25, -hi8(arrb3)
+; CHECK-NEXT: subi r24, lo8(-(arrb3))
+; CHECK-NEXT: sbci r25, hi8(-(arrb3))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: ldi r24, 2
; CHECK-NEXT: out 59, r24
@@ -244,14 +244,14 @@ entry:
define signext i8 @foob4(i16 %a, i16 %b) {
; CHECK-LABEL: foob4:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: subi r22, -lo8(arrb3)
-; CHECK-NEXT: sbci r23, -hi8(arrb3)
+; CHECK-NEXT: subi r22, lo8(-(arrb3))
+; CHECK-NEXT: sbci r23, hi8(-(arrb3))
; CHECK-NEXT: movw r30, r22
; CHECK-NEXT: ldi r18, 2
; CHECK-NEXT: out 59, r18
; CHECK-NEXT: elpm r19, Z
-; CHECK-NEXT: subi r24, -lo8(arrb3)
-; CHECK-NEXT: sbci r25, -hi8(arrb3)
+; CHECK-NEXT: subi r24, lo8(-(arrb3))
+; CHECK-NEXT: sbci r25, hi8(-(arrb3))
; CHECK-NEXT: movw r30, r24
; CHECK-NEXT: out 59, r18
; CHECK-NEXT: elpm r24, Z
diff --git a/llvm/test/CodeGen/AVR/lpmx.ll b/llvm/test/CodeGen/AVR/lpmx.ll
index c5162e2efb503..e84caf40d0709 100644
--- a/llvm/test/CodeGen/AVR/lpmx.ll
+++ b/llvm/test/CodeGen/AVR/lpmx.ll
@@ -26,8 +26,8 @@ define i16 @foo0(i16 %a) addrspace(1) {
; CHECK-O0-NEXT: ldd r31, Y+2
; CHECK-O0-NEXT: lsl r30
; CHECK-O0-NEXT: rol r31
-; CHECK-O0-NEXT: subi r30, -lo8(arr0)
-; CHECK-O0-NEXT: sbci r31, -hi8(arr0)
+; CHECK-O0-NEXT: subi r30, lo8(-(arr0))
+; CHECK-O0-NEXT: sbci r31, hi8(-(arr0))
; CHECK-O0-NEXT: lpm r24, Z+
; CHECK-O0-NEXT: lpm r25, Z
; CHECK-O0-NEXT: adiw r28, 2
@@ -56,8 +56,8 @@ define i16 @foo0(i16 %a) addrspace(1) {
; CHECK-O3-NEXT: std Y+2, r25
; CHECK-O3-NEXT: lsl r24
; CHECK-O3-NEXT: rol r25
-; CHECK-O3-NEXT: subi r24, -lo8(arr0)
-; CHECK-O3-NEXT: sbci r25, -hi8(arr0)
+; CHECK-O3-NEXT: subi r24, lo8(-(arr0))
+; CHECK-O3-NEXT: sbci r25, hi8(-(arr0))
; CHECK-O3-NEXT: movw r30, r24
; CHECK-O3-NEXT: lpm r24, Z+
; CHECK-O3-NEXT: lpm r25, Z
@@ -96,8 +96,8 @@ define i8 @foo1(i16 %a) addrspace(1) {
; CHECK-O0-NEXT: std Y+2, r25
; CHECK-O0-NEXT: ldd r30, Y+1
; CHECK-O0-NEXT: ldd r31, Y+2
-; CHECK-O0-NEXT: subi r30, -lo8(arr1)
-; CHECK-O0-NEXT: sbci r31, -hi8(arr1)
+; CHECK-O0-NEXT: subi r30, lo8(-(arr1))
+; CHECK-O0-NEXT: sbci r31, hi8(-(arr1))
; CHECK-O0-NEXT: lpm r24, Z
; CHECK-O0-NEXT: adiw r28, 2
; CHECK-O0-NEXT: in r0, 63
@@ -123,8 +123,8 @@ define i8 @foo1(i16 %a) addrspace(1) {
; CHECK-O3-NEXT: out 61, r28
; CHECK-O3-NEXT: std Y+1, r24
; CHECK-O3-NEXT: std Y+2, r25
-; CHECK-O3-NEXT: subi r24, -lo8(arr1)
-; CHECK-O3-NEXT: sbci r25, -hi8(arr1)
+; CHECK-O3-NEXT: subi r24, lo8(-(arr1))
+; CHECK-O3-NEXT: sbci r25, hi8(-(arr1))
; CHECK-O3-NEXT: movw r30, r24
; CHECK-O3-NEXT: lpm r24, Z
; CHECK-O3-NEXT: adiw r28, 2
diff --git a/llvm/test/MC/AVR/modifiers.s b/llvm/test/MC/AVR/modifiers.s
index cc1935cf9cbed..592c6ac125c33 100644
--- a/llvm/test/MC/AVR/modifiers.s
+++ b/llvm/test/MC/AVR/modifiers.s
@@ -42,12 +42,12 @@ lo8:
lo8_neg:
- ldi r24, -lo8(123456)
- ldi r24, -lo8(foo)
+ ldi r24, lo8(-(123456))
+ ldi r24, lo8(-(foo))
-; CHECK: ldi r24, -lo8(123456) ; encoding: [0x80,0xec]
-; CHECK: ldi r24, -lo8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -lo8(foo), kind: fixup_lo8_ldi_neg
+; CHECK: ldi r24, lo8(-(123456)) ; encoding: [0x80,0xec]
+; CHECK: ldi r24, lo8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: lo8(-(foo)), kind: fixup_lo8_ldi_neg
hi8:
@@ -63,12 +63,12 @@ hi8:
hi8_neg:
- ldi r24, -hi8(123456)
- ldi r24, -hi8(foo)
+ ldi r24, hi8(-(123456))
+ ldi r24, hi8(-(foo))
-; CHECK: ldi r24, -hi8(123456) ; encoding: [0x8d,0xe1]
-; CHECK: ldi r24, -hi8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -hi8(foo), kind: fixup_hi8_ldi_neg
+; CHECK: ldi r24, hi8(-(123456)) ; encoding: [0x8d,0xe1]
+; CHECK: ldi r24, hi8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: hi8(-(foo)), kind: fixup_hi8_ldi_neg
hh8:
@@ -84,12 +84,12 @@ hh8:
hh8_neg:
- ldi r24, -hh8(123456)
- ldi r24, -hh8(foo)
+ ldi r24, hh8(-(123456))
+ ldi r24, hh8(-(foo))
-; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef]
-; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg
+; CHECK: ldi r24, hh8(-(123456)) ; encoding: [0x8e,0xef]
+; CHECK: ldi r24, hh8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: hh8(-(foo)), kind: fixup_hh8_ldi_neg
hlo8: ; synonym with hh8() above, hence the... odd results
@@ -105,13 +105,13 @@ hlo8: ; synonym with hh8() above, hence the... odd results
hlo8_neg:
- ldi r24, -hlo8(123456)
- ldi r24, -hlo8(foo)
+ ldi r24, hlo8(-(123456))
+ ldi r24, hlo8(-(foo))
-; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef]
-; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg
+; CHECK: ldi r24, hh8(-(123456)) ; encoding: [0x8e,0xef]
+; CHECK: ldi r24, hh8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: hh8(-(foo)), kind: fixup_hh8_ldi_neg
hhi8:
@@ -126,13 +126,13 @@ hhi8:
; CHECK: ; fixup A - offset: 0, value: hhi8(bar+5), kind: fixup_ms8_ldi
hhi8_neg:
- ldi r24, -hhi8(123456)
- ldi r24, -hhi8(foo)
+ ldi r24, hhi8(-(123456))
+ ldi r24, hhi8(-(foo))
-; CHECK: ldi r24, -hhi8(123456) ; encoding: [0x8f,0xef]
-; CHECK: ldi r24, -hhi8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -hhi8(foo), kind: fixup_ms8_ldi_neg
+; CHECK: ldi r24, hhi8(-(123456)) ; encoding: [0x8f,0xef]
+; CHECK: ldi r24, hhi8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: hhi8(-(foo)), kind: fixup_ms8_ldi_neg
pm_lo8:
ldi r24, pm_lo8(0x0815)
@@ -169,35 +169,34 @@ pm_hh8:
pm_lo8_neg:
- ldi r24, -pm_lo8(0x0815)
- ldi r24, -pm_lo8(foo)
- ldi r24, -pm_lo8(bar + 5)
+ ldi r24, pm_lo8(-(0x0815))
+ ldi r24, pm_lo8(-(foo))
+ ldi r24, pm_lo8(-(bar + 5))
-; CHECK: ldi r24, -pm_lo8(2069) ; encoding: [0x85,0xef]
-; CHECK: ldi r24, -pm_lo8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_lo8(foo), kind: fixup_lo8_ldi_pm_neg
-; CHECK: ldi r24, -pm_lo8(bar+5) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_lo8(bar+5), kind: fixup_lo8_ldi_pm_neg
+; CHECK: ldi r24, pm_lo8(-(2069)) ; encoding: [0x85,0xef]
+; CHECK: ldi r24, pm_lo8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_lo8(-(foo)), kind: fixup_lo8_ldi_pm_neg
+; CHECK: ldi r24, pm_lo8(-(bar+5)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_lo8(-(bar+5)), kind: fixup_lo8_ldi_pm_neg
pm_hi8_neg:
- ldi r24, -pm_hi8(0x0815)
- ldi r24, -pm_hi8(foo)
- ldi r24, -pm_hi8(bar + 5)
+ ldi r24, pm_hi8(-(0x0815))
+ ldi r24, pm_hi8(-(foo))
+ ldi r24, pm_hi8(-(bar + 5))
-; CHECK: ldi r24, -pm_hi8(2069) ; encoding: [0x8b,0xef]
-; CHECK: ldi r24, -pm_hi8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_hi8(foo), kind: fixup_hi8_ldi_pm_neg
-; CHECK: ldi r24, -pm_hi8(bar+5) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_hi8(bar+5), kind: fixup_hi8_ldi_pm_neg
+; CHECK: ldi r24, pm_hi8(-(2069)) ; encoding: [0x8b,0xef]
+; CHECK: ldi r24, pm_hi8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_hi8(-(foo)), kind: fixup_hi8_ldi_pm_neg
+; CHECK: ldi r24, pm_hi8(-(bar+5)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_hi8(-(bar+5)), kind: fixup_hi8_ldi_pm_neg
pm_hh8_neg:
- ldi r24, -pm_hh8(0x0815)
- ldi r24, -pm_hh8(foo)
- ldi r24, -pm_hh8(bar + 5)
-
-; CHECK: ldi r24, -pm_hh8(2069) ; encoding: [0x8f,0xef]
-; CHECK: ldi r24, -pm_hh8(foo) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_hh8(foo), kind: fixup_hh8_ldi_pm_neg
-; CHECK: ldi r24, -pm_hh8(bar+5) ; encoding: [0x80'A',0xe0]
-; CHECK: ; fixup A - offset: 0, value: -pm_hh8(bar+5), kind: fixup_hh8_ldi_pm_neg
-
+ ldi r24, pm_hh8(-(0x0815))
+ ldi r24, pm_hh8(-(foo))
+ ldi r24, pm_hh8(-(bar + 5))
+
+; CHECK: ldi r24, pm_hh8(-(2069)) ; encoding: [0x8f,0xef]
+; CHECK: ldi r24, pm_hh8(-(foo)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_hh8(-(foo)), kind: fixup_hh8_ldi_pm_neg
+; CHECK: ldi r24, pm_hh8(-(bar+5)) ; encoding: [0x80'A',0xe0]
+; CHECK: ; fixup A - offset: 0, value: pm_hh8(-(bar+5)), kind: fixup_hh8_ldi_pm_neg
diff --git a/llvm/test/MC/AVR/relocations.s b/llvm/test/MC/AVR/relocations.s
index 074823f7c71de..ffc7ba8b8ff7e 100644
--- a/llvm/test/MC/AVR/relocations.s
+++ b/llvm/test/MC/AVR/relocations.s
@@ -35,98 +35,66 @@ brcs foo+2
; CHECK-NEXT: R_AVR_LO8_LDI bar+0x3
; CHECK-NEXT: R_AVR_LO8_LDI abc
-; CHECK-NEXT: R_AVR_LO8_LDI abc
ldi r24, lo8(bar+3)
-ldi r16, +lo8(abc)
ldi r16, lo8(+(abc))
-; CHECK-NEXT: R_AVR_HI8_LDI abc
; CHECK-NEXT: R_AVR_HI8_LDI abc
; CHECK-NEXT: R_AVR_HI8_LDI abc
ldi r30, hi8(abc)
-ldi r16, +hi8(abc)
ldi r16, hi8(+(abc))
; CHECK-NEXT: R_AVR_LO8_LDI_NEG abc
-; CHECK-NEXT: R_AVR_LO8_LDI_NEG abc
-ldi r16, -lo8(abc)
ldi r16, lo8(-(abc))
; CHECK-NEXT: R_AVR_HI8_LDI_NEG abc
-; CHECK-NEXT: R_AVR_HI8_LDI_NEG abc
-ldi r16, -hi8(abc)
ldi r16, hi8(-(abc))
-; CHECK-NEXT: R_AVR_HH8_LDI foo
; CHECK-NEXT: R_AVR_HH8_LDI foo
; CHECK-NEXT: R_AVR_HH8_LDI foo
ldi r16, hh8(foo)
-ldi r16, +hh8(foo)
ldi r16, hh8(+(foo))
; CHECK-NEXT: R_AVR_HH8_LDI_NEG foo
-; CHECK-NEXT: R_AVR_HH8_LDI_NEG foo
-ldi r16, -hh8(foo)
ldi r16, hh8(-(foo))
-; CHECK-NEXT: R_AVR_HH8_LDI foo
; CHECK-NEXT: R_AVR_HH8_LDI foo
; CHECK-NEXT: R_AVR_HH8_LDI foo
ldi r24, hlo8(foo)
-ldi r24, +hlo8(foo)
ldi r24, hlo8(+(foo))
; CHECK-NEXT: R_AVR_HH8_LDI_NEG foo
-; CHECK-NEXT: R_AVR_HH8_LDI_NEG foo
-ldi r24, -hlo8(foo)
ldi r24, hlo8(-(foo))
-; CHECK-NEXT: R_AVR_MS8_LDI bar
; CHECK-NEXT: R_AVR_MS8_LDI bar
; CHECK-NEXT: R_AVR_MS8_LDI bar
ldi r24, hhi8(bar)
-ldi r24, +hhi8(bar)
ldi r24, hhi8(+(bar))
; CHECK-NEXT: R_AVR_MS8_LDI_NEG bar
-; CHECK-NEXT: R_AVR_MS8_LDI_NEG bar
-ldi r24, -hhi8(bar)
ldi r24, hhi8(-(bar))
-; CHECK-NEXT: R_AVR_LO8_LDI_PM foo
; CHECK-NEXT: R_AVR_LO8_LDI_PM foo
; CHECK-NEXT: R_AVR_LO8_LDI_PM foo
ldi r17, pm_lo8(foo)
-ldi r25, +pm_lo8(foo)
ldi r25, pm_lo8(+(foo))
; CHECK-NEXT: R_AVR_HI8_LDI_PM bar
; CHECK-NEXT: R_AVR_HI8_LDI_PM foo
-; CHECK-NEXT: R_AVR_HI8_LDI_PM foo
ldi r22, pm_hi8(bar)
-ldi r25, +pm_hi8(foo)
ldi r25, pm_hi8(+(foo))
; CHECK-NEXT: R_AVR_HH8_LDI_PM baz
; CHECK-NEXT: R_AVR_HH8_LDI_PM foo
-; CHECK-NEXT: R_AVR_HH8_LDI_PM foo
ldi r25, pm_hh8(baz)
-ldi r25, +pm_hh8(foo)
ldi r25, pm_hh8(+(foo))
; CHECK-NEXT: R_AVR_LO8_LDI_PM_NEG foo
-; CHECK-NEXT: R_AVR_LO8_LDI_PM_NEG foo
-ldi r25, -pm_lo8(foo)
ldi r25, pm_lo8(-(foo))
; CHECK-NEXT: R_AVR_HI8_LDI_PM_NEG foo
-; CHECK-NEXT: R_AVR_HI8_LDI_PM_NEG foo
-ldi r25, -pm_hi8(foo)
ldi r25, pm_hi8(-(foo))
; CHECK-NEXT: R_AVR_HH8_LDI_PM_NEG foo
-; CHECK-NEXT: R_AVR_HH8_LDI_PM_NEG foo
-ldi r25, -pm_hh8(foo)
ldi r25, pm_hh8(-(foo))
; CHECK-NEXT: R_AVR_LO8_LDI_GS foo
More information about the llvm-commits
mailing list