Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / hexagon.s
blob8ef9b8eead8f19d6917aba3e84d13c59e285a69f
1 # REQUIRES: hexagon
2 # RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon.s -o %t1.o
4 # RUN: ld.lld %t.o %t1.o -o %t
5 # RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck %s
7 # Note: 131584 == 0x20200
8 # R_HEX_32_6_X
9 # R_HEX_12_X
10 if (p0) r0 = ##_start
11 # CHECK: immext(#131584)
12 # CHECK: if (p0) r0 = ##131644
14 # R_HEX_B15_PCREL
15 if (p0) jump:nt #_start
16 # CHECK: if (p0) jump:nt 0x2023c
18 # R_HEX_B32_PCREL_X
19 # R_HEX_B15_PCREL_X
20 if (p0) jump:nt ##_start
21 # CHECK: if (p0) jump:nt 0x2023c
23 # R_HEX_B22_PCREL
24 call #_start
25 # CHECK: call 0x2023c
27 # R_HEX_B32_PCREL_X
28 # R_HEX_B22_PCREL_X
29 call ##_start
30 # CHECK: immext(#320)
31 # CHECK: call 0x2023c
33 # R_HEX_6_X tests:
34 # One test for each mask in the lookup table.
36 #0x38000000
37 if (!P0) memw(r0+#8)=##_start
38 # CHECK: 38c0e11c if (!p0) memw(r0+#8) = ##131644 }
40 #0x39000000
41 { p0 = p1
42 if (!P0.new) memw(r0+#0)=##_start }
43 # CHECK: 39c0e01c if (!p0.new) memw(r0+#0) = ##131644 }
45 #0x3e000000
46 memw(r0+##_start)+=r1
47 # CHECK: 3e40de01 memw(r0+##131644) += r1 }
49 #0x3f000000
50 memw(r0+##_start)+=#4
51 # CHECK: 3f40de04 memw(r0+##131644) += #4 }
53 #0x40000000
54 { r0 = r1
55 if (p0) memb(r0+##_start)=r0.new }
56 # CHECK: 40a0e2e0 if (p0) memb(r0+##131644) = r0.new }
58 #0x41000000
59 if (p0) r0=memb(r1+##_start)
60 # CHECK: 4101c780 if (p0) r0 = memb(r1+##131644) }
62 #0x42000000
63 { r0 = r1
64 p0 = p1
65 if (p0.new) memb(r0+##_start)=r0.new }
66 # CHECK: 42a0e2e0 if (p0.new) memb(r0+##131644) = r0.new }
68 #0x43000000
69 { p0 = p1
70 if (P0.new) r0=memb(r0+##_start) }
71 # CHECK: 4300c780 if (p0.new) r0 = memb(r0+##131644) }
73 #0x44000000
74 if (!p0) memb(r0+##_start)=r1
75 # CHECK: 4400e1e0 if (!p0) memb(r0+##131644) = r1 }
77 #0x45000000
78 if (!p0) r0=memb(r1+##_start)
79 # CHECK: 4501c780 if (!p0) r0 = memb(r1+##131644) }
81 #0x46000000
82 { p0 = p1
83 if (!p0.new) memb(r0+##_start)=r1 }
84 # CHECK: 4600e1e0 if (!p0.new) memb(r0+##131644) = r1 }
86 #0x47000000
87 { p0 = p1
88 if (!p0.new) r0=memb(r1+##_start) }
89 # CHECK: 4701c780 if (!p0.new) r0 = memb(r1+##131644) }
91 #0x6a000000 -- Note 4294967132 == -0xa4 the distance between
92 # here and _start, so this will change if
93 # tests are added between here and _start
94 r0=add(pc,##_start@pcrel)
95 # CHECK: 6a49d600 r0 = add(pc,##236) }
97 #0x7c000000
98 r1:0=combine(#8,##_start)
99 # CHECK: 7c9ec100 r1:0 = combine(#8,##131644) }
101 #0x9a000000
102 r1:0=memb_fifo(r2=##_start)
103 # CHECK: 9a82df00 r1:0 = memb_fifo(r2=##131644) }
105 #0x9b000000
106 r0=memb(r1=##_start)
107 # CHECK: 9b01df00 r0 = memb(r1=##131644) }
109 #0x9c000000
110 r1:0=memb_fifo(r2<<#2+##_start)
111 # CHECK: 9c82ff00 r1:0 = memb_fifo(r2<<#2+##131644) }
113 #0x9d000000
114 r0=memb(r1<<#2+##_start)
115 # CHECK: 9d01ff00 r0 = memb(r1<<#2+##131644) }
117 #0x9f000000
118 if (!p0) r0=memb(##_start)
119 # CHECK: 9f1ee880 if (!p0) r0 = memb(##131644) }
121 #0xab000000
122 memb(r0=##_start)=r1
123 # CHECK: ab00c1bc memb(r0=##131644) = r1 }
125 #0xad000000
126 memb(r0<<#2+##_start)=r1
127 # CHECK: ad00e1bc memb(r0<<#2+##131644) = r1 }
129 #0xaf000000
130 if (!p0) memb(##_start)=r1
131 # CHECK: af03c1e4 if (!p0) memb(##131644) = r1 }
133 #0xd7000000
134 r0=add(##_start,mpyi(r1,r2))
135 # CHECK: d761e280 r0 = add(##131644,mpyi(r1,r2)) }
137 #0xd8000000
138 R0=add(##_start,mpyi(r0,#2))
139 # CHECK: d860e082 r0 = add(##131644,mpyi(r0,#2)) }
141 #0xdb000000
142 r0=add(r1,add(r2,##_start))
143 # CHECK: db61e082 r0 = add(r1,add(r2,##131644)) }
145 #0xdf000000
146 r0=add(r1,mpyi(r2,##_start))
147 # CHECK: dfe2e081 r0 = add(r1,mpyi(r2,##131644)) }
149 # Duplex form of R_HEX_6_X
150 # R_HEX_32_6_X
151 # R_HEX_6_X
152 { r0 = ##_start; r2 = r16 }
153 # CHECK: 2bc03082 r0 = ##131644; r2 = r16 }
155 # R_HEX_HI16
156 r0.h = #HI(_start)
157 # CHECK: r0.h = #2
159 # R_HEX_LO16
160 r0.l = #LO(_start)
161 # CHECK: r0.l = #572
163 # R_HEX_8_X has 3 relocation mask variations
164 #0xde000000
165 r0=sub(##_start, asl(r0, #1))
166 # CHECK: de20e1c6 r0 = sub(##131644,asl(r0,#1)) }
168 #0x3c000000
169 memw(r0+#0) = ##_start
170 # CHECK: 3c40c03c memw(r0+#0) = ##131644 }
172 # The rest:
173 r1:0=combine(r2,##_start);
174 # CHECK: 7302e780 r1:0 = combine(r2,##131644) }
176 # R_HEX_32:
177 r_hex_32:
178 .word _start
179 # CHECK: 0002023c
181 # R_HEX_16_X has 4 relocation mask variations
182 # 0x48000000
183 memw(##_start) = r0
184 # CHECK: 4880c03c memw(##131644) = r0 }
186 # 0x49000000
187 r0 = memw(##_start)
188 # CHECK: 4980c780 r0 = memw(##131644)
190 # 0x78000000
191 r0 = ##_start
192 # CHECK: 7800c780 r0 = ##131644 }
194 # 0xb0000000
195 r0 = add(r1, ##_start)
196 # CHECK: b001c780 r0 = add(r1,##131644) }
198 # R_HEX_B9_PCREL:
199 {r0=#1 ; jump #_start}
200 # CHECK: jump 0x2023c
202 # R_HEX_B9_PCREL_X:
203 {r0=#1 ; jump ##_start}
204 # CHECK: jump 0x2023c
206 # R_HEX_B13_PCREL
207 if (r0 == #0) jump:t #_start
208 # CHECK: if (r0==#0) jump:t 0x2023c
210 # R_HEX_9_X
211 p0 = !cmp.gtu(r0, ##_start)
212 # CHECK: p0 = !cmp.gtu(r0,##131644)
214 # R_HEX_10_X
215 p0 = !cmp.gt(r0, ##_start)
216 # CHECK: p0 = !cmp.gt(r0,##131644)
218 # R_HEX_11_X
219 r0 = memw(r1+##_start)
220 # CHECK: r0 = memw(r1+##131644)
222 memw(r0+##_start) = r1
223 # CHECK: memw(r0+##131644) = r1