1 # RUN: llvm-mc %s -triple=riscv32 -riscv-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 -riscv-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 -riscv-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 -riscv-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-OBJ-NOALIAS: beq a0, zero, 512
73 # CHECK-S-OBJ: beqz a0, 512
75 # CHECK-S-OBJ-NOALIAS: bne a1, zero, 1024
76 # CHECK-S-OBJ: bnez a1, 1024
78 # CHECK-S-OBJ-NOALIAS: bge zero, a2, 4
79 # CHECK-S-OBJ: blez a2, 4
81 # CHECK-S-OBJ-NOALIAS: bge a3, zero, 8
82 # CHECK-S-OBJ: bgez a3, 8
84 # CHECK-S-OBJ-NOALIAS: blt a4, zero, 12
85 # CHECK-S-OBJ: bltz a4, 12
87 # CHECK-S-OBJ-NOALIAS: blt zero, a5, 16
88 # CHECK-S-OBJ: bgtz a5, 16
91 # Always output the canonical mnemonic for the pseudo branch instructions.
92 # CHECK-S-OBJ-NOALIAS: blt a6, a5, 20
93 # CHECK-S-OBJ: blt a6, a5, 20
95 # CHECK-S-OBJ-NOALIAS: bge a7, a6, 24
96 # CHECK-S-OBJ: bge a7, a6, 24
98 # CHECK-S-OBJ-NOALIAS: bltu s2, a7, 28
99 # CHECK-S-OBJ: bltu s2, a7, 28
101 # CHECK-S-OBJ-NOALIAS: bgeu s3, s2, 32
102 # CHECK-S-OBJ: bgeu s3, s2, 32
105 # CHECK-S-OBJ-NOALIAS: jal zero, 2044
106 # CHECK-S-OBJ: j 2044
108 # CHECK-S-NOALIAS: jal zero, foo
110 # CHECK-OBJ-NOALIAS: jal zero, 0
112 # CHECK-OBJ: R_RISCV_JAL foo
114 # CHECK-S-NOALIAS: jal zero, a0
116 # CHECK-OBJ-NOALIAS: jal zero, 0
118 # CHECK-OBJ: R_RISCV_JAL a0
120 # CHECK-S-NOALIAS: [[LABEL:.L[[:alnum:]_]+]]:
121 # CHECK-S-NOALIAS-NEXT: jal zero, [[LABEL]]
122 # CHECK-S: [[LABEL:.L[[:alnum:]_]+]]:
123 # CHECK-S-NEXT: j [[LABEL]]
124 # CHECK-OBJ-NOALIAS: jal zero, 0
127 # CHECK-S-OBJ-NOALIAS: jal ra, 2040
128 # CHECK-S-OBJ: jal 2040
130 # CHECK-S-NOALIAS: jal ra, foo
132 # CHECK-OBJ-NOALIAS: jal ra, 0
134 # CHECK-OBJ: R_RISCV_JAL foo
136 # CHECK-S-NOALIAS: jal ra, a0
138 # CHECK-OBJ-NOALIAS: jal ra, 0
140 # CHECK-OBJ: R_RISCV_JAL a0
142 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(s4)
145 # CHECK-S-OBJ-NOALIAS: jalr zero, 6(s5)
146 # CHECK-S-OBJ: jr 6(s5)
148 # CHECK-S-OBJ-NOALIAS: jalr zero, 7(s6)
149 # CHECK-S-OBJ: jr 7(s6)
151 # CHECK-S-OBJ-NOALIAS: jalr ra, 0(s4)
152 # CHECK-S-OBJ: jalr s4
154 # CHECK-S-OBJ-NOALIAS: jalr ra, 8(s5)
155 # CHECK-S-OBJ: jalr 8(s5)
157 # CHECK-S-OBJ-NOALIAS: jalr s6, 0(s7)
158 # CHECK-S-OBJ: jalr s6, s7
160 # CHECK-S-OBJ-NOALIAS: jalr ra, 9(s8)
161 # CHECK-S-OBJ: jalr 9(s8)
163 # CHECK-S-OBJ-NOALIAS: jalr s9, 11(s10)
164 # CHECK-S-OBJ: jalr s9, 11(s10)
166 # CHECK-S-OBJ-NOALIAS: jalr zero, 0(ra)
172 # CHECK-S-OBJ-NOALIAS: fence iorw, iorw
176 # CHECK-S-OBJ-NOALIAS: csrrs s10, instret, zero
177 # CHECK-S-OBJ: rdinstret s10
179 # CHECK-S-OBJ-NOALIAS: csrrs s8, cycle, zero
180 # CHECK-S-OBJ: rdcycle s8
182 # CHECK-S-OBJ-NOALIAS: csrrs s9, time, zero
183 # CHECK-S-OBJ: rdtime s9
186 # CHECK-S-OBJ-NOALIAS: csrrs s0, 336, zero
187 # CHECK-S-OBJ: csrr s0, 336
189 # CHECK-S-OBJ-NOALIAS: csrrw zero, sscratch, s1
190 # CHECK-S-OBJ: csrw sscratch, s1
192 # CHECK-S-OBJ-NOALIAS: csrrs zero, 4095, s6
193 # CHECK-S-OBJ: csrs 4095, s6
195 # CHECK-S-OBJ-NOALIAS: csrrc zero, 4095, s7
196 # CHECK-S-OBJ: csrc 4095, s7
199 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 15
200 # CHECK-S-OBJ: csrwi 336, 15
202 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 4095, 16
203 # CHECK-S-OBJ: csrsi 4095, 16
205 # CHECK-S-OBJ-NOALIAS: csrrci zero, sscratch, 17
206 # CHECK-S-OBJ: csrci sscratch, 17
209 # CHECK-S-OBJ-NOALIAS: csrrwi zero, 336, 7
210 # CHECK-S-OBJ: csrwi 336, 7
212 # CHECK-S-OBJ-NOALIAS: csrrsi zero, 336, 7
213 # CHECK-S-OBJ: csrsi 336, 7
215 # CHECK-S-OBJ-NOALIAS: csrrci zero, 336, 7
216 # CHECK-S-OBJ: csrci 336, 7
219 # CHECK-S-OBJ-NOALIAS: csrrwi t0, 336, 15
220 # CHECK-S-OBJ: csrrwi t0, 336, 15
222 # CHECK-S-OBJ-NOALIAS: csrrsi t0, 4095, 16
223 # CHECK-S-OBJ: csrrsi t0, 4095, 16
224 csrrs t0
, 0xfff, 0x10
225 # CHECK-S-OBJ-NOALIAS: csrrci t0, sscratch, 17
226 # CHECK-S-OBJ: csrrci t0, sscratch, 17
227 csrrc t0
, 0x140, 0x11
229 # CHECK-S-OBJ-NOALIAS: sfence.vma zero, zero
230 # CHECK-S-OBJ: sfence.vma
232 # CHECK-S-OBJ-NOALIAS: sfence.vma a0, zero
233 # CHECK-S-OBJ: sfence.vma a0
236 # The following aliases are accepted as input but the canonical form
237 # of the instruction will always be printed.
238 # CHECK-S-OBJ-NOALIAS: addi a2, a3, 4
239 # CHECK-S-OBJ: addi a2, a3, 4
241 # CHECK-S-OBJ-NOALIAS: andi a2, a3, 4
242 # CHECK-S-OBJ: andi a2, a3, 4
244 # CHECK-S-OBJ-NOALIAS: xori a2, a3, 4
245 # CHECK-S-OBJ: xori a2, a3, 4
247 # CHECK-S-OBJ-NOALIAS: ori a2, a3, 4
248 # CHECK-S-OBJ: ori a2, a3, 4
250 # CHECK-S-OBJ-NOALIAS: slli a2, a3, 4
251 # CHECK-S-OBJ: slli a2, a3, 4
253 # CHECK-S-OBJ-NOALIAS: srli a2, a3, 4
254 # CHECK-S-OBJ: srli a2, a3, 4
256 # CHECK-S-OBJ-NOALIAS: srai a2, a3, 4
257 # CHECK-S-OBJ: srai a2, a3, 4
259 # CHECK-S-OBJ-NOALIAS: slti a2, a3, 4
260 # CHECK-S-OBJ: slti a2, a3, 4
262 # CHECK-S-OBJ-NOALIAS: sltiu a2, a3, 4
263 # CHECK-S-OBJ: sltiu a2, a3, 4
266 # CHECK-S-OBJ-NOALIAS: ebreak
267 # CHECK-S-OBJ: ebreak
270 # CHECK-S-OBJ-NOALIAS: ecall