[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / rvi-aliases-valid.s
blobe6bb6fb5a2d47e665385d488d9fe6bc187e650de
1 # RUN: llvm-mc %s -triple=riscv32 -M no-aliases \
2 # RUN: | FileCheck -check-prefixes=CHECK-S-NOALIAS,CHECK-S-OBJ-NOALIAS %s
3 # RUN: llvm-mc %s -triple=riscv32 \
4 # RUN: | FileCheck -check-prefixes=CHECK-S,CHECK-S-OBJ %s
5 # RUN: llvm-mc %s -triple=riscv64 -M no-aliases \
6 # RUN: | FileCheck -check-prefixes=CHECK-S-NOALIAS,CHECK-S-OBJ-NOALIAS %s
7 # RUN: llvm-mc %s -triple=riscv64 \
8 # RUN: | FileCheck -check-prefixes=CHECK-S,CHECK-S-OBJ %s
9 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
10 # RUN: | llvm-objdump -d -r -M no-aliases - \
11 # RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-S-OBJ-NOALIAS %s
12 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
13 # RUN: | llvm-objdump -d -r - \
14 # RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-S-OBJ %s
15 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
16 # RUN: | llvm-objdump -d -r -M no-aliases - \
17 # RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-S-OBJ-NOALIAS %s
18 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
19 # RUN: | llvm-objdump -d -r - \
20 # RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-S-OBJ %s
22 # The following check prefixes are used in this test:
23 # CHECK-S Match the .s output with aliases enabled
24 # CHECK-S-NOALIAS Match the .s output with aliases disabled
25 # CHECK-OBJ Match the objdumped object output with aliases enabled
26 # CHECK-OBJ-NOALIAS Match the objdumped object output with aliases enabled
27 # CHECK-S-OBJ Match both the .s and objdumped object output with
28 # aliases enabled
29 # CHECK-S-OBJ-NOALIAS Match both the .s and objdumped object output with
30 # aliases disabled
32 # TODO la
33 # TODO lb lh lw
34 # TODO sb sh sw
36 # CHECK-S-OBJ-NOALIAS: addi zero, zero, 0
37 # CHECK-S-OBJ: nop
38 nop
40 # CHECK-S-OBJ-NOALIAS: addi t6, zero, 0
41 # CHECK-S-OBJ: mv t6, zero
42 mv x31, zero
43 # CHECK-S-OBJ-NOALIAS: addi a2, a3, 0
44 # CHECK-S-OBJ: mv a2, a3
45 move a2,a3
46 # CHECK-S-OBJ-NOALIAS: xori t6, ra, -1
47 # CHECK-S-OBJ: not t6, ra
48 not x31, x1
49 # CHECK-S-OBJ-NOALIAS: sub t6, zero, ra
50 # CHECK-S-OBJ: neg t6, ra
51 neg x31, x1
52 # CHECK-S-OBJ-NOALIAS: sltiu t6, ra, 1
53 # CHECK-S-OBJ: seqz t6, ra
54 seqz x31, x1
55 # CHECK-S-OBJ-NOALIAS: sltu t6, zero, ra
56 # CHECK-S-OBJ: snez t6, ra
57 snez x31, x1
58 # CHECK-S-OBJ-NOALIAS: slt t6, ra, zero
59 # CHECK-S-OBJ: sltz t6, ra
60 sltz x31, x1
61 # CHECK-S-OBJ-NOALIAS: slt t6, zero, ra
62 # CHECK-S-OBJ: sgtz t6, ra
63 sgtz x31, x1
65 # CHECK-S-OBJ-NOALIAS: slt ra, gp, sp
66 # CHECK-S-OBJ: slt ra, gp, sp
67 sgt x1, x2, x3
68 # CHECK-S-OBJ-NOALIAS: sltu tp, t1, t0
69 # CHECK-S-OBJ: sltu tp, t1, t0
70 sgtu x4, x5, x6
72 # CHECK-S-NOALIAS: beq a0, zero, 512
73 # CHECK-S: beqz a0, 512
74 # CHECK-OBJ-NOALIAS: beq a0, zero, 0x22c
75 # CHECK-OBJ: beqz a0, 0x22c
76 beqz x10, 512
77 # CHECK-S-NOALIAS: bne a1, zero, 1024
78 # CHECK-S: bnez a1, 1024
79 # CHECK-OBJ-NOALIAS: bne a1, zero, 0x430
80 # CHECK-OBJ: bnez a1, 0x430
81 bnez x11, 1024
82 # CHECK-S-NOALIAS: bge zero, a2, 4
83 # CHECK-S: blez a2, 4
84 # CHECK-OBJ-NOALIAS: bge zero, a2, 0x38
85 # CHECK-OBJ: blez a2, 0x38
86 blez x12, 4
87 # CHECK-S-NOALIAS: bge a3, zero, 8
88 # CHECK-S: bgez a3, 8
89 # CHECK-OBJ-NOALIAS: bge a3, zero, 0x40
90 # CHECK-OBJ: bgez a3, 0x40
91 bgez x13, 8
92 # CHECK-S-NOALIAS: blt a4, zero, 12
93 # CHECK-S: bltz a4, 12
94 # CHECK-OBJ-NOALIAS: blt a4, zero, 0x48
95 # CHECK-OBJ: bltz a4, 0x48
96 bltz x14, 12
97 # CHECK-S-NOALIAS: blt zero, a5, 16
98 # CHECK-S: bgtz a5, 16
99 # CHECK-OBJ-NOALIAS: blt zero, a5, 0x50
100 # CHECK-OBJ: bgtz a5, 0x50
101 bgtz x15, 16
103 # Always output the canonical mnemonic for the pseudo branch instructions.
104 # CHECK-S-NOALIAS: blt a6, a5, 20
105 # CHECK-S: blt a6, a5, 20
106 # CHECK-OBJ-NOALIAS: blt a6, a5, 0x58
107 # CHECK-OBJ: blt a6, a5, 0x58
108 bgt x15, x16, 20
109 # CHECK-S-NOALIAS: bge a7, a6, 24
110 # CHECK-S: bge a7, a6, 24
111 # CHECK-OBJ-NOALIAS: bge a7, a6, 0x60
112 # CHECK-OBJ: bge a7, a6, 0x60
113 ble x16, x17, 24
114 # CHECK-S-NOALIAS: bltu s2, a7, 28
115 # CHECK-S: bltu s2, a7, 28
116 # CHECK-OBJ-NOALIAS: bltu s2, a7, 0x68
117 # CHECK-OBJ: bltu s2, a7, 0x68
118 bgtu x17, x18, 28
119 # CHECK-S-NOALIAS: bgeu s3, s2, 32
120 # CHECK-S: bgeu s3, s2, 32
121 # CHECK-OBJ-NOALIAS: bgeu s3, s2, 0x70
122 # CHECK-OBJ: bgeu s3, s2, 0x70
123 bleu x18, x19, 32
125 # CHECK-S-NOALIAS: jal zero, 2044
126 # CHECK-S: j 2044
127 # CHECK-OBJ-NOALIAS: jal zero, 0x850
128 # CHECK-OBJ: j 0x850
129 j 2044
130 # CHECK-S-NOALIAS: jal zero, foo
131 # CHECK-S: j foo
132 # CHECK-OBJ-NOALIAS: jal zero, 0
133 # CHECK-OBJ: j 0
134 # CHECK-OBJ: R_RISCV_JAL foo
135 j foo
136 # CHECK-S-NOALIAS: jal zero, a0
137 # CHECK-S: j a0
138 # CHECK-OBJ-NOALIAS: jal zero, 0
139 # CHECK-OBJ: j 0
140 # CHECK-OBJ: R_RISCV_JAL a0
141 j a0
142 # CHECK-S-NOALIAS: [[LABEL:.L[[:alnum:]_]+]]:
143 # CHECK-S-NOALIAS-NEXT: jal zero, [[LABEL]]
144 # CHECK-S: [[LABEL:.L[[:alnum:]_]+]]:
145 # CHECK-S-NEXT: j [[LABEL]]
146 # CHECK-OBJ-NOALIAS: jal zero, 0
147 # CHECK-OBJ: j 0
149 # CHECK-S-NOALIAS: jal ra, 2040
150 # CHECK-S: jal 2040
151 # CHECK-OBJ-NOALIAS: jal ra, 0x85c
152 # CHECK-OBJ: jal 0x85c
153 jal 2040
154 # CHECK-S-NOALIAS: jal ra, foo
155 # CHECK-S: jal foo
156 # CHECK-OBJ-NOALIAS: jal ra, 0
157 # CHECK-OBJ: jal 0
158 # CHECK-OBJ: R_RISCV_JAL foo
159 jal foo
160 # CHECK-S-NOALIAS: jal ra, a0
161 # CHECK-S: jal a0
162 # CHECK-OBJ-NOALIAS: jal ra, 0
163 # CHECK-OBJ: jal 0
164 # CHECK-OBJ: R_RISCV_JAL a0
165 jal a0
166 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(s4)
167 # CHECK-S-OBJ: jr s4
168 jr x20
169 # CHECK-S-OBJ-NOALIAS: jalr zero, 6(s5)
170 # CHECK-S-OBJ: jr 6(s5)
171 jr 6(x21)
172 # CHECK-S-OBJ-NOALIAS: jalr zero, 7(s6)
173 # CHECK-S-OBJ: jr 7(s6)
174 jr x22, 7
175 # CHECK-S-OBJ-NOALIAS: jalr ra, 0(s4)
176 # CHECK-S-OBJ: jalr s4
177 jalr x20
178 # CHECK-S-OBJ-NOALIAS: jalr ra, 8(s5)
179 # CHECK-S-OBJ: jalr 8(s5)
180 jalr 8(x21)
181 # CHECK-S-OBJ-NOALIAS: jalr s6, 0(s7)
182 # CHECK-S-OBJ: jalr s6, s7
183 jalr x22, x23
184 # CHECK-S-OBJ-NOALIAS: jalr ra, 9(s8)
185 # CHECK-S-OBJ: jalr 9(s8)
186 jalr x24, 9
187 # CHECK-S-OBJ-NOALIAS: jalr s9, 11(s10)
188 # CHECK-S-OBJ: jalr s9, 11(s10)
189 jalr x25, x26, 11
190 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(ra)
191 # CHECK-S-OBJ: ret
193 # TODO call
194 # TODO tail
196 # CHECK-S-OBJ-NOALIAS: fence iorw, iorw
197 # CHECK-S-OBJ: fence
198 fence
200 # CHECK-S-OBJ-NOALIAS: csrrs s10, instret, zero
201 # CHECK-S-OBJ: rdinstret s10
202 rdinstret x26
203 # CHECK-S-OBJ-NOALIAS: csrrs s8, cycle, zero
204 # CHECK-S-OBJ: rdcycle s8
205 rdcycle x24
206 # CHECK-S-OBJ-NOALIAS: csrrs s9, time, zero
207 # CHECK-S-OBJ: rdtime s9
208 rdtime x25
210 # CHECK-S-OBJ-NOALIAS: csrrs s0, 336, zero
211 # CHECK-S-OBJ: csrr s0, 336
212 csrr x8, 0x150
213 # CHECK-S-OBJ-NOALIAS: csrrw zero, sscratch, s1
214 # CHECK-S-OBJ: csrw sscratch, s1
215 csrw 0x140, x9
216 # CHECK-S-OBJ-NOALIAS: csrrs zero, 4095, s6
217 # CHECK-S-OBJ: csrs 4095, s6
218 csrs 0xfff, x22
219 # CHECK-S-OBJ-NOALIAS: csrrc zero, 4095, s7
220 # CHECK-S-OBJ: csrc 4095, s7
221 csrc 0xfff, x23
223 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 15
224 # CHECK-S-OBJ: csrwi 336, 15
225 csrwi 0x150, 0xf
226 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 4095, 16
227 # CHECK-S-OBJ: csrsi 4095, 16
228 csrsi 0xfff, 0x10
229 # CHECK-S-OBJ-NOALIAS: csrrci zero, sscratch, 17
230 # CHECK-S-OBJ: csrci sscratch, 17
231 csrci 0x140, 0x11
233 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 7
234 # CHECK-S-OBJ: csrwi 336, 7
235 csrw 0x150, 7
236 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 336, 7
237 # CHECK-S-OBJ: csrsi 336, 7
238 csrs 0x150, 7
239 # CHECK-S-OBJ-NOALIAS: csrrci zero, 336, 7
240 # CHECK-S-OBJ: csrci 336, 7
241 csrc 0x150, 7
243 # CHECK-S-OBJ-NOALIAS: csrrwi t0, 336, 15
244 # CHECK-S-OBJ: csrrwi t0, 336, 15
245 csrrw t0, 0x150, 0xf
246 # CHECK-S-OBJ-NOALIAS: csrrsi t0, 4095, 16
247 # CHECK-S-OBJ: csrrsi t0, 4095, 16
248 csrrs t0, 0xfff, 0x10
249 # CHECK-S-OBJ-NOALIAS: csrrci t0, sscratch, 17
250 # CHECK-S-OBJ: csrrci t0, sscratch, 17
251 csrrc t0, 0x140, 0x11
253 # CHECK-S-OBJ-NOALIAS: sfence.vma zero, zero
254 # CHECK-S-OBJ: sfence.vma
255 sfence.vma
256 # CHECK-S-OBJ-NOALIAS: sfence.vma a0, zero
257 # CHECK-S-OBJ: sfence.vma a0
258 sfence.vma a0
260 # The following aliases are accepted as input but the canonical form
261 # of the instruction will always be printed.
262 # CHECK-S-OBJ-NOALIAS: addi a2, a3, 4
263 # CHECK-S-OBJ: addi a2, a3, 4
264 add a2, a3, 4
265 # CHECK-S-OBJ-NOALIAS: andi a2, a3, 4
266 # CHECK-S-OBJ: andi a2, a3, 4
267 and a2, a3, 4
268 # CHECK-S-OBJ-NOALIAS: xori a2, a3, 4
269 # CHECK-S-OBJ: xori a2, a3, 4
270 xor a2, a3, 4
271 # CHECK-S-OBJ-NOALIAS: ori a2, a3, 4
272 # CHECK-S-OBJ: ori a2, a3, 4
273 or a2, a3, 4
274 # CHECK-S-OBJ-NOALIAS: slli a2, a3, 4
275 # CHECK-S-OBJ: slli a2, a3, 4
276 sll a2, a3, 4
277 # CHECK-S-OBJ-NOALIAS: srli a2, a3, 4
278 # CHECK-S-OBJ: srli a2, a3, 4
279 srl a2, a3, 4
280 # CHECK-S-OBJ-NOALIAS: srai a2, a3, 4
281 # CHECK-S-OBJ: srai a2, a3, 4
282 sra a2, a3, 4
283 # CHECK-S-OBJ-NOALIAS: slti a2, a3, 4
284 # CHECK-S-OBJ: slti a2, a3, 4
285 slt a2, a3, 4
286 # CHECK-S-OBJ-NOALIAS: sltiu a2, a3, 4
287 # CHECK-S-OBJ: sltiu a2, a3, 4
288 sltu a2, a3, 4
290 # CHECK-S-OBJ-NOALIAS: ebreak
291 # CHECK-S-OBJ: ebreak
292 sbreak
294 # CHECK-S-OBJ-NOALIAS: ecall
295 # CHECK-S-OBJ: ecall
296 scall