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
29 # CHECK-S-OBJ-NOALIAS Match both the .s and objdumped object output with
36 # CHECK-S-OBJ-NOALIAS: addi zero, zero, 0
40 # CHECK-S-OBJ-NOALIAS: addi t6, zero, 0
41 # CHECK-S-OBJ: mv t6, zero
43 # CHECK-S-OBJ-NOALIAS: addi a2, a3, 0
44 # CHECK-S-OBJ: mv a2, a3
46 # CHECK-S-OBJ-NOALIAS: xori t6, ra, -1
47 # CHECK-S-OBJ: not t6, ra
49 # CHECK-S-OBJ-NOALIAS: sub t6, zero, ra
50 # CHECK-S-OBJ: neg t6, ra
52 # CHECK-S-OBJ-NOALIAS: sltiu t6, ra, 1
53 # CHECK-S-OBJ: seqz t6, ra
55 # CHECK-S-OBJ-NOALIAS: sltu t6, zero, ra
56 # CHECK-S-OBJ: snez t6, ra
58 # CHECK-S-OBJ-NOALIAS: slt t6, ra, zero
59 # CHECK-S-OBJ: sltz t6, ra
61 # CHECK-S-OBJ-NOALIAS: slt t6, zero, ra
62 # CHECK-S-OBJ: sgtz t6, ra
65 # CHECK-S-OBJ-NOALIAS: slt ra, gp, sp
66 # CHECK-S-OBJ: slt ra, gp, sp
68 # CHECK-S-OBJ-NOALIAS: sltu tp, t1, t0
69 # CHECK-S-OBJ: sltu tp, t1, t0
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
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
82 # CHECK-S-NOALIAS: bge zero, a2, 4
84 # CHECK-OBJ-NOALIAS: bge zero, a2, 0x38
85 # CHECK-OBJ: blez a2, 0x38
87 # CHECK-S-NOALIAS: bge a3, zero, 8
89 # CHECK-OBJ-NOALIAS: bge a3, zero, 0x40
90 # CHECK-OBJ: bgez a3, 0x40
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
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
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
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
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
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
125 # CHECK-S-NOALIAS: jal zero, 2044
127 # CHECK-OBJ-NOALIAS: jal zero, 0x850
130 # CHECK-S-NOALIAS: jal zero, foo
132 # CHECK-OBJ-NOALIAS: jal zero, 0
134 # CHECK-OBJ: R_RISCV_JAL foo
136 # CHECK-S-NOALIAS: jal zero, a0
138 # CHECK-OBJ-NOALIAS: jal zero, 0
140 # CHECK-OBJ: R_RISCV_JAL 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
149 # CHECK-S-NOALIAS: jal ra, 2040
151 # CHECK-OBJ-NOALIAS: jal ra, 0x85c
152 # CHECK-OBJ: jal 0x85c
154 # CHECK-S-NOALIAS: jal ra, foo
156 # CHECK-OBJ-NOALIAS: jal ra, 0
158 # CHECK-OBJ: R_RISCV_JAL foo
160 # CHECK-S-NOALIAS: jal ra, a0
162 # CHECK-OBJ-NOALIAS: jal ra, 0
164 # CHECK-OBJ: R_RISCV_JAL a0
166 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(s4)
169 # CHECK-S-OBJ-NOALIAS: jalr zero, 6(s5)
170 # CHECK-S-OBJ: jr 6(s5)
172 # CHECK-S-OBJ-NOALIAS: jalr zero, 7(s6)
173 # CHECK-S-OBJ: jr 7(s6)
175 # CHECK-S-OBJ-NOALIAS: jalr ra, 0(s4)
176 # CHECK-S-OBJ: jalr s4
178 # CHECK-S-OBJ-NOALIAS: jalr ra, 8(s5)
179 # CHECK-S-OBJ: jalr 8(s5)
181 # CHECK-S-OBJ-NOALIAS: jalr s6, 0(s7)
182 # CHECK-S-OBJ: jalr s6, s7
184 # CHECK-S-OBJ-NOALIAS: jalr ra, 9(s8)
185 # CHECK-S-OBJ: jalr 9(s8)
187 # CHECK-S-OBJ-NOALIAS: jalr s9, 11(s10)
188 # CHECK-S-OBJ: jalr s9, 11(s10)
190 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(ra)
196 # CHECK-S-OBJ-NOALIAS: fence iorw, iorw
200 # CHECK-S-OBJ-NOALIAS: csrrs s10, instret, zero
201 # CHECK-S-OBJ: rdinstret s10
203 # CHECK-S-OBJ-NOALIAS: csrrs s8, cycle, zero
204 # CHECK-S-OBJ: rdcycle s8
206 # CHECK-S-OBJ-NOALIAS: csrrs s9, time, zero
207 # CHECK-S-OBJ: rdtime s9
210 # CHECK-S-OBJ-NOALIAS: csrrs s0, 336, zero
211 # CHECK-S-OBJ: csrr s0, 336
213 # CHECK-S-OBJ-NOALIAS: csrrw zero, sscratch, s1
214 # CHECK-S-OBJ: csrw sscratch, s1
216 # CHECK-S-OBJ-NOALIAS: csrrs zero, 4095, s6
217 # CHECK-S-OBJ: csrs 4095, s6
219 # CHECK-S-OBJ-NOALIAS: csrrc zero, 4095, s7
220 # CHECK-S-OBJ: csrc 4095, s7
223 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 15
224 # CHECK-S-OBJ: csrwi 336, 15
226 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 4095, 16
227 # CHECK-S-OBJ: csrsi 4095, 16
229 # CHECK-S-OBJ-NOALIAS: csrrci zero, sscratch, 17
230 # CHECK-S-OBJ: csrci sscratch, 17
233 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 7
234 # CHECK-S-OBJ: csrwi 336, 7
236 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 336, 7
237 # CHECK-S-OBJ: csrsi 336, 7
239 # CHECK-S-OBJ-NOALIAS: csrrci zero, 336, 7
240 # CHECK-S-OBJ: csrci 336, 7
243 # CHECK-S-OBJ-NOALIAS: csrrwi t0, 336, 15
244 # CHECK-S-OBJ: csrrwi t0, 336, 15
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
256 # CHECK-S-OBJ-NOALIAS: sfence.vma a0, zero
257 # CHECK-S-OBJ: 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
265 # CHECK-S-OBJ-NOALIAS: andi a2, a3, 4
266 # CHECK-S-OBJ: andi a2, a3, 4
268 # CHECK-S-OBJ-NOALIAS: xori a2, a3, 4
269 # CHECK-S-OBJ: xori a2, a3, 4
271 # CHECK-S-OBJ-NOALIAS: ori a2, a3, 4
272 # CHECK-S-OBJ: ori a2, a3, 4
274 # CHECK-S-OBJ-NOALIAS: slli a2, a3, 4
275 # CHECK-S-OBJ: slli a2, a3, 4
277 # CHECK-S-OBJ-NOALIAS: srli a2, a3, 4
278 # CHECK-S-OBJ: srli a2, a3, 4
280 # CHECK-S-OBJ-NOALIAS: srai a2, a3, 4
281 # CHECK-S-OBJ: srai a2, a3, 4
283 # CHECK-S-OBJ-NOALIAS: slti a2, a3, 4
284 # CHECK-S-OBJ: slti a2, a3, 4
286 # CHECK-S-OBJ-NOALIAS: sltiu a2, a3, 4
287 # CHECK-S-OBJ: sltiu a2, a3, 4
290 # CHECK-S-OBJ-NOALIAS: ebreak
291 # CHECK-S-OBJ: ebreak
294 # CHECK-S-OBJ-NOALIAS: ecall