Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / avr-reloc.s
blob172c0e03ba74b81b85e1b17eb3cd6755c9d82019
1 ; REQUIRES: avr
2 ; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=atmega328p %s -o %t0.o
3 ; RUN: ld.lld %t0.o --defsym=a=0x12345678 --defsym=b=30 --defsym=c=0x15554 -o %t0
4 ; RUN: llvm-objdump -d --print-imm-hex --mcpu=atmega328p %t0 | \
5 ; RUN: FileCheck --check-prefixes=CHECK,AVR %s
6 ; RUN: llvm-objdump -s --mcpu=atmega328p %t0 | \
7 ; RUN: FileCheck --check-prefixes=HEX,AVRHEX %s
8 ; RUN: llvm-mc -filetype=obj -triple=avr -mcpu=attiny10 %s --defsym=TINY=1 -o %t1.o
9 ; RUN: ld.lld %t1.o --defsym=a=0x12345678 --defsym=b=30 --defsym=c=0x15554 -o %t1
10 ; RUN: llvm-objdump -d --print-imm-hex --mcpu=attiny10 %t1 | FileCheck %s
11 ; RUN: llvm-objdump -s --mcpu=attiny10 %t1 | \
12 ; RUN: FileCheck --check-prefixes=HEX,TINYHEX %s
14 .section .LDI,"ax",@progbits
15 ; CHECK-LABEL: section .LDI:
16 ; CHECK: ldi r20, 0x78
17 ; CHECK-NEXT: ldi r20, 0x56
18 ; CHECK-NEXT: ldi r20, 0x34
19 ; CHECK-NEXT: ldi r20, 0x12
20 ; CHECK-NEXT: ldi r20, 0x3c
21 ; CHECK-NEXT: ldi r20, 0x2b
22 ; CHECK-NEXT: ldi r20, 0x1a
23 ; CHECK-NEXT: ldi r20, 0xaa
24 ; CHECK-NEXT: ldi r20, 0xaa
25 ; CHECK-NEXT: ldi r20, 0xff
27 ldi r20, lo8(a) ; R_AVR_LO8_LDI
28 ldi r20, hi8(a) ; R_AVR_HI8_LDI
29 ldi r20, hh8(a) ; R_AVR_HH8_LDI
30 ldi r20, hhi8(a) ; R_AVR_MS8_LDI
32 ldi r20, pm_lo8(a) ; R_AVR_LO8_LDI_PM
33 ldi r20, pm_hi8(a) ; R_AVR_HI8_LDI_PM
34 ldi r20, pm_hh8(a) ; R_AVR_HH8_LDI_PM
36 ldi r20, lo8_gs(c) ; R_AVR_LO8_LDI_GS
37 ldi r20, hi8_gs(c) ; R_AVR_HI8_LDI_GS
39 ldi r20, b+225
41 .section .LDI_NEG,"ax",@progbits
42 ; CHECK-LABEL: section .LDI_NEG:
43 ; CHECK: ldi r20, 0x88
44 ; CHECK-NEXT: ldi r20, 0xa9
45 ; CHECK-NEXT: ldi r20, 0xcb
46 ; CHECK-NEXT: ldi r20, 0xed
47 ; CHECK-NEXT: ldi r20, 0xc4
48 ; CHECK-NEXT: ldi r20, 0xd4
49 ; CHECK-NEXT: ldi r20, 0xe5
50 ldi r20, lo8(-(a)) ; R_AVR_LO8_LDI_NEG
51 ldi r20, hi8(-(a)) ; R_AVR_HI8_LDI_NEG
52 ldi r20, hh8(-(a)) ; R_AVR_HH8_LDI_NEG
53 ldi r20, hhi8(-(a)) ; R_AVR_MS8_LDI_NEG
55 ldi r20, pm_lo8(-(a)) ; R_AVR_LO8_LDI_PM_NEG
56 ldi r20, pm_hi8(-(a)) ; R_AVR_HI8_LDI_PM_NEG
57 ldi r20, pm_hh8(-(a)) ; R_AVR_HH8_LDI_PM_NEG
59 .ifndef TINY
60 .section .SIX,"ax",@progbits
61 ; AVR-LABEL: section .SIX:
62 ; AVR: std Y+30, r9
63 ; AVR-NEXT: ldd r9, Y+30
64 ; AVR-NEXT: adiw r24, 0x1e
65 ; AVRHEX-LABEL: section .SIX:
66 ; AVRHEX-NEXT: 9e8e9e8c 4e96
67 std Y+b, r9 ; R_AVR_6
68 ldd r9, Y+b ; R_AVR_6
69 adiw r24, b ; R_AVR_6_ADIW
70 .endif
72 .section .PORT,"ax",@progbits
73 ; CHECK-LABEL: section .PORT:
74 ; CHECK: in r20, 0x1e
75 ; CHECK-NEXT: sbic 0x1e, 0x1
76 in r20, b ; R_AVR_PORT6
77 sbic b, 1 ; R_AVR_PORT5
79 .section .PCREL,"ax",@progbits
80 ; CHECK-LABEL: section .PCREL
81 ; CHECK: rjmp .+30
82 ; CHECK-NEXT: rjmp .-36
83 ; CHECK-NEXT: breq .+26
84 ; CHECK-NEXT: breq .-40
85 ; HEX-LABEL: section .PCREL:
86 ; HEX-NEXT: 0fc0eecf 69f061f3
87 foo:
88 rjmp foo + 32 ; R_AVR_13_PCREL
89 rjmp foo - 32 ; R_AVR_13_PCREL
90 breq foo + 32 ; R_AVR_7_PCREL
91 breq foo - 32 ; R_AVR_7_PCREL
93 .section .LDSSTS,"ax",@progbits
94 ; CHECK-LABEL: section .LDSSTS:
95 ; CHECK: lds r20, 0x1e
96 ; CHECK-NEXT: sts 0x1e, r21
97 ; HEX-LABEL: section .LDSSTS:
98 ; AVRHEX: {{.*}} 40911e00 50931e00
99 ; TINYHEX: {{.*}} 4ea15ea9
100 lds r20, b
101 sts b, r21
103 .section .DATA,"ax",@progbits
104 ; HEX-LABEL: section .DATA:
105 ; HEX-NEXT: {{.*}} 1e1e000f 00785634 12785634
106 .byte b ; R_AVR_8
107 .short b ; R_AVR_16
108 .short gs(b) ; R_AVR_16_PM
109 .long a ; R_AVR_32
110 .byte lo8(a) ; R_AVR_8_LO8
111 .byte hi8(a) ; R_AVR_8_HI8
112 .byte hlo8(a) ; R_AVR_8_HLO8